Exemple #1
0
 def convertToUnit(self, unit):
     """
        Change the unit and adjust the value such that
        the combination is equivalent to the original one. The new unit
        must be compatible with the previous unit of the object.
        
        :param C{str} unit: a unit
      
        :raise TypeError: if the unit string is not a know unit or a unit incompatible with the current one
        """
     unit = PhysicalQuantities._findUnit(unit)
     self.value = self._convertValue(self.value, self.unit, unit)
     self.unit = unit
Exemple #2
0
    def __init__(self, propID, valueType, units, objectID=0):
        """
            Initializes the property.

            :param tuple value: A tuple (array) representing property value
            :param PropertyID propID: Property ID
            :param ValueType valueType: Type of a property, i.e. scalar, vector, tensor. Tensor is by default a tuple of 9 values, being compatible with Field's tensor.
            :param Physics.PhysicalQuantity time: Time
            :param units: Property units or string
            :type units: Physics.PhysicalUnits or string
            :param int objectID: Optional ID of problem object/subdomain to which property is related, default = 0
            """
        MupifObject.MupifObject.__init__(self)

        self.propID = propID
        #self.units = units
        self.valueType = valueType
        self.objectID = objectID

        if (PhysicalQuantities.isPhysicalUnit(units)):
            self.unit = units
        else:
            self.unit = PhysicalQuantities._findUnit(units)
Exemple #3
0
    def __init__(self, t, dt, targetTime, units=None, n=1):
        """
        Initializes time step.

        :param t: Time(time at the end of time step)
        :type t: float or Physics.PhysicalQuantity
        :param dt: Step length (time increment), type depends on 'units'
        :type dt: float or Physics.PhysicalQuantity
        :param targetTime: target simulation time (time at the end of simulation, not of a single TimeStep)
        :type targetTime: float or Physics.PhysicalQuantity. targetTime is not related to particular time step rather to the material model (load duration, relaxation spectra etc.)
        :param Physics.PhysicalUnit units: optional units for t, dt, targetTime if given as float values 
        :param int n: Optional, solution time step number, default = 1
        """
        self.number = n  #solution step number, dimensionless

        if (units == None):
            if not PQ.isPhysicalQuantity(t):
                raise TypeError(str(t) + ' is not physical quantity')

            if not PQ.isPhysicalQuantity(dt):
                raise TypeError(str(dt) + ' is not physical quantity')

            if not PQ.isPhysicalQuantity(targetTime):
                raise TypeError(str(targetTime) + ' is not physical quantity')

            self.time = t
            self.dt = dt
            self.targetTime = targetTime
        else:
            if (PQ.isPhysicalUnit(units)):
                unitsTemp = units
            else:
                unitsTemp = PQ._findUnit(units)

            self.time = PQ.PhysicalQuantity(t, unitsTemp)
            self.dt = PQ.PhysicalQuantity(dt, unitsTemp)
            self.targetTime = PQ.PhysicalQuantity(targetTime, unitsTemp)