| 1 | """
|
|---|
| 2 | == == == == == == == == == == == == == == == == == == ==
|
|---|
| 3 | Auto generated python script for ISSM: test1301.m
|
|---|
| 4 | Created on 2012-09-27 via translateToPy.py Ver 1.0 by mikep
|
|---|
| 5 | == == == == == == == == == == == == == == == == == == ==
|
|---|
| 6 |
|
|---|
| 7 | Matlab script conversion into python
|
|---|
| 8 | translateToPy.py Author: Michael Pellegrin
|
|---|
| 9 | translateToPy.py Date: 09/24/12
|
|---|
| 10 | == == == == == == == == == == == == == == == == == == ==
|
|---|
| 11 | """
|
|---|
| 12 |
|
|---|
| 13 | from MatlabFuncs import *
|
|---|
| 14 | from model import *
|
|---|
| 15 | from EnumDefinitions import *
|
|---|
| 16 | from numpy import *
|
|---|
| 17 | from triangle import *
|
|---|
| 18 | from setmask import *
|
|---|
| 19 | from parameterize import *
|
|---|
| 20 | from setflowequation import *
|
|---|
| 21 | from solve import *
|
|---|
| 22 |
|
|---|
| 23 | # This file can be run to check that the melting in simple conduction is correctly modeled.
|
|---|
| 24 |
|
|---|
| 25 | # There is no velocity (no advection) the only thermal boundary conditions are an imposed temperature
|
|---|
| 26 |
|
|---|
| 27 | # at upper surface and an impose flux at its base. The result must be a linear temperature from the upper to the lower
|
|---|
| 28 |
|
|---|
| 29 | # surface with an imposed slope (Geothermal flux). if it is not the case, something is thermal modeling has been changed...
|
|---|
| 30 |
|
|---|
| 31 | printingflag=false
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | md=model()
|
|---|
| 35 | md=triangle(md,'../Exp/Square.exp',100000)
|
|---|
| 36 | md=setmask(md,'','')
|
|---|
| 37 | md=parameterize(md,'../Par/SquareThermal.py')
|
|---|
| 38 | md.extrude(3,2.)
|
|---|
| 39 | md=setflowequation(md,'Pattyn','all')
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | # Some conditions specific to melting test
|
|---|
| 43 |
|
|---|
| 44 | md.initialization.pressure=zeros(md.mesh.numberofvertices,1)
|
|---|
| 45 | md.initialization.temperature=273.15*ones(md.mesh.numberofvertices,1)
|
|---|
| 46 | pos=numpy.nonzero(md.mesh.vertexonsurface)
|
|---|
| 47 | md.thermal.spctemperature(pos)=md.initialization.temperature(pos)
|
|---|
| 48 | md.materials.rheology_B=paterson(md.initialization.temperature)
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | # analytical results
|
|---|
| 52 |
|
|---|
| 53 | # melting heat = geothermal flux
|
|---|
| 54 |
|
|---|
| 55 | # Mb*L*rho=G => Mb=G/L*rho
|
|---|
| 56 |
|
|---|
| 57 | melting=md.basalforcings.geothermalflux/(md.materials.rho_ice*md.materials.latentheat)*md.constants.yts
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 | # modeled results
|
|---|
| 61 |
|
|---|
| 62 | md.cluster=generic('name',oshostname(),'np',2)
|
|---|
| 63 | md=solve(md,ThermalSolutionEnum())
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | # plot results
|
|---|
| 67 |
|
|---|
| 68 | comp_melting=md.results.ThermalSolution.BasalforcingsMeltingRate
|
|---|
| 69 | relative=abs((comp_melting-melting)./melting)*100
|
|---|
| 70 | relative(find(comp_melting==melting))=0
|
|---|
| 71 | plotmodel()(md,'data',comp_melting,'title','Modeled melting','data',melting,'title','Analytical melting',\
|
|---|
| 72 | 'data',comp_melting-melting,'title','Absolute error','data',relative,'title','Relative error [%]',\
|
|---|
| 73 | 'layer#all',1,'caxis#2',[1.02964 1.02966]*10^-4,'FontSize#all',20,'figposition','mathieu')
|
|---|
| 74 | if printingflag,
|
|---|
| 75 | set(gcf,'Color','w')
|
|---|
| 76 | printmodel()('thermalmelting','png','margin','on','marginsize',25,'frame','off','resolution',0.7,'hardcopy','off')
|
|---|
| 77 | system(['mv thermalmelting.png ' ISSM_DIR '/website/doc_pdf/validation/Images/Thermal '])
|
|---|
| 78 | end
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 | # Fields and tolerances to track changes
|
|---|
| 84 |
|
|---|
| 85 | field_names =['BasalMelting']
|
|---|
| 86 | field_tolerances=[1e-08]
|
|---|
| 87 | field_values =[comp_melting]
|
|---|