# mupif.org

### Site Tools

wiki:examples:thermo-mechanical-demo

# Example of thermo-mechanical coupling To demonstrate the platform use, consider first an example of a coupled nonstationary thermo-mechanical analysis. A rectangular domain is clamped on the left edge and subjected to temperature loading according to figure below. Heat convection is prescribed on the top edge with ambient temperature 10°C. Left and bottom edges have prescribed temperature 0°C, the right edge has no boundary condition. Initial temperature is set to 0°C, heat conductivity is 1 W/m/K, heat capacity 1.0 J/kg/K, material density 1.0 kg/m3. The material has assigned Young's modulus as 30 GPa, Poisson's ratio 0.25 and coefficient of linear thermal expansion 12e-6 °C-1. Integration time step is constant as 1 s, 10 steps are executed in total.

First, the temperature distribution has to be solved in the whole domain from the given initial and boundary conditions. The temperature field is passed afterwards to the mechanical analysis, which evaluates the corresponding displacement field.

The discretizations for thermal and mechanical problems are different and the platform takes care of field interpolation. The mesh for thermal problem consist of 50 linear elements with linear approximation and 55 nodes. The mesh for mechanical analysis consist of 168 nodes and 160 elements with linear approximation

Evolution of temperature field and elastic deformation are showed on the following figure. The MuPIF control script for this simulation

```#!/usr/bin/env python
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 = 10.0

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

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
f = thermal.getField(FieldID.FID_Temperature, istep)
#print ("T(l/2)=", f.evaluate((2.5,0.2,0.0)))
data = f.field2VTKData().tofile('T_%s'%str(timestepnumber))

mechanical.setField(f)
sol = mechanical.solveStep(istep)
f = mechanical.getField(FieldID.FID_Displacement, istep)
#print ("D(l,1)=", f.evaluate((5.0,1.0,0.0)))
data = f.field2VTKData().tofile('M_%s'%str(timestepnumber))

# finish step
thermal.finishStep(istep)
mechanical.finishStep(istep)

# determine critical time step
dt = min (thermal.getCriticalTimeStep(), mechanical.getCriticalTimeStep())

# update time
time = time+dt
if (time > targetTime):
# make sure we reach targetTime at the end
time = targetTime
timestepnumber = timestepnumber+1

except APIError.APIError as e:
logger.error("Following API error occurred:",e)
break

# terminate
thermal.terminate();
mechanical.terminate();```

The example is available in examples/Example13-thermoMechanicalNonStat/Demo13.local.py of MuPIF installation. 