perform unit conversion -凯发k8网页登录
perform unit conversion
description
the unitconversion
property specifies whether
to perform unit conversion for the model before simulation. it is
a property of the compileoptions
object. compileoptions
holds
the model's compile time options and is the object property of the configset
object.
when unitconversion
is set to true
,
the simbiology® software converts the matching physical quantities
to one consistent unit system in order to resolve them. this conversion
is in preparation for correct simulation, but species amounts are
returned in the user-specified units.
for example, consider a reaction a b —>
c
. using mass action kinetics the reaction rate is defined
as a*b*k
where k
is the rate
constant of the reaction. if you specify that initial amounts of a
and b
are
0.01m and 0.005m respectively, then units of k
are 1/(m*second)
.
if you specify k
with another equivalent unit definition,
for example, 1/((molecules/liter)*second)
, unitconversion
occurs
after dimensionalanalysis
.
unit conversion requires dimensional analysis. if dimensionalanalysis
is
off, and you turn unitconversion
on, then dimensionalanalysis
is
turned on automatically. if unitconversion
is on
and you turn off dimensionalanalysis
, then unitconversion
is
turned off automatically.
if unitconversion
fails, then you see an
error when you simulate (sbiosimulate
).
if unitconversion
is set to false
,
the simulation uses the given object values.
characteristics
applies to | object: compileoptions (in configset object) |
data type | boolean |
data values |
|
access | read/write |
note
simbiology uses units including empty units in association
with dimensionalanalysis
and unitconversion
features.
when
dimensionalanalysis
andunitconversion
are bothfalse
, units are not used. however, simbiology still performs a minimum level of dimensional analysis to decide whether a reaction rate is in dimensions of amount/time or concentration/time.when
dimensionalanalysis
istrue
andunitconversion
isfalse
, units (if not empty) must have consistent dimensions so that simbiology can perform dimensional analysis. however, the units are not converted.when
unitconversion
is set totrue
(which requiresdimensionalanalysis
to betrue
), simbiology performs a dimensional analysis and converts everything to consistent units. hence, you must specify consistent units, and no units can be empty. if you have a dimensionless parameter, you must still set its unit todimensionless
.
tip
if you have a custom function and unitconversion
is
on, follow the recommendation below.
non-dimensionalize the parameters that are passed to the function if they are not already dimensionless.
suppose you have a custom function defined as
y = f(t)
wheret
is the time in hour andy
is the concentration of a species in mole/liter. when you use this function in your model to define a repeated assignment rule for instance, define it as:s1 = f(time/t0)*s0
, wheretime
is the simulation time,t0
is a parameter defined as 1.0 hour,s0
is a parameter defined as 1.0 mole/liter, ands1
is the concentration of a species in mole/liter. note thattime
ands1
do not have to be in the same units ast0
ands0
, but they must be dimensionally consistent. for example, thetime
ands1
units can be set to minute and picomole/liter, respectively.
examples
this example shows how to retrieve and set unitconversion
from
the default true
to false
in
the default configuration set in a model object.
import a model.
modelobj = sbmlimport('oscillator')
simbiology model - oscillator model components: models: 0 parameters: 0 reactions: 42 rules: 0 species: 23
retrieve the
configset
object of the model object.configsetobj = getconfigset(modelobj) configuration settings - default (active) solvertype: ode15s stoptime: 10.000000 solveroptions: absolutetolerance: 1.000000e-006 relativetolerance: 1.000000e-003 runtimeoptions: statestolog: all compileoptions: unitconversion: false dimensionalanalysis: true
retrieve the
compileoptions
object.optionsobj = get(configsetobj,'compileoptions') compile settings: unitconversion: false dimensionalanalysis: true
assign a value of false to
unitconversion
.set(optionsobj,'unitconversion', true)
see also
, , ,