| 1 | #Test Name: ThermalConduction
|
|---|
| 2 | import numpy
|
|---|
| 3 | import sys
|
|---|
| 4 | from model import *
|
|---|
| 5 | from triangle import *
|
|---|
| 6 | from setmask import *
|
|---|
| 7 | from parameterize import *
|
|---|
| 8 | from setflowequation import *
|
|---|
| 9 | from solve import *
|
|---|
| 10 | from MatlabFuncs import *
|
|---|
| 11 |
|
|---|
| 12 | """
|
|---|
| 13 | This file can be run to check that the conduction is correctly modeled.
|
|---|
| 14 | There is no velocity (no advection) the only thermal boundary conditions are an imposed temperature
|
|---|
| 15 | at the lower and upper surface. The result must be a linear temperature from the upper to the lower
|
|---|
| 16 | surface. if it is not the case, something is thermal modeling has been changed...
|
|---|
| 17 | """
|
|---|
| 18 |
|
|---|
| 19 | printingflag=False
|
|---|
| 20 |
|
|---|
| 21 | md=model()
|
|---|
| 22 | md=triangle(md,'../Exp/Square.exp',100000.)
|
|---|
| 23 | md=setmask(md,'all','')
|
|---|
| 24 | md=parameterize(md,'../Par/SquareThermal.py')
|
|---|
| 25 | md.extrude(11,2.)
|
|---|
| 26 | md=setflowequation(md,'HO','all')
|
|---|
| 27 |
|
|---|
| 28 | pos1=numpy.nonzero(md.mesh.elementonbase)[0]
|
|---|
| 29 | md.thermal.spctemperature[md.mesh.elements[pos1,0:3]-1]=10.
|
|---|
| 30 | pos2=numpy.nonzero(md.mesh.elementonsurface)[0]
|
|---|
| 31 | md.thermal.spctemperature[md.mesh.elements[pos2,3:6]-1]=0.
|
|---|
| 32 | md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,1),int)
|
|---|
| 33 |
|
|---|
| 34 | #analytical results
|
|---|
| 35 | #d2T/dz2=0 T(bed)=10 T(surface)=0 => T=0*(z-bed)/thickness+10*(surface-z)/thickness
|
|---|
| 36 | #each layer of the 3d mesh must have a constant value
|
|---|
| 37 | md.initialization.temperature=10.*(md.geometry.surface-md.mesh.z)/md.geometry.thickness
|
|---|
| 38 |
|
|---|
| 39 | #modeled results
|
|---|
| 40 | md.cluster=generic('name',oshostname(),'np',2)
|
|---|
| 41 | md=solve(md,'Thermal')
|
|---|
| 42 |
|
|---|
| 43 | #plot results
|
|---|
| 44 | comp_temp=md.results.ThermalSolution.Temperature
|
|---|
| 45 | relative=numpy.abs((comp_temp-md.initialization.temperature)/md.initialization.temperature)*100.
|
|---|
| 46 | relative[numpy.nonzero(comp_temp==md.initialization.temperature)[0]]=0.
|
|---|
| 47 | #plotmodel(md,'data',comp_temp,'title','Modeled temperature [K]','data',md.initialization.temperature,'view',3,...
|
|---|
| 48 | # 'title','Analytical temperature [K]','view',3,'data',comp_temp-md.initialization.temperature,...
|
|---|
| 49 | # 'title','Absolute error [K]','view',3,'data',relative,'title','Relative error [%]','view',3,...
|
|---|
| 50 | # 'figposition','mathieu','FontSize#all',20)
|
|---|
| 51 | if printingflag:
|
|---|
| 52 | pass
|
|---|
| 53 | # set(gcf,'Color','w')
|
|---|
| 54 | # printmodel('thermalconduction','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off');
|
|---|
| 55 | # system(['mv thermalconduction.png ' ISSM_DIR '/website/doc_pdf/validation/Images/Thermal ']);
|
|---|
| 56 |
|
|---|
| 57 | #Fields and tolerances to track changes
|
|---|
| 58 | field_names =['ConductionTemperature']
|
|---|
| 59 | field_tolerances=[1e-13]
|
|---|
| 60 | field_values =[comp_temp]
|
|---|