Example 2: heat transfer on 2d plate

Heat transfer on 2d plate.

This example will show : to do.

Here is the script of ‘example0.py’:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import sys

## You may need to specify the MPM package path
## if it is not installed in PYTHONPATH
sys.path.append("/path/to/your/mpm/package")

## GUI settings
app.core.setAnalysisType(AnalysisType = "MPM")
    
## Import MPM python package
import mpm as task

## Initialization of the core: Analysis object
sim=app.core.sim

## Geometry of mesh
length = 1.0
eleNum = 20
elemsize = length / eleNum
pic = 2
xrange = [0, length+2.0*elemsize]
yrange = xrange

## Dimension of the grid
## Arguments: (xmin, xmax, ymin, ymax)
sim.grid.setRange(xrange[0], xrange[1], yrange[0], yrange[1])

## Element numbers
## Arguments: (numberx, numbery)
sim.grid.setNumEle(eleNum+2, eleNum+2)
sim.grid.printInfo()


mc=task.Mc()
mc.rho = 1
mc.E = 5e5

## Thermal properties: specific heat and 
## conductivity coefficient tensor, K
## Arguments: (specific_heat, conduction tensor K)

## The use can initialize the K by four arguments [Kxx, Kxy, Kyx, Kyy]
## If only two arguments are given for the tensor
## they are for Kxx and Kyy, [Kxx, 0., 0., Kyy]
mc.setThermalProp(10.0, [1.0,1.0])

## Material array as member of Analysis object
sim.mats=[mc]

## Ids for each material
sim.mats[-1].setIndex(len(sim.mats)-1)

## Shapes:
left = task.Rectangle(0*elemsize, 1.*elemsize, 1*elemsize, (eleNum+1)*elemsize, task.RIGIDSHAPE)

## Thermal boundary condition, temperature
left.setThermalBc(100.0)
left.setMatProperty(task.RIGIDMAT,0, pic)

right = task.Rectangle(xrange[1] - 1.*elemsize, xrange[1]-0*elemsize, 1*elemsize, (eleNum+1)*elemsize, task.RIGIDSHAPE)
right.setThermalBc(100.0)
right.setMatProperty(task.RIGIDMAT, 0, pic)

bot = task.Rectangle(0*elemsize, xrange[1] -0*elemsize, 0*elemsize, 1.*elemsize, task.RIGIDSHAPE)
bot.setThermalBc(100.0)
bot.setMatProperty(task.RIGIDMAT, 0, pic)

top = task.Rectangle(0*elemsize, xrange[1] -0*elemsize, yrange[1]-1*elemsize, yrange[1]-0.*elemsize, task.RIGIDSHAPE)
top.setThermalBc(100.0)
top.setMatProperty(task.RIGIDMAT, 0, pic)

soil = task.Rectangle(1*elemsize, xrange[1] - 1.*elemsize, 1.*elemsize, (eleNum+1)*elemsize, task.NONEBC)
soil.setMatProperty(task.MCMAT, 0, pic)
soil.setDamping(0.2, 0, 0.1)

## Summary: four sides are imposed by fixing temperature boundary condition
## as 100 Celsius, and soil has a initial temperature as 0 Celsius

## Shapes array as a member of Analysis object
sim.shapes = [left, right, bot, top, soil]

## Analysis settings

## CPU cores (at least 1)
## SetNumThreads must be called explicitly,
## otherwise undeifned behaviour will appear
sim.setNumThreads(1)

## Set the total time elapsed and timestep
## Arguments: (tottal_time, timestep)
sim.setTimeDt(1, 1e-4)

## Simulation resutl archive
## When to start the archive (sec)
sim.writer.setStartTime(0)

## Time to stop the archive (sec) 
sim.writer.setEndTime(10)

## Frequency for the file archive (sec)  
sim.writer.setIntervalTime(0.1)

## MPM interpolation method,
## options: LINEAR, GIMP, LINEARCPDI, BSPLINECPDI
sim.setMethod(task.GIMP)

## Simulation task, options: MANAL, TANAL, PHASEANAL
## MANAL: mechanical simulation
## TANAL: thermal simulation
## PHASEANAL: phase transition simulation
sim.simTypeMasks = task.TANAL

## Where to store the archived datas
## (directory_name, file_name)   
sim.writer.setDir("./Results", "thermal2d")

## Before the calculation,
## run PreAnalysis to initialize the analysis core
sim.PreAnalysis()

## Run specific steps
## If GUI is activated,
## app.run(1)
## else:
## sim.run(1)