source:
issm/oecreview/Archive/21724-22754/ISSM-22266-22267.diff
Last change on this file was 22755, checked in by , 7 years ago | |
---|---|
File size: 199.4 KB |
-
../trunk-jpl/test/Par/SquareThermal.py
25 25 26 26 print " creating temperatures" 27 27 md.initialization.temperature=(273.-20.)*numpy.ones((md.mesh.numberofvertices)) 28 md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,)) 29 md.initialization.waterfraction=numpy.zeros((md.mesh.numberofvertices,)) 30 md.initialization.watercolumn=numpy.zeros((md.mesh.numberofvertices,)) 28 31 29 32 print " creating flow law parameter" 30 33 md.materials.rheology_B=paterson(md.initialization.temperature) … … 32 35 33 36 print " creating surface mass balance" 34 37 md.smb.mass_balance=numpy.ones((md.mesh.numberofvertices))/md.constants.yts #1m/a 35 md.basalforcings.melting_rate=0.*numpy.ones((md.mesh.numberofvertices))/md.constants.yts #1m/a 38 #md.basalforcings.melting_rate=0.*numpy.ones((md.mesh.numberofvertices))/md.constants.yts #1m/a 39 md.basalforcings.groundedice_melting_rate=0.*numpy.ones((md.mesh.numberofvertices))/md.constants.yts #1m/a 40 md.basalforcings.floatingice_melting_rate=0.*numpy.ones((md.mesh.numberofvertices))/md.constants.yts #1m/a 36 41 37 42 #Deal with boundary conditions: 38 43 … … 40 45 md=SetMarineIceSheetBC(md,'../Exp/SquareFront.exp') 41 46 42 47 print " boundary conditions for thermal model" 43 md.thermal.spctemperature =md.initialization.temperature48 md.thermal.spctemperature[:]=md.initialization.temperature 44 49 md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices)) 45 50 md.basalforcings.geothermalflux[numpy.nonzero(md.mask.groundedice_levelset>0.)[0]]=1.*10**-3 #1 mW/m^2 -
../trunk-jpl/test/Par/ISMIPE.par
13 13 md.geometry.base(i)=(1.-coeff)*data(point1,2)+coeff*data(point2,2); 14 14 md.geometry.surface(i)=(1.-coeff)*data(point1,3)+coeff*data(point2,3); 15 15 end 16 16 17 md.geometry.thickness=md.geometry.surface-md.geometry.base; 17 18 md.geometry.thickness(find(~md.geometry.thickness))=0.01; 18 19 md.geometry.base=md.geometry.surface-md.geometry.thickness; -
../trunk-jpl/test/Par/ISMIPE.py
12 12 y=md.mesh.y[i] 13 13 point1=numpy.floor(y/100.) 14 14 point2=numpy.minimum(point1+1,50) 15 coeff=(y-(point1 -1.)*100.)/100.15 coeff=(y-(point1)*100.)/100. 16 16 md.geometry.base[i]=(1.-coeff)*data[point1,1]+coeff*data[point2,1] 17 17 md.geometry.surface[i]=(1.-coeff)*data[point1,2]+coeff*data[point2,2] 18 18 19 md.geometry.thickness=md.geometry.surface-md.geometry.base 19 20 md.geometry.thickness[numpy.nonzero(numpy.logical_not(md.geometry.thickness))]=0.01 20 21 md.geometry.base=md.geometry.surface-md.geometry.thickness -
../trunk-jpl/test/NightlyRun/test2425.py
1 #Test Name: SquareSheetShelfGroundingLine2dSoft 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',150000.) 12 md = setmask(md,'../Exp/SquareShelf.exp','') 13 md = parameterize(md,'../Par/SquareSheetShelf.py') 14 md = setflowequation(md,'SSA','all') 15 md.initialization.vx[:] = 0. 16 md.initialization.vy[:] = 0. 17 md.geometry.base = -700. - (md.mesh.y - 500000.) / 1000. 18 md.geometry.bed = -700. - (md.mesh.y - 500000.) / 1000. 19 md.geometry.thickness[:] = 1300. 20 md.geometry.surface = md.geometry.base + md.geometry.thickness 21 md.transient.isstressbalance = 1 22 md.transient.isgroundingline = 1 23 md.groundingline.migration = 'AggressiveMigration' 24 25 md.timestepping.time_step = .1 26 md.timestepping.final_time = 1 27 28 md.cluster = generic('name',gethostname(),'np',3) 29 md = solve(md,'Transient') 30 vel1 = md.results.TransientSolution[-1].Vel 31 32 #get same results with offset in bed and sea level: 33 md.geometry.base = -700. - (md.mesh.y - 500000.) / 1000. 34 md.geometry.bed = -700. - (md.mesh.y - 500000.) / 1000. 35 md.geometry.thickness[:] = 1300. 36 md.geometry.surface = md.geometry.base + md.geometry.thickness 37 38 md.geometry.base = md.geometry.base + 1000 39 md.geometry.bed = md.geometry.bed + 1000 40 md.geometry.surface = md.geometry.surface + 1000 41 md.slr.sealevel = 1000 * np.ones((md.mesh.numberofvertices,)) 42 43 md = solve(md,'Transient','checkconsistency','no') 44 vel2 = md.results.TransientSolution[-1].Vel 45 46 #Fields and tolerances to track changes 47 field_names = ['Vel','Veloffset'] 48 field_tolerances = [1e-13,1e-13] 49 field_values = [vel1,vel2] 50 -
../trunk-jpl/test/NightlyRun/test342.py
1 #Test Name: SquareSheetTherSteaPlume 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from plumebasalforcings import * 11 12 md = triangle(model(),'../Exp/Square.exp',180000.) 13 md = setmask(md,'','') 14 md = parameterize(md,'../Par/SquareSheetConstrained.py') 15 md.basalforcings = plumebasalforcings() 16 md.basalforcings = md.basalforcings.setdefaultparameters() 17 md.basalforcings.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices,)) 18 md.basalforcings.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices,)) 19 md.basalforcings.plumex = 500000 20 md.basalforcings.plumey = 500000 21 md.extrude(3,1.) 22 md = setflowequation(md,'SSA','all') 23 md.timestepping.time_step = 0. 24 md.thermal.requested_outputs = ['default','BasalforcingsGeothermalflux'] 25 md.cluster = generic('name',gethostname(),'np',3) 26 md = solve(md,'Thermal') 27 28 #Fields and tolerances to track changes 29 field_names = ['Temperature','BasalforcingsGroundediceMeltingRate','BasalforcingsGeothermalflux'] 30 field_tolerances = [1e-13,1e-8,1e-13] 31 field_values = [ 32 md.results.ThermalSolution.Temperature, 33 md.results.ThermalSolution.BasalforcingsGroundediceMeltingRate, 34 md.results.ThermalSolution.BasalforcingsGeothermalflux, 35 ] -
../trunk-jpl/test/NightlyRun/test261.py
1 #Test Name: SquareShelfConstrainedTranEnhanced 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from matenhancedice import * 11 12 md = triangle(model(),'../Exp/Square.exp',180000.) 13 md = setmask(md,'all','') 14 md = parameterize(md,'../Par/SquareShelfConstrained.py') 15 md = md.extrude(3,1.) 16 md = setflowequation(md,'SSA','all') 17 md.cluster = generic('name',gethostname(),'np',3) 18 md.materials = matenhancedice() 19 md.materials.rheology_B = 3.15e8 * np.ones(md.mesh.numberofvertices,) 20 md.materials.rheology_n = 3 * np.ones(md.mesh.numberofelements,) 21 md.materials.rheology_E = np.ones(md.mesh.numberofvertices,) 22 md.transient.isstressbalance = 1 23 md.transient.ismasstransport = 0 24 md.transient.issmb = 1 25 md.transient.isthermal = 1 26 md.transient.isgroundingline = 0 27 md = solve(md,'Transient') 28 29 #Fields and tolerances to track changes 30 field_names = ['Vx','Vy','Vel','Temperature','BasalforcingsGroundediceMeltingRate'] 31 field_tolerances = [1e-13,1e-13,1e-13,1e-13,1e-13] 32 field_values = [ 33 md.results.TransientSolution[0].Vx, 34 md.results.TransientSolution[0].Vy, 35 md.results.TransientSolution[0].Vel, 36 md.results.TransientSolution[0].Temperature, 37 md.results.TransientSolution[0].BasalforcingsGroundediceMeltingRate, 38 ] -
../trunk-jpl/test/NightlyRun/test441.py
1 #Test Name: MISMIP3D 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',100000.) 12 md = setmask(md,'../Exp/SquareShelf.exp','') 13 md = parameterize(md,'../Par/SquareSheetShelf.py') 14 md.initialization.vx[:] = 1. 15 md.initialization.vy[:] = 1. 16 md.geometry.thickness[:] = 500. - md.mesh.x / 10000. 17 md.geometry.bed = -100. - md.mesh.x / 1000. 18 md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water 19 md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed 20 pos = np.array(np.where(md.mask.groundedice_levelset >= 0.)) 21 md.geometry.base[pos] = md.geometry.bed[pos] 22 md.geometry.surface = md.geometry.base + md.geometry.thickness 23 md = setflowequation(md,'SSA','all') 24 25 #Boundary conditions: 26 md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,)) 27 md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0. 28 md.stressbalance.spcvx[:] = float('Nan') 29 md.stressbalance.spcvy[:] = float('Nan') 30 md.stressbalance.spcvz[:] = float('Nan') 31 posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9))) 32 posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1))) 33 pos = np.unique(np.concatenate((posA,posB))) 34 md.stressbalance.spcvy[pos] = 0. 35 pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1))) 36 md.stressbalance.spcvx[pos2] = 0. 37 md.stressbalance.spcvy[pos2] = 0. 38 39 md.materials.rheology_B = 1. / ((10**-25)**(1./3.)) * np.ones((md.mesh.numberofvertices,)) 40 md.materials.rheology_law = 'None' 41 md.friction.coefficient[:] = np.sqrt(1e7) * np.ones((md.mesh.numberofvertices,)) 42 md.friction.p = 3. * np.ones((md.mesh.numberofelements,)) 43 md.smb.mass_balance[:] = 1. 44 md.basalforcings.groundedice_melting_rate[:] = 0. 45 md.basalforcings.floatingice_melting_rate[:] = 30. 46 md.transient.isthermal = 0 47 md.transient.isstressbalance = 1 48 md.transient.isgroundingline = 1 49 md.transient.ismasstransport = 1 50 md.transient.issmb = 1 51 md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate'] 52 md.groundingline.migration = 'SubelementMigration2' 53 md.timestepping.final_time = 30. 54 md.timestepping.time_step = 10. 55 56 md.cluster = generic('name',gethostname(),'np',3) 57 md = solve(md,'Transient') 58 59 #Fields and tolerances to track changes 60 field_names = [ 61 'Bed1','Surface1','Thickness1','Floatingice1','Vx1','Vy1','Pressure1','FloatingiceMeltingrate1', 62 'Bed2','Surface2','Thickness2','Floatingice2','Vx2','Vy2','Pressure2','FloatingiceMeltingrate2', 63 'Bed3','Surface3','Thickness3','Floatingice3','Vx3','Vy3','Pressure3','FloatingiceMeltingrate3'] 64 field_tolerances = [ 65 2e-11,5e-12,2e-11,1e-11,5e-10,1e-08,1e-13,1e-13, 66 3e-11,3e-11,9e-10,7e-11,1e-09,5e-08,1e-10,1e-13, 67 1e-10,3e-11,1e-10,7e-11,1e-09,5e-08,1e-10,1e-13] 68 field_values = [ 69 md.results.TransientSolution[0].Base, 70 md.results.TransientSolution[0].Surface, 71 md.results.TransientSolution[0].Thickness, 72 md.results.TransientSolution[0].MaskGroundediceLevelset, 73 md.results.TransientSolution[0].Vx, 74 md.results.TransientSolution[0].Vy, 75 md.results.TransientSolution[0].Pressure, 76 md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate, 77 md.results.TransientSolution[1].Base, 78 md.results.TransientSolution[1].Surface, 79 md.results.TransientSolution[1].Thickness, 80 md.results.TransientSolution[1].MaskGroundediceLevelset, 81 md.results.TransientSolution[1].Vx, 82 md.results.TransientSolution[1].Vy, 83 md.results.TransientSolution[1].Pressure, 84 md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate, 85 md.results.TransientSolution[2].Base, 86 md.results.TransientSolution[2].Surface, 87 md.results.TransientSolution[2].Thickness, 88 md.results.TransientSolution[2].MaskGroundediceLevelset, 89 md.results.TransientSolution[2].Vx, 90 md.results.TransientSolution[2].Vy, 91 md.results.TransientSolution[2].Pressure, 92 md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate, 93 ] -
../trunk-jpl/test/NightlyRun/test343.py
1 #Test Name: SquareSheetConstrainedSmbGradientsEla2d 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from SMBgradientsela import * 11 12 md = triangle(model(),'../Exp/Square.exp',150000.) 13 md = setmask(md,'','') 14 md = parameterize(md,'../Par/SquareSheetConstrained.py') 15 md = setflowequation(md,'SSA','all') 16 md.smb = SMBgradientsela() 17 md.smb.ela = 1500. * np.ones((md.mesh.numberofvertices+1,)) 18 md.smb.b_pos = 0.002 * np.ones((md.mesh.numberofvertices+1,)) 19 md.smb.b_neg = 0.005 * np.ones((md.mesh.numberofvertices+1,)) 20 md.smb.b_max = 4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,)) 21 md.smb.b_min = -4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,)) 22 23 #Change geometry 24 md.geometry.thickness = md.geometry.surface * 30. 25 md.geometry.surface = md.geometry.base + md.geometry.thickness 26 27 #Transient options 28 md.transient.requested_outputs = ['default','TotalSmb'] 29 md.cluster = generic('name',gethostname(),'np',3) 30 md = solve(md,'Transient') 31 32 #Fields and tolerances to track changes 33 field_names = [ 34 'Vx1','Vy1','Vel1','Bed1','Surface1','Thickness1','SMB1','TotalSmb1', 35 'Vx2','Vy2','Vel2','Bed2','Surface2','Thickness2','SMB2','TotalSmb2', 36 'Vx3','Vy3','Vel3','Bed3','Surface3','Thickness3','SMB3','TotalSmb3'] 37 field_tolerances = [ 38 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13, 39 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13, 40 1e-12,1e-12,1e-12,1e-13,1e-13,1e-13,1.5e-13,1e-13] 41 field_values = [ 42 md.results.TransientSolution[0].Vx, 43 md.results.TransientSolution[0].Vy, 44 md.results.TransientSolution[0].Vel, 45 md.results.TransientSolution[0].Base, 46 md.results.TransientSolution[0].Surface, 47 md.results.TransientSolution[0].Thickness, 48 md.results.TransientSolution[0].SmbMassBalance, 49 md.results.TransientSolution[0].TotalSmb, 50 md.results.TransientSolution[1].Vx, 51 md.results.TransientSolution[1].Vy, 52 md.results.TransientSolution[1].Vel, 53 md.results.TransientSolution[1].Base, 54 md.results.TransientSolution[1].Surface, 55 md.results.TransientSolution[1].Thickness, 56 md.results.TransientSolution[1].TotalSmb, 57 md.results.TransientSolution[1].SmbMassBalance, 58 md.results.TransientSolution[2].Vx, 59 md.results.TransientSolution[2].Vy, 60 md.results.TransientSolution[2].Vel, 61 md.results.TransientSolution[2].Base, 62 md.results.TransientSolution[2].Surface, 63 md.results.TransientSolution[2].Thickness, 64 md.results.TransientSolution[2].SmbMassBalance, 65 md.results.TransientSolution[2].TotalSmb 66 ] -
../trunk-jpl/test/NightlyRun/test540.py
1 #Test Name: PigTranCalvingDevSSA2d 2 from model import * 3 from socket import gethostname 4 from triangle import * 5 from setmask import * 6 from parameterize import * 7 from setflowequation import * 8 from solve import * 9 from calvingvonmises import * 10 11 md = triangle(model(),'../Exp/Pig.exp',10000.) 12 md = setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp') 13 md = parameterize(md,'../Par/Pig.py') 14 md = setflowequation(md,'SSA','all') 15 md.timestepping.time_step = 2 16 md.timestepping.final_time = 50 17 18 #calving parameters 19 md.mask.ice_levelset = 1e4 * (md.mask.ice_levelset + 0.5) 20 md.calving = calvingvonmises() 21 md.calving.meltingrate = np.zeros((md.mesh.numberofvertices,)) 22 md.transient.ismovingfront = 1 23 md.levelset.spclevelset = float('NaN') * np.ones((md.mesh.numberofvertices,)) 24 pos = np.where(md.mesh.vertexonboundary) 25 md.levelset.spclevelset[pos] = md.mask.ice_levelset[pos] 26 27 md.cluster = generic('name',gethostname(),'np',2) 28 md = solve(md,'Transient') 29 30 #Fields and tolerances to track changes 31 field_names = [ 32 'Vx1' ,'Vy1' ,'Vel1' ,'Pressure1' ,'Bed1' ,'Surface1' ,'Thickness1' ,'MaskIceLevelset1' , 33 'Vx2' ,'Vy2' ,'Vel2' ,'Pressure2' ,'Bed2' ,'Surface2' ,'Thickness2' ,'MaskIceLevelset2' , 34 'Vx10','Vy10','Vel10','Pressure10','Bed10','Surface10','Thickness10','MaskIceLevelset10', 35 ] 36 field_tolerances = [ 37 1e-12,2e-12,2e-12,1e-13,1e-13,1e-13,1e-13,1e-13, 38 1e-12,1e-12,1e-12,1e-13,1e-13,1e-13,1e-13,1e-12, 39 1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-11,1e-9, 40 ] 41 field_values = [ 42 md.results.TransientSolution[0].Vx, 43 md.results.TransientSolution[0].Vy, 44 md.results.TransientSolution[0].Vel, 45 md.results.TransientSolution[0].Pressure, 46 md.results.TransientSolution[0].Base, 47 md.results.TransientSolution[0].Surface, 48 md.results.TransientSolution[0].Thickness, 49 md.results.TransientSolution[0].MaskIceLevelset, 50 md.results.TransientSolution[1].Vx, 51 md.results.TransientSolution[1].Vy, 52 md.results.TransientSolution[1].Vel, 53 md.results.TransientSolution[1].Pressure, 54 md.results.TransientSolution[1].Base, 55 md.results.TransientSolution[1].Surface, 56 md.results.TransientSolution[1].Thickness, 57 md.results.TransientSolution[1].MaskIceLevelset, 58 md.results.TransientSolution[9].Vx, 59 md.results.TransientSolution[9].Vy, 60 md.results.TransientSolution[9].Vel, 61 md.results.TransientSolution[9].Pressure, 62 md.results.TransientSolution[9].Base, 63 md.results.TransientSolution[9].Surface, 64 md.results.TransientSolution[9].Thickness, 65 md.results.TransientSolution[9].MaskIceLevelset, 66 ] -
../trunk-jpl/test/NightlyRun/test442.py
1 #Test Name: MISMIP3DHO 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',100000.) 12 md = setmask(md,'../Exp/SquareShelf.exp','') 13 md = parameterize(md,'../Par/SquareSheetShelf.py') 14 md.initialization.vx[:] = 1. 15 md.initialization.vy[:] = 1. 16 md.geometry.thickness[:] = 500. - md.mesh.x / 10000. 17 md.geometry.bed = -100. - md.mesh.x / 1000. 18 md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water 19 md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed 20 pos = np.where(md.mask.groundedice_levelset >= 0.) 21 md.geometry.base[pos] = md.geometry.bed[pos] 22 md.geometry.surface = md.geometry.base + md.geometry.thickness 23 md = md.extrude(4,1.) 24 md = setflowequation(md,'HO','all') 25 26 #Boundary conditions: 27 md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,)) 28 md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0. 29 md.stressbalance.spcvx[:] = float('Nan') 30 md.stressbalance.spcvy[:] = float('Nan') 31 md.stressbalance.spcvz[:] = float('Nan') 32 posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9))) 33 posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1))) 34 pos = np.unique(np.concatenate((posA,posB))) 35 md.stressbalance.spcvy[pos] = 0. 36 pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1))) 37 md.stressbalance.spcvx[pos2] = 0. 38 md.stressbalance.spcvy[pos2] = 0. 39 40 md.materials.rheology_B = 1. / ((10**-25)**(1./3.)) * np.ones((md.mesh.numberofvertices,)) 41 md.materials.rheology_law = 'None' 42 md.friction.coefficient[:] = np.sqrt(1e7) * np.ones((md.mesh.numberofvertices,)) 43 md.friction.p = 3. * np.ones((md.mesh.numberofelements,)) 44 md.smb.mass_balance[:] = 1. 45 md.basalforcings.groundedice_melting_rate[:] = 0. 46 md.basalforcings.floatingice_melting_rate[:] = 30. 47 md.transient.isthermal = 0 48 md.transient.isstressbalance = 1 49 md.transient.isgroundingline = 1 50 md.transient.ismasstransport = 1 51 md.transient.issmb = 1 52 md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate'] 53 md.groundingline.migration = 'SubelementMigration2' 54 md.timestepping.final_time = 30 55 md.timestepping.time_step = 10 56 57 md.cluster = generic('name',gethostname(),'np',3) 58 md = solve(md,'Transient') 59 60 #Fields and tolerances to track changes 61 field_names = [ 62 'Bed1','Surface1','Thickness1','Floatingice1','Vx1','Vy1','Vz1','Pressure1','FloatingiceMeltingrate1', 63 'Bed2','Surface2','Thickness2','Floatingice2','Vx2','Vy2','Vz2','Pressure2','FloatingiceMeltingrate2', 64 'Bed3','Surface3','Thickness3','Floatingice3','Vx3','Vy3','Vz3','Pressure3','FloatingiceMeltingrate3'] 65 field_tolerances = [ 66 2e-11,5e-12,2e-11,1e-11,5e-10,3e-08,6e-10,1e-13,1e-13, 67 3e-11,3e-11,9e-10,7e-11,6e-09,1e-07,1e-09,1e-10,1e-13, 68 1e-8,2e-08,7e-09,2e-7 ,1e-03,8e-04,2e-09,1e-10,1e-13] 69 field_values = [ 70 md.results.TransientSolution[0].Base, 71 md.results.TransientSolution[0].Surface, 72 md.results.TransientSolution[0].Thickness, 73 md.results.TransientSolution[0].MaskGroundediceLevelset, 74 md.results.TransientSolution[0].Vx, 75 md.results.TransientSolution[0].Vy, 76 md.results.TransientSolution[0].Vz, 77 md.results.TransientSolution[0].Pressure, 78 md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate, 79 md.results.TransientSolution[1].Base, 80 md.results.TransientSolution[1].Surface, 81 md.results.TransientSolution[1].Thickness, 82 md.results.TransientSolution[1].MaskGroundediceLevelset, 83 md.results.TransientSolution[1].Vx, 84 md.results.TransientSolution[1].Vy, 85 md.results.TransientSolution[1].Vz, 86 md.results.TransientSolution[1].Pressure, 87 md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate, 88 md.results.TransientSolution[2].Base, 89 md.results.TransientSolution[2].Surface, 90 md.results.TransientSolution[2].Thickness, 91 md.results.TransientSolution[2].MaskGroundediceLevelset, 92 md.results.TransientSolution[2].Vx, 93 md.results.TransientSolution[2].Vy, 94 md.results.TransientSolution[2].Vz, 95 md.results.TransientSolution[2].Pressure, 96 md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate, 97 ] -
../trunk-jpl/test/NightlyRun/test344.py
1 #Test Name: SquareSheetConstrainedSmbGradientsEla3d 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from SMBgradientsela import * 11 12 md = triangle(model(),'../Exp/Square.exp',150000.) 13 md = setmask(md,'','') 14 md = parameterize(md,'../Par/SquareSheetConstrained.py') 15 16 #Change geometry 17 md.geometry.thickness = md.geometry.surface * 30. 18 md.geometry.surface = md.geometry.base + md.geometry.thickness 19 20 md = md.extrude(3,1.) 21 md = setflowequation(md,'HO','all') 22 md.smb = SMBgradientsela() 23 md.smb.ela = 1500. * np.ones((md.mesh.numberofvertices+1,)) 24 md.smb.b_pos = 0.002 * np.ones((md.mesh.numberofvertices+1,)) 25 md.smb.b_neg = 0.005 * np.ones((md.mesh.numberofvertices+1,)) 26 md.smb.b_max = 4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,)) 27 md.smb.b_min = -4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,)) 28 29 30 #Transient options 31 md.transient.requested_outputs = ['default','TotalSmb'] 32 md.cluster = generic('name',gethostname(),'np',3) 33 md = solve(md,'Transient') 34 35 #Fields and tolerances to track changes 36 field_names = ['Vx1','Vy1','Vz1','Vel1','Bed1','Surface1','Thickness1','Temperature1','SMB1','TotalSmb1', 37 'Vx2','Vy2','Vz2','Vel2','Bed2','Surface2','Thickness2','Temperature2','SMB2','TotalSmb2', 38 'Vx3','Vy3','Vz3','Vel3','Bed3','Surface3','Thickness3','Temperature3','SMB3','TotalSmb3'] 39 field_tolerances = [1e-09,1e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10, 40 1e-09,1e-09,1e-10,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10, 41 1e-09,5e-09,1e-09,1e-09,1e-10,1e-10,1e-10,1e-10,1e-10,1e-10] 42 field_values = [ 43 md.results.TransientSolution[0].Vx, 44 md.results.TransientSolution[0].Vy, 45 md.results.TransientSolution[0].Vz, 46 md.results.TransientSolution[0].Vel, 47 md.results.TransientSolution[0].Base, 48 md.results.TransientSolution[0].Surface, 49 md.results.TransientSolution[0].Thickness, 50 md.results.TransientSolution[0].Temperature, 51 md.results.TransientSolution[0].SmbMassBalance, 52 md.results.TransientSolution[0].TotalSmb, 53 md.results.TransientSolution[1].Vx, 54 md.results.TransientSolution[1].Vy, 55 md.results.TransientSolution[1].Vz, 56 md.results.TransientSolution[1].Vel, 57 md.results.TransientSolution[1].Base, 58 md.results.TransientSolution[1].Surface, 59 md.results.TransientSolution[1].Thickness, 60 md.results.TransientSolution[1].Temperature, 61 md.results.TransientSolution[1].SmbMassBalance, 62 md.results.TransientSolution[1].TotalSmb, 63 md.results.TransientSolution[2].Vx, 64 md.results.TransientSolution[2].Vy, 65 md.results.TransientSolution[2].Vz, 66 md.results.TransientSolution[2].Vel, 67 md.results.TransientSolution[2].Base, 68 md.results.TransientSolution[2].Surface, 69 md.results.TransientSolution[2].Thickness, 70 md.results.TransientSolution[2].Temperature, 71 md.results.TransientSolution[2].SmbMassBalance, 72 md.results.TransientSolution[2].TotalSmb, 73 ] -
../trunk-jpl/test/NightlyRun/test460.py
1 #Test Name: SquareSheetShelfStressFSEstar 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from matestar import * 11 12 md=triangle(model(),'../Exp/Square.exp',180000.) 13 md=setmask(md,'../Exp/SquareShelf.exp','') 14 md=parameterize(md,'../Par/SquareSheetShelf.py') 15 md = md.extrude(3,1.) 16 md.materials = matestar() 17 md.materials.rheology_B = 3.15e8 * np.ones((md.mesh.numberofvertices,)) 18 md.materials.rheology_Ec = np.ones((md.mesh.numberofvertices,)) 19 md.materials.rheology_Es = 3 * np.ones((md.mesh.numberofvertices,)) 20 md.cluster = generic('name',gethostname(),'np',3) 21 22 #Go solve 23 field_names=[] 24 field_tolerances=[] 25 field_values=[] 26 #md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.y); 27 for i in ['SSA','HO','FS']: 28 md = setflowequation(md,i,'all') 29 md = solve(md,'Stressbalance') 30 field_names = field_names + ['Vx'+i,'Vy'+i,'Vz'+i,'Vel'+i,'Pressure'+i] 31 field_tolerances = field_tolerances + [6e-07,6e-07,2e-06,1e-06,5e-07] 32 field_values = field_values + [ 33 md.results.StressbalanceSolution.Vx, 34 md.results.StressbalanceSolution.Vy, 35 md.results.StressbalanceSolution.Vz, 36 md.results.StressbalanceSolution.Vel, 37 md.results.StressbalanceSolution.Pressure, 38 ] -
../trunk-jpl/test/NightlyRun/test461.py
1 #Test Name: SquareSheetShelfThermalFSEstar 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from matestar import * 11 12 md = triangle(model(),'../Exp/Square.exp',180000.) 13 md = setmask(md,'../Exp/SquareShelf.exp','') 14 md = parameterize(md,'../Par/SquareSheetShelf.py') 15 md = md.extrude(3,1.) 16 md.materials = matestar() 17 md.materials.rheology_B = 3.15e8 * np.ones((md.mesh.numberofvertices,)) 18 md.materials.rheology_Ec = np.ones((md.mesh.numberofvertices,)) 19 md.materials.rheology_Es = 3. * np.ones((md.mesh.numberofvertices,)) 20 21 md = setflowequation(md,'FS','all') 22 md.initialization.waterfraction = np.zeros((md.mesh.numberofvertices,)) 23 md.initialization.watercolumn = np.zeros((md.mesh.numberofvertices,)) 24 md.transient.isstressbalance = 0 25 md.transient.ismasstransport = 0 26 md.transient.issmb = 1 27 md.transient.isthermal = 1 28 md.transient.isgroundingline = 0 29 md.thermal.isenthalpy = 1 30 md.thermal.isdynamicbasalspc = 1 31 md.cluster = generic('name',gethostname(),'np',3) 32 md = solve(md,'Transient') 33 34 #Fields and tolerances to track changes 35 field_names = [ 36 'Enthalpy1','Waterfraction1','Temperature1', 37 'Enthalpy2','Waterfraction2','Temperature2', 38 'Enthalpy3','Waterfraction3','Temperature3'] 39 field_tolerances = [ 40 1e-12,1e-11,1e-12, 41 1e-12,1e-10,1e-12, 42 1e-12,1e-9,1e-12] 43 field_values = [ 44 md.results.TransientSolution[0].Enthalpy, 45 md.results.TransientSolution[0].Waterfraction, 46 md.results.TransientSolution[0].Temperature, 47 md.results.TransientSolution[1].Enthalpy, 48 md.results.TransientSolution[1].Waterfraction, 49 md.results.TransientSolution[1].Temperature, 50 md.results.TransientSolution[2].Enthalpy, 51 md.results.TransientSolution[2].Waterfraction, 52 md.results.TransientSolution[2].Temperature, 53 ] -
../trunk-jpl/test/NightlyRun/test435.py
1 #Test Name: MISMIP3DHO 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',100000.) 12 md = setmask(md,'../Exp/SquareShelf.exp','') 13 md = parameterize(md,'../Par/SquareSheetShelf.py') 14 md.initialization.vx[:] = 1. 15 md.initialization.vy[:] = 1. 16 md.geometry.thickness[:] = 500. - md.mesh.x / 10000. 17 md.geometry.bed = -100. - md.mesh.x / 1000. 18 md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water 19 md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed 20 pos = np.where(md.mask.groundedice_levelset >= 0) 21 md.geometry.base[pos] = md.geometry.bed[pos] 22 md.geometry.surface = md.geometry.base + md.geometry.thickness 23 md = md.extrude(4,1.) 24 md = setflowequation(md,'HO','all') 25 26 #Boundary conditions: 27 md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,)) 28 md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0. 29 md.stressbalance.spcvx[:] = float('Nan') 30 md.stressbalance.spcvy[:] = float('Nan') 31 md.stressbalance.spcvz[:] = float('Nan') 32 posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9))) 33 posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1))) 34 pos = np.unique(np.concatenate((posA,posB))) 35 md.stressbalance.spcvy[pos] = 0. 36 pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1))) 37 md.stressbalance.spcvx[pos2] = 0. 38 md.stressbalance.spcvy[pos2] = 0. 39 40 md.materials.rheology_B = 1. / ((10**-25)**(1./3.)) * np.ones((md.mesh.numberofvertices,)) 41 md.materials.rheology_law = 'None' 42 md.friction.coefficient[:] = np.sqrt(1e7) * np.ones((md.mesh.numberofvertices,)) 43 md.friction.p = 3. * np.ones((md.mesh.numberofelements,)) 44 md.smb.mass_balance[:] = 1. 45 md.basalforcings.groundedice_melting_rate[:] = 0. 46 md.basalforcings.floatingice_melting_rate[:] = 30. 47 md.transient.isthermal = 0 48 md.transient.isstressbalance = 1 49 md.transient.isgroundingline = 1 50 md.transient.ismasstransport = 1 51 md.transient.issmb = 1 52 md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate'] 53 md.groundingline.migration = 'SubelementMigration' 54 md.timestepping.final_time = 30 55 md.timestepping.time_step = 10 56 57 md.cluster = generic('name',gethostname(),'np',3) 58 md = solve(md,'Transient') 59 60 #Fields and tolerances to track changes 61 field_names = [ 62 'Bed1','Surface1','Thickness1','Floatingice1','Vx1','Vy1','Vz1','Pressure1','FloatingiceMeltingrate1', 63 'Bed2','Surface2','Thickness2','Floatingice2','Vx2','Vy2','Vz2','Pressure2','FloatingiceMeltingrate2', 64 'Bed3','Surface3','Thickness3','Floatingice3','Vx3','Vy3','Vz3','Pressure3','FloatingiceMeltingrate3'] 65 field_tolerances = [ 66 2e-11,5e-12,2e-11,1e-11,5e-10,3e-08,6e-10,1e-13,1e-13, 67 3e-11,3e-11,9e-10,7e-11,6e-09,1e-07,1e-09,1e-10,1e-13, 68 1e-9,2e-08,7e-09,2e-7 ,1e-03,8e-04,2e-09,1e-10,1e-13] 69 field_values = [ 70 md.results.TransientSolution[0].Base, 71 md.results.TransientSolution[0].Surface, 72 md.results.TransientSolution[0].Thickness, 73 md.results.TransientSolution[0].MaskGroundediceLevelset, 74 md.results.TransientSolution[0].Vx, 75 md.results.TransientSolution[0].Vy, 76 md.results.TransientSolution[0].Vz, 77 md.results.TransientSolution[0].Pressure, 78 md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate, 79 md.results.TransientSolution[1].Base, 80 md.results.TransientSolution[1].Surface, 81 md.results.TransientSolution[1].Thickness, 82 md.results.TransientSolution[1].MaskGroundediceLevelset, 83 md.results.TransientSolution[1].Vx, 84 md.results.TransientSolution[1].Vy, 85 md.results.TransientSolution[1].Vz, 86 md.results.TransientSolution[1].Pressure, 87 md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate, 88 md.results.TransientSolution[2].Base, 89 md.results.TransientSolution[2].Surface, 90 md.results.TransientSolution[2].Thickness, 91 md.results.TransientSolution[2].MaskGroundediceLevelset, 92 md.results.TransientSolution[2].Vx, 93 md.results.TransientSolution[2].Vy, 94 md.results.TransientSolution[2].Vz, 95 md.results.TransientSolution[2].Pressure, 96 md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate, 97 ] -
../trunk-jpl/test/NightlyRun/test462.py
1 #Test Name: SquareSheetShelfAmrBamgField 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',150000.) 12 md = setmask(md,'../Exp/SquareShelf.exp','') 13 md = parameterize(md,'../Par/SquareSheetShelf.py') 14 md = setflowequation(md,'SSA','all') 15 md.cluster = generic('name',gethostname(),'np',3) 16 md.transient.isstressbalance = 1 17 md.transient.ismasstransport = 1 18 md.transient.issmb = 0 19 md.transient.isthermal = 0 20 md.transient.isgroundingline = 0 21 #amr bamg settings, just field 22 md.amr.hmin = 10000 23 md.amr.hmax = 100000 24 md.amr.fieldname = 'Vel' 25 md.amr.keepmetric = 1 26 md.amr.gradation = 1.2 27 md.amr.groundingline_resolution = 2000 28 md.amr.groundingline_distance = 0 29 md.amr.icefront_resolution = 1000 30 md.amr.icefront_distance = 0 31 md.amr.thicknesserror_resolution = 1000 32 md.amr.thicknesserror_threshold = 0 33 md.amr.deviatoricerror_resolution = 1000 34 md.amr.deviatoricerror_threshold = 0 35 md.transient.amr_frequency = 1 36 md.timestepping.start_time = 0 37 md.timestepping.final_time = 3 38 md.timestepping.time_step = 1 39 md = solve(md,'Transient') 40 41 #Fields and tolerances to track changes 42 field_names = ['Vx','Vy','Vel','Pressure'] 43 field_tolerances = [1e-13,1e-13,1e-13,1e-13] 44 field_values = [ 45 md.results.TransientSolution[2].Vx, 46 md.results.TransientSolution[2].Vy, 47 md.results.TransientSolution[2].Vel, 48 md.results.TransientSolution[2].Pressure, 49 ] -
../trunk-jpl/test/NightlyRun/test436.py
1 #Test Name: SquareSheetShelfSteaEnthalpyRheologiesHO 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',150000.) 12 md = setmask(md,'../Exp/SquareShelf.exp','') 13 md = parameterize(md,'../Par/SquareSheetShelf.py') 14 md = md.extrude(3,2.) 15 md = setflowequation(md,'HO','all') 16 md.cluster = generic('name',gethostname(),'np',3) 17 md.timestepping.time_step = 0. 18 md.thermal.isenthalpy = 1 19 md.initialization.waterfraction = np.zeros((md.mesh.numberofvertices,)) 20 md.initialization.watercolumn = np.zeros((md.mesh.numberofvertices,)) 21 22 #Go solve 23 field_names = [] 24 field_tolerances = [] 25 field_values = [] 26 for i in ['LliboutryDuval', 'CuffeyTemperate']: 27 print ' ' 28 print '====== Testing rheology law: ' + i + ' =====' 29 30 md.materials.rheology_law = i 31 md = solve(md,'Steadystate') 32 field_names += ['Vx'+i,'Vy'+i,'Vz'+i,'Vel'+i,'Pressure'+i, 33 'Temperature'+i,'Waterfraction'+i,'Enthalpy'+i] 34 field_tolerances += [2e-09,1e-09,1e-09,1e-09,1e-13,1e-10,6e-10,5e-10] 35 field_values += [ 36 md.results.SteadystateSolution.Vx, 37 md.results.SteadystateSolution.Vy, 38 md.results.SteadystateSolution.Vz, 39 md.results.SteadystateSolution.Vel, 40 md.results.SteadystateSolution.Pressure, 41 md.results.SteadystateSolution.Temperature, 42 md.results.SteadystateSolution.Waterfraction, 43 md.results.SteadystateSolution.Enthalpy, 44 ] 45 -
../trunk-jpl/test/NightlyRun/test463.py
1 #Test Name: SquareSheetShelfAmrBamgGroundingline 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',150000.) 12 md = setmask(md,'../Exp/SquareShelf.exp','') 13 md = parameterize(md,'../Par/SquareSheetShelf.py') 14 md = setflowequation(md,'SSA','all') 15 md.cluster = generic('name',gethostname(),'np',3) 16 md.transient.isstressbalance = 1 17 md.transient.ismasstransport = 1 18 md.transient.issmb = 0 19 md.transient.isthermal = 0 20 md.transient.isgroundingline = 0 21 #amr bamg settings, just grounding line 22 md.amr.hmin = 10000 23 md.amr.hmax = 100000 24 md.amr.fieldname = 'None' 25 md.amr.keepmetric = 0 26 md.amr.gradation = 1.2 27 md.amr.groundingline_resolution = 12000 28 md.amr.groundingline_distance = 100000 29 md.amr.icefront_resolution = 1000 30 md.amr.icefront_distance = 0 31 md.amr.thicknesserror_resolution = 1000 32 md.amr.thicknesserror_threshold = 0 33 md.amr.deviatoricerror_resolution = 1000 34 md.amr.deviatoricerror_threshold = 0 35 md.transient.amr_frequency = 1 36 md.timestepping.start_time = 0 37 md.timestepping.final_time = 3 38 md.timestepping.time_step = 1 39 md = solve(md,'Transient') 40 41 #Fields and tolerances to track changes 42 field_names = ['Vx','Vy','Vel','Pressure'] 43 field_tolerances = [1e-8,1e-8,1e-8,1e-8] 44 field_values = [ 45 md.results.TransientSolution[2].Vx, 46 md.results.TransientSolution[2].Vy, 47 md.results.TransientSolution[2].Vel, 48 md.results.TransientSolution[2].Pressure, 49 ] -
../trunk-jpl/test/NightlyRun/test437.py
1 #Test Name: ThermalEnthBasalcondsTrans 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',300000.) 12 md = setmask(md,'','') 13 md = parameterize(md,'../Par/SquareThermal.py') 14 15 h = 100. 16 md.geometry.thickness = h * np.ones((md.mesh.numberofvertices,)) 17 md.geometry.base = -h * np.ones((md.mesh.numberofvertices,)) 18 md.geometry.surface = md.geometry.base + md.geometry.thickness 19 20 md.extrude(41,2.) 21 md = setflowequation(md,'HO','all') 22 md.thermal.isenthalpy = True 23 md.thermal.isdynamicbasalspc = True 24 25 #Basal forcing 26 Ts = 273.15-3. 27 Tb = 273.15-1. 28 Tsw = Tb 29 qgeo = md.materials.thermalconductivity / max(md.geometry.thickness) * (Tb - Ts) #qgeo=kappa*(Tb-Ts)/H 30 md.basalforcings.geothermalflux[np.where(md.mesh.vertexonbase)] = qgeo 31 md.initialization.temperature = qgeo / md.materials.thermalconductivity * (md.geometry.surface - md.mesh.z) + Ts 32 33 #Surface forcing 34 pos = np.where(md.mesh.vertexonsurface) 35 SPC_cold = float('NaN') * np.ones((md.mesh.numberofvertices,)) 36 SPC_warm = float('NaN') * np.ones((md.mesh.numberofvertices,)) 37 SPC_cold[pos] = Ts 38 SPC_warm[pos] = Tsw 39 md.thermal.spctemperature = SPC_cold 40 md.timestepping.time_step = 5. 41 t0 = 0. 42 t1 = 10. 43 t2 = 100. 44 md.timestepping.final_time = 400. 45 md.thermal.spctemperature = np.array([SPC_cold,SPC_cold,SPC_warm,SPC_warm,SPC_cold]).T 46 md.thermal.spctemperature = np.vstack((md.thermal.spctemperature,[t0, t1-1, t1, t2-1, t2])) 47 #print np.shape(md.thermal.spctemperature) 48 #print md.thermal.spctemperature 49 50 #Additional settings 51 md.transient.ismasstransport = False 52 md.transient.isstressbalance = False 53 md.transient.issmb = True 54 md.transient.isthermal = True 55 md.thermal.stabilization = False 56 57 #Go solve 58 md.verbose = verbose(0) 59 md.cluster = generic('name',gethostname(),'np',3) 60 md = solve(md,'Transient') 61 62 #Fields and tolerances to track changes 63 field_names = ['Enthalpy1','Temperature1','Waterfraction1','BasalMeltingRate1','Watercolumn1', 64 'Enthalpy2','Temperature2','Waterfraction2','BasalMeltingRate2','Watercolumn2', 65 'Enthalpy3','Temperature3','Waterfraction3','BasalMeltingRate3','Watercolumn3', 66 'Enthalpy4','Temperature4','Waterfraction4','BasalMeltingRate4','Watercolumn4'] 67 field_tolerances = [1.e-10,1.e-10,1.e-10,1.e-9,1.e-10, 68 1.e-10,1.e-10,1.e-10,2.e-9,2.e-10, 69 1.e-10,1.e-10,1.e-10,2.e-9,1.e-10, 70 1.e-10,1.e-10,1.e-10,2.e-9,1.e-10] 71 i1 = 0 72 i2 = int(np.ceil(t2 / md.timestepping.time_step) + 2)-1 73 i3 = int(np.ceil(md.timestepping.final_time / (2. * md.timestepping.time_step)))-1 74 i4 = np.shape(md.results.TransientSolution)[0]-1 75 field_values = [ 76 md.results.TransientSolution[i1].Enthalpy, 77 md.results.TransientSolution[i1].Temperature, 78 md.results.TransientSolution[i1].Waterfraction, 79 md.results.TransientSolution[i1].BasalforcingsGroundediceMeltingRate, 80 md.results.TransientSolution[i1].Watercolumn, 81 md.results.TransientSolution[i2].Enthalpy, 82 md.results.TransientSolution[i2].Temperature, 83 md.results.TransientSolution[i2].Waterfraction, 84 md.results.TransientSolution[i2].BasalforcingsGroundediceMeltingRate, 85 md.results.TransientSolution[i2].Watercolumn, 86 md.results.TransientSolution[i3].Enthalpy, 87 md.results.TransientSolution[i3].Temperature, 88 md.results.TransientSolution[i3].Waterfraction, 89 md.results.TransientSolution[i3].BasalforcingsGroundediceMeltingRate, 90 md.results.TransientSolution[i3].Watercolumn, 91 md.results.TransientSolution[i4].Enthalpy, 92 md.results.TransientSolution[i4].Temperature, 93 md.results.TransientSolution[i4].Waterfraction, 94 md.results.TransientSolution[i4].BasalforcingsGroundediceMeltingRate, 95 md.results.TransientSolution[i4].Watercolumn, 96 ] -
../trunk-jpl/test/NightlyRun/test464.py
1 #Test Name: SquareSheetShelfAmrBamgIceFront 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',150000.) 12 md = setmask(md,'../Exp/SquareShelf.exp','') 13 md = parameterize(md,'../Par/SquareSheetShelf.py') 14 md = setflowequation(md,'SSA','all') 15 md.cluster = generic('name',gethostname(),'np',3) 16 md.transient.isstressbalance = 1 17 md.transient.ismasstransport = 1 18 md.transient.issmb = 0 19 md.transient.isthermal = 0 20 md.transient.isgroundingline = 0 21 #amr bamg settings, just ice front 22 md.amr.hmin = 10000 23 md.amr.hmax = 100000 24 md.amr.fieldname = 'None' 25 md.amr.keepmetric = 0 26 md.amr.gradation = 1.2 27 md.amr.groundingline_resolution = 12000 28 md.amr.groundingline_distance = 0 29 md.amr.icefront_resolution = 12000 30 md.amr.icefront_distance = 100000 31 md.amr.thicknesserror_resolution = 1000 32 md.amr.thicknesserror_threshold = 0 33 md.amr.deviatoricerror_resolution = 1000 34 md.amr.deviatoricerror_threshold = 0 35 md.transient.amr_frequency = 1 36 md.timestepping.start_time = 0 37 md.timestepping.final_time = 3 38 md.timestepping.time_step = 1 39 md = solve(md,'Transient') 40 41 #Fields and tolerances to track changes 42 field_names = ['Vx','Vy','Vel','Pressure'] 43 field_tolerances = [1e-13,1e-13,1e-13,1e-13] 44 field_values = [ 45 md.results.TransientSolution[2].Vx, 46 md.results.TransientSolution[2].Vy, 47 md.results.TransientSolution[2].Vel, 48 md.results.TransientSolution[2].Pressure, 49 ] -
../trunk-jpl/test/NightlyRun/test438.py
1 #Test Name: TransientFrictionWaterlayer2D 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from frictionwaterlayer import * 11 12 md = triangle(model(),'../Exp/Square.exp',150000.) 13 md = setmask(md,'../Exp/SquareShelf.exp','') 14 md = parameterize(md,'../Par/SquareSheetShelf.py') 15 md = setflowequation(md,'SSA','all') 16 md.friction = frictionwaterlayer(md) 17 md.friction.water_layer = np.zeros((md.mesh.numberofvertices+1,2)) 18 md.friction.water_layer[:,1] = 1. 19 md.friction.water_layer[md.mesh.numberofvertices,:] = [1.,2.] 20 md.friction.f = 0.8 21 md.cluster = generic('name',gethostname(),'np',3) 22 md = solve(md,'Transient') 23 24 #Fields and tolerances to track changes 25 field_names =['Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1', 26 'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2', 27 'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'] 28 field_tolerances=[1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13, 29 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13, 30 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13] 31 field_values = [ 32 md.results.TransientSolution[0].Vx, 33 md.results.TransientSolution[0].Vy, 34 md.results.TransientSolution[0].Vel, 35 md.results.TransientSolution[0].Pressure, 36 md.results.TransientSolution[0].Base, 37 md.results.TransientSolution[0].Surface, 38 md.results.TransientSolution[0].Thickness, 39 md.results.TransientSolution[1].Vx, 40 md.results.TransientSolution[1].Vy, 41 md.results.TransientSolution[1].Vel, 42 md.results.TransientSolution[1].Pressure, 43 md.results.TransientSolution[1].Base, 44 md.results.TransientSolution[1].Surface, 45 md.results.TransientSolution[1].Thickness, 46 md.results.TransientSolution[2].Vx, 47 md.results.TransientSolution[2].Vy, 48 md.results.TransientSolution[2].Vel, 49 md.results.TransientSolution[2].Pressure, 50 md.results.TransientSolution[2].Base, 51 md.results.TransientSolution[2].Surface, 52 md.results.TransientSolution[2].Thickness 53 ] -
../trunk-jpl/test/NightlyRun/test465.py
1 #Test Name: SquareSheetShelfAmrBamgAll 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',150000.) 12 md = setmask(md,'../Exp/SquareShelf.exp','') 13 md = parameterize(md,'../Par/SquareSheetShelf.py') 14 md = setflowequation(md,'SSA','all') 15 md.cluster = generic('name',gethostname(),'np',3) 16 md.transient.isstressbalance = 1 17 md.transient.ismasstransport = 1 18 md.transient.issmb = 0 19 md.transient.isthermal = 0 20 md.transient.isgroundingline = 0 21 #amr bamg settings, field, grounding line and ice front 22 md.amr.hmin = 20000 23 md.amr.hmax = 100000 24 md.amr.fieldname = 'Vel' 25 md.amr.keepmetric = 0 26 md.amr.gradation = 1.2 27 md.amr.groundingline_resolution = 10000 28 md.amr.groundingline_distance = 100000 29 md.amr.icefront_resolution = 15000 30 md.amr.icefront_distance = 100000 31 md.amr.thicknesserror_resolution = 1000 32 md.amr.thicknesserror_threshold = 0 33 md.amr.deviatoricerror_resolution = 1000 34 md.amr.deviatoricerror_threshold = 0 35 md.transient.amr_frequency = 1 36 md.timestepping.start_time = 0 37 md.timestepping.final_time = 3 38 md.timestepping.time_step = 1 39 md = solve(md,'Transient') 40 41 #Fields and tolerances to track changes 42 field_names = ['Vx','Vy','Vel','Pressure'] 43 field_tolerances = [1e-8,1e-8,1e-8,1e-8] 44 field_values = [ 45 md.results.TransientSolution[2].Vx, 46 md.results.TransientSolution[2].Vy, 47 md.results.TransientSolution[2].Vel, 48 md.results.TransientSolution[2].Pressure, 49 ] -
../trunk-jpl/test/NightlyRun/test439.py
1 #Test Name: TransientFrictionWaterlayer3D 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from frictionwaterlayer import * 11 12 md = triangle(model(),'../Exp/Square.exp',150000.) 13 md = setmask(md,'../Exp/SquareShelf.exp','') 14 md = parameterize(md,'../Par/SquareSheetShelf.py') 15 md = md.extrude(4,1.) 16 md = setflowequation(md,'HO','all') 17 md.friction = frictionwaterlayer(md) 18 md.friction.water_layer = np.zeros((md.mesh.numberofvertices+1,2)) 19 md.friction.water_layer[:,1] = 1. 20 md.friction.water_layer[md.mesh.numberofvertices,:] = [1.,2.] 21 md.friction.f = 0.8 22 md.cluster = generic('name',gethostname(),'np',3) 23 md = solve(md,'Transient') 24 25 #Fields and tolerances to track changes 26 field_names =['Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1', 27 'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2', 28 'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3'] 29 field_tolerances = [1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09, 30 1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09, 31 1e-09,1e-09,1e-09,1e-09,1e-09,1e-09,1e-09] 32 field_values = [ 33 md.results.TransientSolution[0].Vx, 34 md.results.TransientSolution[0].Vy, 35 md.results.TransientSolution[0].Vel, 36 md.results.TransientSolution[0].Pressure, 37 md.results.TransientSolution[0].Base, 38 md.results.TransientSolution[0].Surface, 39 md.results.TransientSolution[0].Thickness, 40 md.results.TransientSolution[1].Vx, 41 md.results.TransientSolution[1].Vy, 42 md.results.TransientSolution[1].Vel, 43 md.results.TransientSolution[1].Pressure, 44 md.results.TransientSolution[1].Base, 45 md.results.TransientSolution[1].Surface, 46 md.results.TransientSolution[1].Thickness, 47 md.results.TransientSolution[2].Vx, 48 md.results.TransientSolution[2].Vy, 49 md.results.TransientSolution[2].Vel, 50 md.results.TransientSolution[2].Pressure, 51 md.results.TransientSolution[2].Base, 52 md.results.TransientSolution[2].Surface, 53 md.results.TransientSolution[2].Thickness 54 ] -
../trunk-jpl/test/NightlyRun/test340.py
1 #Test Name: SquareSheetConstrainedSmbGradientsEla3d 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from taoinversion import * 11 12 md = triangle(model(),'../Exp/Square.exp',200000.) 13 md = setmask(md,'','') 14 md = parameterize(md,'../Par/SquareSheetConstrained.py') 15 md.extrude(3,1.) 16 md = setflowequation(md,'HO','all') 17 18 #control parameters 19 md.inversion = taoinversion() 20 md.inversion.iscontrol = 1 21 md.inversion.control_parameters = ['FrictionCoefficient'] 22 md.inversion.min_parameters = 1. * np.ones((md.mesh.numberofvertices,)) 23 md.inversion.max_parameters = 200. * np.ones((md.mesh.numberofvertices,)) 24 md.inversion.maxsteps = 2 25 md.inversion.maxiter = 6 26 md.inversion.cost_functions = [102,501] 27 md.inversion.cost_functions_coefficients = np.ones((md.mesh.numberofvertices,2)) 28 md.inversion.cost_functions_coefficients[:,1] = 2. * 1e-7 29 md.inversion.vx_obs = md.initialization.vx 30 md.inversion.vy_obs = md.initialization.vy 31 32 md.cluster = generic('name',gethostname(),'np',3) 33 md = solve(md,'Stressbalance') 34 35 #Fields and tolerances to track changes 36 field_names = ['Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy'] 37 field_tolerances = [3e-08,1e-07,5e-10,1e-10,1e-09,1e-09,1e-09] 38 field_values = [ 39 md.results.StressbalanceSolution.Gradient1, 40 md.results.StressbalanceSolution.J, 41 md.results.StressbalanceSolution.FrictionCoefficient, 42 md.results.StressbalanceSolution.Pressure, 43 md.results.StressbalanceSolution.Vel, 44 md.results.StressbalanceSolution.Vx, 45 md.results.StressbalanceSolution.Vy 46 ] -
../trunk-jpl/test/NightlyRun/test430.py
1 #Test Name: MISMIP3D 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 11 md = triangle(model(),'../Exp/Square.exp',100000.) 12 md = setmask(md,'../Exp/SquareShelf.exp','') 13 md = parameterize(md,'../Par/SquareSheetShelf.py') 14 md.initialization.vx[:] = 1. 15 md.initialization.vy[:] = 1. 16 md.geometry.thickness[:] = 500. - md.mesh.x / 10000. 17 md.geometry.bed = -100. - md.mesh.x / 1000. 18 md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water 19 md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed 20 pos = np.where(md.mask.groundedice_levelset >= 0.) 21 md.geometry.base[pos] = md.geometry.bed[pos] 22 md.geometry.surface = md.geometry.base + md.geometry.thickness 23 md = setflowequation(md,'SSA','all') 24 25 #Boundary conditions: 26 md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,)) 27 md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0. 28 md.stressbalance.spcvx[:] = float('NaN') 29 md.stressbalance.spcvy[:] = float('NaN') 30 md.stressbalance.spcvz[:] = float('NaN') 31 posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9))) 32 posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1))) 33 pos = np.unique(np.concatenate((posA,posB))) 34 md.stressbalance.spcvy[pos] = 0. 35 pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1))) 36 md.stressbalance.spcvx[pos2] = 0. 37 md.stressbalance.spcvy[pos2] = 0. 38 39 md.materials.rheology_B = 1. / ((10**-25)**(1. / 3.)) * np.ones((md.mesh.numberofvertices,)) 40 md.materials.rheology_law = 'None' 41 md.friction.coefficient[:] = np.sqrt(10**7) * np.ones((md.mesh.numberofvertices,)) 42 md.friction.p = 3. * np.ones((md.mesh.numberofelements,)) 43 md.smb.mass_balance[:] = 1. 44 md.basalforcings.groundedice_melting_rate[:] = 0. 45 md.basalforcings.floatingice_melting_rate[:] = 30. 46 md.transient.isthermal = 0 47 md.transient.isstressbalance = 1 48 md.transient.isgroundingline = 1 49 md.transient.ismasstransport = 1 50 md.transient.issmb = 1 51 md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate'] 52 md.groundingline.migration = 'SubelementMigration' 53 md.timestepping.final_time = 30 54 md.timestepping.time_step = 10 55 56 md.cluster = generic('name',gethostname(),'np',3) 57 md = solve(md,'Transient') 58 #print md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate 59 #print md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate 60 #print md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate 61 62 #Fields and tolerances to track changes 63 field_names = [ 64 'Bed1','Surface1','Thickness1','Floatingice1','Vx1','Vy1','Pressure1','FloatingiceMeltingrate1', 65 'Bed2','Surface2','Thickness2','Floatingice2','Vx2','Vy2','Pressure2','FloatingiceMeltingrate2', 66 'Bed3','Surface3','Thickness3','Floatingice3','Vx3','Vy3','Pressure3','FloatingiceMeltingrate3'] 67 field_tolerances = [2e-11,5e-12,2e-11,1e-11,5e-10,1e-08,1e-13,1e-13, 68 3e-11,3e-11,9e-10,7e-11,1e-09,5e-08,1e-10,1e-13, 69 1e-10,3e-11,1e-10,7e-11,1e-09,5e-08,1e-10,1e-13] 70 field_values = [ 71 md.results.TransientSolution[0].Base, 72 md.results.TransientSolution[0].Surface, 73 md.results.TransientSolution[0].Thickness, 74 md.results.TransientSolution[0].MaskGroundediceLevelset, 75 md.results.TransientSolution[0].Vx, 76 md.results.TransientSolution[0].Vy, 77 md.results.TransientSolution[0].Pressure, 78 md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate, 79 md.results.TransientSolution[1].Base, 80 md.results.TransientSolution[1].Surface, 81 md.results.TransientSolution[1].Thickness, 82 md.results.TransientSolution[1].MaskGroundediceLevelset, 83 md.results.TransientSolution[1].Vx, 84 md.results.TransientSolution[1].Vy, 85 md.results.TransientSolution[1].Pressure, 86 md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate, 87 md.results.TransientSolution[2].Base, 88 md.results.TransientSolution[2].Surface, 89 md.results.TransientSolution[2].Thickness, 90 md.results.TransientSolution[2].MaskGroundediceLevelset, 91 md.results.TransientSolution[2].Vx, 92 md.results.TransientSolution[2].Vy, 93 md.results.TransientSolution[2].Pressure, 94 md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate, 95 ] -
../trunk-jpl/test/NightlyRun/test808.py
1 #Test Name: SquareShelfLevelsetCalvingSSA2dMinThickness 2 from model import * 3 from socket import gethostname 4 from triangle import * 5 from setmask import * 6 from parameterize import * 7 from setflowequation import * 8 from solve import * 9 import numpy as np 10 from calvingminthickness import * 11 12 md = triangle(model(),'../Exp/Square.exp',30000.) 13 md = setmask(md,'all','') 14 md = parameterize(md,'../Par/SquareShelf.py') 15 md = setflowequation(md,'SSA','all') 16 md.cluster = generic('name',gethostname(),'np',3) 17 18 x = md.mesh.x 19 xmin = min(x) 20 xmax = max(x) 21 Lx = (xmax - xmin) 22 alpha = 2. / 3. 23 md.mask.ice_levelset = -1 + 2 * (md.mesh.y > 9e5) 24 25 md.timestepping.time_step = 1 26 md.timestepping.final_time = 30 27 28 #Transient 29 md.transient.isstressbalance = 1 30 md.transient.ismasstransport = 1 31 md.transient.issmb = 1 32 md.transient.isthermal = 0 33 md.transient.isgroundingline = 0 34 md.transient.isgia = 0 35 md.transient.ismovingfront = 1 36 37 md.calving = calvingminthickness() 38 md.calving.min_thickness = 400 39 md.calving.meltingrate = np.zeros((md.mesh.numberofvertices,)) 40 md.levelset.spclevelset = float('NaN')* np.ones((md.mesh.numberofvertices,)) 41 md.levelset.reinit_frequency = 1 42 43 md = solve(md,'Transient') 44 45 #Fields and tolerances to track changes 46 field_names = [ 47 'Vx1','Vy1','Vel1','Pressure1','Thickness1','Surface1','MaskIceLevelset1' 48 'Vx2','Vy2','Vel2','Pressure2','Thickness2','Surface2','MaskIceLevelset2' 49 'Vx3','Vy3','Vel3','Pressure3','Thickness3','Surface3','MaskIceLevelset3'] 50 field_tolerances = [ 51 1e-8,1e-8,1e-8,1e-9,1e-9,1e-9,3e-9, 52 1e-8,1e-8,1e-8,1e-9,1e-9,1e-9,3e-9, 53 1e-8,1e-8,1e-8,1e-9,1e-9,1e-9,3e-9] 54 field_values = [ 55 md.results.TransientSolution[0].Vx, 56 md.results.TransientSolution[0].Vy, 57 md.results.TransientSolution[0].Vel, 58 md.results.TransientSolution[0].Pressure, 59 md.results.TransientSolution[0].Thickness, 60 md.results.TransientSolution[0].Surface, 61 md.results.TransientSolution[0].MaskIceLevelset, 62 md.results.TransientSolution[1].Vx, 63 md.results.TransientSolution[1].Vy, 64 md.results.TransientSolution[1].Vel, 65 md.results.TransientSolution[1].Pressure, 66 md.results.TransientSolution[1].Thickness, 67 md.results.TransientSolution[1].Surface, 68 md.results.TransientSolution[1].MaskIceLevelset, 69 md.results.TransientSolution[2].Vx, 70 md.results.TransientSolution[2].Vy, 71 md.results.TransientSolution[2].Vel, 72 md.results.TransientSolution[2].Pressure, 73 md.results.TransientSolution[2].Thickness, 74 md.results.TransientSolution[2].Surface, 75 md.results.TransientSolution[2].MaskIceLevelset 76 ] -
../trunk-jpl/test/NightlyRun/test2424.py
1 #Test Name: SquareSheetShelfGroundingLine2dAggressive. From test424, with sea level increasing. 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from newforcing import * 11 12 md = triangle(model(),'../Exp/Square.exp',150000.) 13 md = setmask(md,'../Exp/SquareShelf.exp','') 14 md = parameterize(md,'../Par/SquareSheetShelf.py') 15 md = setflowequation(md,'SSA','all') 16 md.initialization.vx[:] = 0. 17 md.initialization.vy[:] = 0. 18 md.smb.mass_balance[:] = 0. 19 20 md.geometry.base = -700. - np.abs(md.mesh.y-500000.) / 1000. 21 md.geometry.bed = -700. - np.abs(md.mesh.y-500000.) / 1000. 22 md.geometry.thickness[:] = 1000. 23 md.geometry.surface = md.geometry.base + md.geometry.thickness 24 25 md.transient.isstressbalance = 0 26 md.transient.isgroundingline = 1 27 md.transient.isthermal = 0 28 md.groundingline.migration = 'AggressiveMigration' 29 md.transient.requested_outputs = ['IceVolume','IceVolumeAboveFloatation','Sealevel'] 30 31 md.timestepping.time_step = .1 32 md.slr.sealevel = newforcing(md.timestepping.start_time, md.timestepping.final_time, 33 md.timestepping.time_step, -200., 200., md.mesh.numberofvertices) 34 35 md.cluster = generic('name',gethostname(),'np',3) 36 md = solve(md,'Transient') 37 38 #we are checking that the grounding line position is near the theorical one, which is the 0 contour level 39 #of surface - sealevel - (1-di)* thickness 40 41 nsteps = len(md.results.TransientSolution) 42 field_names = [] 43 field_tolerances = [] 44 field_values = [] 45 #time is off by the year constant 46 for i in range(nsteps): 47 field_names.append('Time-' + str(md.results.TransientSolution[i].time) + 48 '-yr-ice_levelset-S-sl-(1-di)*H') 49 field_tolerances.append(1e-12) 50 field_values.append(md.results.TransientSolution[i].MaskGroundediceLevelset.reshape(-1,) - (md.geometry.surface - md.results.TransientSolution[i].Sealevel.reshape(-1,) - (1 - md.materials.rho_ice / md.materials.rho_water) * md.geometry.thickness)) 51 -
../trunk-jpl/test/NightlyRun/test260.py
1 #Test Name: SquareShelfStressSSA2dEnhanced 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from matenhancedice import * 11 12 md = triangle(model(),'../Exp/Square.exp',150000.) 13 md = setmask(md,'all','') 14 md.materials = matenhancedice() 15 md.materials.rheology_B = 3.15e8 * np.ones(md.mesh.numberofvertices,) 16 md.materials.rheology_n = 3 * np.ones(md.mesh.numberofelements,) 17 md.materials.rheology_E = np.ones(md.mesh.numberofvertices,) 18 md = parameterize(md,'../Par/SquareShelf.py') 19 md = setflowequation(md,'SSA','all') 20 md.cluster = generic('name',gethostname(),'np',3) 21 md = solve(md,'Stressbalance') 22 23 #Fields and tolerances to track changes 24 field_names = ['Vx','Vy','Vel','Pressure'] 25 field_tolerances = [1e-13,1e-13,1e-13,1e-13] 26 field_values = [ 27 md.results.StressbalanceSolution.Vx, 28 md.results.StressbalanceSolution.Vy, 29 md.results.StressbalanceSolution.Vel, 30 md.results.StressbalanceSolution.Pressure, 31 ] -
../trunk-jpl/test/NightlyRun/test350.py
1 #Test Name: SquareSheetHydrologySommers 2 from operator import itemgetter 3 import numpy as np 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 from frictionsommers import * 12 from hydrologysommers import * 13 from transient import * 14 15 md = triangle(model(),'../Exp/Square.exp',50000.) 16 md.mesh.x = md.mesh.x / 1000 17 md.mesh.y = md.mesh.y / 1000 18 md = setmask(md,'','') 19 md = parameterize(md,'../Par/SquareSheetConstrained.py') 20 md.transient = transient().deactivateall() 21 md.transient.ishydrology = 1 22 md = setflowequation(md,'SSA','all') 23 md.cluster = generic('name',gethostname(),'np',2) 24 25 #Use hydroogy coupled friciton law 26 md.friction = frictionsommers(md) 27 28 #Change hydrology class to Sommers' model 29 md.hydrology = hydrologysommers() 30 31 #Change geometry 32 md.geometry.base = -.02 * md.mesh.x + 20. 33 md.geometry.thickness = 300. * np.ones((md.mesh.numberofvertices,)) 34 md.geometry.bed = md.geometry.base 35 md.geometry.surface = md.geometry.bed + md.geometry.thickness 36 37 #define the initial water head as being such that the water pressure is 50% of the ice overburden pressure 38 md.hydrology.head = 0.5 * md.materials.rho_ice / md.materials.rho_freshwater * md.geometry.thickness + md.geometry.base 39 md.hydrology.gap_height = 0.01 * np.ones((md.mesh.numberofelements,)) 40 md.hydrology.bump_spacing = 2 * np.ones((md.mesh.numberofelements,)) 41 md.hydrology.bump_height = 0.05 * np.ones((md.mesh.numberofelements,)) 42 md.hydrology.englacial_input = 0.5 * np.ones((md.mesh.numberofvertices,)) 43 md.hydrology.reynolds= 1000. * np.ones((md.mesh.numberofelements,)) 44 md.hydrology.spchead = float('NaN') * np.ones((md.mesh.numberofvertices,)) 45 pos = np.intersect1d(np.array(np.where(md.mesh.vertexonboundary)), np.array(np.where(md.mesh.x == 1000))) 46 md.hydrology.spchead[pos] = md.geometry.base[pos] 47 48 #Define velocity 49 md.initialization.vx = 1e-6 * md.constants.yts * np.ones((md.mesh.numberofvertices,)) 50 md.initialization.vy = np.zeros((md.mesh.numberofvertices,)) 51 52 md.timestepping.time_step = 3. * 3600. / md.constants.yts 53 md.timestepping.final_time = .5 / 365. 54 md.materials.rheology_B = (5e-25)**(-1. / 3.) * np.ones((md.mesh.numberofvertices,)) 55 56 #Add one moulin and Neumann BC, varying in time 57 a = np.sqrt((md.mesh.x - 500.)**2 + (md.mesh.y - 500.)**2) 58 pos = min(enumerate(a), key=itemgetter(1))[0] 59 time = np.arange(0,md.timestepping.final_time+1,md.timestepping.time_step) 60 md.hydrology.moulin_input = np.zeros((md.mesh.numberofvertices+1,np.size(time))) 61 md.hydrology.moulin_input[-1,:] = time 62 md.hydrology.moulin_input[pos,:] = 5. * (1. - np.sin(2. * np.pi / (1. / 365.) * time)) 63 md.hydrology.neumannflux = np.zeros((md.mesh.numberofelements+1,np.size(time))) 64 md.hydrology.neumannflux[-1,:] = time 65 segx = md.mesh.x[md.mesh.segments[:,0]-1] 66 segy = md.mesh.y[md.mesh.segments[:,0]-1] 67 posA = np.intersect1d(np.intersect1d(np.array(np.where(segx < 1.)),np.array(np.where(segy > 400.))), np.array(np.where(segy < 600.))) 68 pos = (md.mesh.segments[posA]-1)[:,2] 69 md.hydrology.neumannflux[pos,:] = np.tile(0.05*(1.-np.sin(2.*np.pi/(1./365.)*time)),(len(pos),1)) 70 71 md = solve(md,'Transient') 72 73 #Fields and tolerances to track changes 74 field_names = [ 75 'HydrologyHead1','HydrologyGapHeight1', 76 'HydrologyHead2','HydrologyGapHeight2', 77 'HydrologyHead3','HydrologyGapHeight3', 78 'HydrologyHead4','HydrologyGapHeight4'] 79 field_tolerances = [ 80 1e-13, 1e-13, 81 1e-13, 1e-13, 82 1e-13, 1e-13, 83 1e-13, 1e-12] 84 field_values = [ 85 md.results.TransientSolution[0].HydrologyHead, 86 md.results.TransientSolution[0].HydrologyGapHeight, 87 md.results.TransientSolution[1].HydrologyHead, 88 md.results.TransientSolution[1].HydrologyGapHeight, 89 md.results.TransientSolution[2].HydrologyHead, 90 md.results.TransientSolution[2].HydrologyGapHeight, 91 md.results.TransientSolution[3].HydrologyHead, 92 md.results.TransientSolution[3].HydrologyGapHeight 93 ] 94 -
../trunk-jpl/test/NightlyRun/test243.py
1 #Test Name: SquareShelfSMBGemb 2 import numpy as np 3 import scipy.io as spio 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 from SMBgemb import * 12 13 md = triangle(model(),'../Exp/Square.exp',200000.) 14 md = setmask(md,'all','') 15 md = parameterize(md,'../Par/SquareShelf.py') 16 md = setflowequation(md,'SSA','all') 17 md.materials.rho_ice = 910 18 md.cluster = generic('name',gethostname(),'np',3) 19 20 #Use of Gemb method for SMB computation 21 md.smb = SMBgemb() 22 md.smb.setdefaultparameters(md.mesh,md.geometry) 23 24 #load hourly surface forcing date from 1979 to 2009: 25 inputs = spio.loadmat('../Data/gemb_input.mat',squeeze_me=True) 26 27 #setup the inputs: 28 md.smb.Ta = np.append(np.tile(np.conjugate(inputs['Ta0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0) 29 md.smb.V = np.append(np.tile(np.conjugate(inputs['V0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0) 30 md.smb.dswrf = np.append(np.tile(np.conjugate(inputs['dsw0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0) 31 md.smb.dlwrf = np.append(np.tile(np.conjugate(inputs['dlw0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0) 32 md.smb.P = np.append(np.tile(np.conjugate(inputs['P0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0) 33 md.smb.eAir = np.append(np.tile(np.conjugate(inputs['eAir0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0) 34 md.smb.pAir = np.append(np.tile(np.conjugate(inputs['pAir0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0) 35 md.smb.pAir = np.append(np.tile(np.conjugate(inputs['pAir0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0) 36 md.smb.Vz = np.tile(np.conjugate(inputs['LP']['Vz']),(md.mesh.numberofelements,1)).flatten() 37 md.smb.Tz = np.tile(np.conjugate(inputs['LP']['Tz']),(md.mesh.numberofelements,1)).flatten() 38 md.smb.Tmean = np.tile(np.conjugate(inputs['LP']['Tmean']),(md.mesh.numberofelements,1)).flatten() 39 md.smb.C = np.tile(np.conjugate(inputs['LP']['C']),(md.mesh.numberofelements,1)).flatten() 40 41 #smb settings 42 md.smb.requested_outputs = ['SmbDz','SmbT','SmbD','SmbRe','SmbGdn','SmbGsp','SmbEC','SmbA','SmbMassBalance'] 43 44 #only run smb core: 45 md.transient.isstressbalance = 0 46 md.transient.ismasstransport = 0 47 md.transient.isthermal = 0 48 49 #time stepping: 50 md.timestepping.start_time = 1965. 51 md.timestepping.final_time = 1966. 52 md.timestepping.time_step = 1. / 365.0 53 md.timestepping.interp_forcings = 0. 54 55 #Run transient 56 md = solve(md,'Transient') 57 58 #Fields and tolerances to track changes 59 field_names = ['SmbDz','SmbT' ,'SmbD' ,'SmbRe','SmbGdn','SmbGsp','SmbA' ,'SmbEC','SmbMassBalance'] 60 field_tolerances = [5e-4,5e-5,0.0006,0.0002,1e-5,0.0003,2e-5,2e-7,1e-7] 61 #shape is different in python solution (fixed using reshape) which can cause test failure: 62 field_values = [ 63 md.results.TransientSolution[-1].SmbDz[0,0:240].reshape(1,-1), 64 md.results.TransientSolution[-1].SmbT[0,0:240].reshape(1,-1), 65 md.results.TransientSolution[-1].SmbD[0,0:240].reshape(1,-1), 66 md.results.TransientSolution[-1].SmbRe[0,0:240].reshape(1,-1), 67 md.results.TransientSolution[-1].SmbGdn[0,0:240].reshape(1,-1), 68 md.results.TransientSolution[-1].SmbGsp[0,0:240].reshape(1,-1), 69 md.results.TransientSolution[-1].SmbA[0,0:240].reshape(1,-1), 70 md.results.TransientSolution[-1].SmbEC[0], 71 md.results.TransientSolution[-1].SmbMassBalance[0], 72 ] -
../trunk-jpl/src/m/solve/WriteData.py
50 50 if np.size(data) > 1 and np.size(data,0)==timeserieslength: 51 51 yts = options.getfieldvalue('yts') 52 52 if np.ndim(data) > 1: 53 data[-1,:] = data[-1,:]*yts53 data[-1,:] = yts*data[-1,:] 54 54 else: 55 data[-1] = data[-1]*yts55 data[-1] = yts*data[-1] 56 56 57 57 #Step 1: write the enum to identify this record uniquely 58 58 fid.write(struct.pack('i',len(name))) -
../trunk-jpl/src/m/solve/parseresultsfromdisk.py
174 174 yts=md.constants.yts 175 175 if fieldname=='BalancethicknessThickeningRate': 176 176 field = field*yts 177 elif fieldname=='Time':178 field = field/yts179 177 elif fieldname=='HydrologyWaterVx': 180 178 field = field*yts 181 179 elif fieldname=='HydrologyWaterVy': … … 190 188 field = field*yts 191 189 elif fieldname=='BasalforcingsGroundediceMeltingRate': 192 190 field = field*yts 191 elif fieldname=='BasalforcingsFloatingiceMeltingRate': 192 field = field*yts 193 193 elif fieldname=='TotalFloatingBmb': 194 field = field/10.**12 .*yts #(GigaTon/year)194 field = field/10.**12*yts #(GigaTon/year) 195 195 elif fieldname=='TotalGroundedBmb': 196 field = field/10.**12 .*yts #(GigaTon/year)196 field = field/10.**12*yts #(GigaTon/year) 197 197 elif fieldname=='TotalSmb': 198 field = field/10.**12 .*yts #(GigaTon/year)198 field = field/10.**12*yts #(GigaTon/year) 199 199 elif fieldname=='SmbMassBalance': 200 200 field = field*yts 201 elif fieldname=='SmbPrecipitation': 202 field = field*yts 203 elif fieldname=='SmbRunoff': 204 field = field*yts 205 elif fieldname=='SmbEC': 206 field = field*yts 207 elif fieldname=='SmbAccumulation': 208 field = field*yts 209 elif fieldname=='SmbMelt': 210 field = field*yts 211 elif fieldname=='SmbDz_add': 212 field = field*yts 213 elif fieldname=='SmbM_add': 214 field = field*yts 201 215 elif fieldname=='CalvingCalvingrate': 202 216 field = field*yts 203 217 218 if time !=-9999: 219 time = time/yts 220 204 221 saveres=OrderedDict() 205 222 saveres['fieldname']=fieldname 206 223 saveres['time']=time -
../trunk-jpl/src/m/geometry/NowickiProfile.py
1 import numpy as np 2 3 def NowickiProfile(x): 4 """ 5 NOWICKIPROFILE - Create profile at the transition zone based on Sophie Nowicki's thesis 6 7 Usage: 8 [b h] = NowickiProfile(x) 9 10 - h = ice thickness 11 - b = ice base 12 - x = along flow coordinate 13 """ 14 #Constant for theoretical profile 15 delta = 0.1 #ratio of water density and ice density -1 16 hg = 1. #ice thickness at grounding line 17 sea = hg / (1+delta) #sea level 18 lamda = 0.1 #ration of deviatoric stress and water pressure 19 beta = 5. #friction coefficient 20 ms = 0.005 #surface accumulation rat 21 mu = 5. #viscosity 22 q = 0.801 #ice mass flux 23 24 #mesh parameters 25 b = np.zeros((np.size(x),)) 26 h = np.zeros((np.size(x),)) 27 s = np.zeros((np.size(x),)) 28 29 #upstream of the GL 30 for i in range(np.size(x) / 2): 31 ss = np.roots([1, 4 * lamda * beta, 0, 0, 6 * lamda * ms * x[i]**2 + 32 12 * lamda * q * x[i] - hg**4 - 4 * lamda * beta * hg**3]) 33 for j in range(4): 34 if (np.isreal(ss[j]) > 0) and (np.imag(ss[j]) == 0): 35 s[i] = ss[j] 36 h[i] = s[i] 37 b[i] = 0. 38 39 #downstream of the GL 40 for i in range(np.size(x) / 2, np.size(x)): 41 h[i] = (x[i] / (4. * (delta+1) * q) + hg**(-2))**(-0.5) # ice thickness for ice shelf from (3.1) 42 b[i] = sea - h[i] * (1. / (1+delta)) 43 44 return [b, h, sea] -
../trunk-jpl/src/m/consistency/checkfield.py
83 83 #Check numel 84 84 if options.exist('numel'): 85 85 fieldnumel=options.getfieldvalue('numel') 86 if np.size(field) not in fieldnumel:86 if (type(fieldnumel) == int and np.size(field) != fieldnumel) or (type(fieldnumel) == list and np.size(field) not in fieldnumel): 87 87 if len(fieldnumel)==1: 88 88 md = md.checkmessage(options.getfieldvalue('message',\ 89 89 "field '%s' size should be %d" % (fieldname,fieldnumel))) … … 100 100 md = md.checkmessage(options.getfieldvalue('message',\ 101 101 "NaN values found in field '%s'" % fieldname)) 102 102 103 103 104 #check Inf 104 105 if options.getfieldvalue('Inf',0): 105 106 if np.any(np.isinf(field)): … … 106 107 md = md.checkmessage(options.getfieldvalue('message',\ 107 108 "Inf values found in field '%s'" % fieldname)) 108 109 110 109 111 #check cell 110 112 if options.getfieldvalue('cell',0): 111 113 if not isinstance(field,(tuple,list,dict)): … … 128 130 129 131 #check greater 130 132 if options.exist('>='): 131 lowerbound=options.getfieldvalue('>=') 132 if np.any(field<lowerbound): 133 lowerbound = options.getfieldvalue('>=') 134 field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy() 135 if options.getfieldvalue('timeseries',0): 136 field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1) 137 138 if options.getfieldvalue('singletimeseries',0): 139 field2 = np.reshape(field[0],np.prod(np.shape(field[0])),1) 140 141 if np.any(field2<lowerbound): 133 142 md = md.checkmessage(options.getfieldvalue('message',\ 134 143 "field '%s' should have values above %d" % (fieldname,lowerbound))) 144 135 145 if options.exist('>'): 136 146 lowerbound=options.getfieldvalue('>') 137 if np.any(field<=lowerbound): 147 field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy() 148 if options.getfieldvalue('timeseries',0): 149 field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1) 150 151 if options.getfieldvalue('singletimeseries',0): 152 field2 = np.reshape(field[0],np.prod(np.shape(field[0])),1) 153 154 if np.any(field2<=lowerbound): 138 155 md = md.checkmessage(options.getfieldvalue('message',\ 139 156 "field '%s' should have values above %d" % (fieldname,lowerbound))) 140 157 … … 141 158 #check smaller 142 159 if options.exist('<='): 143 160 upperbound=options.getfieldvalue('<=') 144 if np.any(field>upperbound): 161 field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy() 162 if options.getfieldvalue('timeseries',0): 163 field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1) 164 165 if options.getfieldvalue('singletimeseries',0): 166 field2 = np.reshape(field[0],np.prod(np.shape(field[0])),1) 167 168 if np.any(field2>upperbound): 145 169 md = md.checkmessage(options.getfieldvalue('message',\ 146 170 "field '%s' should have values below %d" % (fieldname,upperbound))) 147 171 if options.exist('<'): 148 172 upperbound=options.getfieldvalue('<') 149 if np.any(field>=upperbound): 173 field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy() 174 if options.getfieldvalue('timeseries',0): 175 field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1) 176 177 if options.getfieldvalue('singletimeseries',0): 178 field2 = np.reshape(field[0],np.prod(np.shape(field[0])),1) 179 180 if np.any(field2>=upperbound): 150 181 md = md.checkmessage(options.getfieldvalue('message',\ 151 182 "field '%s' should have values below %d" % (fieldname,upperbound))) 152 183 … … 163 194 164 195 #Check forcings (size and times) 165 196 if options.getfieldvalue('timeseries',0): 166 if np.size(field,0)==md.mesh.numberofvertices:197 if np.size(field,0)==md.mesh.numberofvertices or np.size(field,0)==md.mesh.numberofelements: 167 198 if np.ndim(field)>1 and not np.size(field,1)==1: 168 199 md = md.checkmessage(options.getfieldvalue('message',\ 169 200 "field '%s' should have only one column as there are md.mesh.numberofvertices lines" % fieldname)) 170 elif np.size(field,0)==md.mesh.numberofvertices+1 or np.size(field,0)== 2:171 if n ot all(field[-1,:]==np.sort(field[-1,:])):201 elif np.size(field,0)==md.mesh.numberofvertices+1 or np.size(field,0)==md.mesh.numberofelements+1: 202 if np.ndim(field) > 1 and not all(field[-1,:]==np.sort(field[-1,:])): 172 203 md = md.checkmessage(options.getfieldvalue('message',\ 173 204 "field '%s' columns should be sorted chronologically" % fieldname)) 174 if any(field[-1,0:-1]==field[-1,1:]):205 if np.ndim(field) > 1 and any(field[-1,0:-1]==field[-1,1:]): 175 206 md = md.checkmessage(options.getfieldvalue('message',\ 176 207 "field '%s' columns must not contain duplicate timesteps" % fieldname)) 177 208 else: … … 197 228 198 229 return md 199 230 231 -
../trunk-jpl/src/m/mech/newforcing.py
1 import numpy as np 2 3 def newforcing(t0,t1,deltaT,f0,f1,nodes): 4 ''' 5 FUNCTION NEWFORCING Build forcing that extends temporally from t0 to t1, and in magnitude from f0 to f1. Equal time 6 and magnitude spacing. 7 8 Usage: forcing=newforcing(t0,t1,deltaT,f0,f1,nodes); 9 Where: 10 t0:t1: time interval. 11 deltaT: time step 12 f0:f1: magnitude interval. 13 nodes: number of vertices where we have a temporal forcing 14 15 Example: 16 md.smb.mass_balance=newforcing(md.timestepping.start_time,md.timestepping.final_time, 17 md.timestepping.time_step,-1,+2,md.mesh.numberofvertices) 18 ''' 19 #Number of time steps: 20 nsteps = (t1 - t0) / deltaT + 1 21 22 #delta forcing: 23 deltaf = (f1 - f0) / (nsteps - 1) 24 25 #creates times: 26 times = np.arange(t0,t1+deltaT,deltaT) #Add deltaT to fix python/matlab discrepency 27 28 #create forcing: 29 forcing = np.arange(f0,f1+deltaf,deltaf)#Add deltaf to fix python/matlab discrepency 30 31 #replicate for all nodes 32 forcing = np.tile(forcing, (nodes+1,1)) 33 forcing[-1,:] = times 34 return forcing -
../trunk-jpl/src/m/dev/devpath.py
30 30 31 31 #Manual imports for commonly used functions 32 32 from plotmodel import plotmodel 33 from runme import runme 33 34 34 35 #c = get_ipython().config 35 36 #c.InteractiveShellApp.exec_lines = [] -
../trunk-jpl/src/m/print/printmodel.py
1 2 import numpy as np 3 #from model import * 4 #from socket import gethostname 5 #from bamg import * 6 #from setmask import * 7 #from parameterize import * 8 #from setflowequation import * 9 #from solve import * 10 from pairoptions import * 11 12 def printmodel(filename,format,*args): 13 ''' PRINTMODEL - save an image of current figure 14 15 filename: output name of image file (no extension) 16 format: image format (ex: 'tiff','jpg','pdf') 17 18 List of options to printfmodel: 19 20 figure: number of figure to print (default: current figure) 21 resolution: use higher resolution to anti-alias (default 2) 22 margin: add margin around final image 23 marginsize: size of margin around final image (default 5) 24 frame: add frame around final image 25 framesize: size of frame around final image (default 5) 26 framecolor: color of frame around final image (default 'black') 27 trim: trim empty space around image (default 'off') 28 hardcopy: 'off' to impose MATLAB to use the same colors (default 'off') 29 30 Usage: 31 printmodel(filename,format,varargin); 32 33 Examples: 34 printmodel('image','tiff') 35 printmodel('image','eps','margin','on','frame','on','hardcopy','on') 36 ''' 37 38 #get options: 39 options = pairoptions(*args) 40 41 #set defaults 42 options = addfielddefault(options,'figure','gcf') 43 options = addfielddefault(options,'format','tiff') 44 options = addfielddefault(options,'resolution',1) 45 options = addfielddefault(options,'margin','on') 46 options = addfielddefault(options,'marginsize',25) 47 options = addfielddefault(options,'frame','on') 48 options = addfielddefault(options,'framesize',3) 49 options = addfielddefault(options,'framecolor','black') 50 options = addfielddefault(options,'trim','on') 51 options = addfielddefault(options,'hardcopy','off') 52 53 #get fig: 54 fig = getfieldvalue(options,'figure') 55 if len(fig) == 1: 56 fig=gcf 57 else: 58 figure(fig) 59 fig=gcf 60 61 #In auto mode, MATLAB prints the figure the same size as it appears on the computer screen, centered on the page 62 set(fig, 'PaperPositionMode', 'auto'); 63 64 #InvertHardcopy off imposes MATLAB to use the same colors 65 set(fig, 'InvertHardcopy', getfieldvalue(options,'hardcopy')); 66 67 #we could have several formats, as a cell array of strings. 68 formats=format; 69 if ~iscell(formats), 70 formats={formats}; 71 end 72 73 #loop on formats: 74 for i=1:length(formats), 75 format=formats{i}; 76 77 #Use higher resolution to anti-alias and use zbuffer to have smooth colors 78 print(fig, '-zbuffer','-dtiff',['-r' num2str(get(0,'ScreenPixelsPerInch')*getfieldvalue(options,'resolution'))],filename); 79 80 #some trimming involved? 81 if ~strcmpi(format,'pdf'), 82 if strcmpi(getfieldvalue(options,'trim'),'on'), 83 system(['convert -trim ' filename '.tif ' filename '.tif']); 84 end 85 end 86 87 #margin? 88 if ~strcmpi(format,'pdf'), 89 if strcmpi(getfieldvalue(options,'margin'),'on'), 90 marginsize=getfieldvalue(options,'marginsize'); 91 system(['convert -border ' num2str(marginsize) 'x' num2str(marginsize) ' -bordercolor "white" ' filename '.tif ' filename '.tif']); 92 end 93 end 94 95 #frame? 96 if ~strcmpi(format,'pdf'), 97 if strcmpi(getfieldvalue(options,'frame'),'on'), 98 framesize=getfieldvalue(options,'framesize'); 99 framecolor=getfieldvalue(options,'framecolor'); 100 system(['convert -border ' num2str(framesize) 'x' num2str(framesize) ' -bordercolor "' framecolor '" ' filename '.tif ' filename '.tif']); 101 end 102 end 103 104 #convert image to correct format 105 if ~strcmpi(format,'tiff') & ~strcmpi(format,'tif'), 106 system(['convert ' filename '.tif ' filename '.' format]); 107 delete([ filename '.tif']); 108 end 109 end -
../trunk-jpl/src/m/classes/thermal.py
100 100 md = checkfield(md,'fieldname','thermal.requested_outputs','stringrow',1) 101 101 102 102 if 'EnthalpyAnalysis' in analyses and md.thermal.isenthalpy and md.mesh.dimension()==3: 103 pos=np.where(~np.isnan(md.thermal.spctemperature[0:md.mesh.numberofvertices])) 103 TEMP = md.thermal.spctemperature[:-1].flatten(-1) 104 pos=np.where(~np.isnan(TEMP)) 104 105 try: 105 106 spccol=np.size(md.thermal.spctemperature,1) 106 107 except IndexError: 107 108 spccol=1 108 replicate=np.tile(md.geometry.surface-md.mesh.z,(spccol)) 109 control=md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*replicate 110 md = checkfield(md,'fieldname','thermal.spctemperature','field',md.thermal.spctemperature[pos],'<=',control[pos],'message',"spctemperature should be below the adjusted melting point") 109 110 replicate=np.tile(md.geometry.surface-md.mesh.z,(spccol)).flatten(-1) 111 112 control=md.materials.meltingpoint-md.materials.beta*md.materials.rho_ice*md.constants.g*replicate+10**-5 113 114 md = checkfield(md,'fieldname','thermal.spctemperature','field',md.thermal.spctemperature.flatten(-1)[pos],'<=',control[pos],'message',"spctemperature should be below the adjusted melting point") 111 115 md = checkfield(md,'fieldname','thermal.isenthalpy','numel',[1],'values',[0,1]) 112 116 md = checkfield(md,'fieldname','thermal.isdynamicbasalspc','numel',[1],'values',[0,1]); 113 117 if(md.thermal.isenthalpy): -
../trunk-jpl/src/m/classes/calvingminthickness.py
1 from fielddisplay import fielddisplay 2 from checkfield import checkfield 3 from WriteData import WriteData 4 5 class calvingminthickness(object): 6 """ 7 CALVINGMINTHICKNESS class definition 8 9 Usage: 10 calvingminthickness=calvingminthickness() 11 """ 12 13 def __init__(self): # {{{ 14 15 self.min_thickness = 0. 16 self.meltingrate = float('NaN') 17 18 #set defaults 19 self.setdefaultparameters() 20 21 #}}} 22 def __repr__(self): # {{{ 23 string=' Calving Minimum thickness:' 24 string="%s\n%s"%(string,fielddisplay(self,'min_thickness','minimum thickness below which no ice is allowed')) 25 string="%s\n%s"%(string,fielddisplay(self,'meltingrate','melting rate at given location [m/a]')) 26 return string 27 #}}} 28 def extrude(self,md): # {{{ 29 self.meltingrate=project3d(md,'vector',self.meltingrate,'type','node') 30 return self 31 #}}} 32 def setdefaultparameters(self): # {{{ 33 34 #minimum thickness is 100 m by default 35 self.min_thickness = 100. 36 #}}} 37 def checkconsistency(self,md,solution,analyses): # {{{ 38 39 #Early return 40 if solution == 'TransientSolution' or md.transient.ismovingfront == 0: 41 return 42 43 md = checkfield(md,'fieldname','calving.min_thickness','>',0,'NaN',1,'Inf',1) 44 md = checkfield(md,'fieldname','calving.meltingrate','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices],'>=',0) 45 return md 46 # }}} 47 def marshall(self,prefix,md,fid): # {{{ 48 yts=md.constants.yts 49 WriteData(fid,prefix,'name','md.calving.law','data',4,'format','Integer') 50 WriteData(fid,prefix,'object',self,'fieldname','min_thickness','format','Double') 51 WriteData(fid,prefix,'object',self,'fieldname','meltingrate','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'scale',1./yts) 52 # }}} -
../trunk-jpl/src/m/classes/calvingdev.py
1 from fielddisplay import fielddisplay 2 from project3d import project3d 3 from checkfield import checkfield 4 from WriteData import WriteData 5 6 class calvingdev(object): 7 """ 8 CALVINGDEV class definition 9 10 Usage: 11 calvingdev=calvingdev(); 12 """ 13 14 def __init__(self): # {{{ 15 16 self.stress_threshold_groundedice = 0. 17 self.stress_threshold_floatingice = 0. 18 self.meltingrate = float('NaN') 19 20 #set defaults 21 self.setdefaultparameters() 22 23 #}}} 24 def __repr__(self): # {{{ 25 string=' Calving Pi parameters:' 26 string="%s\n%s"%(string,fielddisplay(self,'stress_threshold_groundedice','sigma_max applied to grounded ice only [Pa]')) 27 string="%s\n%s"%(string,fielddisplay(self,'stress_threshold_floatingice','sigma_max applied to floating ice only [Pa]')) 28 29 string="%s\n%s"%(string,fielddisplay(self,'meltingrate','melting rate at given location [m/a]')) 30 return string 31 #}}} 32 def extrude(self,md): # {{{ 33 self.meltingrate=project3d(md,'vector',self.meltingrate,'type','node') 34 return self 35 #}}} 36 def setdefaultparameters(self): # {{{ 37 #Default sigma max 38 self.stress_threshold_groundedice = 1e6 39 self.stress_threshold_floatingice = 150e3 40 return self 41 #}}} 42 def checkconsistency(self,md,solution,analyses): # {{{ 43 #Early return 44 if solution == 'TransientSolution' or md.transient.ismovingfront == 0: 45 return 46 47 md = checkfield(md,'fieldname','calving.stress_threshold_groundedice','>',0,'nan',1,'Inf',1) 48 md = checkfield(md,'fieldname','calving.stress_threshold_floatingice','>',0,'nan',1,'Inf',1) 49 md = checkfield(md,'fieldname','calving.meltingrate','NaN',1,'Inf',1,'timeseries',1,'>=',0) 50 51 return md 52 # }}} 53 def marshall(self,prefix,md,fid): # {{{ 54 yts=md.constants.yts 55 56 WriteData(fid,prefix,'name','md.calving.law','data',2,'format','Integer') 57 WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_groundedice','format','DoubleMat','mattype',1) 58 WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_floatingice','format','DoubleMat','mattype',1) 59 WriteData(fid,prefix,'object',self,'fieldname','meltingrate','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1./yts) 60 # }}} -
../trunk-jpl/src/m/classes/mismipbasalforcings.py
39 39 #}}} 40 40 def initialize(self,md): # {{{ 41 41 if np.all(np.isnan(self.groundedice_melting_rate)): 42 self.groundedice_melting_rate=np.zeros( md.mesh.numberofvertices)42 self.groundedice_melting_rate=np.zeros((md.mesh.numberofvertices)) 43 43 print ' no basalforcings.groundedice_melting_rate specified: values set as zero' 44 if np.all(np.isnan(self.geothermalflux)): 45 self.geothermalflux=np.zeros((md.mesh.numberofvertices)) 46 print " no basalforcings.geothermalflux specified: values set as zero" 44 47 return self 45 48 #}}} 46 49 def setdefaultparameters(self): # {{{ … … 83 86 print 'WARNING: value of yts for MISMIP+ runs different from ISSM default!' 84 87 85 88 floatingice_melting_rate = np.zeros((md.mesh.numberofvertices)) 86 floatingice_melting_rate = md.basalforcings.meltrate_factor*np.tanh((md.geometry.base-md.geometry.bed)/md.basalforcings.threshold_thickness)* np.amax(md.basalforcings.upperdepth_melt-md.geometry.base,0)89 floatingice_melting_rate = md.basalforcings.meltrate_factor*np.tanh((md.geometry.base-md.geometry.bed)/md.basalforcings.threshold_thickness)*(md.basalforcings.upperdepth_melt-md.geometry.base) 87 90 88 91 WriteData(fid,prefix,'name','md.basalforcings.model','data',3,'format','Integer') 89 92 WriteData(fid,prefix,'data',floatingice_melting_rate,'format','DoubleMat','name','md.basalforcings.floatingice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts) -
../trunk-jpl/src/m/classes/SMBgradientsela.py
8 8 SMBgradientsela Class definition 9 9 10 10 Usage: 11 SMBgradientsela=SMBgradientsela() ;11 SMBgradientsela=SMBgradientsela() 12 12 """ 13 13 14 14 def __init__(self): # {{{ … … 18 18 self.b_max = float('NaN') 19 19 self.b_min = float('NaN') 20 20 self.requested_outputs = [] 21 self.setdefaultparameters() 21 22 #}}} 22 23 def __repr__(self): # {{{ 23 string=" surface forcings parameters:" 24 string = " surface forcings parameters:" 25 string+= '\n SMB gradients ela parameters:' 24 26 25 string="%s\n%s"%(string,fielddisplay(self,'issmbgradientsela','is smb gradients ela method activated (0 or 1, default is 0)'))26 27 string="%s\n%s"%(string,fielddisplay(self,'ela',' equilibrium line altitude from which deviation is used to calculate smb using the smb gradients ela method [m a.s.l.]')) 27 28 string="%s\n%s"%(string,fielddisplay(self,'b_pos',' vertical smb gradient (dB/dz) above ela')) 28 29 string="%s\n%s"%(string,fielddisplay(self,'b_neg',' vertical smb gradient (dB/dz) below ela')) … … 46 47 47 48 return self 48 49 #}}} 50 def setdefaultparameters(self): # {{{ 51 self.b_max=9999. 52 self.b_min=-9999. 53 return self 54 #}}} 49 55 def checkconsistency(self,md,solution,analyses): # {{{ 50 56 51 57 if 'MasstransportAnalysis' in analyses: … … 55 61 md = checkfield(md,'fieldname','smb.b_max','timeseries',1,'NaN',1,'Inf',1) 56 62 md = checkfield(md,'fieldname','smb.b_min','timeseries',1,'NaN',1,'Inf',1) 57 63 58 md = checkfield(md,'fieldname',' masstransport.requested_outputs','stringrow',1)64 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1) 59 65 return md 60 66 # }}} 61 67 def marshall(self,prefix,md,fid): # {{{ -
../trunk-jpl/src/m/classes/constants.py
11 11 """ 12 12 13 13 def __init__(self): # {{{ 14 self.g = 0 15 self.omega = 0 16 self.yts = 0 17 self.referencetemperature = 0 14 self.g = 0. 15 self.omega = 0. 16 self.yts = 0. 17 self.referencetemperature = 0. 18 18 19 19 #set defaults 20 20 self.setdefaultparameters() … … 48 48 #}}} 49 49 def checkconsistency(self,md,solution,analyses): # {{{ 50 50 51 md = checkfield(md,'fieldname','constants.g','> ',0,'size',[1])52 md = checkfield(md,'fieldname','constants.omega','>=',0,'size',[1 ])53 md = checkfield(md,'fieldname','constants.yts','>',0,'size',[1 ])54 md = checkfield(md,'fieldname','constants.referencetemperature','size',[1 ])51 md = checkfield(md,'fieldname','constants.g','>=',0,'size',[1,1]) 52 md = checkfield(md,'fieldname','constants.omega','>=',0,'size',[1,1]) 53 md = checkfield(md,'fieldname','constants.yts','>',0,'size',[1,1]) 54 md = checkfield(md,'fieldname','constants.referencetemperature','size',[1,1]) 55 55 56 56 return md 57 57 # }}} -
../trunk-jpl/src/m/classes/hydrologysommers.py
1 from fielddisplay import fielddisplay 2 from checkfield import checkfield 3 from WriteData import WriteData 4 5 class hydrologysommers(object): 6 """ 7 HYDROLOGYSOMMERS class definition 8 9 Usage: 10 hydrologysommers=hydrologysommers() 11 """ 12 13 def __init__(self): # {{{ 14 self.head = float('NaN') 15 self.gap_height = float('NaN') 16 self.bump_spacing = float('NaN') 17 self.bump_height = float('NaN') 18 self.englacial_input = float('NaN') 19 self.moulin_input = float('NaN') 20 self.reynolds = float('NaN') 21 self.spchead = float('NaN') 22 self.neumannflux = float('NaN') 23 self.relaxation = 0 24 self.storage = 0 25 26 #set defaults 27 self.setdefaultparameters() 28 29 #}}} 30 def __repr__(self): # {{{ 31 32 string=' hydrologysommers solution parameters:' 33 string="%s\n%s"%(string,fielddisplay(self,'head','subglacial hydrology water head (m)')) 34 string="%s\n%s"%(string,fielddisplay(self,'gap_height','height of gap separating ice to bed (m)')) 35 string="%s\n%s"%(string,fielddisplay(self,'bump_spacing','characteristic bedrock bump spacing (m)')) 36 string="%s\n%s"%(string,fielddisplay(self,'bump_height','characteristic bedrock bump height (m)')) 37 string="%s\n%s"%(string,fielddisplay(self,'englacial_input','liquid water input from englacial to subglacial system (m/yr)')) 38 string="%s\n%s"%(string,fielddisplay(self,'moulin_input','liquid water input from moulins (at the vertices) to subglacial system (m^3/s)')) 39 string="%s\n%s"%(string,fielddisplay(self,'reynolds','Reynolds'' number')) 40 string="%s\n%s"%(string,fielddisplay(self,'neumannflux','water flux applied along the model boundary (m^2/s)')) 41 string="%s\n%s"%(string,fielddisplay(self,'spchead','water head constraints (NaN means no constraint) (m)')) 42 string="%s\n%s"%(string,fielddisplay(self,'relaxation','under-relaxation coefficient for nonlinear iteration')) 43 string="%s\n%s"%(string,fielddisplay(self,'storage','englacial storage coefficient (void ratio)')) 44 return string 45 #}}} 46 def extrude(self,md): # {{{ 47 return self 48 #}}} 49 def setdefaultparameters(self): # {{{ 50 # Set under-relaxation parameter to be 1 (no under-relaxation of nonlinear iteration) 51 self.relaxation=1 52 self.storage=0 53 return self 54 #}}} 55 def checkconsistency(self,md,solution,analyses): # {{{ 56 57 #Early return 58 if 'HydrologySommersAnalysis' not in analyses: 59 return md 60 61 md = checkfield(md,'fieldname','hydrology.head','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1) 62 md = checkfield(md,'fieldname','hydrology.gap_height','>=',0,'size',[md.mesh.numberofelements],'NaN',1,'Inf',1) 63 md = checkfield(md,'fieldname','hydrology.bump_spacing','>',0,'size',[md.mesh.numberofelements],'NaN',1,'Inf',1) 64 md = checkfield(md,'fieldname','hydrology.bump_height','>=',0,'size',[md.mesh.numberofelements],'NaN',1,'Inf',1) 65 md = checkfield(md,'fieldname','hydrology.englacial_input','>=',0,'NaN',1,'Inf',1,'timeseries',1) 66 md = checkfield(md,'fieldname','hydrology.moulin_input','>=',0,'NaN',1,'Inf',1,'timeseries',1) 67 md = checkfield(md,'fieldname','hydrology.reynolds','>',0,'size',[md.mesh.numberofelements],'NaN',1,'Inf',1) 68 md = checkfield(md,'fieldname','hydrology.neumannflux','timeseries',1,'NaN',1,'Inf',1) 69 md = checkfield(md,'fieldname','hydrology.spchead','size',[md.mesh.numberofvertices]) 70 md = checkfield(md,'fieldname','hydrology.relaxation','>=',0) 71 md = checkfield(md,'fieldname','hydrology.storage','>=',0) 72 73 return md 74 # }}} 75 def marshall(self,prefix,md,fid): # {{{ 76 yts=md.constants.yts 77 78 WriteData(fid,prefix,'name','md.hydrology.model','data',3,'format','Integer') 79 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','head','format','DoubleMat','mattype',1) 80 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','gap_height','format','DoubleMat','mattype',2) 81 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','bump_spacing','format','DoubleMat','mattype',2) 82 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','bump_height','format','DoubleMat','mattype',2) 83 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','englacial_input','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts) 84 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','moulin_input','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts) 85 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','reynolds','format','DoubleMat','mattype',2) 86 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','neumannflux','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) 87 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','spchead','format','DoubleMat','mattype',1) 88 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','relaxation','format','Double') 89 WriteData(fid,prefix,'object',self,'class','hydrology','fieldname','storage','format','Double') 90 # }}} -
../trunk-jpl/src/m/classes/flowequation.py
91 91 md = checkfield(md,'fieldname','flowequation.isFS','numel',[1],'values',[0,1]) 92 92 md = checkfield(md,'fieldname','flowequation.fe_SSA','values',['P1','P1bubble','P1bubblecondensed','P2','P2bubble']) 93 93 md = checkfield(md,'fieldname','flowequation.fe_HO' ,'values',['P1','P1bubble','P1bubblecondensed','P1xP2','P2xP1','P2','P2bubble','P1xP3','P2xP4']) 94 md = checkfield(md,'fieldname','flowequation.fe_FS' ,'values',['P1P1','P1P1GLS','MINIcondensed','MINI','TaylorHood',' XTaylorHood','OneLayerP4z','CrouzeixRaviart'])94 md = checkfield(md,'fieldname','flowequation.fe_FS' ,'values',['P1P1','P1P1GLS','MINIcondensed','MINI','TaylorHood','LATaylorHood','XTaylorHood','OneLayerP4z','CrouzeixRaviart','LACrouzeixRaviart']) 95 95 md = checkfield(md,'fieldname','flowequation.borderSSA','size',[md.mesh.numberofvertices],'values',[0,1]) 96 96 md = checkfield(md,'fieldname','flowequation.borderHO','size',[md.mesh.numberofvertices],'values',[0,1]) 97 97 md = checkfield(md,'fieldname','flowequation.borderFS','size',[md.mesh.numberofvertices],'values',[0,1]) … … 103 103 if m.strcmp(md.mesh.domaintype(),'2Dhorizontal'): 104 104 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',[1,2]) 105 105 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',[1,2]) 106 elif m.strcmp(md.mesh.domaintype(),'2Dvertical'): 107 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',[2,4,5]) 108 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',[2,4,5]) 106 109 elif m.strcmp(md.mesh.domaintype(),'3D'): 107 110 md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',np.arange(0,8+1)) 108 111 md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',np.arange(0,8+1)) -
../trunk-jpl/src/m/classes/basalforcings.py
44 44 if np.all(np.isnan(self.floatingice_melting_rate)): 45 45 self.floatingice_melting_rate=np.zeros((md.mesh.numberofvertices)) 46 46 print " no basalforcings.floatingice_melting_rate specified: values set as zero" 47 #if np.all(np.isnan(self.geothermalflux)): 48 #self.geothermalflux=np.zeros((md.mesh.numberofvertices)) 49 #print " no basalforcings.geothermalflux specified: values set as zero" 47 50 48 51 return self 49 52 #}}} -
../trunk-jpl/src/m/classes/calvingvonmises.py
1 from fielddisplay import fielddisplay 2 from project3d import project3d 3 from checkfield import checkfield 4 from WriteData import WriteData 5 6 class calvingvonmises(object): 7 """ 8 CALVINGVONMISES class definition 9 10 Usage: 11 calvingvonmises=calvingvonmises() 12 """ 13 14 def __init__(self): # {{{ 15 16 self.stress_threshold_groundedice = 0. 17 self.stress_threshold_floatingice = 0. 18 self.meltingrate = float('NaN') 19 20 #set defaults 21 self.setdefaultparameters() 22 23 #}}} 24 def __repr__(self): # {{{ 25 string=' Calving VonMises parameters:' 26 string="%s\n%s"%(string,fielddisplay(self,'stress_threshold_groundedice','sigma_max applied to grounded ice only [Pa]')) 27 string="%s\n%s"%(string,fielddisplay(self,'stress_threshold_floatingice','sigma_max applied to floating ice only [Pa]')) 28 29 string="%s\n%s"%(string,fielddisplay(self,'meltingrate','melting rate at given location [m/a]')) 30 return string 31 #}}} 32 def extrude(self,md): # {{{ 33 self.meltingrate=project3d(md,'vector',self.meltingrate,'type','node') 34 return self 35 #}}} 36 def setdefaultparameters(self): # {{{ 37 #Default sigma max 38 self.stress_threshold_groundedice = 1e6 39 self.stress_threshold_floatingice = 150e3 40 return self 41 #}}} 42 def checkconsistency(self,md,solution,analyses): # {{{ 43 #Early return 44 if solution == 'TransientSolution' or md.transient.ismovingfront == 0: 45 return 46 47 md = checkfield(md,'fieldname','calving.stress_threshold_groundedice','>',0,'nan',1,'Inf',1) 48 md = checkfield(md,'fieldname','calving.stress_threshold_floatingice','>',0,'nan',1,'Inf',1) 49 md = checkfield(md,'fieldname','calving.meltingrate','NaN',1,'Inf',1,'timeseries',1,'>=',0) 50 51 return md 52 # }}} 53 def marshall(self,prefix,md,fid): # {{{ 54 yts=md.constants.yts 55 56 WriteData(fid,prefix,'name','md.calving.law','data',2,'format','Integer') 57 WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_groundedice','format','DoubleMat','mattype',1) 58 WriteData(fid,prefix,'object',self,'fieldname','stress_threshold_floatingice','format','DoubleMat','mattype',1) 59 WriteData(fid,prefix,'object',self,'fieldname','meltingrate','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts,'scale',1./yts) 60 # }}} -
../trunk-jpl/src/m/classes/transient.py
11 11 """ 12 12 13 13 def __init__(self): # {{{ 14 self.issmb = False14 self.issmb = False 15 15 self.ismasstransport = False 16 16 self.isstressbalance = False 17 17 self.isthermal = False … … 22 22 self.ismovingfront = False 23 23 self.ishydrology = False 24 24 self.isslr = False 25 self.iscoupler = False 26 self.amr_frequency = 0 25 27 self.isoceancoupling = False 26 self.iscoupler = False27 amr_frequency = 028 28 self.requested_outputs = [] 29 29 30 30 #set defaults … … 80 80 self.requested_outputs=[] 81 81 return self 82 82 #}}} 83 def deactivateall(self):#{{{ 84 self.issmb = False 85 self.ismasstransport = False 86 self.isstressbalance = False 87 self.isthermal = False 88 self.isgroundingline = False 89 self.isgia = False 90 self.isesa = False 91 self.isdamageevolution = False 92 self.ismovingfront = False 93 self.ishydrology = False 94 self.isslr = False 95 self.isoceancoupling = False 96 self.iscoupler = False 97 self.amr_frequency = 0 98 99 #default output 100 self.requested_outputs=[] 101 return self 102 #}}} 83 103 def setdefaultparameters(self): # {{{ 84 104 85 105 #full analysis: Stressbalance, Masstransport and Thermal but no groundingline migration for now -
../trunk-jpl/src/m/classes/mesh2dvertical.py
1 import numpy as np 2 from fielddisplay import fielddisplay 3 from checkfield import checkfield 4 import MatlabFuncs as m 5 from WriteData import WriteData 6 7 class mesh2dvertical(object): 8 """ 9 MESH2DVERTICAL class definition 10 11 Usage: 12 mesh2dvertical=mesh2dvertical(); 13 """ 14 15 def __init__(self): # {{{ 16 self.x = float('NaN') 17 self.y = float('NaN') 18 self.elements = float('NaN') 19 self.numberofelements = 0 20 self.numberofvertices = 0 21 self.numberofedges = 0 22 23 self.lat = float('NaN') 24 self.long = float('NaN') 25 self.epsg = float('NaN') 26 27 self.vertexonboundary = float('NaN') 28 self.vertexonbase = float('NaN') 29 self.vertexonsurface = float('NaN') 30 31 self.edges = float('NaN') 32 self.segments = float('NaN') 33 self.segmentmarkers = float('NaN') 34 self.vertexconnectivity = float('NaN') 35 self.elementconnectivity = float('NaN') 36 self.average_vertex_connectivity = 0 37 38 #set defaults 39 self.setdefaultparameters() 40 41 #}}} 42 def __repr__(self): # {{{ 43 string=" 2D tria Mesh (vertical):" 44 45 string="%s\n%s"%(string,"\n Elements and vertices:") 46 string="%s\n%s"%(string,fielddisplay(self,"numberofelements","number of elements")) 47 string="%s\n%s"%(string,fielddisplay(self,"numberofvertices","number of vertices")) 48 string="%s\n%s"%(string,fielddisplay(self,"elements","vertex indices of the mesh elements")) 49 string="%s\n%s"%(string,fielddisplay(self,"x","vertices x coordinate [m]")) 50 string="%s\n%s"%(string,fielddisplay(self,"y","vertices y coordinate [m]")) 51 string="%s\n%s"%(string,fielddisplay(self,"edges","edges of the 2d mesh (vertex1 vertex2 element1 element2)")) 52 string="%s\n%s"%(string,fielddisplay(self,"numberofedges","number of edges of the 2d mesh")) 53 54 string="%s%s"%(string,"\n\n Properties:") 55 string="%s\n%s"%(string,fielddisplay(self,"vertexonboundary","vertices on the boundary of the domain flag list")) 56 string="%s\n%s"%(string,fielddisplay(self,'vertexonbase','vertices on the bed of the domain flag list')) 57 string="%s\n%s"%(string,fielddisplay(self,'vertexonsurface','vertices on the surface of the domain flag list')) 58 string="%s\n%s"%(string,fielddisplay(self,"segments","edges on domain boundary (vertex1 vertex2 element)")) 59 string="%s\n%s"%(string,fielddisplay(self,"segmentmarkers","number associated to each segment")) 60 string="%s\n%s"%(string,fielddisplay(self,"vertexconnectivity","list of vertices connected to vertex_i")) 61 string="%s\n%s"%(string,fielddisplay(self,"elementconnectivity","list of vertices connected to element_i")) 62 string="%s\n%s"%(string,fielddisplay(self,"average_vertex_connectivity","average number of vertices connected to one vertex")) 63 64 string="%s%s"%(string,"\n\n Projection:") 65 string="%s\n%s"%(string,fielddisplay(self,"lat","vertices latitude [degrees]")) 66 string="%s\n%s"%(string,fielddisplay(self,"long","vertices longitude [degrees]")) 67 string="%s\n%s"%(string,fielddisplay(self,"epsg","EPSG code (ex: 3413 for UPS Greenland, 3031 for UPS Antarctica)")) 68 return string 69 #}}} 70 def setdefaultparameters(self): # {{{ 71 72 #the connectivity is the averaged number of nodes linked to a 73 #given node through an edge. This connectivity is used to initially 74 #allocate memory to the stiffness matrix. A value of 16 seems to 75 #give a good memory/time ration. This value can be checked in 76 #trunk/test/Miscellaneous/runme.m 77 self.average_vertex_connectivity=25. 78 79 return self 80 #}}} 81 def checkconsistency(self,md,solution,analyses): # {{{ 82 if(solution=='LoveSolution'): 83 return 84 85 md = checkfield(md,'fieldname','mesh.x','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices]) 86 md = checkfield(md,'fieldname','mesh.y','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices]) 87 md = checkfield(md,'fieldname','mesh.elements','NaN',1,'Inf',1,'>',0,'values',np.arange(1,md.mesh.numberofvertices+1)) 88 md = checkfield(md,'fieldname','mesh.elements','size',[md.mesh.numberofelements,3]) 89 if np.any(np.logical_not(m.ismember(np.arange(1,md.mesh.numberofvertices+1),md.mesh.elements))): 90 md.checkmessage("orphan nodes have been found. Check the mesh outline") 91 md = checkfield(md,'fieldname','mesh.numberofelements','>',0) 92 md = checkfield(md,'fieldname','mesh.numberofvertices','>',0) 93 md = checkfield(md,'fieldname','mesh.vertexonbase','size',[md.mesh.numberofvertices],'values',[0,1]) 94 md = checkfield(md,'fieldname','mesh.vertexonsurface','size',[md.mesh.numberofvertices],'values',[0,1]) 95 md = checkfield(md,'fieldname','mesh.average_vertex_connectivity','>=',9,'message',"'mesh.average_vertex_connectivity' should be at least 9 in 2d") 96 97 if solution=='ThermalSolution': 98 md.checkmessage("thermal not supported for 2d mesh") 99 100 return md 101 # }}} 102 def domaintype(self): # {{{ 103 return "2Dvertical" 104 #}}} 105 def dimension(self): # {{{ 106 return 2 107 #}}} 108 def elementtype(self): # {{{ 109 return "Tria" 110 #}}} 111 def vertexflags(self,value): # {{{ 112 flags = np.zeros((self.numberofvertices,)) 113 pos = self.segments[np.where(self.segmentmarkers==value),0:2]-1 114 flags[pos] = 1 115 return flags 116 #}}} 117 def marshall(self,prefix,md,fid): # {{{ 118 WriteData(fid,prefix,'name','md.mesh.domain_type','data',"Domain"+self.domaintype(),'format','String'); 119 WriteData(fid,prefix,'name','md.mesh.domain_dimension','data',self.dimension(),'format','Integer'); 120 WriteData(fid,prefix,'name','md.mesh.elementtype','data',self.elementtype(),'format','String'); 121 WriteData(fid,prefix,'object',self,'class','mesh','fieldname','x','format','DoubleMat','mattype',1) 122 WriteData(fid,prefix,'object',self,'class','mesh','fieldname','y','format','DoubleMat','mattype',1) 123 WriteData(fid,prefix,'name','md.mesh.z','data',np.zeros(self.numberofvertices),'format','DoubleMat','mattype',1); 124 WriteData(fid,prefix,'object',self,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2) 125 WriteData(fid,prefix,'object',self,'class','mesh','fieldname','numberofelements','format','Integer') 126 WriteData(fid,prefix,'object',self,'class','mesh','fieldname','numberofvertices','format','Integer') 127 WriteData(fid,prefix,'object',self,'class','mesh','fieldname','vertexonbase','format','BooleanMat','mattype',1) 128 WriteData(fid,prefix,'object',self,'class','mesh','fieldname','vertexonsurface','format','BooleanMat','mattype',1) 129 WriteData(fid,prefix,'object',self,'class','mesh','fieldname','average_vertex_connectivity','format','Integer') 130 # }}} -
../trunk-jpl/src/m/classes/matenhancedice.py
1 from fielddisplay import fielddisplay 2 from project3d import project3d 3 from checkfield import checkfield 4 from WriteData import WriteData 5 6 class matenhancedice(object): 7 """ 8 MATICE class definition 9 10 Usage: 11 matenhancedice=matenhancedice(); 12 """ 13 14 def __init__(self): # {{{ 15 self.rho_ice = 0. 16 self.rho_water = 0. 17 self.rho_freshwater = 0. 18 self.mu_water = 0. 19 self.heatcapacity = 0. 20 self.latentheat = 0. 21 self.thermalconductivity = 0. 22 self.temperateiceconductivity = 0. 23 self.meltingpoint = 0. 24 self.beta = 0. 25 self.mixed_layer_capacity = 0. 26 self.thermal_exchange_velocity = 0. 27 self.rheology_E = float('NaN') 28 self.rheology_B = float('NaN') 29 self.rheology_n = float('NaN') 30 self.rheology_law = '' 31 32 #giaivins: 33 self.lithosphere_shear_modulus = 0. 34 self.lithosphere_density = 0. 35 self.mantle_shear_modulus = 0. 36 self.mantle_density = 0. 37 38 #SLR 39 self.earth_density= 0 # average density of the Earth, (kg/m^3) 40 41 self.setdefaultparameters() 42 #}}} 43 def __repr__(self): # {{{ 44 string=" Materials:" 45 46 string="%s\n%s"%(string,fielddisplay(self,"rho_ice","ice density [kg/m^3]")) 47 string="%s\n%s"%(string,fielddisplay(self,"rho_water","water density [kg/m^3]")) 48 string="%s\n%s"%(string,fielddisplay(self,"rho_freshwater","fresh water density [kg/m^3]")) 49 string="%s\n%s"%(string,fielddisplay(self,"mu_water","water viscosity [N s/m^2]")) 50 string="%s\n%s"%(string,fielddisplay(self,"heatcapacity","heat capacity [J/kg/K]")) 51 string="%s\n%s"%(string,fielddisplay(self,"thermalconductivity","ice thermal conductivity [W/m/K]")) 52 string="%s\n%s"%(string,fielddisplay(self,"temperateiceconductivity","temperate ice thermal conductivity [W/m/K]")) 53 string="%s\n%s"%(string,fielddisplay(self,"meltingpoint","melting point of ice at 1atm in K")) 54 string="%s\n%s"%(string,fielddisplay(self,"latentheat","latent heat of fusion [J/m^3]")) 55 string="%s\n%s"%(string,fielddisplay(self,"beta","rate of change of melting point with pressure [K/Pa]")) 56 string="%s\n%s"%(string,fielddisplay(self,"mixed_layer_capacity","mixed layer capacity [W/kg/K]")) 57 string="%s\n%s"%(string,fielddisplay(self,"thermal_exchange_velocity","thermal exchange velocity [m/s]")) 58 string="%s\n%s"%(string,fielddisplay(self,"rheology_E","enhancement factor")) 59 string="%s\n%s"%(string,fielddisplay(self,"rheology_B","flow law parameter [Pa/s^(1/n)]")) 60 string="%s\n%s"%(string,fielddisplay(self,"rheology_n","Glen's flow law exponent")) 61 string="%s\n%s"%(string,fielddisplay(self,"rheology_law","law for the temperature dependance of the rheology: 'None', 'BuddJacka', 'Cuffey', 'CuffeyTemperate', 'Paterson', 'Arrhenius' or 'LliboutryDuval'")) 62 string="%s\n%s"%(string,fielddisplay(self,"lithosphere_shear_modulus","Lithosphere shear modulus [Pa]")) 63 string="%s\n%s"%(string,fielddisplay(self,"lithosphere_density","Lithosphere density [g/cm^-3]")) 64 string="%s\n%s"%(string,fielddisplay(self,"mantle_shear_modulus","Mantle shear modulus [Pa]")) 65 string="%s\n%s"%(string,fielddisplay(self,"mantle_density","Mantle density [g/cm^-3]")) 66 string="%s\n%s"%(string,fielddisplay(self,"earth_density","Mantle density [kg/m^-3]")) 67 68 return string 69 #}}} 70 def extrude(self,md): # {{{ 71 self.rheology_E=project3d(md,'vector',self.rheology_E,'type','node') 72 self.rheology_B=project3d(md,'vector',self.rheology_B,'type','node') 73 self.rheology_n=project3d(md,'vector',self.rheology_n,'type','element') 74 return self 75 #}}} 76 def setdefaultparameters(self): # {{{ 77 #ice density (kg/m^3) 78 self.rho_ice=917. 79 80 #ocean water density (kg/m^3) 81 self.rho_water=1023. 82 83 #fresh water density (kg/m^3) 84 self.rho_freshwater=1000. 85 86 #water viscosity (N.s/m^2) 87 self.mu_water=0.001787 88 89 #ice heat capacity cp (J/kg/K) 90 self.heatcapacity=2093. 91 92 #ice latent heat of fusion L (J/kg) 93 self.latentheat=3.34*10**5 94 95 #ice thermal conductivity (W/m/K) 96 self.thermalconductivity=2.4 97 98 #temperate ice thermal conductivity (W/m/K) 99 self.temperateiceconductivity=0.24 100 101 #the melting point of ice at 1 atmosphere of pressure in K 102 self.meltingpoint=273.15 103 104 #rate of change of melting point with pressure (K/Pa) 105 self.beta=9.8*10**-8 106 107 #mixed layer (ice-water interface) heat capacity (J/kg/K) 108 self.mixed_layer_capacity=3974. 109 110 #thermal exchange velocity (ice-water interface) (m/s) 111 self.thermal_exchange_velocity=1.00*10**-4 112 113 #Rheology law: what is the temperature dependence of B with T 114 #available: none, paterson and arrhenius 115 self.rheology_law='Paterson' 116 117 # GIA: 118 self.lithosphere_shear_modulus = 6.7*10**10 # (Pa) 119 self.lithosphere_density = 3.32 # (g/cm^-3) 120 self.mantle_shear_modulus = 1.45*10**11 # (Pa) 121 self.mantle_density = 3.34 # (g/cm^-3) 122 123 #SLR 124 self.earth_density= 5512 #average density of the Earth, (kg/m^3) 125 126 return self 127 #}}} 128 def checkconsistency(self,md,solution,analyses): # {{{ 129 md = checkfield(md,'fieldname','materials.rho_ice','>',0) 130 md = checkfield(md,'fieldname','materials.rho_water','>',0) 131 md = checkfield(md,'fieldname','materials.rho_freshwater','>',0) 132 md = checkfield(md,'fieldname','materials.mu_water','>',0) 133 md = checkfield(md,'fieldname','materials.rheology_E','>',0,'timeseries',1,'NaN',1,'Inf',1) 134 md = checkfield(md,'fieldname','materials.rheology_B','>',0,'timeseries',1,'NaN',1,'Inf',1) 135 md = checkfield(md,'fieldname','materials.rheology_n','>',0,'size',[md.mesh.numberofelements]) 136 md = checkfield(md,'fieldname','materials.rheology_law','values',['None','BuddJacka','Cuffey','CuffeyTemperate','Paterson','Arrhenius','LliboutryDuval']) 137 138 if 'GiaAnalysis' in analyses: 139 md = checkfield(md,'fieldname','materials.lithosphere_shear_modulus','>',0,'numel',1) 140 md = checkfield(md,'fieldname','materials.lithosphere_density','>',0,'numel',1) 141 md = checkfield(md,'fieldname','materials.mantle_shear_modulus','>',0,'numel',1) 142 md = checkfield(md,'fieldname','materials.mantle_density','>',0,'numel',1) 143 if 'SealevelriseAnalysis' in analyses: 144 md = checkfield(md,'fieldname','materials.earth_density','>',0,'numel',1) 145 return md 146 # }}} 147 def marshall(self,prefix,md,fid): # {{{ 148 WriteData(fid,prefix,'name','md.materials.type','data',4,'format','Integer') 149 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_ice','format','Double') 150 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_water','format','Double') 151 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_freshwater','format','Double') 152 WriteData(fid,prefix,'object',self,'class','materials','fieldname','mu_water','format','Double') 153 WriteData(fid,prefix,'object',self,'class','materials','fieldname','heatcapacity','format','Double') 154 WriteData(fid,prefix,'object',self,'class','materials','fieldname','latentheat','format','Double') 155 WriteData(fid,prefix,'object',self,'class','materials','fieldname','thermalconductivity','format','Double') 156 WriteData(fid,prefix,'object',self,'class','materials','fieldname','temperateiceconductivity','format','Double') 157 WriteData(fid,prefix,'object',self,'class','materials','fieldname','meltingpoint','format','Double') 158 WriteData(fid,prefix,'object',self,'class','materials','fieldname','beta','format','Double') 159 WriteData(fid,prefix,'object',self,'class','materials','fieldname','mixed_layer_capacity','format','Double') 160 WriteData(fid,prefix,'object',self,'class','materials','fieldname','thermal_exchange_velocity','format','Double') 161 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_E','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts) 162 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts) 163 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_n','format','DoubleMat','mattype',2) 164 WriteData(fid,prefix,'data',self.rheology_law,'name','md.materials.rheology_law','format','String') 165 166 WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_shear_modulus','format','Double') 167 WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_density','format','Double','scale',10^3) 168 WriteData(fid,prefix,'object',self,'class','materials','fieldname','mantle_shear_modulus','format','Double') 169 WriteData(fid,prefix,'object',self,'class','materials','fieldname','mantle_density','format','Double','scale',10^3) 170 WriteData(fid,prefix,'object',self,'class','materials','fieldname','earth_density','format','Double') 171 # }}} -
../trunk-jpl/src/m/classes/amr.py
27 27 self.deviatoricerror_resolution= 0. 28 28 self.deviatoricerror_threshold = 0. 29 29 self.deviatoricerror_maximum = 0. 30 self.restart=0. 30 31 #set defaults 31 32 self.setdefaultparameters() 32 33 #}}} … … 47 48 string="%s\n%s"%(string,fielddisplay(self,"deviatoricerror_resolution","element length when deviatoric stress error estimator is used")) 48 49 string="%s\n%s"%(string,fielddisplay(self,"deviatoricerror_threshold","maximum threshold deviatoricstress error permitted")) 49 50 string="%s\n%s"%(string,fielddisplay(self,"deviatoricerror_maximum","maximum deviatoricstress error permitted")) 51 string="%s\n%s"%(string,fielddisplay(self,'restart',['indicates if ReMesh() will call before first time step'])) 50 52 return string 51 53 #}}} 52 54 def setdefaultparameters(self): # {{{ … … 66 68 self.deviatoricerror_resolution= 500. 67 69 self.deviatoricerror_threshold = 0 68 70 self.deviatoricerror_maximum = 0 71 self.restart = 0. 69 72 return self 70 73 #}}} 71 74 def checkconsistency(self,md,solution,analyses): # {{{ … … 83 86 md = checkfield(md,'fieldname','amr.deviatoricerror_resolution','numel',[1],'>',0,'<',self.hmax,'NaN',1); 84 87 md = checkfield(md,'fieldname','amr.deviatoricerror_threshold','numel',[1],'>=',0,'<=',1,'NaN',1); 85 88 md = checkfield(md,'fieldname','amr.deviatoricerror_maximum','numel',[1],'>=',0,'NaN',1,'Inf',1); 89 md = checkfield(md,'fieldname','amr.restart','numel',[1],'>=',0,'<=',1,'NaN',1) 86 90 return md 87 91 # }}} 88 92 def marshall(self,prefix,md,fid): # {{{ … … 103 107 WriteData(fid,prefix,'object',self,'fieldname','deviatoricerror_resolution','format','Double'); 104 108 WriteData(fid,prefix,'object',self,'fieldname','deviatoricerror_threshold','format','Double'); 105 109 WriteData(fid,prefix,'object',self,'fieldname','deviatoricerror_maximum','format','Double'); 110 WriteData(fid,prefix,'object',self,'class','amr','fieldname','restart','format','Integer') 106 111 # }}} -
../trunk-jpl/src/m/classes/matestar.py
1 import numpy as np 2 from fielddisplay import fielddisplay 3 from project3d import project3d 4 from checkfield import checkfield 5 from WriteData import WriteData 6 7 class matestar(object): 8 """ 9 matestar class definition 10 11 Usage: 12 matestar=matestar() 13 """ 14 15 def __init__(self): # {{{ 16 17 rho_ice = 0. 18 rho_water = 0. 19 rho_freshwater = 0. 20 mu_water = 0. 21 heatcapacity = 0. 22 latentheat = 0. 23 thermalconductivity = 0. 24 temperateiceconductivity = 0. 25 meltingpoint = 0. 26 beta = 0. 27 mixed_layer_capacity = 0. 28 thermal_exchange_velocity = 0. 29 rheology_B = float('NaN') 30 rheology_Ec = float('NaN') 31 rheology_Es = float('NaN') 32 rheology_law = '' 33 34 #giaivins: 35 lithosphere_shear_modulus = 0. 36 lithosphere_density = 0. 37 mantle_shear_modulus = 0. 38 mantle_density = 0. 39 40 #slr 41 earth_density = 0 42 43 #set default parameters: 44 self.setdefaultparameters() 45 #}}} 46 def __repr__(self): # {{{ 47 string=" Materials:" 48 49 string="%s\n%s"%(string,fielddisplay(self,'rho_ice','ice density [kg/m^3]')) 50 string="%s\n%s"%(string,fielddisplay(self,'rho_water','ocean water density [kg/m^3]')) 51 string="%s\n%s"%(string,fielddisplay(self,'rho_freshwater','fresh water density [kg/m^3]')) 52 string="%s\n%s"%(string,fielddisplay(self,'mu_water','water viscosity [N s/m^2]')) 53 string="%s\n%s"%(string,fielddisplay(self,'heatcapacity','heat capacity [J/kg/K]')) 54 string="%s\n%s"%(string,fielddisplay(self,'thermalconductivity',['ice thermal conductivity [W/m/K]'])) 55 string="%s\n%s"%(string,fielddisplay(self,'temperateiceconductivity','temperate ice thermal conductivity [W/m/K]')) 56 string="%s\n%s"%(string,fielddisplay(self,'meltingpoint','melting point of ice at 1atm in K')) 57 string="%s\n%s"%(string,fielddisplay(self,'latentheat','latent heat of fusion [J/kg]')) 58 string="%s\n%s"%(string,fielddisplay(self,'beta','rate of change of melting point with pressure [K/Pa]')) 59 string="%s\n%s"%(string,fielddisplay(self,'mixed_layer_capacity','mixed layer capacity [W/kg/K]')) 60 string="%s\n%s"%(string,fielddisplay(self,'thermal_exchange_velocity','thermal exchange velocity [m/s]')) 61 string="%s\n%s"%(string,fielddisplay(self,'rheology_B','flow law parameter [Pa/s^(1/3)]')) 62 string="%s\n%s"%(string,fielddisplay(self,'rheology_Ec','compressive enhancement factor')) 63 string="%s\n%s"%(string,fielddisplay(self,'rheology_Es','shear enhancement factor')) 64 string="%s\n%s"%(string,fielddisplay(self,'rheology_law',['law for the temperature dependance of the rheology: ''None'', ''BuddJacka'', ''Cuffey'', ''CuffeyTemperate'', ''Paterson'', ''Arrhenius'' or ''LliboutryDuval'''])) 65 string="%s\n%s"%(string,fielddisplay(self,'lithosphere_shear_modulus','Lithosphere shear modulus [Pa]')) 66 string="%s\n%s"%(string,fielddisplay(self,'lithosphere_density','Lithosphere density [g/cm^-3]')) 67 string="%s\n%s"%(string,fielddisplay(self,'mantle_shear_modulus','Mantle shear modulus [Pa]')) 68 string="%s\n%s"%(string,fielddisplay(self,'mantle_density','Mantle density [g/cm^-3]')) 69 string="%s\n%s"%(string,fielddisplay(self,'earth_density','Mantle density [kg/m^-3]')) 70 71 return string 72 #}}} 73 def extrude(self,md): # {{{ 74 self.rheology_B=project3d(md,'vector',self.rheology_B,'type','node') 75 self.rheology_Ec=project3d(md,'vector',self.rheology_Ec,'type','node') 76 self.rheology_Es=project3d(md,'vector',self.rheology_Es,'type','node') 77 return self 78 #}}} 79 def setdefaultparameters(self): # {{{ 80 #ice density (kg/m^3) 81 self.rho_ice=917. 82 83 #ocean water density (kg/m^3) 84 self.rho_water=1023. 85 86 #fresh water density (kg/m^3) 87 self.rho_freshwater=1000. 88 89 #water viscosity (N.s/m^2) 90 self.mu_water=0.001787 91 92 #ice heat capacity cp (J/kg/K) 93 self.heatcapacity=2093. 94 95 #ice latent heat of fusion L (J/kg) 96 self.latentheat=3.34*10**5 97 98 #ice thermal conductivity (W/m/K) 99 self.thermalconductivity=2.4 100 101 #wet ice thermal conductivity (W/m/K) 102 self.temperateiceconductivity=.24 103 104 #the melting point of ice at 1 atmosphere of pressure in K 105 self.meltingpoint=273.15 106 107 #rate of change of melting point with pressure (K/Pa) 108 self.beta=9.8*10**-8 109 110 #mixed layer (ice-water interface) heat capacity (J/kg/K) 111 self.mixed_layer_capacity=3974. 112 113 #thermal exchange velocity (ice-water interface) (m/s) 114 self.thermal_exchange_velocity=1.00*10**-4 115 116 #Rheology law: what is the temperature dependence of B with T 117 #available: none, paterson and arrhenius 118 self.rheology_law='Paterson' 119 120 # GIA: 121 self.lithosphere_shear_modulus = 6.7*10**10 # (Pa) 122 self.lithosphere_density = 3.32 # (g/cm^-3) 123 self.mantle_shear_modulus = 1.45*10**11 # (Pa) 124 self.mantle_density = 3.34 # (g/cm^-3) 125 126 #SLR 127 self.earth_density= 5512 # average density of the Earth, (kg/m^3) 128 129 return self 130 #}}} 131 def checkconsistency(self,md,solution,analyses): # {{{ 132 md = checkfield(md,'fieldname','materials.rho_ice','>',0) 133 md = checkfield(md,'fieldname','materials.rho_water','>',0) 134 md = checkfield(md,'fieldname','materials.rho_freshwater','>',0) 135 md = checkfield(md,'fieldname','materials.mu_water','>',0) 136 md = checkfield(md,'fieldname','materials.rheology_B','>',0,'size',[md.mesh.numberofvertices],'NaN',1,'Inf',1) 137 md = checkfield(md,'fieldname','materials.rheology_Ec','>',0,'size',[md.mesh.numberofvertices],'NaN',1,'Inf',1) 138 md = checkfield(md,'fieldname','materials.rheology_Es','>',0,'size',[md.mesh.numberofvertices],'NaN',1,'Inf',1) 139 md = checkfield(md,'fieldname','materials.rheology_law','values',['None','BuddJacka', 'Cuffey','CuffeyTemperate','Paterson','Arrhenius','LliboutryDuval']) 140 141 if 'GiaAnalysis' in analyses: 142 md = checkfield(md,'fieldname','materials.lithosphere_shear_modulus','>',0,'numel',1) 143 md = checkfield(md,'fieldname','materials.lithosphere_density','>',0,'numel',1) 144 md = checkfield(md,'fieldname','materials.mantle_shear_modulus','>',0,'numel',1) 145 md = checkfield(md,'fieldname','materials.mantle_density','>',0,'numel',1) 146 if 'SealevelriseAnalysis' in analyses: 147 md = checkfield(md,'fieldname','materials.earth_density','>',0,'numel',1) 148 149 return md 150 # }}} 151 def marshall(self,prefix,md,fid): # {{{ 152 WriteData(fid,prefix,'name','md.materials.type','data',2,'format','Integer') 153 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_ice','format','Double') 154 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_water','format','Double') 155 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rho_freshwater','format','Double') 156 WriteData(fid,prefix,'object',self,'class','materials','fieldname','mu_water','format','Double') 157 WriteData(fid,prefix,'object',self,'class','materials','fieldname','heatcapacity','format','Double') 158 WriteData(fid,prefix,'object',self,'class','materials','fieldname','latentheat','format','Double') 159 WriteData(fid,prefix,'object',self,'class','materials','fieldname','thermalconductivity','format','Double') 160 WriteData(fid,prefix,'object',self,'class','materials','fieldname','temperateiceconductivity','format','Double') 161 WriteData(fid,prefix,'object',self,'class','materials','fieldname','meltingpoint','format','Double') 162 WriteData(fid,prefix,'object',self,'class','materials','fieldname','beta','format','Double') 163 WriteData(fid,prefix,'object',self,'class','materials','fieldname','mixed_layer_capacity','format','Double') 164 WriteData(fid,prefix,'object',self,'class','materials','fieldname','thermal_exchange_velocity','format','Double') 165 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_B','format','DoubleMat','mattype',1) 166 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_Ec','format','DoubleMat','mattype',1) 167 WriteData(fid,prefix,'object',self,'class','materials','fieldname','rheology_Es','format','DoubleMat','mattype',1) 168 WriteData(fid,prefix,'data',self.rheology_law,'name','md.materials.rheology_law','format','String') 169 170 WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_shear_modulus','format','Double') 171 WriteData(fid,prefix,'object',self,'class','materials','fieldname','lithosphere_density','format','Double','scale',10^3) 172 WriteData(fid,prefix,'object',self,'class','materials','fieldname','mantle_shear_modulus','format','Double') 173 WriteData(fid,prefix,'object',self,'class','materials','fieldname','mantle_density','format','Double','scale',10**3) 174 WriteData(fid,prefix,'object',self,'class','materials','fieldname','earth_density','format','Double') 175 # }}} -
../trunk-jpl/src/m/classes/frictionsommers.py
1 from fielddisplay import fielddisplay 2 from project3d import project3d 3 from checkfield import checkfield 4 from WriteData import WriteData 5 6 class frictionsommers(object): 7 """ 8 FRICTIONSOMMERS class definition 9 10 Usage: 11 friction=frictionsommers() 12 """ 13 14 def __init__(self,md): # {{{ 15 self.coefficient = md.friction.coefficient 16 #set defaults 17 self.setdefaultparameters() 18 19 #}}} 20 def __repr__(self): # {{{ 21 string="Basal shear stress parameters: Sigma_b = coefficient^2 * Neff * u_b\n(effective stress Neff=rho_ice*g*thickness+rho_water*g*(head-b))" 22 23 string="%s\n%s"%(string,fielddisplay(self,"coefficient","friction coefficient [SI]")) 24 return string 25 #}}} 26 def extrude(self,md): # {{{ 27 self.coefficient=project3d(md,'vector',self.coefficient,'type','node','layer',1) 28 return self 29 #}}} 30 def setdefaultparameters(self): # {{{ 31 return self 32 #}}} 33 def checkconsistency(self,md,solution,analyses): # {{{ 34 35 #Early return 36 if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses: 37 return md 38 39 md = checkfield(md,'fieldname','friction.coefficient','timeseries',1,'NaN',1,'Inf',1) 40 return md 41 42 # }}} 43 def marshall(self,prefix,md,fid): # {{{ 44 yts=md.constants.yts 45 WriteData(fid,prefix,'name','md.friction.law','data',8,'format','Integer') 46 WriteData(fid,prefix,'object',self,'fieldname','coefficient','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts) 47 # }}} -
../trunk-jpl/src/m/classes/SMBgemb.py
1 import numpy as np 2 from fielddisplay import fielddisplay 3 from checkfield import checkfield 4 from WriteData import WriteData 5 from project3d import project3d 6 7 class SMBgemb(object): 8 """ 9 SMBgemb Class definition 10 11 Usage: 12 SMB = SMBgemb() 13 """ 14 15 def __init__(self): # {{{ 16 #each one of these properties is a transient forcing to the GEMB model, loaded from meteorological data derived 17 #from an automatic weather stations (AWS). Each property is therefore a matrix, of size (numberofvertices x number 18 #of time steps. ) 19 20 #solution choices 21 #check these: 22 #isgraingrowth 23 #isalbedo 24 #isshortwave 25 #isthermal 26 #isaccumulation 27 #ismelt 28 #isdensification 29 #isturbulentflux 30 31 #inputs: 32 Ta = float('NaN') #2 m air temperature, in Kelvin 33 V = float('NaN') #wind speed (m/s-1) 34 dswrf = float('NaN') #downward shortwave radiation flux [W/m^2] 35 dlwrf = float('NaN') #downward longwave radiation flux [W/m^2] 36 P = float('NaN') #precipitation [mm w.e. / m^2] 37 eAir = float('NaN') #screen level vapor pressure [Pa] 38 pAir = float('NaN') #surface pressure [Pa] 39 40 Tmean = float('NaN') #mean annual temperature [K] 41 C = float('NaN') #mean annual snow accumulation [kg m-2 yr-1] 42 Tz = float('NaN') #height above ground at which temperature (T) was sampled [m] 43 Vz = float('NaN') #height above ground at which wind (V) eas sampled [m] 44 45 # Initialization of snow properties 46 Dzini = float('NaN') #cell depth (m) 47 Dini = float('NaN') #snow density (kg m-3) 48 Reini = float('NaN') #effective grain size (mm) 49 Gdnini = float('NaN') #grain dricity (0-1) 50 Gspini = float('NaN') #grain sphericity (0-1) 51 ECini = float('NaN') #evaporation/condensation (kg m-2) 52 Wini = float('NaN') #Water content (kg m-2) 53 Aini = float('NaN') #albedo (0-1) 54 Tini = float('NaN') #snow temperature (K) 55 Sizeini = float('NaN') #Number of layers 56 57 #settings: 58 aIdx = float('NaN') #method for calculating albedo and subsurface absorption (default is 1) 59 # 1: effective grain radius [Gardner & Sharp, 2009] 60 # 2: effective grain radius [Brun et al., 2009] 61 # 3: density and cloud amount [Greuell & Konzelmann, 1994] 62 # 4: exponential time decay & wetness [Bougamont & Bamber, 2005] 63 swIdx = float('NaN') # apply all SW to top grid cell (0) or allow SW to penetrate surface (1) (default 1) 64 65 denIdx = float('NaN') #densification model to use (default is 2): 66 # 1 = emperical model of Herron and Langway (1980) 67 # 2 = semi-emerical model of Anthern et al. (2010) 68 # 3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010) 69 # 4 = DO NOT USE: emperical model of Li and Zwally (2004) 70 # 5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008) 71 72 zTop = float('NaN') # depth over which grid length is constant at the top of the snopack (default 10) [m] 73 dzTop = float('NaN') # initial top vertical grid spacing (default .05) [m] 74 dzMin = float('NaN') # initial min vertical allowable grid spacing (default dzMin/2) [m] 75 zY = float('NaN') # strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)] 76 zMax = float('NaN') #initial max model depth (default is min(thickness,500)) [m] 77 zMin = float('NaN') #initial min model depth (default is min(thickness,30)) [m] 78 outputFreq = float('NaN') #output frequency in days (default is monthly, 30) 79 80 #specific albedo parameters: 81 #Method 1 and 2: 82 aSnow = float('NaN') # new snow albedo (0.64 - 0.89) 83 aIce = float('NaN') # range 0.27-0.58 for old snow 84 #Method 3: Radiation Correction Factors -> only used for met station data and Greuell & Konzelmann, 1994 albedo 85 cldFrac = float('NaN') # average cloud amount 86 #Method 4: additonal tuning parameters albedo as a funtion of age and water content (Bougamont et al., 2005) 87 t0wet = float('NaN') # time scale for wet snow (15-21.9) 88 t0dry = float('NaN') # warm snow timescale (30) 89 K = float('NaN') # time scale temperature coef. (7) 90 91 #densities: 92 InitDensityScaling = float('NaN') #initial scaling factor multiplying the density of ice, which describes the density of the snowpack. 93 94 requested_outputs = [] 95 96 #Several fields are missing from the standard GEMB model, which are capture intrinsically by ISSM. 97 #dateN: that's the last row of the above fields. 98 #dt: included in dateN. Not an input. 99 #elev: this is taken from the ISSM surface itself. 100 101 #}}} 102 def __repr__(self): # {{{ 103 #string = " surface forcings parameters:" 104 #string = "#s\n#s"%(string,fielddisplay(self,'mass_balance','surface mass balance [m/yr ice eq]')) 105 #string = "#s\n#s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested')) 106 string = ' surface forcings for SMB GEMB model :' 107 108 string="%s\n%s"%(string,fielddisplay(self,'issmbgradients','is smb gradients method activated (0 or 1, default is 0)')) 109 string = "%s\n%s"%(string,fielddisplay(self,'isgraingrowth','run grain growth module (default true)')) 110 string = "%s\n%s"%(string,fielddisplay(self,'isalbedo','run albedo module (default true)')) 111 string = "%s\n%s"%(string,fielddisplay(self,'isshortwave','run short wave module (default true)')) 112 string = "%s\n%s"%(string,fielddisplay(self,'isthermal','run thermal module (default true)')) 113 string = "%s\n%s"%(string,fielddisplay(self,'isaccumulation','run accumulation module (default true)')) 114 string = "%s\n%s"%(string,fielddisplay(self,'ismelt','run melting module (default true)')) 115 string = "%s\n%s"%(string,fielddisplay(self,'isdensification','run densification module (default true)')) 116 string = "%s\n%s"%(string,fielddisplay(self,'isturbulentflux','run turbulant heat fluxes module (default true)')) 117 string = "%s\n%s"%(string,fielddisplay(self,'Ta','2 m air temperature, in Kelvin')) 118 string = "%s\n%s"%(string,fielddisplay(self,'V','wind speed (m/s-1)')) 119 string = "%s\n%s"%(string,fielddisplay(self,'dlwrf','downward shortwave radiation flux [W/m^2]')) 120 string = "%s\n%s"%(string,fielddisplay(self,'dswrf','downward longwave radiation flux [W/m^2]')) 121 string = "%s\n%s"%(string,fielddisplay(self,'P','precipitation [mm w.e. / m^2]')) 122 string = "%s\n%s"%(string,fielddisplay(self,'eAir','screen level vapor pressure [Pa]')) 123 string = "%s\n%s"%(string,fielddisplay(self,'pAir','surface pressure [Pa]')) 124 string = "%s\n%s"%(string,fielddisplay(self,'Tmean','mean annual temperature [K]')) 125 string = "%s\n%s"%(string,fielddisplay(self,'C','mean annual snow accumulation [kg m-2 yr-1]')) 126 string = "%s\n%s"%(string,fielddisplay(self,'Tz','height above ground at which temperature (T) was sampled [m]')) 127 string = "%s\n%s"%(string,fielddisplay(self,'Vz','height above ground at which wind (V) eas sampled [m]')) 128 string = "%s\n%s"%(string,fielddisplay(self,'zTop','depth over which grid length is constant at the top of the snopack (default 10) [m]')) 129 string = "%s\n%s"%(string,fielddisplay(self,'dzTop','initial top vertical grid spacing (default .05) [m] ')) 130 string = "%s\n%s"%(string,fielddisplay(self,'dzMin','initial min vertical allowable grid spacing (default dzMin/2) [m] ')) 131 string = "%s\n%s"%(string,fielddisplay(self,'zMax','initial max model depth (default is min(thickness,500)) [m]')) 132 string = "%s\n%s"%(string,fielddisplay(self,'zMin','initial min model depth (default is min(thickness,30)) [m]')) 133 string = "%s\n%s"%(string,fielddisplay(self,'zY','strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)]')) 134 string = "%s\n%s"%(string,fielddisplay(self,'InitDensityScaling',['initial scaling factor multiplying the density of ice','which describes the density of the snowpack.'])) 135 string = "%s\n%s"%(string,fielddisplay(self,'outputFreq','output frequency in days (default is monthly, 30)')) 136 string = "%s\n%s"%(string,fielddisplay(self,'aIdx',['method for calculating albedo and subsurface absorption (default is 1)', 137 '1: effective grain radius [Gardner & Sharp, 2009]', 138 '2: effective grain radius [Brun et al., 2009]', 139 '3: density and cloud amount [Greuell & Konzelmann, 1994]', 140 '4: exponential time decay & wetness [Bougamont & Bamber, 2005]'])) 141 142 #snow properties init 143 string = "%s\n%s"%(string,fielddisplay(self,'Dzini','Initial cel depth when restart [m]')) 144 string = "%s\n%s"%(string,fielddisplay(self,'Dini','Initial snow density when restart [kg m-3]')) 145 string = "%s\n%s"%(string,fielddisplay(self,'Reini','Initial grain size when restart [mm]')) 146 string = "%s\n%s"%(string,fielddisplay(self,'Gdnini','Initial grain dricity when restart [-]')) 147 string = "%s\n%s"%(string,fielddisplay(self,'Gspini','Initial grain sphericity when restart [-]')) 148 string = "%s\n%s"%(string,fielddisplay(self,'ECini','Initial evaporation/condensation when restart [kg m-2]')) 149 string = "%s\n%s"%(string,fielddisplay(self,'Wini','Initial snow water content when restart [kg m-2]')) 150 string = "%s\n%s"%(string,fielddisplay(self,'Aini','Initial albedo when restart [-]')) 151 string = "%s\n%s"%(string,fielddisplay(self,'Tini','Initial snow temperature when restart [K]')) 152 string = "%s\n%s"%(string,fielddisplay(self,'Sizeini','Initial number of layers when restart [K]')) 153 154 #additional albedo parameters: 155 if type(self.aIdx) == list or type(self.aIdx) == type(np.array([1,2])) and (self.aIdx == [1,2] or (1 in self.aIdx and 2 in self.aIdx)): 156 string = "%s\n%s"%(string,fielddisplay(self,'aSnow','new snow albedo (0.64 - 0.89)')) 157 string = "%s\n%s"%(string,fielddisplay(self,'aIce','albedo of ice (0.27-0.58)')) 158 elif self.aIdx == 3: 159 string = "%s\n%s"%(string,fielddisplay(self,'cldFrac','average cloud amount')) 160 elif self.aIdx == 4: 161 string = "%s\n%s"%(string,fielddisplay(self,'t0wet','time scale for wet snow (15-21.9) [d]')) 162 string = "%s\n%s"%(string,fielddisplay(self,'t0dry','warm snow timescale (30) [d]')) 163 string = "%s\n%s"%(string,fielddisplay(self,'K','time scale temperature coef. (7) [d]')) 164 165 string = "%s\n%s"%(string,fielddisplay(self,'swIdx','apply all SW to top grid cell (0) or allow SW to penetrate surface (1) [default 1]')) 166 string = "%s\n%s"%(string,fielddisplay(self,'denIdx',['densification model to use (default is 2):', 167 '1 = emperical model of Herron and Langway (1980)', 168 '2 = semi-emerical model of Anthern et al. (2010)', 169 '3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010)', 170 '4 = DO NOT USE: emperical model of Li and Zwally (2004)', 171 '5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)'])) 172 string = "%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested')) 173 return string 174 #}}} 175 176 def extrude(self,md): # {{{ 177 178 self.Ta = project3d(md,'vector',self.Ta,'type','node') 179 self.V = project3d(md,'vector',self.V,'type','node') 180 self.dswrf = project3d(md,'vector',self.dswrf,'type','node') 181 self.dswrf = project3d(md,'vector',self.dswrf,'type','node') 182 self.P = project3d(md,'vector',self.P,'type','node') 183 self.eAir = project3d(md,'vector',self.eAir,'type','node') 184 self.pAir = project3d(md,'vector',self.pAir,'type','node') 185 return self 186 #}}} 187 def defaultoutputs(self,md): # {{{ 188 return ['SmbMassBalance'] 189 #}}} 190 191 def setdefaultparameters(self,mesh,geometry): # {{{ 192 self.isgraingrowth = 1 193 self.isalbedo = 1 194 self.isshortwave = 1 195 self.isthermal = 1 196 self.isaccumulation = 1 197 self.ismelt = 1 198 self.isdensification = 1 199 self.isturbulentflux = 1 200 201 self.aIdx = 1 202 self.swIdx = 1 203 self.denIdx = 2 204 self.zTop = 10*np.ones((mesh.numberofelements,)) 205 self.dzTop = .05* np.ones((mesh.numberofelements,)) 206 self.dzMin = self.dzTop/2 207 self.InitDensityScaling = 1.0 208 209 self.zMax = 250*np.ones((mesh.numberofelements,)) 210 self.zMin = 130*np.ones((mesh.numberofelements,)) 211 self.zY = 1.10*np.ones((mesh.numberofelements,)) 212 self.outputFreq = 30 213 214 #additional albedo parameters 215 self.aSnow = 0.85 216 self.aIce = 0.48 217 self.cldFrac = 0.1 218 self.t0wet = 15 219 self.t0dry = 30 220 self.K = 7 221 222 self.Dzini = 0.05*np.ones((mesh.numberofelements,2)) 223 self.Dini = 910.0*np.ones((mesh.numberofelements,2)) 224 self.Reini = 2.5*np.ones((mesh.numberofelements,2)) 225 self.Gdnini = 0.0*np.ones((mesh.numberofelements,2)) 226 self.Gspini = 0.0*np.ones((mesh.numberofelements,2)) 227 self.ECini = 0.0*np.ones((mesh.numberofelements,)) 228 self.Wini = 0.0*np.ones((mesh.numberofelements,2)) 229 self.Aini = self.aSnow*np.ones((mesh.numberofelements,2)) 230 self.Tini = 273.15*np.ones((mesh.numberofelements,2)) 231 # /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh). 232 # If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp 233 self.Sizeini = 2*np.ones((mesh.numberofelements,)) 234 #}}} 235 236 def checkconsistency(self,md,solution,analyses): # {{{ 237 238 md = checkfield(md,'fieldname','smb.isgraingrowth','values',[0,1]) 239 md = checkfield(md,'fieldname','smb.isalbedo','values',[0,1]) 240 md = checkfield(md,'fieldname','smb.isshortwave','values',[0,1]) 241 md = checkfield(md,'fieldname','smb.isthermal','values',[0,1]) 242 md = checkfield(md,'fieldname','smb.isaccumulation','values',[0,1]) 243 md = checkfield(md,'fieldname','smb.ismelt','values',[0,1]) 244 md = checkfield(md,'fieldname','smb.isdensification','values',[0,1]) 245 md = checkfield(md,'fieldname','smb.isturbulentflux','values',[0,1]) 246 247 md = checkfield(md,'fieldname','smb.Ta','timeseries',1,'NaN',1,'Inf',1,'>',273-100,'<',273+100) #-100/100 celsius min/max value 248 md = checkfield(md,'fieldname','smb.V','timeseries',1,'NaN',1,'Inf',1,'> = ',0,'<',45) #max 500 km/h 249 md = checkfield(md,'fieldname','smb.dswrf','timeseries',1,'NaN',1,'Inf',1,'> = ',0,'< = ',1400) 250 md = checkfield(md,'fieldname','smb.dlwrf','timeseries',1,'NaN',1,'Inf',1,'> = ',0) 251 md = checkfield(md,'fieldname','smb.P','timeseries',1,'NaN',1,'Inf',1,'> = ',0,'< = ',100) 252 md = checkfield(md,'fieldname','smb.eAir','timeseries',1,'NaN',1,'Inf',1) 253 254 md = checkfield(md,'fieldname','smb.Tmean','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'>',273-100,'<',273+100) #-100/100 celsius min/max value 255 md = checkfield(md,'fieldname','smb.C','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0) 256 md = checkfield(md,'fieldname','smb.Tz','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0,'< = ',5000) 257 md = checkfield(md,'fieldname','smb.Vz','size',[md.mesh.numberofelements],'NaN',1,'Inf',1,'> = ',0,'< = ',5000) 258 259 md = checkfield(md,'fieldname','smb.aIdx','NaN',1,'Inf',1,'values',[1,2,3,4]) 260 md = checkfield(md,'fieldname','smb.swIdx','NaN',1,'Inf',1,'values',[0,1]) 261 md = checkfield(md,'fieldname','smb.denIdx','NaN',1,'Inf',1,'values',[1,2,3,4,5]) 262 263 md = checkfield(md,'fieldname','smb.zTop','NaN',1,'Inf',1,'> = ',0) 264 md = checkfield(md,'fieldname','smb.dzTop','NaN',1,'Inf',1,'>',0) 265 md = checkfield(md,'fieldname','smb.dzMin','NaN',1,'Inf',1,'>',0) 266 md = checkfield(md,'fieldname','smb.zY','NaN',1,'Inf',1,'> = ',1) 267 md = checkfield(md,'fieldname','smb.outputFreq','NaN',1,'Inf',1,'>',0,'<',10*365) #10 years max 268 md = checkfield(md,'fieldname','smb.InitDensityScaling','NaN',1,'Inf',1,'> = ',0,'< = ',1) 269 270 if type(self.aIdx) == list or type(self.aIdx) == type(np.array([1,2])) and (self.aIdx == [1,2] or (1 in self.aIdx and 2 in self.aIdx)): 271 md = checkfield(md,'fieldname','smb.aSnow','NaN',1,'Inf',1,'> = ',.64,'< = ',.89) 272 md = checkfield(md,'fieldname','smb.aIce','NaN',1,'Inf',1,'> = ',.27,'< = ',.58) 273 elif self.aIdx == 3: 274 md = checkfield(md,'fieldname','smb.cldFrac','NaN',1,'Inf',1,'> = ',0,'< = ',1) 275 elif self.aIdx == 4: 276 md = checkfield(md,'fieldname','smb.t0wet','NaN',1,'Inf',1,'> = ',15,'< = ',21.9) 277 md = checkfield(md,'fieldname','smb.t0dry','NaN',1,'Inf',1,'> = ',30,'< = ',30) 278 md = checkfield(md,'fieldname','smb.K','NaN',1,'Inf',1,'> = ',7,'< = ',7) 279 280 281 #check zTop is < local thickness: 282 he = np.sum(md.geometry.thickness[md.mesh.elements-1],axis=1)/np.size(md.mesh.elements,1) 283 if np.any(he<self.zTop): 284 error('SMBgemb consistency check error: zTop should be smaller than local ice thickness') 285 286 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1) 287 return md 288 # }}} 289 290 def marshall(self,prefix,md,fid): # {{{ 291 292 yts = md.constants.yts 293 294 WriteData(fid,prefix,'name','md.smb.model','data',8,'format','Integer') 295 296 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isgraingrowth','format','Boolean') 297 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isalbedo','format','Boolean') 298 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isshortwave','format','Boolean') 299 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isthermal','format','Boolean') 300 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isaccumulation','format','Boolean') 301 WriteData(fid,prefix,'object',self,'class','smb','fieldname','ismelt','format','Boolean') 302 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isdensification','format','Boolean') 303 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isturbulentflux','format','Boolean') 304 305 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Ta','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) 306 WriteData(fid,prefix,'object',self,'class','smb','fieldname','V','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) 307 WriteData(fid,prefix,'object',self,'class','smb','fieldname','dswrf','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) 308 WriteData(fid,prefix,'object',self,'class','smb','fieldname','dlwrf','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) 309 WriteData(fid,prefix,'object',self,'class','smb','fieldname','P','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) 310 WriteData(fid,prefix,'object',self,'class','smb','fieldname','eAir','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) 311 WriteData(fid,prefix,'object',self,'class','smb','fieldname','pAir','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts) 312 313 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tmean','format','DoubleMat','mattype',2) 314 WriteData(fid,prefix,'object',self,'class','smb','fieldname','C','format','DoubleMat','mattype',2) 315 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tz','format','DoubleMat','mattype',2) 316 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Vz','format','DoubleMat','mattype',2) 317 WriteData(fid,prefix,'object',self,'class','smb','fieldname','zTop','format','DoubleMat','mattype',2) 318 WriteData(fid,prefix,'object',self,'class','smb','fieldname','dzTop','format','DoubleMat','mattype',2) 319 WriteData(fid,prefix,'object',self,'class','smb','fieldname','dzMin','format','DoubleMat','mattype',2) 320 WriteData(fid,prefix,'object',self,'class','smb','fieldname','zY','format','DoubleMat','mattype',2) 321 WriteData(fid,prefix,'object',self,'class','smb','fieldname','zMax','format','DoubleMat','mattype',2) 322 WriteData(fid,prefix,'object',self,'class','smb','fieldname','zMin','format','DoubleMat','mattype',2) 323 324 WriteData(fid,prefix,'object',self,'class','smb','fieldname','aIdx','format','Integer') 325 WriteData(fid,prefix,'object',self,'class','smb','fieldname','swIdx','format','Integer') 326 WriteData(fid,prefix,'object',self,'class','smb','fieldname','denIdx','format','Integer') 327 WriteData(fid,prefix,'object',self,'class','smb','fieldname','InitDensityScaling','format','Double') 328 WriteData(fid,prefix,'object',self,'class','smb','fieldname','outputFreq','format','Double') 329 WriteData(fid,prefix,'object',self,'class','smb','fieldname','aSnow','format','Double') 330 WriteData(fid,prefix,'object',self,'class','smb','fieldname','aIce','format','Double') 331 WriteData(fid,prefix,'object',self,'class','smb','fieldname','cldFrac','format','Double') 332 WriteData(fid,prefix,'object',self,'class','smb','fieldname','t0wet','format','Double') 333 WriteData(fid,prefix,'object',self,'class','smb','fieldname','t0dry','format','Double') 334 WriteData(fid,prefix,'object',self,'class','smb','fieldname','K','format','Double') 335 336 #snow properties init 337 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Dzini','format','DoubleMat','mattype',3) 338 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Dini','format','DoubleMat','mattype',3) 339 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Reini','format','DoubleMat','mattype',3) 340 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Gdnini','format','DoubleMat','mattype',3) 341 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Gspini','format','DoubleMat','mattype',3) 342 WriteData(fid,prefix,'object',self,'class','smb','fieldname','ECini','format','DoubleMat','mattype',2) 343 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Wini','format','DoubleMat','mattype',3) 344 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Aini','format','DoubleMat','mattype',3) 345 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tini','format','DoubleMat','mattype',3) 346 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Sizeini','format','IntMat','mattype',2) 347 348 #figure out dt from forcings: 349 time = self.Ta[-1] #assume all forcings are on the same time step 350 dtime = np.diff(time,n=1,axis=0) 351 dt = min(dtime) / yts 352 353 WriteData(fid,prefix,'data',dt,'name','md.smb.dt','format','Double','scale',yts) 354 355 # Check if smb_dt goes evenly into transient core time step 356 if (md.timestepping.time_step % dt >= 1e-10): 357 error('smb_dt/dt = #f. The number of SMB time steps in one transient core time step has to be an an integer',md.timestepping.time_step/dt) 358 359 #process requested outputs 360 outputs = self.requested_outputs 361 indices = [i for i, x in enumerate(outputs) if x == 'default'] 362 if len(indices) > 0: 363 outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:] 364 outputs =outputscopy 365 366 WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray') 367 # }}} 368 -
../trunk-jpl/src/m/classes/taoinversion.py
5 5 from fielddisplay import fielddisplay 6 6 from IssmConfig import IssmConfig 7 7 from marshallcostfunctions import marshallcostfunctions 8 from supportedcontrols import * 9 from supportedcostfunctions import * 8 10 9 10 class taoinversion: 11 class taoinversion(object): 11 12 def __init__(self): 12 iscontrol = 0 13 incomplete_adjoint = 0 14 control_parameters = float('NaN') 15 maxsteps = 0 16 maxiter = 0 17 fatol = 0 18 frtol = 0 19 gatol = 0 20 grtol = 0 21 gttol = 0 22 algorithm = '' 23 cost_functions = float('NaN') 24 cost_functions_coefficients = float('NaN') 25 min_parameters = float('NaN') 26 max_parameters = float('NaN') 27 vx_obs = float('NaN') 28 vy_obs = float('NaN') 29 vz_obs = float('NaN') 30 vel_obs = float('NaN') 31 thickness_obs = float('NaN') 32 surface_obs = float('NaN') 13 self.iscontrol = 0 14 self.incomplete_adjoint = 0 15 self.control_parameters = float('NaN') 16 self.maxsteps = 0 17 self.maxiter = 0 18 self.fatol = 0 19 self.frtol = 0 20 self.gatol = 0 21 self.grtol = 0 22 self.gttol = 0 23 self.algorithm = '' 24 self.cost_functions = float('NaN') 25 self.cost_functions_coefficients = float('NaN') 26 self.min_parameters = float('NaN') 27 self.max_parameters = float('NaN') 28 self.vx_obs = float('NaN') 29 self.vy_obs = float('NaN') 30 self.vz_obs = float('NaN') 31 self.vel_obs = float('NaN') 32 self.thickness_obs = float('NaN') 33 self.surface_obs = float('NaN') 34 self.setdefaultparameters() 33 35 34 36 def __repr__(self): 35 37 string = ' taoinversion parameters:' … … 97 99 98 100 #several responses can be used: 99 101 self.cost_functions=101; 100 101 102 return self 102 103 103 104 def extrude(self,md): … … 118 119 return self 119 120 120 121 def checkconsistency(self,md,solution,analyses): 121 if not self. control:122 if not self.iscontrol: 122 123 return md 123 124 if not IssmConfig('_HAVE_TAO_')[0]: 124 125 md = checkmessage(md,['TAO has not been installed, ISSM needs to be reconfigured and recompiled with TAO']) 125 126 126 127 127 num_controls= np. numel(md.inversion.control_parameters)128 num_costfunc= np.size(md.inversion.cost_functions ,2)128 num_controls= np.size(md.inversion.control_parameters) 129 num_costfunc= np.size(md.inversion.cost_functions) 129 130 130 131 md = checkfield(md,'fieldname','inversion.iscontrol','values',[0, 1]) 131 md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0, 132 md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0,1]) 132 133 md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols()) 133 134 md = checkfield(md,'fieldname','inversion.maxsteps','numel',1,'>=',0) 134 135 md = checkfield(md,'fieldname','inversion.maxiter','numel',1,'>=',0) … … 142 143 PETSCMAJOR = IssmConfig('_PETSC_MAJOR_')[0] 143 144 PETSCMINOR = IssmConfig('_PETSC_MINOR_')[0] 144 145 if(PETSCMAJOR>3 or (PETSCMAJOR==3 and PETSCMINOR>=5)): 145 md = checkfield(md,'fieldname','inversion.algorithm','values', {'blmvm','cg','lmvm'})146 md = checkfield(md,'fieldname','inversion.algorithm','values',['blmvm','cg','lmvm']) 146 147 else: 147 md = checkfield(md,'fieldname','inversion.algorithm','values', {'tao_blmvm','tao_cg','tao_lmvm'})148 md = checkfield(md,'fieldname','inversion.algorithm','values',['tao_blmvm','tao_cg','tao_lmvm']) 148 149 149 150 150 md = checkfield(md,'fieldname','inversion.cost_functions','size', [1,num_costfunc],'values',supportedcostfunctions())151 md = checkfield(md,'fieldname','inversion.cost_functions','size', [num_costfunc],'values',supportedcostfunctions()) 151 152 md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices, num_costfunc],'>=',0) 152 153 md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices, num_controls]) 153 154 md = checkfield(md,'fieldname','inversion.max_parameters','size',[md.mesh.numberofvertices, num_controls]) … … 161 162 md = checkfield(md,'fieldname','inversion.vx_obs','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1) 162 163 md = checkfield(md,'fieldname','inversion.vy_obs','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1) 163 164 164 def marshall(self, md,fid):165 def marshall(self,prefix,md,fid): 165 166 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 167 yts=md.constants.yts; 168 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','iscontrol','format','Boolean') 169 WriteData(fid,prefix,'name','md.inversion.type','data',1,'format','Integer') 170 if not self.iscontrol: 171 return 172 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','incomplete_adjoint','format','Boolean') 173 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','maxsteps','format','Integer') 174 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','maxiter','format','Integer') 175 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','fatol','format','Double') 176 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','frtol','format','Double') 177 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','gatol','format','Double') 178 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','grtol','format','Double') 179 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','gttol','format','Double') 180 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','algorithm','format','String') 181 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1) 182 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3) 183 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3) 184 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts) 185 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts) 186 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts) 187 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',1) 188 WriteData(fid,prefix,'object',self,'class','inversion','fieldname','surface_obs','format','DoubleMat','mattype',1) 188 189 189 190 num_control_parameters = np.numel(self.control_parameters)191 192 190 #process control parameters 191 num_control_parameters = np.size(self.control_parameters) 192 WriteData(fid,prefix,'object',self,'fieldname','control_parameters','format','StringArray') 193 WriteData(fid,prefix,'data',num_control_parameters,'name','md.inversion.num_control_parameters','format','Integer') 193 194 194 195 num_cost_functions = np.size(self.cost_functions,2)196 197 198 195 #process cost functions 196 num_cost_functions = np.size(self.cost_functions) 197 data= marshallcostfunctions(self.cost_functions) 198 WriteData(fid,prefix,'data',data,'name','md.inversion.cost_functions','format','StringArray') 199 WriteData(fid,prefix,'data',num_cost_functions,'name','md.inversion.num_cost_functions','format','Integer') -
../trunk-jpl/src/m/classes/SMBgemb.m
357 357 dt=min(dtime); 358 358 359 359 WriteData(fid,prefix,'data',dt,'name','md.smb.dt','format','Double','scale',yts); 360 360 361 361 % Check if smb_dt goes evenly into transient core time step 362 362 if (mod(md.timestepping.time_step,dt) >= 1e-10) 363 363 error('smb_dt/dt = %f. The number of SMB time steps in one transient core time step has to be an an integer',md.timestepping.time_step/dt); -
../trunk-jpl/src/m/classes/plumebasalforcings.py
1 from fielddisplay import fielddisplay 2 from checkfield import checkfield 3 from WriteData import WriteData 4 from project3d import project3d 5 6 class plumebasalforcings(object): 7 ''' 8 PLUME BASAL FORCINGS class definition 9 10 Usage: 11 plumebasalforcings=plumebasalforcings() 12 ''' 13 14 def __init__(self): # {{{ 15 floatingice_melting_rate = float('NaN') 16 groundedice_melting_rate = float('NaN') 17 mantleconductivity = float('NaN') 18 nusselt = float('NaN') 19 dtbg = float('NaN') 20 plumeradius = float('NaN') 21 topplumedepth = float('NaN') 22 bottomplumedepth = float('NaN') 23 plumex = float('NaN') 24 plumey = float('NaN') 25 crustthickness = float('NaN') 26 uppercrustthickness = float('NaN') 27 uppercrustheat = float('NaN') 28 lowercrustheat = float('NaN') 29 30 self.setdefaultparameters() 31 #}}} 32 33 def __repr__(self): # {{{ 34 print ' mantle plume basal melt parameterization:' 35 36 string="%s\n%s"%(string,fielddisplay(self,'groundedice_melting_rate','basal melting rate (positive if melting) [m/yr]')) 37 string="%s\n%s"%(string,fielddisplay(self,'floatingice_melting_rate','basal melting rate (positive if melting) [m/yr]')) 38 string="%s\n%s"%(string,fielddisplay(self,'mantleconductivity','mantle heat conductivity [W/m^3]')) 39 string="%s\n%s"%(string,fielddisplay(self,'nusselt','nusselt number, ratio of mantle to plume [1]')) 40 string="%s\n%s"%(string,fielddisplay(self,'dtbg','background temperature gradient [degree/m]')) 41 string="%s\n%s"%(string,fielddisplay(self,'plumeradius','radius of the mantle plume [m]')) 42 string="%s\n%s"%(string,fielddisplay(self,'topplumedepth','depth of the mantle plume top below the crust [m]')) 43 string="%s\n%s"%(string,fielddisplay(self,'bottomplumedepth','depth of the mantle plume base below the crust [m]')) 44 string="%s\n%s"%(string,fielddisplay(self,'plumex','x coordinate of the center of the plume [m]')) 45 string="%s\n%s"%(string,fielddisplay(self,'plumey','y coordinate of the center of the plume [m]')) 46 string="%s\n%s"%(string,fielddisplay(self,'crustthickness','thickness of the crust [m]')) 47 string="%s\n%s"%(string,fielddisplay(self,'uppercrustthickness','thickness of the upper crust [m]')) 48 string="%s\n%s"%(string,fielddisplay(self,'uppercrustheat','volumic heat of the upper crust [w/m^3]')) 49 string="%s\n%s"%(string,fielddisplay(self,'lowercrustheat','volumic heat of the lowercrust [w/m^3]')) 50 51 return string 52 #}}} 53 54 def initialize(self,md): #{{{ 55 if np.all(np.isnan(self.groundedice_melting_rate)): 56 self.groundedice_melting_rate=np.zeros((md.mesh.numberofvertices,)) 57 print ' no basalforcings.groundedice_melting_rate specified: values set as zero' 58 if np.all(np.isnan(self.floatingice_melting_rate)): 59 self.floatingice_melting_rate=np.zeros((md.mesh.numberofvertices,)) 60 print ' no basalforcings.floatingice_melting_rate specified: values set as zero' 61 return 62 #}}} 63 64 def extrude(self,md): # {{{ 65 self.groundedice_melting_rate=project3d(md,'vector',self.groundedice_melting_rate,'type','node','layer',1); 66 self.floatingice_melting_rate=project3d(md,'vector',self.floatingice_melting_rate,'type','node','layer',1); 67 return self 68 #}}} 69 70 def setdefaultparameters(self): # {{{ 71 #default values for melting parameterization 72 self.mantleconductivity = 2.2 73 self.nusselt = 300 74 self.dtbg = 11/1000. 75 self.plumeradius = 100000 76 self.topplumedepth = 10000 77 self.bottomplumedepth = 1050000 78 self.crustthickness = 30000 79 self.uppercrustthickness = 14000 80 self.uppercrustheat = 1.7*10**-6 81 self.lowercrustheat = 0.4*10**-6 82 return self 83 #}}} 84 85 def checkconsistency(self,md,solution,analyses): # {{{ 86 if 'MasstransportAnalysis' in analyses and not (solution == 'TransientSolution' and md.transient.ismasstransport==0): 87 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1) 88 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,'timeseries',1) 89 if 'BalancethicknessAnalysis' in analyses: 90 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'size',[md.mesh.numberofvertices]) 91 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,'size',[md.mesh.numberofvertices]) 92 if 'ThermalAnalysis' in analyses and not (solution == 'TransientSolution' and md.transient.isthermal==0): 93 md = checkfield(md,'fieldname','basalforcings.groundedice_melting_rate','NaN',1,'timeseries',1) 94 md = checkfield(md,'fieldname','basalforcings.floatingice_melting_rate','NaN',1,'timeseries',1) 95 md = checkfield(md,'fieldname','basalforcings.mantleconductivity','>=',0,'numel',1) 96 md = checkfield(md,'fieldname','basalforcings.nusselt','>',0,'numel',1) 97 md = checkfield(md,'fieldname','basalforcings.dtbg','>',0,'numel',1) 98 md = checkfield(md,'fieldname','basalforcings.topplumedepth','>',0,'numel',1) 99 md = checkfield(md,'fieldname','basalforcings.bottomplumedepth','>',0,'numel',1) 100 md = checkfield(md,'fieldname','basalforcings.plumex','numel',1) 101 md = checkfield(md,'fieldname','basalforcings.plumey','numel',1) 102 md = checkfield(md,'fieldname','basalforcings.crustthickness','>',0,'numel',1) 103 md = checkfield(md,'fieldname','basalforcings.uppercrustthickness','>',0,'numel',1) 104 md = checkfield(md,'fieldname','basalforcings.uppercrustheat','>',0,'numel',1) 105 md = checkfield(md,'fieldname','basalforcings.lowercrustheat','>',0,'numel',1) 106 return md 107 # }}} 108 def marshall(self,prefix,md,fid): # {{{ 109 yts=md.constants.yts 110 111 WriteData(fid,prefix,'name','md.basalforcings.model','data',4,'format','Integer') 112 WriteData(fid,prefix,'object',self,'fieldname','floatingice_melting_rate','format','DoubleMat','name','md.basalforcings.floatingice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts) 113 WriteData(fid,prefix,'object',self,'fieldname','groundedice_melting_rate','format','DoubleMat','name','md.basalforcings.groundedice_melting_rate','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts) 114 WriteData(fid,prefix,'object',self,'fieldname','mantleconductivity','format','Double') 115 WriteData(fid,prefix,'object',self,'fieldname','nusselt','format','Double') 116 WriteData(fid,prefix,'object',self,'fieldname','dtbg','format','Double') 117 WriteData(fid,prefix,'object',self,'fieldname','plumeradius','format','Double') 118 WriteData(fid,prefix,'object',self,'fieldname','topplumedepth','format','Double') 119 WriteData(fid,prefix,'object',self,'fieldname','bottomplumedepth','format','Double') 120 WriteData(fid,prefix,'object',self,'fieldname','plumex','format','Double') 121 WriteData(fid,prefix,'object',self,'fieldname','plumey','format','Double') 122 WriteData(fid,prefix,'object',self,'fieldname','crustthickness','format','Double') 123 WriteData(fid,prefix,'object',self,'fieldname','uppercrustthickness','format','Double') 124 WriteData(fid,prefix,'object',self,'fieldname','uppercrustheat','format','Double') 125 WriteData(fid,prefix,'object',self,'fieldname','lowercrustheat','format','Double') 126 # }}} -
../trunk-jpl/test/NightlyRun/test701.py
1 #Test Name: FlowbandFSshelf 2 import numpy as np 3 from scipy.interpolate import interp1d 4 from model import * 5 from solve import * 6 from setflowequation import * 7 from bamgflowband import * 8 from paterson import * 9 10 x = np.arange(1,3001,100).T 11 h = np.linspace(1000,300,np.size(x)).T 12 b = -917./1023.*h 13 14 md = bamgflowband(model(),x,b+h,b,'hmax',80.) 15 print md.mesh.numberofvertices 16 17 #Geometry #interp1d returns a function to be called on md.mesh.x 18 md.geometry.surface = interp1d(x,b+h)(md.mesh.x) 19 md.geometry.base = interp1d(x,b)(md.mesh.x) 20 md.geometry.thickness = md.geometry.surface-md.geometry.base 21 22 #mask 23 md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,)) 24 md.mask.ice_levelset[np.where(md.mesh.vertexflags(2))] = 0. 25 md.mask.groundedice_levelset = np.zeros((md.mesh.numberofvertices,)) - 0.5 26 27 #materials 28 md.initialization.temperature = (273.-20.)*np.ones((md.mesh.numberofvertices,)) 29 md.materials.rheology_B = paterson(md.initialization.temperature) 30 md.materials.rheology_n = 3.*np.ones((md.mesh.numberofelements,)) 31 32 #friction 33 md.friction.coefficient = np.zeros((md.mesh.numberofvertices,)) 34 md.friction.coefficient[np.where(md.mesh.vertexflags(1))] = 20. 35 md.friction.p = np.ones((md.mesh.numberofelements,)) 36 md.friction.q = np.ones((md.mesh.numberofelements,)) 37 38 #Boundary conditions 39 md.stressbalance.referential = float('NaN')*np.ones((md.mesh.numberofvertices,6)) 40 md.stressbalance.loadingforce = 0. * np.ones((md.mesh.numberofvertices,3)) 41 md.stressbalance.spcvx = float('NaN') * np.ones((md.mesh.numberofvertices,)) 42 md.stressbalance.spcvy = float('NaN') * np.ones((md.mesh.numberofvertices,)) 43 md.stressbalance.spcvz = float('NaN') * np.ones((md.mesh.numberofvertices,)) 44 md.stressbalance.spcvx[np.where(md.mesh.vertexflags(4))] = 0. 45 md.stressbalance.spcvy[np.where(md.mesh.vertexflags(4))] = 0. 46 47 #Misc 48 md = setflowequation(md,'FS','all') 49 md.stressbalance.abstol = float('NaN') 50 #md.stressbalance.reltol = 10**-16 51 md.stressbalance.FSreconditioning = 1. 52 md.stressbalance.maxiter = 20 53 md.flowequation.augmented_lagrangian_r = 10000. 54 md.miscellaneous.name = 'test701' 55 md.verbose = verbose('convergence',True) 56 md.cluster = generic('np',2) 57 58 #Go solve 59 field_names = [] 60 field_tolerances = [] 61 field_values = [] 62 #md.initialization.pressure = md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.y) 63 for i in ['MINI','MINIcondensed','TaylorHood','LATaylorHood','CrouzeixRaviart','LACrouzeixRaviart']: 64 print ' ' 65 print '======Testing ' +i+ ' Full-Stokes Finite element=====' 66 md.flowequation.fe_FS = i 67 md = solve(md,'Stressbalance') 68 field_names = field_names + [['Vx'+i],['Vy'+i],['Vel'+i],['Pressure'+i]] 69 field_tolerances = field_tolerances + [9e-5,9e-5,9e-5,1e-10] 70 field_values = field_values + [ 71 md.results.StressbalanceSolution.Vx, 72 md.results.StressbalanceSolution.Vy, 73 md.results.StressbalanceSolution.Vel, 74 md.results.StressbalanceSolution.Pressure 75 ] -
../trunk-jpl/test/NightlyRun/test703.py
1 #Test Name: FlowbandFSsheetshelfTrans 2 import numpy as np 3 from scipy.interpolate import interp1d 4 import copy 5 from model import * 6 from socket import gethostname 7 from triangle import * 8 from meshconvert import * 9 from setmask import * 10 from parameterize import * 11 from setflowequation import * 12 from solve import * 13 from NowickiProfile import * 14 from bamgflowband import * 15 from paterson import * 16 17 #mesh parameters 18 x = np.arange(-5,5.5,.5).T 19 [b,h,sea] = NowickiProfile(x) 20 x = x * 10**3 21 h = h * 10**3 22 b = (b-sea) * 10**3 23 24 #mesh domain 25 md = bamgflowband(model(),x,b+h,b,'hmax',150) 26 print md.mesh.numberofvertices 27 28 #geometry 29 md.geometry.surface = interp1d(x,b+h)(md.mesh.x) 30 md.geometry.base = interp1d(x,b)(md.mesh.x) 31 md.geometry.thickness = md.geometry.surface - md.geometry.base 32 33 #mask 34 md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,)) 35 md.mask.ice_levelset[np.where(md.mesh.vertexflags(2))] = 0 36 md.mask.groundedice_levelset = np.zeros((md.mesh.numberofvertices,)) - 0.5 37 38 #materials 39 md.initialization.temperature = (273. - 20.) * np.ones((md.mesh.numberofvertices,)) 40 md.materials.rheology_B = paterson(md.initialization.temperature) 41 md.materials.rheology_n = 3 * np.ones((md.mesh.numberofelements,)) 42 43 #friction 44 md.friction.coefficient = np.zeros((md.mesh.numberofvertices,)) 45 md.friction.coefficient[np.where(md.mesh.vertexflags(1))] = 20 46 md.friction.p = np.ones((md.mesh.numberofelements,)) 47 md.friction.q = np.ones((md.mesh.numberofelements,)) 48 49 #boundary conditions 50 md.stressbalance.spcvx = float('NaN') * np.ones((md.mesh.numberofvertices,)) 51 md.stressbalance.spcvy = float('NaN') * np.ones((md.mesh.numberofvertices,)) 52 md.stressbalance.spcvz = float('NaN') * np.ones((md.mesh.numberofvertices,)) 53 md.stressbalance.referential = float('NaN') * np.ones((md.mesh.numberofvertices,6)) 54 md.stressbalance.loadingforce = 0 * np.ones((md.mesh.numberofvertices,3)) 55 md.stressbalance.spcvx[np.where(md.mesh.vertexflags(4))] = 800. 56 md.stressbalance.spcvy[np.where(md.mesh.vertexflags(4))] = 0. 57 58 #print md.stressbalance.referential 59 #print md.stressbalance.loadingforce 60 #print md.stressbalance.spcvx 61 #print md.stressbalance.spcvy 62 #print md.stressbalance.spcvz 63 #print np.shape(md.stressbalance.referential) 64 #print np.shape(md.stressbalance.loadingforce) 65 #print np.shape(md.stressbalance.spcvx) 66 #print np.shape(md.stressbalance.spcvy) 67 #print np.shape(md.stressbalance.spcvz) 68 69 #Misc 70 md = setflowequation(md,'FS','all') 71 md.flowequation.fe_FS = 'TaylorHood' 72 md.stressbalance.abstol = float('NaN') 73 md.miscellaneous.name = 'test703' 74 75 #Transient settings 76 md.timestepping.time_step = 0.000001 77 md.timestepping.final_time = 0.000005 78 md.stressbalance.shelf_dampening = 1. 79 md.smb.mass_balance = np.zeros((md.mesh.numberofvertices,)) 80 md.basalforcings.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices,)) 81 md.basalforcings.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices,)) 82 md.basalforcings.geothermalflux = np.zeros((md.mesh.numberofvertices,)) 83 posb = np.intersect1d(np.where(md.mesh.x > 0.), np.where(md.mesh.vertexonbase)) 84 md.basalforcings.groundedice_melting_rate[posb] = 18. 85 md.basalforcings.floatingice_melting_rate[posb] = 18. 86 md.initialization.vx = np.zeros((md.mesh.numberofvertices,)) 87 md.initialization.vy = np.zeros((md.mesh.numberofvertices,)) 88 md.initialization.pressure = np.zeros((md.mesh.numberofvertices,)) 89 md.masstransport.spcthickness = float('NaN') * np.ones((md.mesh.numberofvertices,)) 90 md.thermal.spctemperature = float('NaN') * np.ones((md.mesh.numberofvertices,)) 91 md.transient.isthermal = 0 92 md.masstransport.isfreesurface = 1 93 94 #Go solve 95 md.cluster = generic('np',3) 96 md.stressbalance.shelf_dampening = 1 97 md1 = solve(md,'Transient') 98 99 md.stressbalance.shelf_dampening = 0 100 md = solve(md,'Transient') 101 102 #Fields and tolerances to track changes 103 field_names = [ 104 'Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1', 105 'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2', 106 'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3', 107 'Vx1_damp','Vy1_damp','Vel1_damp','Pressure1_damp','Bed1_damp','Surface1_damp','Thickness1_damp', 108 'Vx2_damp','Vy2_damp','Vel2_damp','Pressure2_damp','Bed2_damp','Surface2_damp','Thickness2_damp', 109 'Vx3_damp','Vy3_damp','Vel3_damp','Pressure3_damp','Bed3_damp','Surface3_damp','Thickness3_damp'] 110 field_tolerances = [ 111 2e-08,2e-08,2e-08,1e-08,1e-10,1e-10,1e-10, 112 2e-08,2e-08,2e-08,1e-08,1e-10,1e-10,1e-10, 113 2e-08,2e-08,2e-08,1e-08,1e-10,1e-10,1e-10, 114 5e-08,5e-08,5e-08,1e-08,1e-10,1e-10,1e-10, 115 5e-08,5e-08,5e-08,1e-08,1e-10,1e-10,1e-10, 116 5e-08,5e-08,5e-08,1e-08,1e-10,1e-10,1e-10] 117 field_values = [ 118 md.results.TransientSolution[0].Vx, 119 md.results.TransientSolution[0].Vy, 120 md.results.TransientSolution[0].Vel, 121 md.results.TransientSolution[0].Pressure, 122 md.results.TransientSolution[0].Base, 123 md.results.TransientSolution[0].Surface, 124 md.results.TransientSolution[0].Thickness, 125 md.results.TransientSolution[1].Vx, 126 md.results.TransientSolution[1].Vy, 127 md.results.TransientSolution[1].Vel, 128 md.results.TransientSolution[1].Pressure, 129 md.results.TransientSolution[1].Base, 130 md.results.TransientSolution[1].Surface, 131 md.results.TransientSolution[1].Thickness, 132 md.results.TransientSolution[2].Vx, 133 md.results.TransientSolution[2].Vy, 134 md.results.TransientSolution[2].Vel, 135 md.results.TransientSolution[2].Pressure, 136 md.results.TransientSolution[2].Base, 137 md.results.TransientSolution[2].Surface, 138 md.results.TransientSolution[2].Thickness, 139 md1.results.TransientSolution[0].Vx, 140 md1.results.TransientSolution[0].Vy, 141 md1.results.TransientSolution[0].Vel, 142 md1.results.TransientSolution[0].Pressure, 143 md1.results.TransientSolution[0].Base, 144 md1.results.TransientSolution[0].Surface, 145 md1.results.TransientSolution[0].Thickness, 146 md1.results.TransientSolution[1].Vx, 147 md1.results.TransientSolution[1].Vy, 148 md1.results.TransientSolution[1].Vel, 149 md1.results.TransientSolution[1].Pressure, 150 md1.results.TransientSolution[1].Base, 151 md1.results.TransientSolution[1].Surface, 152 md1.results.TransientSolution[1].Thickness, 153 md1.results.TransientSolution[2].Vx, 154 md1.results.TransientSolution[2].Vy, 155 md1.results.TransientSolution[2].Vel, 156 md1.results.TransientSolution[2].Pressure, 157 md1.results.TransientSolution[2].Base, 158 md1.results.TransientSolution[2].Surface, 159 md1.results.TransientSolution[2].Thickness, 160 ] -
../trunk-jpl/test/NightlyRun/test293.py
1 #Test Name: SquareShelfTranSSA2dMismipFloatingMeltParam 2 import numpy as np 3 from model import * 4 from socket import gethostname 5 from triangle import * 6 from setmask import * 7 from parameterize import * 8 from setflowequation import * 9 from solve import * 10 from mismipbasalforcings import * 11 12 md = triangle(model(),'../Exp/Square.exp',150000.) 13 md = setmask(md,'all','') 14 md = parameterize(md,'../Par/SquareShelf.py') 15 md = setflowequation(md,'SSA','all') 16 md.cluster = generic('name',gethostname(),'np',3) 17 md.constants.yts = 365.2422 * 24. * 3600. 18 md.basalforcings = mismipbasalforcings() 19 md.basalforcings = md.basalforcings.initialize(md) 20 md.transient.isgroundingline = 1 21 md.geometry.bed = min(md.geometry.base) * np.ones(md.mesh.numberofvertices,) 22 md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate'] 23 print md.constants.yts 24 25 md = solve(md,'Transient') 26 27 #Fields and tolerances to track changes 28 field_names =['Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1','BasalforcingsFloatingiceMeltingRate1', 29 'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2','BasalforcingsFloatingiceMeltingRate2', 30 'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3','BasalforcingsFloatingiceMeltingRate3'] 31 field_tolerances = [ 32 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,2e-13, 33 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,2e-13, 34 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,2e-13] 35 field_values = [ 36 md.results.TransientSolution[0].Vx, 37 md.results.TransientSolution[0].Vy, 38 md.results.TransientSolution[0].Vel, 39 md.results.TransientSolution[0].Pressure, 40 md.results.TransientSolution[0].Base, 41 md.results.TransientSolution[0].Surface, 42 md.results.TransientSolution[0].Thickness, 43 md.results.TransientSolution[0].BasalforcingsFloatingiceMeltingRate, 44 md.results.TransientSolution[1].Vx, 45 md.results.TransientSolution[1].Vy, 46 md.results.TransientSolution[1].Vel, 47 md.results.TransientSolution[1].Pressure, 48 md.results.TransientSolution[1].Base, 49 md.results.TransientSolution[1].Surface, 50 md.results.TransientSolution[1].Thickness, 51 md.results.TransientSolution[1].BasalforcingsFloatingiceMeltingRate, 52 md.results.TransientSolution[2].Vx, 53 md.results.TransientSolution[2].Vy, 54 md.results.TransientSolution[2].Vel, 55 md.results.TransientSolution[2].Pressure, 56 md.results.TransientSolution[2].Base, 57 md.results.TransientSolution[2].Surface, 58 md.results.TransientSolution[2].Thickness, 59 md.results.TransientSolution[2].BasalforcingsFloatingiceMeltingRate, 60 ] -
../trunk-jpl/src/m/mesh/bamgflowband.py
1 import numpy as np 2 from model import * 3 from collections import OrderedDict 4 from bamg import * 5 from mesh2dvertical import * 6 7 def bamgflowband(md,x,surf,base,*args): 8 """ 9 BAMGFLOWBAND - create flowband mesh with bamg 10 11 Usage: 12 md=bamgflowband(md,x,surf,base,OPTIONS) 13 14 surf and bed are the surface elevation and base for each x provided 15 x must be increasing 16 OPTIONS are bamg options 17 18 Example: 19 x =np.arrange(1,3001,100) 20 h=linspace(1000,300,numel(x)) 21 b=-917/1023*h 22 md=bamgflowband(model,b+h,b,'hmax',80,'vertical',1,'Markers',m) 23 """ 24 25 #Write expfile with domain outline 26 A = OrderedDict() 27 A.x = np.concatenate((x,np.flipud(x),[x[0]])) 28 A.y = np.concatenate((base,np.flipud(surf),[base[0]])) 29 A.nods = np.size(A.x) 30 31 #markers: 32 m = np.ones((np.size(A.x)-1,)) # base = 1 33 m[np.size(x) - 1] = 2 # right side = 2 34 m[np.size(x):2 * np.size(x) - 1] = 3 # top surface = 3 35 m[2 * np.size(x) - 1] = 4 # left side = 4 36 37 #mesh domain 38 md = bamg(model(),'domain',[A],'vertical',1,'Markers',m,*args) 39 #print md.mesh.numberofvertices 40 41 #Deal with vertices on bed 42 md.mesh.vertexonbase = np.zeros((md.mesh.numberofvertices,)) 43 md.mesh.vertexonbase[np.where(md.mesh.vertexflags(1))] = 1 44 md.mesh.vertexonsurface = np.zeros((md.mesh.numberofvertices,)) 45 md.mesh.vertexonsurface[np.where(md.mesh.vertexflags(3))] = 1 46 47 return md -
../trunk-jpl/src/m/mesh/bamg.py
1 1 import os.path 2 2 import numpy as np 3 from mesh2d import mesh2d3 from mesh2dvertical import * 4 4 from collections import OrderedDict 5 5 from pairoptions import pairoptions 6 6 from bamggeom import bamggeom … … 79 79 80 80 #Check that file exists 81 81 domainfile=options.getfieldvalue('domain') 82 if not os.path.exists(domainfile): 83 raise IOError("bamg error message: file '%s' not found" % domainfile) 84 domain=expread(domainfile) 82 if type(domainfile) == str: 83 if not os.path.exists(domainfile): 84 raise IOError("bamg error message: file '%s' not found" % domainfile) 85 domain=expread(domainfile) 86 else: 87 domain=domainfile 85 88 86 89 #Build geometry 87 90 count=0 … … 88 91 for i,domaini in enumerate(domain): 89 92 90 93 #Check that the domain is closed 91 if (domaini ['x'][0]!=domaini['x'][-1] or domaini['y'][0]!=domaini['y'][-1]):94 if (domaini.x[0]!=domaini.x[-1] or domaini.y[0]!=domaini.y[-1]): 92 95 raise RuntimeError("bamg error message: all contours provided in ''domain'' should be closed") 93 96 94 97 #Checks that all holes are INSIDE the principle domain outline 95 98 if i: 96 flags=ContourToNodes(domaini ['x'],domaini['y'],domainfile,0)[0]99 flags=ContourToNodes(domaini.x,domaini.y,domainfile,0)[0] 97 100 if np.any(np.logical_not(flags)): 98 101 raise RuntimeError("bamg error message: All holes should be strictly inside the principal domain") 99 102 100 103 #Add all points to bamg_geometry 101 nods=domaini ['nods']-1 #the domain are closed 0=end102 bamg_geometry.Vertices=np.vstack((bamg_geometry.Vertices,np.vstack((domaini ['x'][0:nods],domaini['y'][0:nods],np.ones((nods)))).T))104 nods=domaini.nods-1 #the domain are closed 0=end 105 bamg_geometry.Vertices=np.vstack((bamg_geometry.Vertices,np.vstack((domaini.x[0:nods],domaini.y[0:nods],np.ones((nods)))).T)) 103 106 bamg_geometry.Edges =np.vstack((bamg_geometry.Edges,np.vstack((np.arange(count+1,count+nods+1),np.hstack((np.arange(count+2,count+nods+1),count+1)),1.*np.ones((nods)))).T)) 104 107 if i: 105 108 bamg_geometry.SubDomains=np.vstack((bamg_geometry.SubDomains,[2,count+1,1,-subdomain_ref])) … … 115 118 #update counter 116 119 count+=nods 117 120 121 if options.getfieldvalue('vertical',0): 122 if np.size(options.getfieldvalue('Markers',[]))!=np.size(bamg_geometry.Edges,0): 123 raise RuntimeError('for 2d vertical mesh, ''Markers'' option is required, and should be of size ' + str(np.size(bamg_geometry.Edges,0))) 124 if np.size(options.getfieldvalue('Markers',[]))==np.size(bamg_geometry.Edges,0): 125 bamg_geometry.Edges[:,2]=options.getfieldvalue('Markers') 126 118 127 #take care of rifts 119 128 if options.exist('rifts'): 120 129 … … 322 331 bamgmesh_out,bamggeom_out=BamgMesher(bamg_mesh.__dict__,bamg_geometry.__dict__,bamg_options) 323 332 324 333 # plug results onto model 334 if options.getfieldvalue('vertical',0): 335 md.mesh=mesh2dvertical() 336 md.mesh.x=bamgmesh_out['Vertices'][:,0].copy() 337 md.mesh.y=bamgmesh_out['Vertices'][:,1].copy() 338 md.mesh.elements=bamgmesh_out['Triangles'][:,0:3].astype(int) 339 md.mesh.edges=bamgmesh_out['IssmEdges'].astype(int) 340 md.mesh.segments=bamgmesh_out['IssmSegments'][:,0:3].astype(int) 341 md.mesh.segmentmarkers=bamgmesh_out['IssmSegments'][:,3].astype(int) 342 343 #Fill in rest of fields: 344 md.mesh.numberofelements=np.size(md.mesh.elements,axis=0) 345 md.mesh.numberofvertices=np.size(md.mesh.x) 346 md.mesh.numberofedges=np.size(md.mesh.edges,axis=0) 347 md.mesh.vertexonboundary=np.zeros(md.mesh.numberofvertices,bool) 348 md.mesh.vertexonboundary[md.mesh.segments[:,0:2]-1]=True 349 350 #Now, build the connectivity tables for this mesh. Doubled in matlab for some reason 351 md.mesh.vertexonboundary=np.zeros(md.mesh.numberofvertices,) 352 md.mesh.vertexonboundary[md.mesh.segments[:,0:2]-1]=1 353 354 elif options.getfieldvalue('3dsurface',0): 355 md.mesh=mesh3dsurface() 356 md.mesh.x=bamgmesh_out['Vertices'][:,0].copy() 357 md.mesh.y=bamgmesh_out['Vertices'][:,1].copy() 358 md.mesh.z=md.mesh.x 359 md.mesh.z[:]=0 360 md.mesh.elements=bamgmesh_out['Triangles'][:,0:3].astype(int) 361 md.mesh.edges=bamgmesh_out['IssmEdges'].astype(int) 362 md.mesh.segments=bamgmesh_out['IssmSegments'][:,0:3].astype(int) 363 md.mesh.segmentmarkers=bamgmesh_out['IssmSegments'][:,3].astype(int) 364 365 #Fill in rest of fields: 366 md.mesh.numberofelements=np.size(md.mesh.elements,axis=0) 367 md.mesh.numberofvertices=np.size(md.mesh.x) 368 md.mesh.numberofedges=np.size(md.mesh.edges,axis=0) 369 md.mesh.vertexonboundary=np.zeros(md.mesh.numberofvertices,bool) 370 md.mesh.vertexonboundary[md.mesh.segments[:,0:2]-1]=True 371 372 else: 373 md.mesh=mesh2d() 374 md.mesh.x=bamgmesh_out['Vertices'][:,0].copy() 375 md.mesh.y=bamgmesh_out['Vertices'][:,1].copy() 376 md.mesh.elements=bamgmesh_out['Triangles'][:,0:3].astype(int) 377 md.mesh.edges=bamgmesh_out['IssmEdges'].astype(int) 378 md.mesh.segments=bamgmesh_out['IssmSegments'][:,0:3].astype(int) 379 md.mesh.segmentmarkers=bamgmesh_out['IssmSegments'][:,3].astype(int) 380 381 #Fill in rest of fields: 382 md.mesh.numberofelements=np.size(md.mesh.elements,axis=0) 383 md.mesh.numberofvertices=np.size(md.mesh.x) 384 md.mesh.numberofedges=np.size(md.mesh.edges,axis=0) 385 md.mesh.vertexonboundary=np.zeros(md.mesh.numberofvertices,bool) 386 md.mesh.vertexonboundary[md.mesh.segments[:,0:2]-1]=True 387 388 #Bamg private fields 325 389 md.private.bamg=OrderedDict() 326 390 md.private.bamg['mesh']=bamgmesh(bamgmesh_out) 327 391 md.private.bamg['geometry']=bamggeom(bamggeom_out) 328 md.mesh = mesh2d()329 md.mesh.x=bamgmesh_out['Vertices'][:,0].copy()330 md.mesh.y=bamgmesh_out['Vertices'][:,1].copy()331 md.mesh.elements=bamgmesh_out['Triangles'][:,0:3].astype(int)332 md.mesh.edges=bamgmesh_out['IssmEdges'].astype(int)333 md.mesh.segments=bamgmesh_out['IssmSegments'][:,0:3].astype(int)334 md.mesh.segmentmarkers=bamgmesh_out['IssmSegments'][:,3].astype(int)335 336 #Fill in rest of fields:337 md.mesh.numberofelements=np.size(md.mesh.elements,axis=0)338 md.mesh.numberofvertices=np.size(md.mesh.x)339 md.mesh.numberofedges=np.size(md.mesh.edges,axis=0)340 md.mesh.vertexonboundary=np.zeros(md.mesh.numberofvertices,bool)341 md.mesh.vertexonboundary[md.mesh.segments[:,0:2]-1]=True342 392 md.mesh.elementconnectivity=md.private.bamg['mesh'].ElementConnectivity 343 393 md.mesh.elementconnectivity[np.nonzero(np.isnan(md.mesh.elementconnectivity))]=0 344 394 md.mesh.elementconnectivity=md.mesh.elementconnectivity.astype(int)
Note:
See TracBrowser
for help on using the repository browser.