Example #1
0
    def __init__(self, targetTime=PQ.PhysicalQuantity(3., 's')):
        super(Demo13, self).__init__(file='',
                                     workdir='',
                                     targetTime=targetTime)

        self.thermal = demoapp.thermal_nonstat('inputT13.in', '.')
        self.mechanical = demoapp.mechanical('inputM13.in', '.')
        self.matPlotFig = None
Example #2
0
    def __init__(self, targetTime=PQ.PhysicalQuantity(3., 's')):
        super(Demo13, self).__init__(targetTime=targetTime)

        self.thermal = demoapp.thermal_nonstat()
        self.mechanical = demoapp.mechanical()
        self.matPlotFig = None

        if (status):  # experimental section by bp
            from Config import config
            import Pyro4
            cfg = config(3)
            ns = PyroUtil.connectNameServer(nshost=cfg.nshost,
                                            nsport=cfg.nsport,
                                            hkey=cfg.hkey)
            uri = ns.lookup(cfg.monitorName)
            self.workflowMonitor = Pyro4.Proxy(uri)
        self.updateStatus('Initialized')
        if (status):
            time.sleep(10)
Example #3
0
    def __init__(self, metaData={}):
        """
        Initializes the workflow.
        """
        MD = {
            'Name':
            'Thermo-mechanical stationary problem',
            'ID':
            'Thermo-mechanical-1',
            'Description':
            'stationary thermo-mechanical problem using finite elements on rectangular domain',
            'Model_refs_ID': [{
                'Name': 'NonStatThermo-1',
                'ID': 'ss',
                'Version_date': 'dd'
            }, {
                'Name': 'Mechanical-1',
                'ID': 'ss',
                'Version_date': 'dd'
            }],
            'Inputs': [],
            'Outputs': [{
                'Type': 'mupif.Field',
                'Type_ID': 'mupif.FieldID.FID_Temperature',
                'Name': 'Temperature field',
                'Description': 'Temperature field on 2D domain',
                'Units': 'degC'
            }, {
                'Type': 'mupif.Field',
                'Type_ID': 'mupif.FieldID.FID_Displacement',
                'Name': 'Displacement field',
                'Description': 'Displacement field on 2D domain',
                'Units': 'm'
            }]
        }
        super(Example06, self).__init__(metaData=MD)
        self.updateMetadata(metaData)

        self.thermalSolver = demoapp.thermal()
        self.mechanicalSolver = demoapp.mechanical()
Example #4
0
#Mechanical server for nonstationary problem
import os, sys
sys.path.extend(['..', '../../..', '../Example10'])
from mupif import *
import demoapp
import conf as cfg
Util.changeRootLogger('mechanical.log')

#locate nameserver
ns = PyroUtil.connectNameServer(nshost=cfg.nshost,
                                nsport=cfg.nsport,
                                hkey=cfg.hkey)

#Run a daemon. It will run even the port has DROP/REJECT status. The connection from a client is then impossible.
daemon = cfg.Pyro4.Daemon(host=cfg.server2, port=cfg.serverPort2)

mechanical = demoapp.mechanical(
    '..' + os.path.sep + 'Example13-thermoMechanicalNonStat' + os.path.sep +
    'inputM13.in', '.')
#register agent
uri = daemon.register(mechanical)
ns.register('mechanical', uri)
log.debug("Daemon for mechanical problem runs at " + str(uri))
daemon.requestLoop()
Example #5
0
sys.path.append("../../..")
import demoapp
import meshgen
from mupif import FieldID
from mupif import Field
from mupif import ValueType
from mupif import TimeStep
from mupif import PropertyID
from mupif import Mesh
from mupif import Vertex
from mupif import Cell


if True:
    app = demoapp.thermal("inputT.in", ".")
    print(app.getApplicationSignature())

    sol = app.solveStep(TimeStep.TimeStep(0, 1))
    f = app.getField(FieldID.FID_Temperature, 0.0)
    data = f.field2VTKData().tofile("example2")

if True:
    app2 = demoapp.mechanical("inputM.in", ".")
    print(app2.getApplicationSignature())

    app2.setField(f)
    sol = app2.solveStep(TimeStep.TimeStep(0, 1))
    f = app2.getField(FieldID.FID_Displacement, 0.0)
    data = f.field2VTKData().tofile("example3")
Example #6
0
import demoapp
import logging
log = logging.getLogger()

## Local setup - nameserver, thermal server, mechanical server, steering script.
## All runs on a local machine ##
#import conf as cfg
#mechanical = demoapp.mechanical('inputM11.in', '.')
#log.info(mechanical.getApplicationSignature())
##locate nameserver and register application
#PyroUtil.runAppServer(server=cfg.server2, port=cfg.serverPort2, nathost=cfg.server2, natport=cfg.serverPort2, nshost=cfg.nshost, nsport=cfg.nsport, appName='mechanicalServer1', hkey=cfg.hkey, app=mechanical)

## Distributed setup using VPN and peer-to-peer connection. Nameserver remote, thermal server remote.
## Mechanical server local, steering script local
import conf_vpn as cfg
mechanical = demoapp.mechanical('inputM11.in', '.')
log.info(mechanical.getApplicationSignature())
#locate nameserver and register application
PyroUtil.runAppServer(server=cfg.server3,
                      port=cfg.serverPort3,
                      nathost=cfg.server3,
                      natport=cfg.serverPort3,
                      nshost=cfg.nshost,
                      nsport=cfg.nsport,
                      appName='mechanicalServer1',
                      hkey=cfg.hkey,
                      app=mechanical)

##Run a daemon for jobManager on this machine
#daemon = cfg.Pyro4.Daemon(host=127.0.0.1, port=44382)
##Run job manager on a server
Example #7
0
def createAppInputFile():
    inFile = open(fileName, 'w')
    inFile.write('%f %f\n' % (length, height))
    inFile.write('%d %d\n' % (numX, numY))
    inFile.write('%f\n' % (thickness))
    inFile.write('%e %f\n' % (Emodulus, PoissonRatio))
    inFile.write('0.0\n')
    inFile.write('1 N\n2 N\n3 C 0. %f\n4 D\n' % (-distribLoad))
    inFile.close()


#Input data for app1 are in cantilever1.in
createAppInputFile()
tstep = TimeStep.TimeStep(1., 1., 10, 's')
app1 = demoapp.mechanical(fileName, '.')
sol = app1.solveStep(tstep)
f = app1.getField(FieldID.FID_Displacement, tstep.getTargetTime())
f.field2VTKData().tofile('cantilever1.vtk')
#f.field2Image2D(fieldComponent=1, title='Displacement', fileName='cantilever1.png')
#right bottom point
#time.sleep(2)
maxDeflection = -f.evaluate((app1.xl, 0., 0)).getValue()[1]
log.info("Max. deflection from plane-stress task (m): %.3e" % maxDeflection)

app2 = demoapp.EulerBernoulli(b=thickness,
                              h=height,
                              L=length,
                              E=Emodulus,
                              f=distribLoad)
app2.solveStep(tstep)
Example #8
0
from __future__ import print_function
import sys
sys.path.append('../../..')
sys.path.append('../Example10')
import demoapp
import meshgen
from mupif import *

if True:
    app = demoapp.thermal('inputT11.in','.')
    print(app.getApplicationSignature())

    sol = app.solveStep(TimeStep.TimeStep(0,1)) 
    f = app.getField(FieldID.FID_Temperature, 1.0)
    f.field2VTKData().tofile('thermal11')
    f.field2Image2D(title='Thermal', fileName='thermal.png')

if True:
    app2 = demoapp.mechanical('inputM11.in', '.')
    print(app2.getApplicationSignature())

    app2.setField(f)
    sol = app2.solveStep(TimeStep.TimeStep(0,1)) 
    f = app2.getField(FieldID.FID_Displacement, 1.0)
    f.field2VTKData().tofile('mechanical11')
    f.field2Image2D(fieldComponent=1, title='Mechanical', fileName='mechanical.png')

#import time
#time.sleep(5)
Example #9
0
import demoapp
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)

Util.changeRootLogger('mechanical.log')

#locate nameserver
ns = PyroUtil.connectNameServer(nshost=cfg.nshost,
                                nsport=cfg.nsport,
                                hkey=cfg.hkey)

#(user, hostname)=PyroUtil.getUserInfo()

mechanical = demoapp.mechanical(
    '..' + os.path.sep + 'Example13-transiTM-local' + os.path.sep +
    'inputM13.in', '.')
PyroUtil.runAppServer(server=cfg.server,
                      port=cfg.serverPort2,
                      nathost=cfg.server,
                      natport=cfg.serverPort2,
                      nshost=cfg.nshost,
                      nsport=cfg.nsport,
                      appName='mechanical',
                      hkey=cfg.hkey,
                      app=mechanical)
Example #10
0
if True:
    app = demoapp.thermal('inputT10.in', '.')
    print(app.getApplicationSignature())

    tstep = TimeStep.TimeStep(1., 1., 10, 's')
    sol = app.solveStep(tstep)
    f = app.getField(FieldID.FID_Temperature, app.getAssemblyTime(tstep))
    f.field2VTKData().tofile('thermal10')
    f.field2Image2D(title='Thermal', fileName='thermal.png')
    time.sleep(1)
    valueT = f.evaluate((4.1, 0.9, 0.0))
    #print (valueT)

if True:
    app2 = demoapp.mechanical('inputM10.in', '.')
    print(app2.getApplicationSignature())

    app2.setField(f)
    sol = app2.solveStep(tstep)
    f = app2.getField(FieldID.FID_Displacement, tstep.getTargetTime())
    f.field2VTKData().tofile('mechanical10')
    f.field2Image2D(fieldComponent=1,
                    title='Mechanical',
                    fileName='mechanical.png')
    time.sleep(1)
    valueM = f.evaluate((4.1, 0.9, 0.0))
    #print (valueM)

if ((abs(valueT.getValue()[0] - 5.1996464044328956) <= 1.e-8)
        and (abs(valueM.getValue()[1] - (-1.2033973431029044e-05)) <= 1.e-8)):
Example #11
0
import demoapp
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)

Util.changeRootLogger('mechanical.log')

#locate nameserver
ns = PyroUtil.connectNameServer(nshost=cfg.nshost,
                                nsport=cfg.nsport,
                                hkey=cfg.hkey)

#(user, hostname)=PyroUtil.getUserInfo()

mechanical = demoapp.mechanical()
mechanical.initialize(
    '..' + os.path.sep + 'Example13-transiTM-local' + os.path.sep +
    'inputM13.in', '.')
PyroUtil.runAppServer(server=cfg.server,
                      port=cfg.serverPort2,
                      nathost=cfg.server,
                      natport=cfg.serverPort2,
                      nshost=cfg.nshost,
                      nsport=cfg.nsport,
                      appName='mechanical',
                      hkey=cfg.hkey,
                      app=mechanical)
Example #12
0
#Mechanical server for nonstationary problem
from __future__ import print_function
import os,sys
sys.path.extend(['..','../../..','../Example10'])
from mupif import *
import mupif
import demoapp
import conf as cfg

#locate nameserver
ns = PyroUtil.connectNameServer(nshost=cfg.nshost, nsport=cfg.nsport, hkey=cfg.hkey)

#Run a daemon. It will run even the port has DROP/REJECT status. The connection from a client is then impossible.
daemon = cfg.Pyro4.Daemon(host=cfg.server2, port=cfg.serverPort2)

mechanical = demoapp.mechanical('..'+os.path.sep+'Example13-thermoMechanicalNonStat'+os.path.sep+'inputM13.in', '.')
#register agent
uri = daemon.register(mechanical)
ns.register('mechanical', uri)
mupif.log.debug ("Daemon for mechanical problem runs at " + str(uri))
daemon.requestLoop()
Example #13
0
from __future__ import print_function
import sys
sys.path.append('../../..')
from mupif import *
from mupif import logger
# Import module Example10/demoapp.py
sys.path.append('../Example10')
import demoapp

time  = 0.
dt = 0.
timestepnumber = 0
targetTime = 3

thermal = demoapp.thermal_nonstat('inputT13.in','.')
mechanical = demoapp.mechanical('inputM13.in', '.')
matPlotFig = None

while (abs(time - targetTime) > 1.e-6):

    logger.debug("Step: %g %g %g"%(timestepnumber,time,dt))
    # create a time step
    istep = TimeStep.TimeStep(time, dt, timestepnumber)

    try:
        # solve problem 1
        thermal.solveStep(istep)
        # request Temperature from thermal
        ft = thermal.getField(FieldID.FID_Temperature, istep.getTime())
        #print ("T(l/2)=", f.evaluate((2.5,0.2,0.0)))
        data = ft.field2VTKData().tofile('T_%s'%str(timestepnumber))