def __init__(self, targetTime=PQ.PhysicalQuantity(3., 's')): super(Demo15l, self).__init__(targetTime=targetTime) self.thermal = demoapp.thermal()
def main(): # generate field and corresponding mesh mesh = Mesh.UnstructuredMesh() vertices = [] values1 = [] values2 = [] num = 0 for i in range(40): for j in range(15): vertices.append( Vertex.Vertex((i * 15) + j, (i * 15) + j + 1, (float(i), float(j), 0.0))) values1.append((num, )) num += 0.5 cells = [] num = 0 for i in range(39): for j in range(14): cells.append( Cell.Quad_2d_lin(mesh, num, num, ((i * 15) + j, (i + 1) * 15 + j, (i + 1) * 15 + j + 1, ((i * 15) + j + 1)))) values2.append((num, )) num += 1 mesh.setup(vertices, cells) #Check saving a mesh mesh.dumpToLocalFile('mesh.dat') Mesh.Mesh.loadFromLocalFile('mesh.dat') time = PQ.PhysicalQuantity(1.0, 's') # field1 is vertex based, i.e., field values are provided at vertices field1 = Field.Field(mesh, FieldID.FID_Temperature, ValueType.Scalar, temperatureUnit, time, values1) #field1.field2Image2D(title='Field', barFormatNum='%.0f') # field2 is cell based, i.e., field values are provided for cells field2 = Field.Field(mesh, FieldID.FID_Temperature, ValueType.Scalar, temperatureUnit, time, values2, Field.FieldType.FT_cellBased) # evaluate field at given point position = (20.1, 7.5, 0.0) value1 = field1.evaluate(position) #correct answer 154.5 log.debug("Field1 value at position " + str(position) + " is " + str(value1)) position = (20.1, 8.5, 0.0) value2 = field2.evaluate(position) #correct answer 287.0 log.debug("Field2 value at position " + str(position) + " is " + str(value2)) field1.field2VTKData().tofile('example1') field2.field2VTKData().tofile('example2') #Test pickle module - serialization field1.dumpToLocalFile('field.dat') field3 = Field.Field.loadFromLocalFile('field.dat') position = (20.1, 9.5, 0.0) value3 = field3.evaluate(position) #correct answer 155.5 if ((abs(value1.getValue()[0] - 154.5) <= 1.e-4) and (abs(value2.getValue()[0] - 288.0) <= 1.e-4) and (abs(value3.getValue()[0] - 155.5) <= 1.e-4)): log.info("Test OK") else: log.error("Test FAILED") import sys sys.exit(1)
def getCriticalTimeStep(self): return PQ.PhysicalQuantity(0.1, 's')
import sys sys.path.append('../../..') # for mupif import import os import platform from subprocess import * import socket import time as timeTime import pyvtk from mupif import * import logging import mupif.Physics.PhysicalQuantities as PQ dummyUnits = PQ.PhysicalUnit('dummy', 1., [0, 0, 0, 0, 0, 0, 0, 0, 0]) timeUnits = PQ.PhysicalUnit('s', 1., [0, 0, 1, 0, 0, 0, 0, 0, 0]) import micressConfig as mConf #Micress import #import Property import MICPropertyID import MICFieldID VtkReader2.pyvtk_monkeypatch() class micress(Application.Application): """ MICRESS application interface class
def setProperty(self, property, objectID=0): if (property.getPropertyID() == PropertyID.PID_UserTimeStep): # remember the mapped value self.userDT = PQ.PhysicalQuantity(property.getValue()[0], property.getUnits()) else: raise APIError.APIError ('Unknown property ID')
def getProperty(self, propID, time, objectID=0): if (propID == PropertyID.PID_Demo_Integral): return Property.ConstantProperty(float(self.integral), PropertyID.PID_Demo_Integral, ValueType.Scalar, propID, PQ.getDimensionlessUnit(), time=time) elif (propID == PropertyID.PID_Demo_Volume): return Property.ConstantProperty(float(self.volume), PropertyID.PID_Demo_Volume, ValueType.Scalar, propID, PQ.getDimensionlessUnit(),time=time) else: raise APIError.APIError ('Unknown property ID')
log.info("Thermal problem solved") # get temperature field temperatureField = self.thermalSolver.getField(FieldID.FID_Temperature, istep.getTime()) temperatureField.field2VTKData().tofile('T_distributed') #terminate log.info("Time consumed %f s" % (timeT.time() - start)) def getCriticalTimeStep(self): # determine critical time step return PQ.PhysicalQuantity(1.0, 's') def terminate(self): #terminate solver, job manager, and super self.thermalSolver.terminate() self.thermalJobMan.terminate() super(Demo15d, self).terminate() def getApplicationSignature(self): return "Demo15 distributed workflow 1.0" def getAPIVersion(self): return "1.0" if __name__ == '__main__': demo = Demo15d(targetTime=PQ.PhysicalQuantity(1., 's')) demo.solve() log.info("Test OK")
import sys sys.path.append('../../..') from mupif import * import mupif.Physics.PhysicalQuantities as PQ timeUnits = PQ.PhysicalUnit('s', 1., [0, 0, 1, 0, 0, 0, 0, 0, 0]) temperatureUnits = PQ.PhysicalUnit('K', 1., [0, 0, 0, 0, 1, 0, 0, 0, 0]) class Celsian(Model.Model): def __init__(self, file): super(Celsian, self).__init__(file) self.mesh = None def getField(self, fieldID, time): parts = [1, 2] partRec = [] if (self.mesh == None): self.mesh = EnsightReader2.readEnsightGeo( 'paraview/MMPTestCase_v1.geo', parts, partRec) f = EnsightReader2.readEnsightField('paraview/fld_TEMPERATURE.escl', parts, partRec, 1, FieldID.FID_Temperature, self.mesh, temperatureUnits, time) return f def solveStep(self, tstep, stageID=0, runInBackground=False): time = tstep.getTime() self.value = 1.0 * time
sol = self.mechanical.solveStep(istep) f = self.mechanical.getField(FieldID.FID_Displacement, istep.getTime()) data = f.field2VTKData().tofile('M_%s' % str(istep.getNumber())) self.thermal.finishStep(istep) self.mechanical.finishStep(istep) def getCriticalTimeStep(self): # determine critical time step return min(self.thermal.getCriticalTimeStep(), self.mechanical.getCriticalTimeStep()) def terminate(self): #self.thermalAppRec.terminateAll() self.thermal.terminate() self.thermalJobMan.terminate() self.mechanical.terminate() super(Demo16, self).terminate() def getApplicationSignature(self): return "Demo16 workflow 1.0" def getAPIVersion(self): return "1.0" if __name__ == '__main__': demo = Demo16(targetTime=PQ.PhysicalQuantity(10., 's')) demo.solve() log.info("Test OK")
targetCells.append(c) targetMesh.setup(targetVertices, targetCells) targetField = Field.Field(targetMesh, FieldID.FID_FibreOrientation, sourceField.getValueType(), sourceField.getUnits(), sourceField.getTime(), values=fvalues, fieldType=sourceField.getFieldType(), objectID=sourceField.getObjectID()) return targetField if __name__ == "__main__": workflow = INSAWorkflow(targetTime=PQ.PhysicalQuantity(1.0, 's')) workflow.setProperty( Property.ConstantProperty(100, PropertyID.PID_ExtensionalInPlaneStiffness, ValueType.Scalar, 'MPa')) workflow.setProperty( Property.ConstantProperty( 100, PropertyID.PID_ExtensionalOutOfPlaneStiffness, ValueType.Scalar, 'MPa')) workflow.setProperty( Property.ConstantProperty(100, PropertyID.PID_ShearInPlaneStiffness, ValueType.Scalar, 'MPa')) workflow.setProperty( Property.ConstantProperty(100, PropertyID.PID_ShearOutOfPlaneStiffness, ValueType.Scalar, PQ.getDimensionlessUnit())) workflow.setProperty(
def getCriticalTimeStep(self): """ Returns true or false depending whether solve has completed. """ return PQ.PhysicalQuantity(1.0, 's')
def __init__(self, targetTime=PQ.PhysicalQuantity('0 s')): """ Initializes the workflow. """ super(Workflow_1_1_5, self).__init__(file='', workdir='', targetTime=targetTime) #list of recognized input porperty IDs self.myInputPropIDs = [ PropertyID.PID_MatrixYoung, PropertyID.PID_MatrixPoisson, PropertyID.PID_InclusionYoung, PropertyID.PID_InclusionPoisson, PropertyID.PID_InclusionVolumeFraction, PropertyID.PID_InclusionAspectRatio ] # list of compulsory IDs self.myCompulsoryPropIDs = self.myInputPropIDs #list of recognized output property IDs self.myOutPropIDs = [ PropertyID.PID_ESI_VPS_BUCKL_LOAD, PropertyID.PID_CompositeAxialYoung, PropertyID.PID_CompositeInPlaneYoung, PropertyID.PID_CompositeInPlaneShear, PropertyID.PID_CompositeTransverseShear, PropertyID.PID_CompositeInPlanePoisson, PropertyID.PID_CompositeTransversePoisson ] #dictionary of input properties (values) self.myInputProps = {} #dictionary of output properties (values) self.myOutProps = {} #locate nameserver ns = PyroUtil.connectNameServer(nshost, nsport, hkey) #connect to digimat JobManager running on (remote) server self.digimatJobMan = PyroUtil.connectJobManager( ns, digimatJobManName, hkey) #connect to mult2 JobManager running on (remote) server self.vpsJobMan = PyroUtil.connectJobManager(ns, vpsJobManName, hkey) # solvers self.digimatSolver = None self.vpsSolver = None #allocate the Digimat remote instance try: self.digimatSolver = PyroUtil.allocateApplicationWithJobManager( ns, self.digimatJobMan, None, hkey) log.info('Created digimat job') self.vpsSolver = PyroUtil.allocateApplicationWithJobManager( ns, self.vpsJobMan, None, hkey) log.info('Created vps job') except Exception as e: log.exception(e) else: if ((self.digimatSolver is not None) and (self.vpsSolver is not None)): digimatSolverSignature = self.digimatSolver.getApplicationSignature( ) log.info("Working digimat solver on server " + digimatSolverSignature) vpsSolverSignature = self.vpsSolver.getApplicationSignature() log.info("Working vps solver on server " + vpsSolverSignature) else: log.debug("Connection to server failed, exiting")
def initialize(self, file='', workdir='', targetTime=PQ.PhysicalQuantity('0 s'), metaData={}, validateMetaData=True, **kwargs): super(Example07, self).initialize(file=file, workdir=workdir, targetTime=targetTime, metaData=metaData, validateMetaData=validateMetaData, **kwargs) # locate nameserver ns = PyroUtil.connectNameServer(nshost=cfg.nshost, nsport=cfg.nsport, hkey=cfg.hkey) # connect to JobManager running on (remote) server if mode == 1: self.thermalJobMan = PyroUtil.connectJobManager( ns, cfg.jobManName, cfg.hkey, PyroUtil.SSHContext( userName=cfg.serverUserName, sshClient=cfg.sshClient, options=cfg.options, sshHost=cfg.sshHost ) ) self.mechanicalJobMan = PyroUtil.connectJobManager( ns, mCfg.jobManName, cfg.hkey, PyroUtil.SSHContext( userName=mCfg.serverUserName, sshClient=mCfg.sshClient, options=mCfg.options, sshHost=mCfg.sshHost ) ) else: self.thermalJobMan = PyroUtil.connectJobManager(ns, cfg.jobManName, cfg.hkey) self.mechanicalJobMan = PyroUtil.connectJobManager(ns, mCfg.jobManName, cfg.hkey) # allocate the application instances try: self.thermalSolver = PyroUtil.allocateApplicationWithJobManager( ns, self.thermalJobMan, cfg.jobNatPorts[0], cfg.hkey, PyroUtil.SSHContext( userName=cfg.serverUserName, sshClient=cfg.sshClient, options=cfg.options, sshHost=cfg.sshHost ) ) log.info('Created thermal job') self.mechanicalSolver = PyroUtil.allocateApplicationWithJobManager( ns, self.mechanicalJobMan, mCfg.jobNatPorts[0], mCfg.hkey, PyroUtil.SSHContext( userName=mCfg.serverUserName, sshClient=mCfg.sshClient, options=mCfg.options, sshHost=mCfg.sshHost ) ) log.info('Created mechanical job') log.info('Creating reverse tunnel') # Create a reverse tunnel so mechanical server can access thermal server directly self.appsTunnel = PyroUtil.connectApplicationsViaClient( PyroUtil.SSHContext( userName=mCfg.serverUserName, sshClient=mCfg.sshClient, options=mCfg.options, sshHost=PyroUtil.getNSConnectionInfo(ns, mCfg.jobManName)[0] ), self.mechanicalSolver, self.thermalSolver ) except Exception as e: log.exception(e) else: # No exception if (self.thermalSolver is not None) and (self.mechanicalSolver is not None): thermalSolverSignature = self.thermalSolver.getApplicationSignature() log.info("Working thermal solver on server " + thermalSolverSignature) mechanicalSolverSignature = self.mechanicalSolver.getApplicationSignature() log.info("Working mechanical solver on server " + mechanicalSolverSignature) log.info("Uploading input files to servers") pf = self.thermalJobMan.getPyroFile(self.thermalSolver.getJobID(), "input.in", 'wb') PyroUtil.uploadPyroFile("inputT.in", pf, cfg.hkey) mf = self.mechanicalJobMan.getPyroFile(self.mechanicalSolver.getJobID(), "input.in", 'wb') PyroUtil.uploadPyroFile("inputM.in", mf, mCfg.hkey) # To be sure update only required passed metadata in models passingMD = { 'Execution': { 'ID': self.getMetadata('Execution.ID'), 'Use_case_ID': self.getMetadata('Execution.Use_case_ID'), 'Task_ID': self.getMetadata('Execution.Task_ID') } } self.thermalSolver.updateMetadata(passingMD) self.mechanicalSolver.updateMetadata(passingMD) self.thermalSolver.initialize( file="./input.in", workdir=self.thermalJobMan.getJobWorkDir(self.thermalSolver.getJobID()), metaData=passingMD ) self.mechanicalSolver.initialize( file="./input.in", workdir=self.mechanicalJobMan.getJobWorkDir(self.mechanicalSolver.getJobID()), metaData=passingMD ) else: log.debug("Connection to server failed, exiting")
def getCriticalTimeStep(self): # determine critical time step return PQ.PhysicalQuantity(1.0, 's') def terminate(self): self.thermalSolver.terminate() self.mechanicalSolver.terminate() self.appsTunnel.terminate() super(Example07, self).terminate() def getApplicationSignature(self): return "Example07 workflow 1.0" def getAPIVersion(self): return "1.0" if __name__ == '__main__': demo = Example07() md = { 'Execution': { 'ID': '1', 'Use_case_ID': '1_1', 'Task_ID': '1' } } demo.initialize(targetTime=PQ.PhysicalQuantity(1., 's'), metaData=md) demo.solve() log.info("Test OK")
#!/usr/bin/env python from builtins import str import sys sys.path.append('../../..') from mupif import * import logging log = logging.getLogger() import mupif.Physics.PhysicalQuantities as PQ timeUnits = PQ.PhysicalUnit('s', 1., [0, 0, 1, 0, 0, 0, 0, 0, 0]) class application1(Application.Application): """ Simple application that generates a property with a value equal to actual time """ def __init__(self, file): super(application1, self).__init__(self, file) def getProperty(self, propID, time, objectID=0): if (propID == PropertyID.PID_Velocity): return Property.ConstantProperty(self.value, PropertyID.PID_Velocity, ValueType.Scalar, 'm/s', time, 0) else: raise APIError.APIError('Unknown property ID') def solveStep(self, tstep, stageID=0, runInBackground=False): time = tstep.getTime().inUnitsOf(timeUnits).getValue() self.value = 1.0 * time
def __init__(self, targetTime=PQ.PhysicalQuantity('0 s')): """ Initializes the workflow. """ super(Demo15d, self).__init__(targetTime=targetTime)
def getProperty(self, propID, time, objectID=0): if (propID == PropertyID.PID_Demo_Min): return Property.ConstantProperty(self._min, PropertyID.PID_Demo_Min, ValueType.Scalar, propID, PQ.getDimensionlessUnit(), time=time) elif (propID == PropertyID.PID_Demo_Max): return Property.ConstantProperty(self._max, PropertyID.PID_Demo_Max, ValueType.Scalar, propID, PQ.getDimensionlessUnit(), time=time) else: raise APIError.APIError ('Unknown property ID')
barRange=(-9e-5, 1.6e-6), fileName='mechanical.png', fieldComponent=1, figsize=(12, 6), matPlotFig=self.matPlotFig) except APIError.APIError as e: log.error("Following API error occurred:", e) def getCriticalTimeStep(self): # determine critical time step return min(self.thermal.getCriticalTimeStep(), self.mechanical.getCriticalTimeStep()) def terminate(self): self.thermal.terminate() self.mechanical.terminate() def getApplicationSignature(self): return "Demo13 workflow 1.0" def getAPIVersion(self): return "1.0" if __name__ == '__main__': demo = Demo13(targetTime=PQ.PhysicalQuantity(3.0, 's')) demo.solve() #ft.field2Image2DBlock() #To block the window log.info("Test OK")
if (property.getPropertyID() == PropertyID.PID_Concentration): # remember the mapped value self.contrib = property else: raise APIError.APIError('Unknown property ID') def getCriticalTimeStep(self): return PQ.PhysicalQuantity(1.0, 's') def getApplicationSignature(self): return "Demo06 workflow 1.0" def getAPIVersion(self): return "1.0" if __name__ == '__main__': targetTime = PQ.PhysicalQuantity('1 s') demo = Demo06(targetTime) demo.solve() kpi = demo.getProperty(PropertyID.PID_KPI01, targetTime) demo.terminate() if (kpi.getValue(targetTime) == 1000): log.info("Test OK") kpi = 0 sys.exit(0) else: log.info("Test FAILED") kpi = 0 sys.exit(1)
def setUp(self): self.mesh = Mesh.UnstructuredMesh() self.mesh.setup([ Vertex.Vertex(0, 0, (0., 0., 0.)), Vertex.Vertex(1, 1, (2., 0., 0.)), Vertex.Vertex(2, 2, (0., 5., 0.)), Vertex.Vertex(3, 3, (4., 2., 0.)) ], [ Cell.Triangle_2d_lin(self.mesh, 1, 1, (0, 1, 2)), Cell.Triangle_2d_lin(self.mesh, 2, 2, (1, 2, 3)) ]) self.mesh3 = Mesh.UnstructuredMesh() self.mesh3.setup([ Vertex.Vertex(0, 16, (5., 6., 0.)), Vertex.Vertex(1, 5, (8., 8., 0.)), Vertex.Vertex(2, 8, (6., 10., 0.)) ], [Cell.Triangle_2d_lin(self.mesh3, 3, 8, (0, 1, 2))]) self.mesh4 = Mesh.UnstructuredMesh() self.mesh4.setup([ Vertex.Vertex(0, 0, (0., 0., 0.)), Vertex.Vertex(1, 1, (2., 0., 2.)), Vertex.Vertex(2, 2, (0., 5., 3.)), Vertex.Vertex(3, 3, (3., 3., 2.)), Vertex.Vertex(4, 4, (8., 15., 0.)) ], [ Cell.Tetrahedron_3d_lin(self.mesh4, 1, 1, (0, 1, 2, 3)), Cell.Tetrahedron_3d_lin(self.mesh4, 2, 2, (1, 2, 3, 4)) ]) self.f1 = Field.Field(self.mesh, FieldID.FID_Displacement, ValueType.Scalar, PU({'m': 1}, 1, (1, 0, 0, 0, 0, 0, 0)), PQ.PhysicalQuantity(13, 's'), [(0, ), (12, ), (175, ), (94, )], 1) self.f2 = Field.Field( self.mesh, FieldID.FID_Strain, ValueType.Vector, PU({ 'kg': 1, 's': -2, 'm': -1 }, 1, (1, 1, 1, 0, 0, 0, 0)), PQ.PhysicalQuantity(128, 's'), [(3, 6), (2, 8), (2, 3)], 1) self.f3 = Field.Field( self.mesh, FieldID.FID_Stress, ValueType.Tensor, PU({ 'kg': 1, 's': -2, 'm': -1 }, 1, (1, 1, 1, 0, 0, 0, 0)), PQ.PhysicalQuantity(66, 's'), [(3, 6, 4), (2, 8, 5), (2, 3, 6)], 1) self.f4 = Field.Field(self.mesh4, FieldID.FID_Displacement, ValueType.Scalar, PU({'m': 1}, 1, (1, 0, 0, 0, 0, 0, 0)), PQ.PhysicalQuantity(16, 's'), [(6, ), (16, ), (36, ), (33, ), (32, )]) self.f5 = Field.Field(self.mesh3, FieldID.FID_Displacement, ValueType.Scalar, PU({'m': 1}, 1, (1, 0, 0, 0, 0, 0, 0)), PQ.PhysicalQuantity(13, 's'), [(3, ), (5, ), (4, )], 1) self.f6 = Field.Field(self.mesh4, FieldID.FID_Displacement, ValueType.Scalar, PU({'m': 1}, 1, (1, 0, 0, 0, 0, 0, 0)), PQ.PhysicalQuantity(16, 's'), [(0, ), (12, ), (39, ), (33, ), (114, )]) self.f7 = Field.Field(self.mesh4, FieldID.FID_Displacement, ValueType.Scalar, PU({'m': 1}, 1, (1, 0, 0, 0, 0, 0, 0)), PQ.PhysicalQuantity(16, 's'), [(2, ), (16, )], Field.FieldType.FT_cellBased) self.f8 = Field.Field(self.mesh, FieldID.FID_Displacement, ValueType.Scalar, PU({'m': 1}, 1, (1, 0, 0, 0, 0, 0, 0)), PQ.PhysicalQuantity(13, 's'), None, 1) self.f9 = Field.Field(self.mesh, FieldID.FID_Displacement, ValueType.Scalar, PU({'m': 1}, 1, (1, 0, 0, 0, 0, 0, 0)), PQ.PhysicalQuantity(13, 's'), None, Field.FieldType.FT_cellBased) l = len(self.f8.value) self.assertEqual(l, self.mesh.getNumberOfVertices()) l = len(self.f9.value) self.assertEqual(l, self.mesh.getNumberOfCells()) # register assertEqual operation for PhysicalQuantities self.addTypeEqualityFunc(PQ.PhysicalQuantity, self.assertPhysicalQuantitiesEqual)
def getCriticalTimeStep(self): # determine critical time step return PQ.PhysicalQuantity(1.0, 's')
time = time + dt if time > targetTime: # make sure we reach targetTime at the end time = targetTime timestepnumber = timestepnumber + 1 log.debug("Step: %g %g %g" % (timestepnumber, time, dt)) # create a time step istep = TimeStep.TimeStep(time, dt, targetTime, 's', timestepnumber) # solve problem 1 app1.solveStep(istep) # request Concentration property from app1 v = app1.getProperty(PropertyID.PID_Time, istep.getTime()) # Create a PhysicalQuantity object V = PQ.PhysicalQuantity(v.getValue(istep.getTime())[0], v.getUnits()) val = V.inBaseUnits() log.debug(val) # can be converted in min? log.debug(V.isCompatible('min')) # can be converted in m? log.debug(V.isCompatible('m')) # convert to min V.convertToUnit('min') log.debug(V) # give only the value
from __future__ import print_function from builtins import str import sys sys.path.append('../../..') from mupif import * import os import logging log = logging.getLogger() import mupif.Physics.PhysicalQuantities as PQ timeUnits = PQ.PhysicalUnit('s', 1., [0,0,1,0,0,0,0,0,0]) class application1(Application.Application): """ Simple application that generates a property with a value equal to actual time """ def __init__(self, file): super(application1, self).__init__(file) return def getProperty(self, propID, time, objectID=0): if (propID == PropertyID.PID_Concentration): return Property.ConstantProperty(self.value, PropertyID.PID_Concentration, ValueType.Scalar, 'kg/m**3', time) else: raise APIError.APIError ('Unknown property ID') def solveStep(self, tstep, stageID=0, runInBackground=False): time = tstep.getTime().inUnitsOf(timeUnits).getValue() self.value=1.0*time def getCriticalTimeStep(self): return PQ.PhysicalQuantity(0.1,'s') def getAssemblyTime(self, tstep):
self.vpsSolver.terminate() super(Workflow_1_1_6x, self).terminate() def getApplicationSignature(self): return "Composelector workflow 1.0" def getAPIVersion(self): return "1.0" if __name__ == '__main__': useCaseID = 1 execID = 1 workflow = Workflow_1_1_6x(targetTime=PQ.PhysicalQuantity(1., 's')) # create and set lammps material properties workflow.setProperty( Property.ConstantProperty(1000, PropertyID.PID_SMILE_MOLECULAR_STRUCTURE, ValueType.Scalar, PQ.getDimensionlessUnit(), None, 0)) workflow.setProperty( Property.ConstantProperty(100, PropertyID.PID_MOLECULAR_WEIGHT, ValueType.Scalar, 'mol', None, 0)) workflow.setProperty( Property.ConstantProperty(0.2, PropertyID.PID_CROSSLINKER_TYPE, ValueType.Scalar, PQ.getDimensionlessUnit(), None, 0)) workflow.setProperty( Property.ConstantProperty(12, PropertyID.PID_FILLER_DESIGNATION,
def __init__ (self, targetTime=PQ.PhysicalQuantity('0 s')): super(Demo03, self).__init__(file='', workdir='', targetTime=targetTime) self.app1 = application1(None) self.app3 = application3(None)
def __init__(self, targetTime=PQ.PhysicalQuantity('0 s')): """ Initializes the workflow. """ super(Workflow_1_1_6x, self).__init__(file='', workdir='', targetTime=targetTime) #list of recognized input porperty IDs self.myInputPropIDs = [ PropertyID.PID_SMILE_MOLECULAR_STRUCTURE, PropertyID.PID_MOLECULAR_WEIGHT, PropertyID.PID_CROSSLINKER_TYPE, PropertyID.PID_FILLER_DESIGNATION, PropertyID.PID_CROSSLINKONG_DENSITY, PropertyID.PID_FILLER_CONCENTRATION, PropertyID.PID_TEMPERATURE, PropertyID.PID_PRESSURE, PropertyID.PID_POLYDISPERSITY_INDEX, PropertyID.PID_SMILE_MODIFIER_MOLECULAR_STRUCTURE, PropertyID.PID_SMILE_FILLER_MOLECULAR_STRUCTURE, PropertyID.PID_DENSITY_OF_FUNCTIONALIZATION, PropertyID.PID_InclusionYoung, PropertyID.PID_InclusionPoisson, PropertyID.PID_InclusionVolumeFraction, PropertyID.PID_InclusionAspectRatio ] # list of compulsory IDs self.myCompulsoryPropIDs = self.myInputPropIDs #list of recognized output property IDs self.myOutPropIDs = [ PropertyID.PID_EModulus, PropertyID.PID_PoissonRatio, PropertyID.PID_CompositeAxialYoung, PropertyID.PID_CompositeInPlaneYoung, PropertyID.PID_CompositeInPlaneShear, PropertyID.PID_CompositeInPlaneShear, PropertyID.PID_CompositeTransverseShear, PropertyID.PID_CompositeInPlanePoisson, PropertyID.PID_CompositeTransversePoisson, PropertyID.PID_CriticalLoadLevel ] #dictionary of input properties (values) self.myInputProps = {} #dictionary of output properties (values) self.myOutProps = {} #locate nameserver ns = PyroUtil.connectNameServer(nshost, nsport, hkey) #connect to digimat JobManager running on (remote) server self.digimatJobMan = PyroUtil.connectJobManager( ns, digimatJobManName, hkey) #connect to comsol JobManager running on (remote) server self.comsolJobMan = PyroUtil.connectJobManager(ns, comsolJobManName, hkey) #connect to vpn JobManager running on (remote) server self.vpsJobMan = PyroUtil.connectJobManager(ns, vpsJobManName, hkey) # solvers self.lammpsSolver = lammps.emailAPI(None) # local LAMMPS API instances self.digimatSolver = None self.comsolSolver = None self.vpsSolver = None #allocate the remote instances try: self.digimatSolver = PyroUtil.allocateApplicationWithJobManager( ns, self.digimatJobMan, None, hkey) log.info('Created digimat job') self.comsolSolver = PyroUtil.allocateApplicationWithJobManager( ns, self.comsolJobMan, None, hkey) log.info('Created comsol job') self.vpsSolver = PyroUtil.allocateApplicationWithJobManager( ns, self.vpsJobMan, None, hkey) log.info('Created vps job') except Exception as e: log.exception(e) else: if ((self.lammpsSolver is not None) and (self.digimatSolver is not None) and (self.comsolSolver is not None) and (self.vpsSolver is not None)): lammpsSolverSignature = self.lammpsSolver.getApplicationSignature( ) log.info("Working lammps solver on server " + lammpsSolverSignature) digimatSolverSignature = self.digimatSolver.getApplicationSignature( ) log.info("Working digimat solver on server " + digimatSolverSignature) comsolSolverSignature = self.comsolSolver.getApplicationSignature( ) log.info("Working comsol solver on server " + comsolSolverSignature) vpsSolverSignature = self.vpsSolver.getApplicationSignature() log.info("Working vps solver on server " + vpsSolverSignature) else: log.debug("Connection to server failed, exiting")
# Vit Smilauer 07/2017, vit.smilauer (et) fsv.cvut.cz import sys sys.path.extend(['..', '../../..']) from mupif import * import logging log = logging.getLogger() import argparse # Read int for mode as number behind '-m' argument: 0-local (default), 1-ssh, 2-VPN mode = argparse.ArgumentParser(parents=[Util.getParentParser()]).parse_args().mode from Config import config cfg = config(mode) import mupif.Physics.PhysicalQuantities as PQ timeUnits = PQ.PhysicalUnit('s', 1., [0, 0, 1, 0, 0, 0, 0, 0, 0]) class application1(Model.Model): """ Simple application that generates a property with a value equal to actual time """ def __init__(self, metaData={}): MD = { 'Name': 'Simple application storing time steps', 'ID': 'N/A', 'Description': 'Cummulates time steps', 'Physics': { 'Type': 'Other', 'Entity': 'Other' },
import sys #import common configuration file sys.path.append('..') import clientConfig as cConf from mupif import * import time as timeTime import getopt import logging logger = logging.getLogger() start = timeTime.time() logger.info('Timer started') import mupif.Physics.PhysicalQuantities as PQ timeUnits = PQ.PhysicalUnit('s', 1., [0, 0, 1, 0, 0, 0, 0, 0, 0]) #locate nameserver ns = PyroUtil.connectNameServer(nshost=cConf.nshost, nsport=cConf.nsport, hkey=cConf.hkey) #localize JobManager running on (remote) server and create a tunnel to it #allocate the first application app1 solverAppRec = None try: solverJobManRec = (cConf.serverPort, cConf.serverNatport, cConf.server, cConf.serverUserName, cConf.jobManName) solverAppRec = PyroUtil.allocateApplicationWithJobManager( ns, solverJobManRec, cConf.jobNatPorts.pop(0), cConf.sshClient, cConf.options, cConf.sshHost)
#!/usr/bin/env python from builtins import range # # This example requires pyvtk module, install it using # pip install pyvtk # Note: pyvtk is only available in Python 2.x (Sept, 2014) # import sys import logging sys.path.append('../../..') from mupif import * import mupif.Physics.PhysicalQuantities as PQ log = logging.getLogger() temperatureUnit = PQ.PhysicalUnit('K', 1., [0, 0, 0, 0, 1, 0, 0, 0, 0]) def main(): # generate field and corresponding mesh mesh = Mesh.UnstructuredMesh() vertices = [] values1 = [] values2 = [] num = 0 for i in range(40): for j in range(15): vertices.append( Vertex.Vertex((i * 15) + j, (i * 15) + j + 1, (float(i), float(j), 0.0))) values1.append((num, ))
if self.thermalJobMan is not None: self.thermalJobMan.terminate() if self.mechanical is not None: self.mechanical.terminate() # self.printMetadata() super(Example08, self).terminate() def getApplicationSignature(self): return "Example08 workflow 1.0 - Thermo-mechanical non-stationary problem" def getAPIVersion(self): return "1.0" if __name__ == '__main__': demo = Example08() workflowMD = { 'Execution': { 'ID': '1', 'Use_case_ID': '1_1', 'Task_ID': '1' } } demo.initialize(targetTime=PQ.PhysicalQuantity(10., 's'), metaData=workflowMD) # demo.printMetadata() # print(demo.hasMetadata('Execution.ID')) # exit(0) demo.solve() log.info("Test OK")