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