| 219 | == Another UOM problems == |
| 220 | |
| 221 | Currently EMSO support Units Of Measurement (UOM) for variables, parameters, equations, etc. |
| 222 | But there is a potential problem when deriving types with a UOM: |
| 223 | |
| 224 | {{{ |
| 225 | #!mso |
| 226 | Model MyModel |
| 227 | VARIABLES |
| 228 | P as pressure(Unit = 'm') |
| 229 | ... |
| 230 | end |
| 231 | }}} |
| 232 | |
| 233 | The above model has serious problems: |
| 234 | - '''P''' derived from a pressure type but has a ''length'' unit |
| 235 | - What about the limits if the UOM changed? |
| 236 | |
| 237 | In order to fix this kind of problem the following changes are proposed: |
| 238 | - add a '''final''' modifier for the attributes, preventing it to be changed |
| 239 | - add another attribute called '''DisplayUnit''', which should be compatible with '''Unit''' (the GUI will report all results converted to this UOM) |
| 240 | - the limits are considered to be in respect to the '''Unit''' and not '''DisplayUnit''' |
| 241 | - declare all UOM in '''types.mso''' as '''final''' |
| 242 | |
| 243 | Sample code in the with the propositions included: |
| 244 | {{{ |
| 245 | #!mso |
| 246 | # Pressure |
| 247 | pressure as Real (Brief = "Pressure", Default=1, Lower=1e-30, Upper=5e7, final Unit = 'atm'); |
| 248 | press_delta as pressure (Brief = "Pressure Difference", Default=0.01, Lower=-5e6); |
| 249 | head as Real (Brief = "Head", Default=50, Lower=-1e6, Upper=1e6, final Unit = 'kJ/kg'); |
| 250 | |
| 251 | Model reactor |
| 252 | VARIABLES |
| 253 | C(NComp) as conc_mol(Brief="Concentration", DisplayUnit='mol/l', Lower=0); |
| 254 | Co(NComp) as conc_mol(Brief="Inlet concentration", DisplayUnit='mol/l', Lower=0); |
| 255 | ... |
| 256 | end |
| 257 | }}} |
| 258 | |
| 259 | |
| 260 | ||Who || Opinion || Why || |
| 261 | ||Rafael || '''agreed''' || Proposed the change || |
| 262 | |