def __init__(self, value, propID, valueType, units, time=None, objectID=0, metaData={}): """ 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 when property is evaluated. If None (default), no time dependence :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 """ Property.__init__(self, propID, valueType, units, objectID) self.value = value if PhysicalQuantities.isPhysicalQuantity(time) or time is None: self.time = time else: raise TypeError("PhysicalValue expected for time") self.updateMetadata(metaData)
def initialize(self, file='', workdir='', targetTime=PQ.PhysicalQuantity(0., 's'), metaData={}, validateMetaData=True, **kwargs): """ Initializes application, i.e. all functions after constructor and before run. :param str file: Name of file :param str workdir: Optional parameter for working directory :param PhysicalQuantity targetTime: target simulation time :param dict metaData: Optional dictionary used to set up metadata (can be also set by setMetadata() ) :param bool validateMetaData: Defines if the metadata validation will be called :param named_arguments kwargs: Arbitrary further parameters """ self.updateMetadata(metaData) # print (targetTime) if PQ.isPhysicalQuantity(targetTime): self.targetTime = targetTime else: raise TypeError('targetTime is not PhysicalQuantity') self.file = file if workdir == '': self.workDir = os.getcwd() else: self.workDir = workdir if validateMetaData: self.validateMetadata(WorkflowSchema)
def _sum(self, other, sign1, sign2): """ Override of PhysicalQuantity._sum method """ if not PhysicalQuantities.isPhysicalQuantity(other): raise TypeError('Incompatible types') factor = other.unit.conversionFactorTo(self.unit) new_value = tuple(sign1*s+sign2*o*factor for (s,o) in zip(self.value, other.value)) #new_value = sign1*self.value + \ # sign2*other.value*other.unit.conversionFactorTo(self.unit) return self.__class__(new_value, self.propID, self.valueType, self.time, self.unit)
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: PQ.PhysicalQuantity :param dt: Step length (time increment), type depends on 'units' :type dt: PQ.PhysicalQuantity :param targetTime: target simulation time (time at the end of simulation, not of a single TimeStep) :type targetTime: PQ.PhysicalQuantity. targetTime is not related to particular time step rather to the material model (load duration, relaxation spectra etc.) :param PQ.PhysicalUnit or str 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 is 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): units_temp = units else: units_temp = PQ.findUnit(units) self.time = PQ.PhysicalQuantity(t, units_temp) self.dt = PQ.PhysicalQuantity(dt, units_temp) self.targetTime = PQ.PhysicalQuantity(targetTime, units_temp)
def __init__ (self, file='', workdir='', targetTime=PQ.PhysicalQuantity(0., 's')): """ Constructor. Initializes the workflow :param str file: Name of file :param str workdir: Optional parameter for working directory :param PhysicalQuantity targetTime: target simulation time """ super(Workflow, self).__init__(file=file, workdir=workdir) #print (targetTime) if (PQ.isPhysicalQuantity(targetTime)): self.targetTime = targetTime else: raise TypeError ('targetTime is not PhysicalQuantity') (username, hostname) = PyroUtil.getUserInfo() self.setMetadata(MetadataKeys.USERNAME, username) self.setMetadata(MetadataKeys.HOSTNAME, hostname)