How ChemPlugin works

With the ChemPlugin self-linking software object, you can create full-featured reactive transport simulators in any configuration simply, quickly, and reliably.

You supply the top-level program that calls the shots. ChemPlugin instances do the work, solving the mass and heat transport equations, and evaluating the chemical state of equilibrium and kinetic reactions.

This page explains how ChemPlugin works. In the ChemPlugin User's Guide, we develop from scratch a series of short client programs; the repurposing page outlines how to transform a legacy model into an RT simulator.

Client program
Client program

Client Program is the boss. Every ChemPlugin application starts with a client program. The client may be either

  • A C++, FORTRAN, or Python program, or
  • A legacy flow model being repurposed as an RT simulator

A client might be a couple dozen lines of code, or thousands. Regardless, the client runs the show!

ChemPlugin instances
ChemPlugin instances

Client spawns ChemPlugin instances. The client creates one or more copies of the ChemPlugin object.

To create an instance, the client simply declares it, as it would a variable or data structure.

Each copy of ChemPlugin is known as an instance, and each instance is memory-independent of other instances.

An instance represents a portion of the domain: a nodal block, finite volume, reach of stream, length of pipe, or a reactor tank, for example.

Member function calls
Member function calls

Instances are controlled by member functions. The client controls each ChemPlugin instance by calling the instance's member functions.

Member function Config(), for example, configures the instance, whereas Initialize() triggers the instance to determine its initial state.

Instances self-link and work together
Member function calls

Instances self-link into any geometry. The client uses the Link() member function to connect one ChemPlugin instance to another.

In this way, the client forms a domain of any geometry. The domain might be a continuum in one, two, or three dimensions, a branching chain, a network, and so on.

By calling the FlowRate() and Transmissivity() member functions, the client controls zero-order and first-order transport across each link.

The instances work together as a quorum to model transport and chemical reaction. Member functions AdvanceTimeLevel(), AdvanceTransport(), AdvanceHeatTransport(), and AdvanceChemical() trigger the instances to time march through a simulation.

Client retrieves results
Member function calls

Results available to client program. Throughout the simulation, the results calculated by the quorum of ChemPlugin instances are available immediately to the client program.

The client uses the Report() member function to retrieve results from a ChemPlugin instance. The client can then write out the results for later plotting by the user.

The client can also use the result to initiate feedback loops. Minerals that precipitate at an instance can affect permeability, for example, in turn changing flow rate within the domain.