Examples of UnitDefinition


Examples of org.sbml.jsbml.UnitDefinition

  /* (non-Javadoc)
   * @see org.sbml.jsbml.ASTNodeCompiler#frac(int, int)
   */
  public ASTNodeValue frac(int numerator, int denominator) {
    ASTNodeValue value = new ASTNodeValue(
        new UnitDefinition(level, version), this);
    value.setValue(((double) numerator) / ((double) denominator));
    return value;
  }
View Full Code Here

Examples of org.sbml.jsbml.UnitDefinition

   * @see org.sbml.jsbml.ASTNodeCompiler#getConstantAvogadro(java.lang.String)
   */
  public ASTNodeValue getConstantAvogadro(String name) {
      // TODO: If there is a different value in a later SBML specification, this must be checked here.
    ASTNodeValue value = new ASTNodeValue(Maths.AVOGADRO_L3V1, this);
    UnitDefinition perMole = new UnitDefinition(level, version);
    perMole.setLevel(level);
    perMole.setId("per_mole");
    perMole.addUnit(new Unit(Kind.MOLE, -1, level, version));
    value.setUnits(perMole);
    return value;
  }
View Full Code Here

Examples of org.sbml.jsbml.UnitDefinition

   * Creates an invalid unit definition encapsulated in an ASTNodeValue.
   *
   * @return
   */
  private ASTNodeValue invalid() {
    UnitDefinition ud = new UnitDefinition(level, version);
    ud.addUnit(new Unit(level, version));
    return new ASTNodeValue(ud, this);
  }
View Full Code Here

Examples of org.sbml.jsbml.UnitDefinition

    ASTNodeValue compiledvalues[] = new ASTNodeValue[values.size()];
    for (ASTNode node : values) {
      compiledvalues[i++] = node.compile(this);
    }
    value.setValue(Integer.valueOf(0));
    UnitDefinition ud = new UnitDefinition(level, version);
    ud.addUnit(Unit.Kind.INVALID);
    value.setUnits(ud);

    i = 0;

    while (i < compiledvalues.length) {
View Full Code Here

Examples of org.sbml.jsbml.UnitDefinition

    for (ASTNode node : values) {
      compiledvalues[i++] = node.compile(this);
    }

    value.setValue(Integer.valueOf(0));
    UnitDefinition ud = new UnitDefinition(level, version);
    ud.addUnit(Unit.Kind.INVALID);
    value.setUnits(ud);

    i = compiledvalues.length - 1;

    while (i >= 0) {
View Full Code Here

Examples of org.sbml.jsbml.UnitDefinition

      throws SBMLException {
    double exp = Double.NaN, v;
    v = exponent.toDouble();
    exp = v == 0d ? 0d : 1d / v;
    if (exp == 0d) {
      UnitDefinition ud = new UnitDefinition(level, version);
      ud.addUnit(Kind.DIMENSIONLESS);
      ASTNodeValue value = new ASTNodeValue(ud, this);
      value.setValue(Integer.valueOf(1));
      return value;
    }
    if (!Double.isNaN(exp)) {
View Full Code Here

Examples of org.sbml.jsbml.UnitDefinition

   * @return
   * @throws SBMLException
   */
  private ASTNodeValue root(double rootExponent, ASTNodeValue radiant)
      throws SBMLException {
    UnitDefinition ud = radiant.getUnits().clone();
    for (Unit u : ud.getListOfUnits()) {
      if ((((u.getExponent() / rootExponent) % 1d) != 0d) && !u.isDimensionless() && !u.isInvalid()) {
        new UnitException(MessageFormat.format(
          "Cannot perform power or root operation due to incompatibility with a unit exponent. Given are {0,number} as the exponent of the unit and {1,number} as the root exponent for the current computation.",
          u.getExponent(), rootExponent));
      }
View Full Code Here

Examples of org.sbml.jsbml.UnitDefinition

  /* (non-Javadoc)
   * @see org.sbml.jsbml.ASTNodeCompiler#symbolTime(java.lang.String)
   */
  public ASTNodeValue symbolTime(String time) {
    UnitDefinition ud;
    if (model != null) {
      ud = model.getTimeUnitsInstance();
      if (ud == null) {
        ud = model.getUnitDefinition(time);
      }
View Full Code Here

Examples of org.sbml.jsbml.UnitDefinition

  /* (non-Javadoc)
   * @see org.sbml.jsbml.ASTNodeCompiler#times(org.sbml.jsbml.ASTNodeValue[])
   */
  public ASTNodeValue times(List<ASTNode> values) throws SBMLException {
    UnitDefinition ud = new UnitDefinition(level, version);
    UnitDefinition v;
    double d = 1d;

    for (ASTNode value : values) {
      ASTNodeValue av = value.compile(this);
      v = av.getUnits().clone();
View Full Code Here

Examples of org.sbml.jsbml.UnitDefinition

    assertEquals(M.getFunctionDefinition(-2), null);
  }

  @Test
  public void test_Model_add_get_UnitDefinitions() {
    UnitDefinition ud1 = new UnitDefinition(2, 4);
    UnitDefinition ud2 = new UnitDefinition(2, 4);
    ud1.setId("ud1");
    ud2.setId("ud2");
    ud1.createUnit(Kind.LITRE);
    ud2.createUnit(Kind.METRE);
    M.addUnitDefinition(ud1);
    M.addUnitDefinition(ud2);
    assertTrue(M.getUnitDefinitionCount() == 2);
    // assertTrue(!M.getUnitDefinition(0).equals(ud1)); // would be the same in jsbml
    // assertTrue(!M.getUnitDefinition(1).equals(ud2));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.