Python API/IDE interactions

Hi all. I am new to OpenMC as well as to Spyder, so please bear with me if I use some incorrect terminology in what follows. I used the Spyder console and the OpenMC Python API to create the pin cell example xml input files, and got the simulation running on my Linux laptop. Now let’s say I want to revisit the model next week with the idea of revising a few of the input files. I set my working directory in Spyder to the directory where the input files exist. How can I import an input file (say, the geometry xml file) into Spyder so that I can revise specific xml elements in the file from within the console, and then export the changes back out to the original xml file(s)? I don’t know how to make Spyder know that the code I type into the console is supposed to go into an xml file I previously created. Thanks.

Hi James,

If you created a pyhton script with all the definitions of your problem and you open it with Spyder, any change that you do should be reflected in the xml files. Remember to include in each case the respective export_to_xml option, something like this:

materials = openmc.Materials([mat1, mat2, …])

materials.export_to_xml()

geometry = openmc.Geometry(root universe)
geometry.export_to_xml()

Regards,
Javier