Internal API

Here, all internal API is documented. Note that this is, as the name says, internal. Thus it is only intended for internal use and might change unexpectedly.

Index

ProcessSimulator Internal API

ProcessElement Interface

BioChemicalTreatment.ProcessSimulator.AbstractProcessElementType
AbstractProcessElement

An abstract type for every flow element for implementing generic functionality.

This abstract type is used for implementing generic functionality needed for every flow element, e.g. Reactor, FlowElement or Process. It defines the default interface and some general functions on them.

As this library is designed to be fully compatible with ModelingToolkit all flow elements should be convertible to an ODESystem. This abstract type then implements several functions from ModelingToolkit by falling back to this conversion. Further it implements the most general interface consisting of:

Extended help

Implementation

If implementing a type inheriting from this, the Base.convert(::Type{<:ODESystem}, x::AbstractProcessElement) should be implemented for the new type, and it should return a ModelingToolkit.ODESystem.

Further, where applicable, the following as well:

source
BioChemicalTreatment.ProcessSimulator.typestrFunction
typestr(sys::AbstractProcessElement)

Get a string representing the type of the processelement. Added to the type to carry additional data.

Defaults to the typestr field of sys or the real type.

source

Reactor

BioChemicalTreatment.ProcessSimulator.@reactorMacro
@reactor function NAME(ARGS; KWARGS)
    # Reactor implementation
    # Returns a Reactor, takes the `states` as arg
    # and `name` as kwarg
end

Given the Base implementation of a reactor, needs to be based on the states in the reactor, given as argument called states, automatically create methods to call the same reactor with one or multiple processes, which are then automatically connected.

Conditions for the provided function:

  • A vector of states is provided to the reactor in an argument called states. It can be of type Vector, but cannot have a default value.
  • The function must take the name of the resulting reactor as kwarg called name. Can be of type Symbol, but cannot have a default value.

Results in defining a function with the given name and two methods:

  • The function as given
  • A method for providing a Process or Vector{Process} instead of the states. Makes all processes internal to the reactor and automatically connected, adds the default processes as well. See the connection implementation.

Documents the added function as well. For this, the docstring of the original function is reused with the following modifications:

  • Replace the function call with the appropriate arguments

  • Replace everything beginning with:

    'The system defines the mass flow'

    by

    'This function constructs a REACTORNAME, directly with the supplied processes in it. If `usedefault_processes = true`, the default processes are added, which enables easy addition of processes to the default ones as well as calling this function without any process.'

  • Change of states parameter documentation by processes

  • Addition of parameter documentation for state_mapping and use_default_processes

source

Defaults

Ports

BioChemicalTreatment.ProcessSimulator.InflowPortFunction
InflowPort(components; initial_flow, initial_concentrations, set_guess, name)

A connector for connecting inflows carrying components.

Parameters:

  • components: The components in the flow. Can be provided as:
    • A Dict with keys being Strings representing the names of the components in the flow and values being Boolean meaning if the component is particulate or not. Does not include the flow rate.
    • An array of symbols for the components. Name and if particulate or not are taken from these symbols. May or may not include the the flow rate q.
  • initial_flow: The initial value for the flow rate q. Defaults to 0.
  • initial_concentrations: Initial concentrations of the components in the flow, supports array and variable map (keys can be string, symbol or symbolic variables). Defaults to 0 for each component or the default values of the symbols if given as symbols.
  • set_guess: Initial values set only guesses. This is to prevent contradicting initial conditions. Defaults to true.

States:

  • q: The flow rate
  • A state for each component specified by the components parameter.
source
BioChemicalTreatment.ProcessSimulator.OutflowPortFunction
OutflowPort(components; initial_flow, initial_concentrations, set_guess, name)

A connector for connecting outflows carrying components.

Parameters:

  • components: The components in the flow. Can be provided as:
    • A Dict with keys being Strings representing the names of the components in the flow and values being Boolean meaning if the component is particulate or not. Does not include the flow rate.
    • An array of symbols for the components. Name and if particulate or not are taken from these symbols. May or may not include the the flow rate q.
  • initial_flow: The initial value for the flow rate q. Defaults to 0.
  • initial_concentrations: Initial concentrations of the components in the flow, supports array and variable map (keys can be string, symbol or symbolic variables). Defaults to 0 for each component or the default values of the symbols if given as symbols.
  • set_guess: Initial values set only guesses. This is to prevent contradicting initial conditions. Defaults to true.

States:

  • q: The flow rate
  • A state for each component specified by the components parameter.
source
BioChemicalTreatment.ProcessSimulator.ReactionInputPortFunction
ReactionInputPort(components; initial_rates, name)

A connector for connecting reaction rates as input.

Parameters:

  • components: The components. Can be provided as:
    • An array of Strings for the component names.
    • An array of symbols for the components, from which the names are taken.
  • initial_rates: The initial reaction rates, supports array and variable map (keys can be string, symbol or symbolic variables). Defaults to 0 for all rates or the default value if given as symbolic.
  • set_guess: Initial values set only guesses. This is to prevent contradicting initial conditions. Defaults to true

States:

  • A state for each reaction rate specified by the components parameter.
source
BioChemicalTreatment.ProcessSimulator.ReactionOutputPortFunction
ReactionOutputPort(components; initial_rates, name)

A connector for connecting reaction rates as output.

Parameters:

  • components: The components. Can be provided as:
    • An array of Strings for the component names.
    • An array of symbols for the components, from which the names are taken.
  • initial_rates: The initial reaction rates, supports array and variable map (keys can be string, symbol or symbolic variables). Defaults to 0 for all rates or the default value if given as symbolic.
  • set_guess: Initial values set only guesses. This is to prevent contradicting initial conditions. Defaults to true

States:

  • A state for each reaction rate specified by the components parameter.
source
BioChemicalTreatment.ProcessSimulator.StateInputPortFunction
StateInputPort(states; initial_states, name)

A connector for connecting reactor states as input.

Parameters:

  • states: The states. Can be provided as:
    • A Dict with keys being Strings representing the names of the states and values being a named tuple with fields parBoolean or nothing meaning if the component is particulate or not (or not a component).
    • An array of symbols for the components. Name and if particulate or not are taken from these symbols.
  • initial_states: Initial states, supports array and variable map (keys can be string, symbol or symbolic variables). Defaults to 0 for each state or the default values of the symbols if given as symbols.
  • set_guess: Initial values set only guesses. This is to prevent contradicting initial conditions. Defaults to true

States:

  • A state for each state specified by the states parameter
source
BioChemicalTreatment.ProcessSimulator.StateOutputPortFunction
StateOutputPort(states; initial_states, name)

A connector for connecting reactor states as output.

Parameters

  • states: The states. Can be provided as:
    • A Dict with keys being Strings representing the names of the states and values being Boolean or nothing meaning if the component is particulate or not (or not a component).
    • An array of symbols for the components. Name and if particulate or not are taken from these symbols.
  • initial_states: Initial states, supports array and variable map (keys can be string, symbol or symbolic variables). Defaults to 0 for each state or the default values of the symbols if given as symbols.
  • set_guess: Initial values set only guesses. This is to prevent contradicting initial conditions. Defaults to true

States:

  • A state for each state specified by the states parameter
source

PortMetadata

BioChemicalTreatment.ProcessSimulator.set_port_metadata!Function
set_port_metadata!(port, pe::AbstractProcessElement)

Set the metadata of port which is an connector of the processelement pe according to its position in the process element.

source
set_port_metadata!(pe::AbstractProcessElement, getter_function)

Set the metadata of all ports of pe which are output by applying the getter_function on it. The metadata is set according to its position in the process element.

Usually, the getter_function is one of

  • states: Set the metadata of all states in the system
  • rates: Set the metadata of all rates in the system
  • inflows: Set the metadata of all inflows in the system
  • outflows: Set the metadata of all outflows in the system
  • exogenous_inputs: Set the metadata of all exogenous_inputs in the system
  • exogenous_outputs: Set the metadata of all exogenous_outputs in the system
source
set_port_metadata!(pe::AbstractProcessElement)

Set the metadata all connectors in the processelement pe according to the type and it position in the process element.

source
BioChemicalTreatment.ProcessSimulator.assemble_port_metadata_fieldsFunction
assemble_port_metadata_fields(port, pe::AbstractProcessElement)

Get the metadata fields of port which is an connector of the processelement pe according to its position in the process element. Throws an error if the port is not found in any of the connectors of the process element pe.

source
assemble_port_metadata_fields(port, parent::ModelingToolkit.AbstractSystem; port_type = :unknown)

Get the metadata fields of port which is an connector of the system pe. The fields are assigned as followed

  • name: The name of the port with the name of the parent stripped on the left.
  • type: The given port_type argument. Defaults to :unknown.
  • isinput: false if the any part of the namespace in the name (without the parent) starts with the regex r"[Oo]ut(put)?". Otherwise true -> Default treated as
  • index: If any part of the namespace in the name (without the parent) ends with a number, the last of these numbers is the index. If none, default to 1.
  • parent: The given parent system

Throws a warning if the name of the port does not start with the name of the parent.

source

Utilities

BioChemicalTreatment.ProcessSimulator.to_ordered_arrayFunction
to_ordered_array(order, vals; default = 0)

A helper function to transform the values to a array with elements ordered as given by order. Supports a array or variable maps (keys as Symbols, Strings or Symbolic variables). The default gets applied to all elements in order, which do not have a corresponding entry in vals.

If default = nothing, no defaults are applied and an error is thrown if no value is supplied for any element in order.

source
BioChemicalTreatment.ProcessSimulator.realports_from_combinedportFunction
realports_from_combinedport(port::ODESystem; name, output_port = false)

Helper function for StandardLibrary Ports compatibility: Generates a RealInput/RealOutput for each state in the port. Returns a ODESystem with the equations for setting the new ports and the corresponding state equal and the newly generated In-/Outputs

source
BioChemicalTreatment.ProcessSimulator.symbolic_to_namestringFunction
symbolic_to_namestring(sym; namespace_separator=ModelingToolkit.NAMESPACE_SEPARATOR)

A helper function to get the name of a symbol as string. Removes all namespacing (split by namespace_separator) and dependencies. E.g.

julia> sym
"system₊component₊variable(t)"
julia> ProcessSimulator.symbolic_to_namestring(sym)
"variable"
source
BioChemicalTreatment.ProcessSimulator.strip_dependenciesFunction
strip_dependencies(sym)

Strip the dependencies (e.g. t, in brackets (t)) of sym. If sym isa Symbolics variable, it's name is taken. E.g.

julia> sym
"system₊component₊variable(t)"
julia> ProcessSimulator.strip_dependencies(sym)
"system₊component₊variable"

Works independent of the number of arguments in the dependencies:

julia> sym
"system₊component₊variable(t, x, y)"
julia> ProcessSimulator.strip_dependencies(sym)
"system₊component₊variable"

Or as well for Symbols (or everything convertable to a string) and without any dependency:

julia> sym
:system₊component₊parameter
julia> ProcessSimulator.strip_dependencies(sym)
"system₊component₊parameter"
source
BioChemicalTreatment.ProcessSimulator.lstrip_namespaceFunction
lstrip_namespace(sym, str; namespace_separator=ModelingToolkit.NAMESPACE_SEPARATOR)

Removes the namespacing matching str of the beginning of symbol name of sym. Namespacing is separated by namespace_separator. E.g.

julia> sym
"system₊component₊subcomponent"
julia> ProcessSimulator.lstrip_namespace(sym, "system")
"component₊subcomponent"
julia> ProcessSimulator.lstrip_namespace(sym, "system₊component")
"subcomponent"

If sym does not contain str in the beginning, nothing is stripped (no matter of how much matches) and the input is returned as a whole:

julia> ProcessSimulator.lstrip_namespace(sym, "system₊component1")
"system₊component₊subcomponent"
source
BioChemicalTreatment.ProcessSimulator.rstrip_namespaceFunction
rstrip_namespace(sym, str; namespace_separator=ModelingToolkit.NAMESPACE_SEPARATOR)

Removes the namespacing matching str of the end of symbol name of sym. Namespace separator is set by namespace_separator E.g.

julia> sym
"system₊component₊subcomponent"
julia> ProcessSimulator.rstrip_namespace(sym, "subcomponent")
"system₊component"
julia> ProcessSimulator.rstrip_namespace(sym, "component₊subcomponent")
"system"

If sym does not contain str in the beginning, nothing is stripped (no matter of how much matches) and the input is returned as a whole:

julia> ProcessSimulator.rstrip_namespace(sym, "component1₊subcomponent")
"system₊component₊subcomponent"
source
BioChemicalTreatment.ProcessSimulator.split_namespaceFunction
split_namespace(sym; namespace_separator=ModelingToolkit.NAMESPACE_SEPARATOR)

Get the namespace parts of a symbol as strings. The namespace is assumed to be split by the given namespace_separator. Defaults to ModelingToolkit.NAMESPACE_SEPARATOR. E.g.

julia> sym
"system₊component₊subcomponent"
julia> ProcessSimulator.split_namespace(sym)
3-element Vector{SubString{String}}:
 "system"
 "component"
 "subcomponent"
julia> sym = "system.component.subcomponent"
"system.component.subcomponent"
julia> ProcessSimulator.split_namespace(sym, namespace_separator='.')
3-element Vector{SubString{String}}:
 "system"
 "component"
 "subcomponent"
source
BioChemicalTreatment.ProcessSimulator.get_namespaced_propertyFunction
get_namespaced_property(value, name; namespace_separator=ModelingToolkit.NAMESPACE_SEPARATOR)

Get a propery of value, where name can contain namespacing separated by namespace_separator. Works on any value. E.g.

julia> a
(b = (c = 2,),)
julia> BioChemicalTreatment.ProcessSimulator.get_namespaced_property(a, "b.c"; namespace_separator='.')
2
julia> BioChemicalTreatment.ProcessSimulator.get_namespaced_property(a, "b/c"; namespace_separator='/')
2
source

ProcessDiagram

BioChemicalTreatment.ProcessSimulator.remove_elem!Function
remove_elem!(pd, chain_idx, column_idx)

Remove the element at (chain_idx, column_idx) and return it. If there is none, return missing. If an element is removed, it is replaced by missing and no elements are shifted.

chain_idx is the row, column_idx the column index. The indices are relative to a grid and start from the top left (treated including empty positions).

Warning

This can mess up the ProcessDiagram and make it incomplete if a non-missing element is removed.

source
BioChemicalTreatment.ProcessSimulator.strip_namespaceFunction
strip_namespace(sym; namespace_separator=ModelingToolkit.NAMESPACE_SEPARATOR)

Removes the entire namespacing of the symbol name of sym. Namespace is separated by namespace_separator. E.g.

julia> sym
"system₊component₊subcomponent"
julia> ProcessSimulator.strip_namespace(sym)
"subcomponent"
source
BioChemicalTreatment.ProcessSimulator.get_tikzpicture_bodyFunction
get_tikzpicture_body(pd::ProcessDiagram)

Get the body for the tikzpicture showing pd.

Does the heavylifting for making a tikzpicture from the ProcessDiagram.

Contains placing all nodes and the connections inbetween.

Places the nodes according to the ordering in pd and considers it for drawing the connections inbetween.

source
BioChemicalTreatment.ProcessSimulator.get_portmetadataFunction
get_portmetadata(sys, systems)

Get the port metadata of the system.

If it is already in the metadata of sys, simply return it.

If not, find the parent system in systems and use assemble_port_metadata_fields to get the associated metadata. A system in systems is considered a potential parent of sys if:

  • The name of sys (including namespacing) starts with the name of the parent
  • If there are multiple, take the one with the shortest name (the most upper parent)
source
BioChemicalTreatment.ProcessSimulator.find_reference_chainsFunction
find_reference_chains(chains)

Find the indices of the reference chains to start horizontally ordering the other chains.

Chosen as (first that matches):

  • First and last elements in the chain do not occur in other chains (multiple can match).
  • First **or"" last element in the chain does not match another chain. If multiple, pick the longest one.
  • Pick the longest chain
source
BioChemicalTreatment.ProcessSimulator.get_blockingFunction
get_blocking(pd::ProcessDiagram, chain_idx::Integer, ref_chain::Integer)

Get a boolean array which is true where the chain at index idx blocks the space for the elements in ref_chain. A chain is blocking each index which is:

  • Occupied by an element
  • A connection going to the left/right, but not to the reference chain
source
BioChemicalTreatment.ProcessSimulator.insert_elem!Function
insert_elem!(pd, chain_idx, column_idx, elem)

Insert the element elem at (chain_idx, column_idx). All elements right of this one, until the next missing one, are shifted to the right.

chain_idx is the row, column_idx the column index. The indices are relative to a grid and start from the top left (treated including empty positions).

Warning

This can mess up the ProcessDiagram and make it incomplete if a non-existant element is inserted.

source
BioChemicalTreatment.ProcessSimulator.order_connectionsFunction
order_connections(pd, elem)

Order the connections of the node elem in direction of connection (left, right, up, down) and edge direction.

Is used for nice printing of the connections, that they exit the node at a good position.

Returns an Array of Arrays (similar to 2d-matrix), each element of which is associated with a direction for the connection and a direction of the first edge. The ordering is as follows:

Node edge \ first bend directionleft or upstraightdown or right
leftleft-upleft-straightleft-down
rightright-upright-straightright-down
toptop-lefttop-straighttop-right
bottombottom-leftbottom-straightbottom-right

Each element in this table is a vector of connections (tuples of the connected port metadata, always the one being part of elem.parent first) which have this property.

source
BioChemicalTreatment.ProcessSimulator.get_node_styleFunction
get_node_style(elem; opts=missing, get_def=false)

Get the node style for printing the element using Latex/Tikz. Determines the styling of the resulting node. Parameters for it are given in opts. Check ProcessDiagram for the defined options.

If get_def=true, return the style definition (i.e. what should be inserted as STYLEOPTIONS into `\tikzstyle{name} = [STYLEOPTIONS]`), otherwise only the name.

Note

If get_def = true, opts must be given as well.

Defaults to a simple rectangular block.

Note

If you add new styles, make sure that the resulting block has:

  • width: blockwidth
  • height: blockheight

as otherwise the plotting will not match. If you need the text width,

source
BioChemicalTreatment.ProcessSimulator.get_element_positionsFunction
get_element_positions(chains, shifts, elem)

Get all positions where elem is found in chains considering the chain shifts in shifts.

Returns a vector with tuples of the form (chain_idx, column_idxs) for each chain containing elem. chain_idx is the index of the chain, column_idxs is an array with all columns in this chain which contain this elem.

source
get_element_positions(pd::ProcessDiagram, elem)

Get all positions where elem is found in the chains of pd. See get_element_positions for details.

source
BioChemicalTreatment.ProcessSimulator.assemble_chainsFunction
assemble_chains(metadata_connections; conn_type_precedence = [[:flow], [:state, :rate, :exogenous, :unknown]])

Assemble chains (considered straight rows) of systems from the given metadata connections and directly order them vertically.

Parameters

  • metadata_connections: The connections that define the ProcessDiagram.
  • conn_type_precedence: The precedences between the different connectors. First only connections of the first precedence type are considered, then of the second etc. Is a vector of vectors the inner of which contain the types of same precedence.

Assembling a chain

To assemble a chain it is proceeded as follows (details below):

  1. Find a first element for the chain
  2. Find next elements in the chain
  3. Order the chain vertically into the already assembled chains

Finding the first element

Determined as (First rule that matches a system):

  1. Systems that have only outputs and no inputs (in this precedence type)
  2. Any that has an output (in this precedence type)
  3. Any that has a connector (in- or output) in this precedence type

If none is found, go to the next precedence types or stop

For all of these rules, they is always first checked for systems already in the chain before going to new ones.

Finding the next elements in the chain

Add new systems to the chain, until no matching is found anymore.

A new system is considered matching if and only if:

  • The system is connected at output port 1 with a connection of the given precedence type.
  • The system is not yet in the current chain
  • The system is not yet in any already assembled chain

For the last element in the chain, an exception is made and it can be already in an assembled chain or the first one of the current chain.

Like this, the first and last elements in each chain can occur in an other chain and then indicate that there is a connection between them. This is later used to horizontally order the chains.

Ordering the chain vertically into the already ordered chains

This is done using the following heuristic:

Default to the bottom (last index), then move up one by one as long as any of the following holds (checked in this order):

  • No connection to the next upper one and none to any of the lower ones
  • No connection to any lower one but a connection between any lower one and an upper one
  • No connection to any lower one but the next upper one is connected to a lower one
source
BioChemicalTreatment.ProcessSimulator.order_chains_horizontallyFunction
order_chains_horizontally(chains)

Get the horizontal shifts to move the chains on the grid.

Logic:

  1. Find a reference chain (see find_reference_chains)
  2. While not all chains are ordered, pick a random (not yet ordered) chain to order from a pot (initially containing all unordered chains)
    • If the first or last element of this chain occurs in the middle of any unordered chain
      • Remove this one from the pot
      • Put the ones this connects to the middle of back into the pot
      • Pick a new one
    • If there is no match of the first or last element in this chain with an already ordered one
      • Remove this one from the pot
      • If there are no new ones to pick, pick new reference chains from all not yet ordered ones and put all not yet ordered ones back into the pot
      • Pick a new one
    • Find the horizontal index of the first and last elements in the already ordered chains
    • If the chain has only one or two elements and all of them are contained in others
      • Remove it (as it is an internal connection of another chain)
      • Pick a new one
    • If only one end of the chain matches
      • Make it the first one (reverse if it is the last one)
      • Insert missing columns of the length of this chain (no vertical overlap with any except the first element)
      • Remove the first element from the chain (the same as contained in the already ordered chain)
      • Set the shift to have the first element overlapping with the matching one
    • If both ends of the chain match
      • If the first is more to the right as the last
        • Reverse the chain
      • If neccessary, insert as much columns s.t. the first and last element can match
      • Remove the first and last elements from the chain (the same as contained in the already ordered chain)
      • Set the shift to have the first element overlapping with the matching one

The random picking of chains is done intelligently: If a chain is not yet to be ordered, it is removed from the pot. As soon as a new chain has been ordered, all non-ordered chains are put back into the pot.

Returns the new chains (redundant removed and reversed where neccessary) and the shifts to shift the chains horizontally.

source
BioChemicalTreatment.ProcessSimulator.squeeze_vertically!Function
squeeze_vertically!(pd::ProcessDiagram)

Squeeze the process diagram in the vertical direction by merging neighbouring chains as long as possible.

Merging is considered possible as long as:

  • There are no overlaps between systems
  • There is no connection:
    • From the first to the left to an element further than (or at same distance) the last of the other chain
    • From the last to the right to an element further than (or at same distance) the first of the other chain

Repeated iteratively, as long as chains can be merged.

source
BioChemicalTreatment.ProcessSimulator.straightify_verticals!Function
straightify_verticals!(pd)

Shift full chains to make the vertical connections in the ProcessDiagram as straight as possible.

Heuristic

Go over all chains and do (in this sequence):

  1. If one of the endings is not connecting (starting/ending node) -> do not shift
  2. If both ends are connected in one and the same direction only -> shift by the minimal shift in this direction
  3. If no end has a non-straight connection to a middle element -> do not shift
  4. If any end has a non-straight connection to a middle element and all of those are in the same direction -> shift by the most often occuring shift in this direction
source

Reactions Internal API

BioChemicalReactionSystem

BioChemicalTreatment.Reactions.parameter_expressionsFunction
parameter_expressions(sys::BioChemicalReactionSystem, default=0; kwargs...)

Return a dict mapping parameters associated with expressions to the corresponding expression. Defaults for each parameter can be overridden in kwargs, overall default (if nothing else provided) is set by default.

source
BioChemicalTreatment.Reactions.parameter_valuesFunction
parameter_values(sys::BioChemicalReactionSystem, default=0; kwargs...)

Return a dict mapping parameters to the corresponding values. For parameters associated with expressions, the expression is evaluated. Currently only works if there are no dependencies of expressions on other non-numeric parameters. Defaults for each parameter can be overridden in kwargs, overall default (if nothing else provided) is set by default.

source
BioChemicalTreatment.Reactions.parameter_value_or_expressionFunction
parameter_value_or_expression(sys::BioChemicalReactionSystem, default=0; kwargs...)

Get the value or expression for each parameter of the given sys. Defaults can be overridden by providing corresponding kwargs.

Returns a dict with keys being the parameters and values the corresponding value or expression. For values, the following values are taken (always the first in the list that exists):

  1. Value or expression provided in kwargs
  2. Default value provided in system
  3. Default expression provided in system
  4. default parameter provided to this function
source

Parsing

BioChemicalTreatment.Reactions.DEFAULT_PARSING_CONTEXTConstant
DEFAULT_PARSING_CONTEXT

The default context used for parsing expressions. Contains only mathematical functions.

This is done to restrict to mathematical functions which hopefully should prevent remote code execution problems. (Generally anyways no problem as only trusted models should be included. But add additional layer of security)

source
BioChemicalTreatment.Reactions.parse_equationFunction
parse_equation(eqn, symbols; context::AbstractDict = DEFAULT_PARSING_CONTEXT)

Parse an equation given as Expr or String. Only Numbers, Variables given in symbols, and functions from context are parsed. If a symbol not found in any of those, an error is thrown.

Purpose of this is to restrict available functionality when parsing strings. Should mitigate problematic remote code execution if symbols and context is chosen appropriately.

source
BioChemicalTreatment.Reactions.parse_variableFunction
parse_variable(var; 
               dependency::AbstractArray{<:Union{Symbolics.BasicSymbolic, Symbolics.Num}} = Symbolics.Num[], 
               description::AbstractString = "", particulate::Union{Bool, Nothing} = nothing, 
               colloidal::Union{Bool, Nothing} = nothing, soluble::Union{Bool, Nothing} = nothing)

Parse the variable var and return a Symbolics variable with this name. Keyword arguments to specify properties of it.

Available keyworks/properties:

  • description: Description of the variable
  • particulate: If the represented compound is particulate
  • colloidal: If the represented compound is colloidal
  • soluble: If the represented compound is soluble
source
BioChemicalTreatment.Reactions.parse_statesFunction
parse_states(statemat, header)

Parse the states given in matrix statemat with header header. Required fields are:

  • name: The name of the state
  • description: The description of the state
  • particle_size: The particle size; particulate, colloidal or soluble. Multiple can be specified (just need to contain all of them)
source
BioChemicalTreatment.Reactions.parse_paramsFunction
parse_params(paramsmat, header)

Parse the parameters given in matrix paramsmat with header header. Required fields are:

  • name: The name of the parameter
  • description: The description of the parameter

Optional fields are:

  • expression: An expression to set the parameter if no value is given. Can consist of the parameters and the functions in DEFAULT_PARSING_CONTEXT.
source
BioChemicalTreatment.Reactions.parse_processratesFunction
parse_processrates(statemat, header, states, params)

Parse the process rates given in matrix ratesmat with header header. Required fields are:

  • name: The name of the parameter
  • description: The description of the parameter
  • equation: The rate equation. Allowed symbols are the variables defined in states and params and the functions in DEFAULT_PARSING_CONTEXT.
source
BioChemicalTreatment.Reactions.parse_compmatFunction
parse_compmat(compmat, mat_states, composition_names, params)

Parse the composition matrix given in compmat with columns specified by state variables mat_states and the composition in the rows are named composition_names. It can contain numbers, the parameters in params and mathematical functions in DEFAULT_PARSING_CONTEXT.

source

Utilities