Jump to content
Geochemist's Workbench Support Forum

Running X1t from Python


Recommended Posts

Hi, 
Basic question. Is it possible to initialize and run X1t (using a text input script) from Python and then retrieve select results also from Python? Can ChemPlugin be used for this? 
Thanks
James 

Link to comment
Share on other sites

Hello James,

If you would like to run X1t input scripts directly, I think the GWB Plugin may be better suited. You can set up a X1t input file and in Python, call the GWB Plugin to run the script. You can retrieve the result from your simulation using the 'results' command. A good place to get started is the Plug-in Chapter in the GWB Reference Manual. You can find example scripts installed with your software.

ChemPlugin is a powerful software object that can be called in a client program, such as python, to configure a reactive transport model of any geometry. The user prepares a client program that spawns any number of ChemPlugin objects, called instances, that self-links into a network to represent the system being modeled. The client program at a minimum specifies the rate at which fluid flows across each link. The client can also set at each link transmissivities representing diffusion, physical mixing during flow, and heat conduction.Then, as it marches forward in time, the client prompts each instance to perform essential steps: reporting the optimum time step size, transporting mass, transferring heat, and solving the equations describing chemical reactions. While ChemPlugin is derived from the same compute engine as that of The GWB, it operates independently from the rest of the GWB modeling applications. If you are interested in learning more, visit the ChemPlugin webpage for more details regarding the software and its capabilities. You can also review the ChemPlugin Academy for example clients.  

Hope this helps,
Jia Wang
Aqueous Solutions LLC

Link to comment
Share on other sites

Hi Jia,
Thanks for your feedback. I am working with a colleague, and we have a Python script that successfully initializes and runs our X1t script. Our question now is how to return specific results as a function of time for a specified node. To get the results, we ran:myGWBrun.results("Mass reacted, CO2(g)", "kg", ix=0)which returns an array of length 2 of [-999999, 3.5]We have 2 main questions:
  1. What exactly does this array represent?
  2. More importantly, how can we return specific results as a function of time for the node?
Thanks again,
James
Link to comment
Share on other sites

Hello James,

I am glad to hear that you are making progress with your script and the GWB Plugin. The "result" command always returns values in an array, even when requesting a single value. If the "result" command fails for any reason, such as the requested data doesn't exist or the specified unit conversion fails, the command will return ANULL, which is -999999. In your script, the program interprets the first string "mass" as the argument for a component, element, aqueous or surface species, minerals, and end members in the fluid. So the returned -999999 is telling you that there's not a mass value for "reacted" . The right command for what you want is "mass_reacted" for your result function. You might already know this but the full list of accepted arguments can be found under the Report chapter in the GWB Reference manual.

The GWB Plugin is designed to only retrieve the result of each nodal block at the end of the simulation. If you would like to retrieve results at different time slices, you can run the simulation multiple times with the desired time level set for the end time point and retrieve the information and store it in a text file. Another option is to parse the plot output file for data at each time step. The Plugin writes out a plot dataset (with extension.xtp for an X1t run) by default in binary format. You can set the output format to write out human readable xml with the command plot = character in your X1t script.

If you are looking to create simulations that you wish to report results at each time step, you can try setting up a Chemplugin run. While GWB Plugin is designed to report results at the final time step, ChemPlugin can retrieve information at each timestep. The ChemPlugin User’s Guide describes how the software works and example scripts are provided for setting up a 1D reactive transport model.

Hope this helps,
Jia

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi Jia,

 

It seems that the X1t simulation is by default split into 50 equal time intervals in the plot. Is there any way to change/configure this (e.g. 20 or 40 intervals instead)

 

Best,

Kush 

Link to comment
Share on other sites

Hello Kush,

You can change the output interval of the plot file by adjusting the dxplot parameter in Config -> Output dialog. For more information on dxplot, please see the GWB Command Reference.

Best,
Jia

  • Like 1
Link to comment
Share on other sites

Thanks Jia, that worked well for me. Another question, is there any way we can create different .xtp files for different runs/control what the files are called? Right now they all get written to the same X1t_plot.xtp file

Link to comment
Share on other sites

Hello Kush,

You're welcome. You can use the suffix command to set a unique name for your output files. You can look up more information on that in the same Command Reference mentioned above. 

Best regards,
Jia

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...