Jump to content
Geochemist's Workbench Support Forum
elg0086

ChemPlugin Setting Units

Recommended Posts

Brian,

I apologize if the answer to this question is already posted in the manual but I could not readily find it. How do you set units for the simulation parameters? The images below are from two different tutorials and neither directly sets units but references them differently with # meters or # cm.

Also, this link appears to be broken:

https://academy.gwb.com/RTM1.py

Regards,

Erik

 

M.thumb.PNG.c6a09106f41a5ec872cf3dfcf73b1b69.PNGCM.thumb.PNG.dca299d49a7ec0ca7679fc961a537d41.PNG

Share this post


Link to post
Share on other sites

Hi Erik,

You can use a variety of units when configuring a ChemPlugin instance. For example, 

cp.Config(“Ca++ = 1 mmol/kg”)
cp.Config(“Ca++ = 40.08 mg/kg”)

You can use a variety of units in retrieving results, as well. For example,

cp.Report("concentration aqueous", "mmol/kg")
cp.Report("concentration aqueous", "mg/kg")

Similarly, you can use a variety of units in setting the links between instances. For example, this code from the Reactive Transport Model lesson on the ChemPlugin Academy is used to set up a link between an inlet fluid and the first node of a 1D domain. The client calculates three variables (flow, trans, and ttrans, representing flow rate, transmissivity, and thermal transmissivity, respectively) and passes them to ChemPlugin using three member functions (FlowRate(), Transmissivity(), and HeatTrans(), respectively). 

flow = some number
trans = some number
ttrans = some number

link = cp[0].Link(cp_inlet)
link.FlowRate(flow, “m3/s”)
link.Transmissivity(trans, “m3/s”)
link.HeatTrans(ttrans, “W/K”)

The simulation parameters you’ve highlighted are from simple example client programs that use ChemPlugin, not ChemPlugin itself. A client could be relatively basic, like these, with no options for choosing units. Or, it could be a full-blown polished program with a GUI to choose units. Either way, ChemPlugin doesn’t care. The client just tells ChemPlugin what unit it used, and ChemPlugin is happy to accept it. If you look at the rest of the two client programs you’ve mentioned, you’ll see that the flow rates and transmissivities calculated by the client are either in cm3/s or m3/s, depending on the simulation parameters you’ve shown, and the units used were passed in the appropriate member functions. The important thing to remember is that you’re building a client, a reactive transport simulator tailor-made to your specifications here. It can be of any geometry, with any connections and feedbacks that you want to incorporate, and the user can interface with it however you’d like.

Thanks, we’ll take a look at the website link.

Hope this helps,

Brian Farrell
Aqueous Solutions
 

Share this post


Link to post
Share on other sites

Brian,

Thank you for the response as it cleared up some of my questions. I'm still getting my head around the workflow of Chemplugin with python as the client so I imagine I will have more questions in the future. Thank you.

 

-Erik

Share this post


Link to post
Share on other sites

I'm glad to hear it helped. I hope you enjoy using the software.

Brian

Share this post


Link to post
Share on other sites
Brian,
 
I have a question which builds on the topic found here:
 
 
Part of my model uses the output solution from the last instance and "loops" it back to the first instance. I was hoping to adjust the pH and sulfate entering the first node based on the output concentrations from the last node. However, calling the cp.Config command within a time marching loop is not possible  (I expected this would not be possible). I would like to confirm that the "cp.Config" command will not run within a time marching loop.
 
Another option I explored was running my model in "stages" using the "extend run" command. According to the aforementioned forum topic, kinetic minerals present within an instance will reset after calling the "extend run" command. Currently I have one kinetic mineral but will possibly be adding up to eight additional minerals. Furthermore, sorption and precipitation will be enabled, presenting a daunting task to reset each instance with concentrations and mass from the previous day.
 
Currently, I have a work-around model involving an instance with a sliding pH that might achieve 90% of what I am attempting to simulate.
 
In summary, to what extent can the chemistry of a system be dynamically altered in a time marching loop? In other words, is it possible to actively read and write input/output chemistry during a simulation? Thank you for your time!
 
Regards,
Erik

Share this post


Link to post
Share on other sites

Hi Erik,

Can you clarify whether you want the fluid that flows out of the last node to loop directly into the first node, or whether it should be transformed in some way? If it’s being transformed, can you please elaborate on how this is done? What’s the process?

Thanks,
Brian
 

Share this post


Link to post
Share on other sites

Brian,

Thank you for the response and I apologize for any ambiguity. The solution leaving the last node of the domain is transformed prior to looping back to the first instance. Within this loop sulfuric acid is added to achieve a target concentration of 10 g/l (sulfuric acid). However, the mass required to achieve this concentration is an unknown and controlled by reactions within the domain. Currently, I have a separate instance linked between the last node and first node to allow for this transformation. However, I have not quite figured out the best method to determine the difference between the final node and target chemistry (H+ and SO4--), and then configure the "transformation" instance to reflect this difference.

Regards,

Erik

Share this post


Link to post
Share on other sites

Hi Erik,

Ok, thanks for the additional information. A very simple strategy for that intermediate instance would be to fix pH and charge balance on SO4--. Assuming reaction within the domain increases pH, so that you’re always adding sulfuric acid to the effluent, the program will add enough H+ to achieve the desired pH, along with SO4-- to balance it out. If reaction along the domain were to decrease pH, however, the program would remove H+ and SO4-- from the intermediate instance to maintain the pH. In that case, the configuration is not realistic. I’m assuming here that you’re monitoring pH in the real world as a proxy for sulfuric acid concentration, since that’s an effectively instantaneous measurement, but that may not be the case.

If that’s not quite right, a more complex solution might be to do something like the second task in the Time Marching Loops lesson in the ChemPlugin Modeling with Python Academy. In that example, the client titrates NaOH into a fluid and queries ChemPlugin for the pH after each small addition. It stops the titration when the desired pH is achieved. Perhaps you could titrate sulfuric acid into the fluid and query ChemPlugin for whatever you need, then once you reach that target, send that fluid to the inlet of your domain.

Hope this helps,
Brian
 
 

Share this post


Link to post
Share on other sites

Brain,

Thank you for the response. I am currently using the first approach you mention, but your second suggestion is also intriguing and will prove useful in the future. Thank you!

Regards,

Erik

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×