- From: m.cooling at auckland.ac.nz (Mike Cooling)
- Subject: [cellml-discussion] unit conversion
- Date: Tue, 3 Jun 2008 11:43:33 +1200
Could we perhaps consider built-in scaling factors for CellML 1.2?
That way could still support the SI units but just that one of them (mole)
is as a scaling factor which is what it is as far as I can see.
We might also include built-in scaling factors for converting between
prefixes. For example if I have
a variable A in nanomolar and another B in micromolar I might want to say:
A = 1e3 * B
One way to do this is to define a scaling factor unit say (in CORspeak)
def unit nanospermicro from
unit liter {pref: nano};
unit liter {pref: micro, expo:-1};
enddef;
and then have
A = 1e3 {nanospermicro} * B.
Which is slightly clunky.
(I think the use of 'liter' above should also be replaced with
'dimensionless', but that is a different issue).
We could also include dozen, which would aid the bakery-modelling community
too ;).
-----Original Message-----
From: cellml-discussion-bounces at cellml.org
[
mailto:cellml-discussion-bounces at cellml.org] On Behalf Of Peter Hunter
Sent: Tuesday, 3 June 2008 11:35 a.m.
To: CellML Discussion List
Subject: Re: [cellml-discussion] unit conversion
Hi Mike,
I agree - but there they are in the SI base unit list see
http://physics.nist.gov/cuu/Units/units.html
so probably 150 years too late to do much about it!
Cheers,
Peter
Mike Cooling wrote:
>
Does it strike anyone else as inconsistent that 'moles' are a unit
>
when moles are just a scaling factor? Like dozen. Maybe they should be
>
implemented using 'multiplier' or similar rather than a base unit.
>
>
For example, I could have a mole of amps. I couldn't have a second of
amps.
>
>
>
>
-----Original Message-----
>
From: cellml-discussion-bounces at cellml.org
>
[mailto:cellml-discussion-bounces at cellml.org] On Behalf Of James
>
Lawson
>
Sent: Tuesday, 3 June 2008 11:07 a.m.
>
To: Erik B
>
Cc: cellml-discussion at cellml.org
>
Subject: Re: [cellml-discussion] unit conversion
>
>
Thanks Erik,
>
>
I managed to fix the issue before receiving your email, but this
>
clears things up for me very concisely. I would venture to say that
>
the reason that so many CellML models in the CellML repository do not
>
pass Jsim's units checking is not because of CellML, or any tools used
>
to create CellML models. Rather it is often because the models
>
themselves contain unit inconsistencies. It does not help that units
>
are irrelevant to most modelling tools, but I think the modelling
>
community is starting to raise the bar with regards to this issue.
>
Unfortunately it is often quite difficult to 'fix' inappropriate units
>
(both quantitatively and
>
qualitatively,) in a model without breaking it.
>
>
FYI I've uploaded the model in question, which now runs in Jsim, COR
>
and PCEnv, at:
>
http://www.cellml.org/models/sachse_moreno_abildskov_2008_version02
>
>
The 'auto' setting for the integrator in Jsim will not run the model -
>
the CVode integrator must be selected manually.
>
>
Kind regards,
>
James Lawson
>
>
Erik Butterworth wrote:
>
> On Thu, 29 May 2008, Andrew Miller wrote:
>
>
>
>> I think James had something more along the lines of:
>
>> I_inter_fibro = 10^6 * (V_fibro - V) / R_mf (where 10^6 is marked as
>
>> a dimensionless number).
>
>>
>
>> In this case the intention of the modeller is that the expression
>
>> being equated to I_inter_fibro is already in nanoamps, and this will
>
>> give the correct results in PCEnv and COR, I believe.
>
>>
>
>> I agree that it would be better modelling practice to mark 10^6 as
>
>> being in units nanoamps per milliamps, and in this case PCEnv and
>
>> COR will give correct results of 1E6 nanoamperes (and I presume also
JSim?).
>
> Short answer: yes.
>
>
>
> Long answer: JSim has two unit conversion modes, on and off. With
>
> conversion on, the simplest correct formation in MML is
>
>
>
> 1. I_inter_fibro = (V_fibro - V) / R_mf;
>
>
>
> With unit conversion off, the simplest correct formation is:
>
>
>
> 2. I_inter_fibro = 10^6 * (V_fibro - V) / R_mf;
>
>
>
> With either unit conversion on or off, a dimensionalized constant
>
> will produce correct results, at the expense of conciseness:
>
>
>
> 3. I_inter_fibro = (10^6 nanoamp/milliamp) * (V_fibro - V) / R_mf;
>
>
>
> To be compatible with (my understanding of) the CellML units spec,
>
> JSim's CellML -> MML converter creates MML with unit conversion on.
>
> However, due the the historically large (although perhaps decreasing)
>
> number of CellML models that didn't pass JSim unit balance, the JSim
>
> WWW site provides (for CellML models not passing unit balance) an
>
> "imperfect" MML translation with unit conversion off. This allows
>
> the models to be compiled and run, even if they may need conversion
>
> factor editing. Even if the CellML model doesn't pass JSim unit
>
> balance, it would still run correctly if all needed conversion
>
> factors were in the CellML in form #3 above.
>
>
>
> Hope this helps,
>
>
>
> Erik B.
>
>
>
>
>
>
>
>> At least my reading of the CellML specification is that tools should
>
>> not be automatically inserting conversion factors like this when
>
>> processing CellML models, although they may optionally warn the user
>
>> that a conversion factor may be missing and / or offer to insert it
>
>> for them.
>
>>
>
>> Best regards,
>
>> Andrew
>
>>
>
>>> Erik Butterworth butterw at u.washington.edu 206-685-2007
>
>>>
>
>>> On Thu, 29 May 2008, Andrew Miller wrote:
>
>>>
>
>>>> Date: Thu, 29 May 2008 11:29:50 +1200
>
>>>> From: Andrew Miller <ak.miller at auckland.ac.nz>
>
>>>> To: James Lawson <j.lawson at auckland.ac.nz>
>
>>>> Cc: James Lawson <j.lawson at auckland.ac.nz>,
>
>>>> butterw at u.washington.edu
>
>>>> Subject: Re: unit conversion
>
>>>>
>
>>>> James Lawson wrote:
>
>>>>> Hi Andrew, Justin,
>
>>>>>
>
>>>>> Thanks for your help. Basically, I've had to multiply a current
>
>>>>> by a scaling factor of 1 million to get the model to run in
>
>>>>> PCEnv. It was made in Jsim and worked fine, but now I have a
>
>>>>> model that will run in PCEnv but not Jsim. Do you guys have any
>
>>>>> idea about what I could do to get it running in both? Would
>
>>>>> showing you the model help? I could email the Jsim guys and ask
>
>>>>> them if I knew what to ask.. It seems like Jsim doesn't really
>
>>>>> convert nanoamps into
>
>>>>> 10e-6 amps and work with the value from there, whereas PCEnv does.
>
>>>>> Would this be right?
>
>>>>>
>
>>>>> Basically the issue that I have addressed is that units for the
>
>>>>> variables in the equation for I_inter_fibro aren't dimensionally
>
>>>>> equivalent:
>
>>>>>
>
>>>>> The equation is: I_inter_fibro =(V_fibro - V) / R_mf
>
>>>>>
>
>>>>> Where I_inter_fibro is in nanoamperes, V_fibro and V are in
>
>>>>> millivolts and R_mf is in ohms. So the equation says that
>
>>>>> nanoamps = millivolts / ohms. Thus I have changed the equation to
>
>>>>> say I_inter_fibro = 1e+06 * (V_fibro - V) / R_mf
>
>>>> Hi James,
>
>>>>
>
>>>> What are the units on the 1E6 scaling factor? If you put them in
>
>>>> nanoamps_per_milliamp or something like that, then I think all
>
>>>> software should do the right thing. Automatically inserting the
>
>>>> conversion factor is not the correct software behaviour however;
>
>>>> at most software should be flagging the problem and helping the
>
>>>> user to insert the factor if they decide there is an actual problem.
>
>>>>
>
>>>> Best regards,
>
>>>> Andrew
>
>>>>
>
>>>>> So at the moment I do not know how to get the model to run in
>
>>>>> both PCEnv and Jsim. What I'll do is upload a variant of the
>
>>>>> model to the repository with different curation notes, but
>
>>>>> ideally I should be able to get one model that runs in both
>
>>>>> environments. This looks like it might be a pretty persistent problem
unfortunately.
>
>>>>>
>
>>>>> Thanks,
>
>>>>> James
>
>>>>>
>
>>>>> Andrew Miller wrote:
>
>>>>>> James Lawson wrote:
>
>>>>>>> Hi guys,
>
>>>>>>>
>
>>>>>>> I was wondering if you might be able to help me out with a
>
>>>>>>> curation issue. I've been working on a model that was tested in
>
>>>>>>> Jsim that just wasn't producing the right results in PCEnv.
>
>>>>>>> Finally I figured out that it was something to do with the
>
>>>>>>> magnitude of a current being out by a factor of a million -
>
>>>>>>> milli to nano. So obviously this is something to do with unit
>
>>>>>>> conversions being applied in one tool and not the other. I was
>
>>>>>>> under the impression that it was Jsim that doesn't apply units
>
>>>>>>> conversions and PCEnv and COR that do - am I right here? I'm
>
>>>>>>> worried that having fixed the model under PCEnv, I've broken it
>
>>>>>>> under Jsim. Could you guys please explain here?
>
>>>>>>>
>
>>>>>>> I do have JSim on my computer but I'm unable to figure out how
>
>>>>>>> to import a CellML file into it and run it.
>
>>>>>> PCEnv carries out units conversions at the connections (so if
>
>>>>>> you cannot something in millimol/L to something in nanomol/L it
>
>>>>>> will convert for you; this is what the CellML specificatin
requires).
>
>>>>>> COR doesn't do this, and instead gives an error if you try to
>
>>>>>> connect variables in diffferent units. I've heard that some
>
>>>>>> versions of JSim try to actually change the maths to insert
>
>>>>>> conversion factors in at the equation level - but I believe this
>
>>>>>> is usually turned off.
>
>>>>>>
>
>>>>>> Best regards,
>
>>>>>> Andrew
>
>>>>
>
>>
>
>
>
_______________________________________________
>
cellml-discussion mailing list
>
cellml-discussion at cellml.org
>
http://www.cellml.org/mailman/listinfo/cellml-discussion
Archive powered by MHonArc 2.6.18.