General Commands > About General Commands > model.unitSystem()

model.unitSystem()
Unit systems.
Syntax
UnitSystem us = model.unitSystem().create(<tag>);
us.baseUnit().create(<tag>,<symbol>,<quantity>)
us.derivedUnit().create(<tag>,<units>,<powers>);
us.additionalUnit().create(<tag>,<dim>);
model.unitSystem().builtInTags();
 
us.baseUnit(<tag>);
us.derivedUnit(<tag>);
us.additionalUnit(<tag>)
us.derivedUnit(<tag>).aliases();
us.baseUnit(<tag>).dimension();
us.derivedUnit(<tag>).quantity();
us.derivedUnit(<tag>).offset();
us.derivedUnit(<tag>).scale();
us.derivedUnit(<tag>).symbol();
us.derivedUnit(<tag>).definition(<units>,<powers>);
us.additionalUnit(<tag>).aliases(<aliases>);
us.additionalUnit(<tag>).quantity(<quantity>);
us.additionalUnit(<tag>).offset(<offset>);
us.additionalUnit(<tag>).scale(<scale>);
us.additionalUnit(<tag>).offset(<offset>);
us.additionalUnit(<tag>).symbol(<symbol>);
Description
model.unitSystem().create(<uname>) creates a unit system <uname>.
us.baseUnit().create(<tag>,<symbol>,<quantity>) creates a base unit for the quantity <quantity>, tagged <tag> with the symbol <symbol>. The quantity is any of the seven base dimensions (length, mass, time, current, temperature, substance, and intensity).
us.derivedUnit().create(<tag>,<units>,<powers>) creates a new derived unit tagged <tag> and derived from the units in <units> each to the power of the powers in <powers>.
us.derivedUnit(<tag>).definition(<units>,<powers>) sets the definition of a derived unit in powers of other units. The resulting dimension must agree with any previously specified dimension for this unit. Use the create method to define a dimension from the derived units.
us.additionalUnit().create(<tag>,<dim>) creates a new additional unit.
All methods below are valid for all units, no matter what unit list they belong to. Furthermore, only the set methods are described here, but there is also a corresponding get method.
model.unitSystem().builtInTags() returns the tags of the built-in unit systems. The method model.unitSystem().tags() returns the tags of the user-defined unit systems. Both sets of tags can be used to retrieve the unit system using model.unitSystem(<tag>).
us.additionalUnit(<tag>).aliases(<aliases>) sets alternate names for the unit that can be used in unit expressions.
us.additionalUnit(<tag>).quantity(<quantity>) assigns a physical quantity to the given unit.
us.additionalUnit(<tag>).scale(<scale>) sets the scale of the additional unit.
us.derivedUnit(<tag>).symbol(<symbol>) sets the symbol of the derived unit.
us.derivedUnit(<tag>).offset(<offset>) sets the offset of the derived unit.
Notes
You can set the base unit system for the entire model using model.baseSystem(<utag>) or separately for each model node using model.modelNode(<tag>).baseSystem(<utag>).
The SI system is read only and always created by default.
Example
Create a cgs2 unit system with the base unit for length set to centimeter (cm). Also add meter/second (m/s) as a derived unit for speed and degrees Celsius as an additional unit for temperature:
Code for use with Java
Model model = ModelUtil.create("Model");
UnitSystem us = model.unitSystem().create("cgs2");
model.baseSystem("cgs2");
us.baseUnit().create("centimeter","cm","length");
us.derivedUnit().create("meter_per_second",new int[]{1,0,-1,0,0,0,0,0});
Unit du = us.derivedUnit("meter_per_second");
du.definition(new String[]{"meter","second"},new int[]{1,-1,0,0,0,0,0,0});
Unit au = us.additionalUnit().create("celsius",new int[]{0,0,0,0,1,0,0,0});
au.offset(273.15);
Code for use with MATLAB
model = ModelUtil.create('Model');
us = model.unitSystem.create('cgs2');
model.baseSystem('cgs2');
us.baseUnit.create('centimeter','cm','length');
us.derivedUnit.create('meter_per_second',[1,0,-1,0,0,0,0,0]);
du = us.derivedUnit('meter_per_second');
du.definition({'meter','second'},[1,-1,0,0,0,0,0,0]);
au = us.additionalUnit.create('celsius',[0,0,0,0,1,0,0,0]);
au.offset(273.15);
See Also
model.physics()