idaholab / moose

Multiphysics Object Oriented Simulation Environment
https://www.mooseframework.org
GNU Lesser General Public License v2.1
1.77k stars 1.05k forks source link

Geochemistry: reactive transport #15693

Closed WilkAndy closed 4 years ago

WilkAndy commented 4 years ago

Reason

Implement reactive-transport in the geochemistry module to allow these kinds of simulations

Design

As i implement this functionality, i'll note the enhancements here since i'm currently not exactly sure what is required.

Impact

Reactive transport in the geochemistry module!

WilkAndy commented 4 years ago

Hey @loganharbour , in a NodalUserObject _subproblem.mesh().getMesh().n_local_nodes() gives me the number of nodes that will be looped over in execute(). This is also the size of the std::vector<something> that i'm trying to compute with my NodalUserObject (ie, the "something" exists at each node).

WilkAndy commented 4 years ago

Hi again @loganharbour . Can you give me some design advice?

At every node, i need a ModelGeochemicalDatabase. This holds the current basis species, the current equilibrium species, etc, that are relevant for that node. This is why i used a NodalUserObject in my "Reactor" classes. However, for reactive transport i see two possibilities, and i'm not really sure which is the best.

  1. At every node, i also have a GeochemicalSystem. This holds all the information about the current molalities (concentrations) of every species. In the NodalUserObject, i update this (given information about sources/sinks active at the node, and using a GeochemicalSolver) at every time step. There may be AuxVariables that record some of these molalities - they just use the existing GeochemistyQuantityAux.

  2. At every node I demand that there are AuxVariables that record the molalities (and any other info i need). Perhaps @YaqiWang 's VectorAuxVariable thing. I only have one GeochemicalSystem. In a loop over the nodes, i populate the single GeochemicalSystem using the AuxVariables at the current node, solve the system, and repopulate the AuxVariables with the solution.

The advantage of (1) is that it's pretty simple coding, since this was the design all along. It also allows users to be quite precise with their "constraints", eg fixing pH at one node but not another, although i'm not sure whether anyone will actually do this. However, it might be more complicated with mesh adaptivity, since i'm not relying on MOOSE doing the right thing with AuxVariables. Also, it's more difficult to restart a crashed simulation. Also, it uses more memory than (2).

If I go for (2), perhaps i shouldn't use a UserObject? I will need to const_cast the AuxVariables so i can directly write to them as soon as the GeochemicalSolver finds the solution. Perhaps i should use an AuxKernel instead that modifies a bunch of AuxVariables at once? But i still need a ModelGeochemicalDatabase at every node, which will be modified by the AuxKernel.

WilkAndy commented 4 years ago

I tried to do (2), above. It didn't work well because i couldn't actually write to the AuxVariables using the UserObject, boohoo. Not sure why - the const_cast was fine, but the AuxVariables didn't actually update.

(1) seems fine so far.

WilkAndy commented 4 years ago

I just completed my first reactive transport sim with geochemistry, @rpodgorney and @cpgr. Days of code-tidying to do, but the proof-of-concept is there - good way to end the week.

rpodgorney commented 4 years ago

Well done Andy. Enjoy your weekend.

-- Robert Podgorney, PhD, PG Geothermal Program Manager, Idaho National Laboratory Modeling and Simulation Lead, Utah FORGE Program Thermal Systems Co-Lead, INL Integrated Energy Systems Initiative

Office: 208-526-1524 Cell: 208-520-9361 email: robert.podgorney@inl.govmailto:robert.podgorney@inl.gov Statement of Confidentiality The contents of this e-mail message and any attachments are confidential and are intended solely for addressee. The information may also be legally privileged. This transmission is sent in trust, for the sole purpose of delivery to the intended recipient. If you have received this transmission in error, any use, reproduction or dissemination of this transmission is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply e-mail or phone and delete this message and its attachments, if any.

From: Andy Wilkins notifications@github.com Reply-To: idaholab/moose reply@reply.github.com Date: Friday, August 7, 2020 at 1:23 AM To: idaholab/moose moose@noreply.github.com Cc: Robert Podgorney Robert.Podgorney@inl.gov, Mention mention@noreply.github.com Subject: [EXTERNAL] Re: [idaholab/moose] Geochemistry: reactive transport (#15693)

I just completed my first reactive transport sim with geochemistry, @rpodgorneyhttps://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frpodgorney&data=02%7C01%7Crobert.podgorney%40inl.gov%7C9fcc0f4df09e4357baac08d83aa2cb62%7C4cf464b7869a42368da2a98566485554%7C0%7C0%7C637323818160662024&sdata=J8%2BoV6ldm0ED3PPrP%2BgQlUjnpFZonq1Rkac%2Bwk8RPvM%3D&reserved=0 and @cpgrhttps://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcpgr&data=02%7C01%7Crobert.podgorney%40inl.gov%7C9fcc0f4df09e4357baac08d83aa2cb62%7C4cf464b7869a42368da2a98566485554%7C0%7C0%7C637323818160662024&sdata=q5EdQ4pLlxq%2B%2BOslVG40R2dprkraxz6GZwm%2BfCNbz0w%3D&reserved=0. Days of code-tidying to do, but the proof-of-concept is there - good way to end the week.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fidaholab%2Fmoose%2Fissues%2F15693%23issuecomment-670371774&data=02%7C01%7Crobert.podgorney%40inl.gov%7C9fcc0f4df09e4357baac08d83aa2cb62%7C4cf464b7869a42368da2a98566485554%7C0%7C0%7C637323818160672018&sdata=LTwjcPQF%2B1CIVr2ECuBjFfeHHj9rXEMptiYBcANTdzU%3D&reserved=0, or unsubscribehttps://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACWGDT5E6EEIGFR7YZBLBV3R7OTXLANCNFSM4PSY4POQ&data=02%7C01%7Crobert.podgorney%40inl.gov%7C9fcc0f4df09e4357baac08d83aa2cb62%7C4cf464b7869a42368da2a98566485554%7C0%7C0%7C637323818160672018&sdata=ZIlc9TK2rju6gECamDsmrMMkZfAoVqEJJ0YpIzAXlT8%3D&reserved=0.