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[EMAIL PROTECTED]206-685-2007 On Thu, 29 May 2008, Andrew Miller wrote: Date: Thu, 29 May 2008 11:29:50 +1200 From: Andrew Miller [EMAIL PROTECTED] To: James Lawson [EMAIL PROTECTED] Cc: James Lawson [EMAIL PROTECTED], [EMAIL PROTECTED] 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.
Re: [cellml-discussion] unit conversion
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Lawson Sent: Tuesday, 3 June 2008 11:07 a.m. To: Erik B Cc: cellml-discussion@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[EMAIL PROTECTED]206-685-2007 On Thu, 29 May 2008, Andrew Miller wrote: Date: Thu, 29 May 2008 11:29:50 +1200 From: Andrew Miller [EMAIL PROTECTED] To: James Lawson [EMAIL PROTECTED] Cc: James Lawson [EMAIL PROTECTED], [EMAIL PROTECTED] 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
Re: [cellml-discussion] unit conversion
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Lawson Sent: Tuesday, 3 June 2008 11:07 a.m. To: Erik B Cc: cellml-discussion@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
Re: [cellml-discussion] unit conversion
Mike Cooling wrote: 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. Units already allow words like micro, milli and so on to be specified on them to specified as the prefix, and other scaling factors can be attached to units using multiplier. Although you can technically talk about a mole of anything, the way it is used by the SI system of units, it is always talking about a mole of some kind of particle, whether that particle is an electron or some large protein. As such, mole, when used in this sense, truly is a unit as the term is used in CellML, rather than just a scaling factor (and in fact, it would make sense to define a 'particle' derived unit in terms of mole using a multiplier of the inverse of Avogadro's number). 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. This is a perfectly valid way of expressing the model, and if necessary, editing tools could help the user to create such units as required - we shouldn't complicate the specification substantially for processing tools based on what might make it easier to do something with current editing tools, because editing tools will have to change for CellML 1.2 anyway. (I think the use of 'liter' above should also be replaced with 'dimensionless', but that is a different issue). It doesn't really make sense to say nanodimensionless per microdimensionless, I prefer nanolitres per microlitre even though you need to duplicate it if you have other conversion factors. We could also include dozen, which would aid the bakery-modelling community too ;). If we are talking about dozens of particles, that can already be done in terms of moles easily using multiplier 12 / nA (i.e. 1.99264653979527 * 10^-23) Best regards, Andrew -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Lawson Sent: Tuesday, 3 June 2008 11:07 a.m. To: Erik B Cc: cellml-discussion@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
Re: [cellml-discussion] unit conversion
Oh, to clarify, I mean the statement It doesn't really make sense to say nanodimensionless per microdimensionless DOES in fact make sense.Colloquially we say.. Etc etc. From: Mike Cooling [mailto:[EMAIL PROTECTED] Sent: Tuesday, 3 June 2008 1:42 p.m. To: 'CellML Discussion List' Subject: RE: [cellml-discussion] (OT) the nature of 'mole' | Re: unit conversion Andrew said: It doesn't really make sense to say nanodimensionless per microdimensionless, I prefer nanolitres per microlitre even though you need to duplicate it if you have other conversion factors. Duplication brings in the possibility of error and inconsistencies, and is tedious and I think should be reduced at all points. I think your statement above makes perfect sense, it just isn't commonly said. Colloquially we say how many femtos in a micro? - same thing. But, I wasn't advocating using dimensionless really, I think these conversions between prefixes could be built in, just as the prefixes themselves are. If reducing constructs in the specification was your goal then prefixes are unnecessary and could be implemented via multipliers. At the moment, we provide prefixes as a separate construct without easy conversion between them - it just seems like we are providing half a feature. ___ cellml-discussion mailing list cellml-discussion@cellml.org http://www.cellml.org/mailman/listinfo/cellml-discussion