Package org.sbml.jsbml

Examples of org.sbml.jsbml.UnitDefinition


    KineticLaw kl;
    LocalParameter p;
    Reaction r;
    Species s;
    SpeciesReference sr;
    UnitDefinition ud;
    String filename = DATA_FOLDER + "/libsbml-test-data/l1v1-branch.xml";
    d = new SBMLReader().readSBML(filename);
    if (d == null)
      ;
    {
    }
    assertTrue(d.getLevel() == 1);
    assertTrue(d.getVersion() == 1);
    m = d.getModel();
    assertTrue(m.getName().equals("Branch"));
    assertTrue(m.getNumCompartments() == 1);
    c = m.getCompartment(0);
    assertTrue(c.getName().equals("compartmentOne"));
    assertTrue(c.getVolume() == 1);
    ud = c.getDerivedUnitDefinition();
    assertTrue(ud.getNumUnits() == 1);

    // assertTrue(ud.getUnit(0).getKind() == Unit.Kind.LITRE); // getDerivedUnitDefinition not working properly
    assertTrue(m.getNumSpecies() == 4);
    s = m.getSpecies(0);
    assertTrue(s.getName().equals("S1"));
View Full Code Here


  /**
   * @param args
   */
  public static void main(String[] args) {
    int level = 2, version = 1;
    UnitDefinition ud = new UnitDefinition(level, version), ud2;
    ud.addUnit(new Unit(Unit.Kind.VOLT, 2, level, version));
    ud.addUnit(new Unit(Unit.Kind.SIEMENS, 4, level, version));
    ud.addUnit(new Unit(Unit.Kind.AMPERE, 1, level, version));
    ud.addUnit(new Unit(Unit.Kind.WEBER, 0, level, version));
    Unit u = new Unit(Unit.Kind.WATT, 3, level, version);
    u.setMultiplier(5.3);
    // u.setOffset(-271.15);
    ud.addUnit(u);
    ud.addUnit(new Unit(Unit.Kind.NEWTON, 2, level, version));
    ud.addUnit(new Unit(Unit.Kind.GRAM, 0, level, version));
    System.out.println(UnitDefinition.printUnits(ud, true));
    System.out.println(UnitDefinition.printUnits(ud.simplify(), true));
    ud.convertToSIUnits();
    System.out.println(UnitDefinition.printUnits(ud,true));

    // AMPERE CELSIUS GRAM NEWTON SIEMENS VOLT WEBER
    // A °C^3 1 N^2 S^4 V^2 1
   
    ud = new UnitDefinition(level, version);
    ud.addUnit(new Unit(-3, Unit.Kind.JOULE, level, version));
    ud.addUnit(new Unit(-3, Unit.Kind.MOLE, level, version));

    ud2 = new UnitDefinition(level, version);
    ud2.addUnit(new Unit(Unit.Kind.JOULE, 5, level, version));
    ud2.addUnit(new Unit(Unit.Kind.MOLE, 5, level, version));

    System.out.printf("\n%s / %s\t=\t", UnitDefinition.printUnits(ud, true), UnitDefinition.printUnits(ud2, true));
    ud.divideBy(ud2);
    ud.simplify();
    System.out.println(UnitDefinition.printUnits(ud, true));

    ud = new UnitDefinition(level, version);
    ud.addUnit(new Unit(-3, Unit.Kind.MOLE, 2, level, version));
    ud.addUnit(new Unit(-3, Unit.Kind.LITRE, -2, level, version));
    ud2 = new UnitDefinition(level, version);
    ud2.addUnit(new Unit(-3, Unit.Kind.MOLE, level, version));
    ud2.addUnit(new Unit(-3, Unit.Kind.LITRE, -1, level, version));

    System.out.printf("\n%s * %s\t=\t", UnitDefinition.printUnits(ud, true), UnitDefinition.printUnits(ud2, true));

    ud.multiplyWith(ud2);
    ud.simplify();
    System.out.println(UnitDefinition.printUnits(ud, true));

    ud = new UnitDefinition(level, version);
    ud.addUnit(new Unit(18, Unit.Kind.JOULE, 6, level, version));
    ud2 = new UnitDefinition(level, version);
    ud2.addUnit(new Unit(-3, Unit.Kind.MOLE, -6, level, version));

    System.out.printf("\n%s / %s\t=\t", UnitDefinition.printUnits(ud, true), UnitDefinition.printUnits(ud2, true));
    ud.divideBy(ud2);
    ud.simplify();
    System.out.println(UnitDefinition.printUnits(ud, true));

    ud = new UnitDefinition(level, version);
    ud.addUnit(new Unit(18, Unit.Kind.JOULE, 6, level, version));
    ud.addUnit(new Unit(-3, Unit.Kind.MOLE, -6, level, version));
    ud2 = new UnitDefinition(level, version);
    ud2.addUnit(new Unit(Unit.Kind.JOULE, level, version));
    ud2.addUnit(new Unit(Unit.Kind.MOLE, -1, level, version));

    System.out.printf("\n%s / %s\t=\t", UnitDefinition.printUnits(ud, true), UnitDefinition.printUnits(ud2, true));
    ud.divideBy(ud2);
    ud.simplify();
    System.out.println(UnitDefinition.printUnits(ud, true));

    ud = new UnitDefinition(level, version);
    ud.addUnit(new Unit(-3, Unit.Kind.MOLE, 1d, level, version));
    ud.addUnit(new Unit(Unit.Kind.LITRE, -1d, level, version));
    ud2 = new UnitDefinition(level, version);
    ud2.addUnit(new Unit(-3, Unit.Kind.MOLE, 1d, level, version));
    ud2.addUnit(new Unit(Unit.Kind.LITRE, -1d, level, version));
    ud.divideBy(ud2);
    System.out.println(UnitDefinition.printUnits(ud, true));
    ud.simplify();
    System.out.println(UnitDefinition.printUnits(ud, true));
  }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    int level = 2, version = 1;
    UnitDefinition ud = new UnitDefinition(level, version);
    ud.addUnit(new Unit(Unit.Kind.VOLT, 2, level, version));
    ud.addUnit(new Unit(Unit.Kind.SIEMENS, 4, level, version));
    ud.addUnit(new Unit(Unit.Kind.AMPERE, 1, level, version));
    ud.addUnit(new Unit(Unit.Kind.WEBER, 0, level, version));
    Unit u = new Unit(Unit.Kind.WATT, 3, level, version);
    u.setMultiplier(5.3);
    // u.setOffset(-271.15);
    ud.addUnit(u);
    ud.addUnit(new Unit(Unit.Kind.NEWTON, 2, level, version));
    ud.addUnit(new Unit(Unit.Kind.GRAM, 0, level, version));
    System.out.println(UnitDefinition.printUnits(ud, true));
    System.out.println(UnitDefinition.printUnits(ud.simplify(), true));
    ud.convertToSIUnits();
    System.out.println(UnitDefinition.printUnits(ud,true));

    // AMPERE CELSIUS GRAM NEWTON SIEMENS VOLT WEBER
    // A °C^3 1 N^2 S^4 V^2 1
  }
View Full Code Here

   
    assertTrue(doc.getLevel() == 2 && doc.getVersion() == 3);
   
    assertTrue(model.getNumUnitDefinitions() == 4);
   
    UnitDefinition microM = model.getUnitDefinition(2);
    UnitDefinition microMById = model.getUnitDefinition("microM");
   
    assertTrue(microM.equals(microMById));
   
    assertTrue(microM.getNumUnits() == 2);
    assertTrue(microM.getName().equals("microM"));
View Full Code Here

    private static void processUnitsMap(Map<String, UnitDefinition> unitsMap, Model model, String elementUnits) {

      Logger debugLogger = Logger.getLogger(SubModel.class);
        debugLogger.debug("processUnitsMap called with " + elementUnits);

        UnitDefinition unit = model.getUnitDefinition(elementUnits);

        debugLogger.debug("processUnitsMap : unit = " + elementUnits);

        if (unit != null && !unitsMap.containsKey(unit.getId())) {
            unitsMap.put(unit.getId(), unit);
        }
    }
View Full Code Here

    private static void processUnitsMap(Map<String, UnitDefinition> unitsMap, Model model, String elementUnits) {

      Logger debugLogger = Logger.getLogger(SubModel.class);
        debugLogger.debug("processUnitsMap called with " + elementUnits);

        UnitDefinition unit = model.getUnitDefinition(elementUnits);

        debugLogger.debug("processUnitsMap : unit = " + elementUnits);

        if (unit != null && !unitsMap.containsKey(unit.getId())) {
            unitsMap.put(unit.getId(), unit);
        }
    }
View Full Code Here

   *
   * @return
   */
  public UnitDefinition getUnits() {
    if (!isSetUnit()) {
      unitDef = new UnitDefinition(level, version);
      unitDef.createUnit();
    }
    return unitDef;
  }
View Full Code Here

   *
   * @param b
   * @return
   */
  public ASTNodeValue compile(boolean b) {
    UnitDefinition ud = new UnitDefinition(level, version);
    ud.addUnit(Kind.DIMENSIONLESS);
    ASTNodeValue value = new ASTNodeValue(b, this);
    value.setUnits(ud);
    return value;
  }
View Full Code Here

   *
   * @see org.sbml.jsbml.ASTNodeCompiler#compile(double, java.lang.String)
   */
  public ASTNodeValue compile(double real, String units) {
    ASTNodeValue v = new ASTNodeValue(real, this);
    UnitDefinition ud;
    if (Unit.Kind.isValidUnitKindString(units, level, version)) {
      ud = new UnitDefinition(level, version);
      ud.addUnit(Unit.Kind.valueOf(units.toUpperCase()));
      v.setUnits(ud);
    } else if (model != null) {
      ud = model.getUnitDefinition(units);
      if (ud != null) {
        v.setUnits(ud);
View Full Code Here

     * parameter are determined from the built-in time. The value of the d
     * parameter, when evaluated, must be numerical (i.e., a number in
     * MathML real, integer, or e-notation format) and be greater than or
     * equal to 0. (v2l4)
     */
    UnitDefinition value = x.compile(this).getUnits().clone();
    UnitDefinition time = delay.compile(this).getUnits().clone();

    if (model.getTimeUnitsInstance() != null) {
      if (!UnitDefinition.areEquivalent(model.getTimeUnitsInstance(),
          time)) {
        throw new IllegalArgumentException(
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.UnitDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.