Package org.sbml.jsbml

Examples of org.sbml.jsbml.UnitDefinition


  /**
   * @param args
   */
  public static void main(String[] args) {
    int level = 2, version = 1;
    UnitDefinition ud, ud2;
    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);
    // 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("Initial unit:\t\t" + UnitDefinition.printUnits(ud, true));
    System.out.println("Simplified unit:\t" + UnitDefinition.printUnits(ud.simplify(), true));
    ud.convertToSIUnits();
    System.out.println("SI units:\t\t" + 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


    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

    LocalParameter lp;
    AssignmentRule ar;
    Reaction r;
    SpeciesReference sr;
    KineticLaw kl;
    UnitDefinition ud;
    Reaction r1;
    ListOf<Compartment> loc;
    Compartment c1;
    ListOf<Rule> lor;
    AssignmentRule ar1;
View Full Code Here

   
    assertTrue(doc.getLevel() == 2 && doc.getVersion() == 3);
   
    assertTrue(model.getUnitDefinitionCount() == 4);
   
    UnitDefinition microM = model.getUnitDefinition(2);
    UnitDefinition microMById = model.getUnitDefinition("microM");
   
    assertTrue(microM.equals(microMById));
   
    assertTrue(microM.getUnitCount() == 2);
    assertTrue(microM.getName().equals("microM"));
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

  /* (non-Javadoc)
   * @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

   * ASTNodeValue.
   *
   * @return
   */
  private ASTNodeValue dimensionless() {
    UnitDefinition ud = new UnitDefinition(level, version);
    ud.addUnit(Unit.Kind.DIMENSIONLESS);
    return new ASTNodeValue(ud, this);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.sbml.jsbml.ASTNodeCompiler#frac(org.sbml.jsbml.ASTNodeValue, org.sbml.jsbml.ASTNodeValue)
   */
  public ASTNodeValue frac(ASTNode numerator, ASTNode denominator)
      throws SBMLException {
    UnitDefinition ud = numerator.compile(this).getUnits().clone();
    UnitDefinition denom = denominator.compile(this).getUnits().clone();
    setLevelAndVersion(ud);
    setLevelAndVersion(denom);
    ud.divideBy(denom);
    ASTNodeValue value = new ASTNodeValue(ud, this);
    value.setValue(numerator.compile(this).toDouble()
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.