source: issm/oecreview/Archive/21724-22754/ISSM-22266-22267.diff@ 22755

Last change on this file since 22755 was 22755, checked in by Mathieu Morlighem, 7 years ago

CHG: added 21724-22754

File size: 199.4 KB
  • ../trunk-jpl/test/Par/SquareThermal.py

     
    2525
    2626print "      creating temperatures"
    2727md.initialization.temperature=(273.-20.)*numpy.ones((md.mesh.numberofvertices))
     28md.initialization.pressure=numpy.zeros((md.mesh.numberofvertices,))
     29md.initialization.waterfraction=numpy.zeros((md.mesh.numberofvertices,))
     30md.initialization.watercolumn=numpy.zeros((md.mesh.numberofvertices,))
    2831
    2932print "      creating flow law parameter"
    3033md.materials.rheology_B=paterson(md.initialization.temperature)
     
    3235
    3336print "      creating surface mass balance"
    3437md.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
     39md.basalforcings.groundedice_melting_rate=0.*numpy.ones((md.mesh.numberofvertices))/md.constants.yts    #1m/a
     40md.basalforcings.floatingice_melting_rate=0.*numpy.ones((md.mesh.numberofvertices))/md.constants.yts    #1m/a
    3641
    3742#Deal with boundary conditions:
    3843
     
    4045md=SetMarineIceSheetBC(md,'../Exp/SquareFront.exp')
    4146
    4247print "      boundary conditions for thermal model"
    43 md.thermal.spctemperature=md.initialization.temperature
     48md.thermal.spctemperature[:]=md.initialization.temperature
    4449md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices))
    4550md.basalforcings.geothermalflux[numpy.nonzero(md.mask.groundedice_levelset>0.)[0]]=1.*10**-3    #1 mW/m^2
  • ../trunk-jpl/test/Par/ISMIPE.par

     
    1313        md.geometry.base(i)=(1.-coeff)*data(point1,2)+coeff*data(point2,2);
    1414        md.geometry.surface(i)=(1.-coeff)*data(point1,3)+coeff*data(point2,3);
    1515end
     16
    1617md.geometry.thickness=md.geometry.surface-md.geometry.base;
    1718md.geometry.thickness(find(~md.geometry.thickness))=0.01;
    1819md.geometry.base=md.geometry.surface-md.geometry.thickness;
  • ../trunk-jpl/test/Par/ISMIPE.py

     
    1212        y=md.mesh.y[i]
    1313        point1=numpy.floor(y/100.)
    1414        point2=numpy.minimum(point1+1,50)
    15         coeff=(y-(point1-1.)*100.)/100.
     15        coeff=(y-(point1)*100.)/100.
    1616        md.geometry.base[i]=(1.-coeff)*data[point1,1]+coeff*data[point2,1]
    1717        md.geometry.surface[i]=(1.-coeff)*data[point1,2]+coeff*data[point2,2]
     18
    1819md.geometry.thickness=md.geometry.surface-md.geometry.base
    1920md.geometry.thickness[numpy.nonzero(numpy.logical_not(md.geometry.thickness))]=0.01
    2021md.geometry.base=md.geometry.surface-md.geometry.thickness
  • ../trunk-jpl/test/NightlyRun/test2425.py

     
     1#Test Name: SquareSheetShelfGroundingLine2dSoft
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',150000.)
     12md = setmask(md,'../Exp/SquareShelf.exp','')
     13md = parameterize(md,'../Par/SquareSheetShelf.py')
     14md = setflowequation(md,'SSA','all')
     15md.initialization.vx[:] = 0.
     16md.initialization.vy[:] = 0.
     17md.geometry.base = -700. - (md.mesh.y - 500000.) / 1000.
     18md.geometry.bed = -700. - (md.mesh.y - 500000.) / 1000.
     19md.geometry.thickness[:] = 1300.
     20md.geometry.surface = md.geometry.base + md.geometry.thickness
     21md.transient.isstressbalance = 1
     22md.transient.isgroundingline = 1
     23md.groundingline.migration = 'AggressiveMigration'
     24
     25md.timestepping.time_step = .1
     26md.timestepping.final_time = 1
     27
     28md.cluster = generic('name',gethostname(),'np',3)
     29md = solve(md,'Transient')
     30vel1 = md.results.TransientSolution[-1].Vel
     31
     32#get same results with offset in bed and sea level:
     33md.geometry.base = -700. - (md.mesh.y - 500000.) / 1000.
     34md.geometry.bed  = -700. - (md.mesh.y - 500000.) / 1000.
     35md.geometry.thickness[:] = 1300.
     36md.geometry.surface = md.geometry.base + md.geometry.thickness
     37
     38md.geometry.base = md.geometry.base + 1000
     39md.geometry.bed = md.geometry.bed + 1000
     40md.geometry.surface = md.geometry.surface + 1000
     41md.slr.sealevel = 1000 * np.ones((md.mesh.numberofvertices,))
     42
     43md = solve(md,'Transient','checkconsistency','no')
     44vel2 = md.results.TransientSolution[-1].Vel
     45
     46#Fields and tolerances to track changes
     47field_names = ['Vel','Veloffset']
     48field_tolerances = [1e-13,1e-13]
     49field_values = [vel1,vel2]
     50
  • ../trunk-jpl/test/NightlyRun/test342.py

     
     1#Test Name: SquareSheetTherSteaPlume
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from plumebasalforcings import *
     11
     12md = triangle(model(),'../Exp/Square.exp',180000.)
     13md = setmask(md,'','')
     14md = parameterize(md,'../Par/SquareSheetConstrained.py')
     15md.basalforcings = plumebasalforcings()
     16md.basalforcings = md.basalforcings.setdefaultparameters()
     17md.basalforcings.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices,))
     18md.basalforcings.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices,))
     19md.basalforcings.plumex = 500000
     20md.basalforcings.plumey = 500000
     21md.extrude(3,1.)
     22md = setflowequation(md,'SSA','all')
     23md.timestepping.time_step = 0.
     24md.thermal.requested_outputs = ['default','BasalforcingsGeothermalflux']
     25md.cluster = generic('name',gethostname(),'np',3)
     26md = solve(md,'Thermal')
     27
     28#Fields and tolerances to track changes
     29field_names      = ['Temperature','BasalforcingsGroundediceMeltingRate','BasalforcingsGeothermalflux']
     30field_tolerances = [1e-13,1e-8,1e-13]
     31field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from matenhancedice import *
     11
     12md = triangle(model(),'../Exp/Square.exp',180000.)
     13md = setmask(md,'all','')
     14md = parameterize(md,'../Par/SquareShelfConstrained.py')
     15md = md.extrude(3,1.)
     16md = setflowequation(md,'SSA','all')
     17md.cluster = generic('name',gethostname(),'np',3)
     18md.materials = matenhancedice()
     19md.materials.rheology_B = 3.15e8 * np.ones(md.mesh.numberofvertices,)
     20md.materials.rheology_n = 3 * np.ones(md.mesh.numberofelements,)
     21md.materials.rheology_E = np.ones(md.mesh.numberofvertices,)
     22md.transient.isstressbalance = 1
     23md.transient.ismasstransport = 0
     24md.transient.issmb = 1
     25md.transient.isthermal = 1
     26md.transient.isgroundingline = 0
     27md = solve(md,'Transient')
     28
     29#Fields and tolerances to track changes
     30field_names      = ['Vx','Vy','Vel','Temperature','BasalforcingsGroundediceMeltingRate']
     31field_tolerances = [1e-13,1e-13,1e-13,1e-13,1e-13]
     32field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',100000.)
     12md = setmask(md,'../Exp/SquareShelf.exp','')
     13md = parameterize(md,'../Par/SquareSheetShelf.py')
     14md.initialization.vx[:] = 1.
     15md.initialization.vy[:] = 1.
     16md.geometry.thickness[:] = 500. - md.mesh.x / 10000.
     17md.geometry.bed = -100. - md.mesh.x / 1000.
     18md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water
     19md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed
     20pos = np.array(np.where(md.mask.groundedice_levelset >= 0.))
     21md.geometry.base[pos] = md.geometry.bed[pos]
     22md.geometry.surface = md.geometry.base + md.geometry.thickness
     23md = setflowequation(md,'SSA','all')
     24
     25#Boundary conditions:
     26md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
     27md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0.
     28md.stressbalance.spcvx[:] = float('Nan')
     29md.stressbalance.spcvy[:] = float('Nan')
     30md.stressbalance.spcvz[:] = float('Nan')
     31posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9)))
     32posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1)))
     33pos = np.unique(np.concatenate((posA,posB)))
     34md.stressbalance.spcvy[pos] = 0.
     35pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1)))
     36md.stressbalance.spcvx[pos2] = 0.
     37md.stressbalance.spcvy[pos2] = 0.
     38
     39md.materials.rheology_B = 1. / ((10**-25)**(1./3.)) * np.ones((md.mesh.numberofvertices,))
     40md.materials.rheology_law = 'None'
     41md.friction.coefficient[:] = np.sqrt(1e7) * np.ones((md.mesh.numberofvertices,))
     42md.friction.p = 3. * np.ones((md.mesh.numberofelements,))
     43md.smb.mass_balance[:] = 1.
     44md.basalforcings.groundedice_melting_rate[:] = 0.
     45md.basalforcings.floatingice_melting_rate[:] = 30.
     46md.transient.isthermal = 0
     47md.transient.isstressbalance = 1
     48md.transient.isgroundingline = 1
     49md.transient.ismasstransport = 1
     50md.transient.issmb = 1
     51md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate']
     52md.groundingline.migration = 'SubelementMigration2'
     53md.timestepping.final_time = 30.
     54md.timestepping.time_step = 10.
     55
     56md.cluster = generic('name',gethostname(),'np',3)
     57md = solve(md,'Transient')
     58
     59#Fields and tolerances to track changes
     60field_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']
     64field_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]
     68field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from SMBgradientsela import *
     11
     12md = triangle(model(),'../Exp/Square.exp',150000.)
     13md = setmask(md,'','')
     14md = parameterize(md,'../Par/SquareSheetConstrained.py')
     15md = setflowequation(md,'SSA','all')
     16md.smb = SMBgradientsela()
     17md.smb.ela = 1500. * np.ones((md.mesh.numberofvertices+1,))
     18md.smb.b_pos = 0.002 * np.ones((md.mesh.numberofvertices+1,))
     19md.smb.b_neg = 0.005 * np.ones((md.mesh.numberofvertices+1,))
     20md.smb.b_max = 4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,))
     21md.smb.b_min = -4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,))
     22
     23#Change geometry
     24md.geometry.thickness = md.geometry.surface * 30.
     25md.geometry.surface = md.geometry.base + md.geometry.thickness
     26
     27#Transient options
     28md.transient.requested_outputs = ['default','TotalSmb']
     29md.cluster = generic('name',gethostname(),'np',3)
     30md = solve(md,'Transient')
     31
     32#Fields and tolerances to track changes
     33field_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']
     37field_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]
     41field_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
     2from model import *
     3from socket import gethostname
     4from triangle import *
     5from setmask import *
     6from parameterize import *
     7from setflowequation import *
     8from solve import *
     9from calvingvonmises import *
     10
     11md = triangle(model(),'../Exp/Pig.exp',10000.)
     12md = setmask(md,'../Exp/PigShelves.exp','../Exp/PigIslands.exp')
     13md = parameterize(md,'../Par/Pig.py')
     14md = setflowequation(md,'SSA','all')
     15md.timestepping.time_step = 2
     16md.timestepping.final_time = 50
     17
     18#calving parameters
     19md.mask.ice_levelset = 1e4 * (md.mask.ice_levelset + 0.5)
     20md.calving = calvingvonmises()
     21md.calving.meltingrate = np.zeros((md.mesh.numberofvertices,))
     22md.transient.ismovingfront = 1
     23md.levelset.spclevelset = float('NaN') * np.ones((md.mesh.numberofvertices,))
     24pos = np.where(md.mesh.vertexonboundary)
     25md.levelset.spclevelset[pos] = md.mask.ice_levelset[pos]
     26
     27md.cluster = generic('name',gethostname(),'np',2)
     28md = solve(md,'Transient')
     29
     30#Fields and tolerances to track changes
     31field_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        ]
     36field_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        ]
     41field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',100000.)
     12md = setmask(md,'../Exp/SquareShelf.exp','')
     13md = parameterize(md,'../Par/SquareSheetShelf.py')
     14md.initialization.vx[:] = 1.
     15md.initialization.vy[:] = 1.
     16md.geometry.thickness[:] = 500. - md.mesh.x / 10000.
     17md.geometry.bed = -100. - md.mesh.x / 1000.
     18md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water
     19md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed
     20pos = np.where(md.mask.groundedice_levelset >= 0.)
     21md.geometry.base[pos] = md.geometry.bed[pos]
     22md.geometry.surface = md.geometry.base + md.geometry.thickness
     23md = md.extrude(4,1.)
     24md = setflowequation(md,'HO','all')
     25
     26#Boundary conditions:
     27md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
     28md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0.
     29md.stressbalance.spcvx[:] = float('Nan')
     30md.stressbalance.spcvy[:] = float('Nan')
     31md.stressbalance.spcvz[:] = float('Nan')
     32posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9)))
     33posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1)))
     34pos = np.unique(np.concatenate((posA,posB)))
     35md.stressbalance.spcvy[pos] = 0.
     36pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1)))
     37md.stressbalance.spcvx[pos2] = 0.
     38md.stressbalance.spcvy[pos2] = 0.
     39
     40md.materials.rheology_B = 1. / ((10**-25)**(1./3.)) * np.ones((md.mesh.numberofvertices,))
     41md.materials.rheology_law = 'None'
     42md.friction.coefficient[:] = np.sqrt(1e7) * np.ones((md.mesh.numberofvertices,))
     43md.friction.p = 3. * np.ones((md.mesh.numberofelements,))
     44md.smb.mass_balance[:] = 1.
     45md.basalforcings.groundedice_melting_rate[:] = 0.
     46md.basalforcings.floatingice_melting_rate[:] = 30.
     47md.transient.isthermal = 0
     48md.transient.isstressbalance = 1
     49md.transient.isgroundingline = 1
     50md.transient.ismasstransport = 1
     51md.transient.issmb = 1
     52md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate']
     53md.groundingline.migration = 'SubelementMigration2'
     54md.timestepping.final_time = 30
     55md.timestepping.time_step = 10
     56
     57md.cluster = generic('name',gethostname(),'np',3)
     58md = solve(md,'Transient')
     59
     60#Fields and tolerances to track changes
     61field_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']
     65field_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]
     69field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from SMBgradientsela import *
     11
     12md = triangle(model(),'../Exp/Square.exp',150000.)
     13md = setmask(md,'','')
     14md = parameterize(md,'../Par/SquareSheetConstrained.py')
     15
     16#Change geometry
     17md.geometry.thickness = md.geometry.surface * 30.
     18md.geometry.surface = md.geometry.base + md.geometry.thickness
     19
     20md = md.extrude(3,1.)
     21md = setflowequation(md,'HO','all')
     22md.smb = SMBgradientsela()
     23md.smb.ela = 1500. * np.ones((md.mesh.numberofvertices+1,))
     24md.smb.b_pos = 0.002 * np.ones((md.mesh.numberofvertices+1,))
     25md.smb.b_neg = 0.005 * np.ones((md.mesh.numberofvertices+1,))
     26md.smb.b_max = 4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,))
     27md.smb.b_min = -4. * (md.materials.rho_freshwater / md.materials.rho_ice) * np.ones((md.mesh.numberofvertices+1,))
     28
     29
     30#Transient options
     31md.transient.requested_outputs = ['default','TotalSmb']
     32md.cluster = generic('name',gethostname(),'np',3)
     33md = solve(md,'Transient')
     34
     35#Fields and tolerances to track changes
     36field_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']
     39field_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]
     42field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from matestar import *
     11
     12md=triangle(model(),'../Exp/Square.exp',180000.)
     13md=setmask(md,'../Exp/SquareShelf.exp','')
     14md=parameterize(md,'../Par/SquareSheetShelf.py')
     15md = md.extrude(3,1.)
     16md.materials = matestar()
     17md.materials.rheology_B = 3.15e8 * np.ones((md.mesh.numberofvertices,))
     18md.materials.rheology_Ec = np.ones((md.mesh.numberofvertices,))
     19md.materials.rheology_Es = 3 * np.ones((md.mesh.numberofvertices,))
     20md.cluster = generic('name',gethostname(),'np',3)
     21
     22#Go solve
     23field_names=[]
     24field_tolerances=[]
     25field_values=[]
     26#md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.y);
     27for 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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from matestar import *
     11
     12md = triangle(model(),'../Exp/Square.exp',180000.)
     13md = setmask(md,'../Exp/SquareShelf.exp','')
     14md = parameterize(md,'../Par/SquareSheetShelf.py')
     15md = md.extrude(3,1.)
     16md.materials = matestar()
     17md.materials.rheology_B = 3.15e8 * np.ones((md.mesh.numberofvertices,))
     18md.materials.rheology_Ec = np.ones((md.mesh.numberofvertices,))
     19md.materials.rheology_Es = 3. * np.ones((md.mesh.numberofvertices,))
     20
     21md = setflowequation(md,'FS','all')
     22md.initialization.waterfraction = np.zeros((md.mesh.numberofvertices,))
     23md.initialization.watercolumn = np.zeros((md.mesh.numberofvertices,))
     24md.transient.isstressbalance = 0
     25md.transient.ismasstransport = 0
     26md.transient.issmb = 1
     27md.transient.isthermal = 1
     28md.transient.isgroundingline = 0
     29md.thermal.isenthalpy = 1
     30md.thermal.isdynamicbasalspc = 1
     31md.cluster = generic('name',gethostname(),'np',3)
     32md = solve(md,'Transient')
     33
     34#Fields and tolerances to track changes
     35field_names = [
     36        'Enthalpy1','Waterfraction1','Temperature1',
     37        'Enthalpy2','Waterfraction2','Temperature2',
     38        'Enthalpy3','Waterfraction3','Temperature3']
     39field_tolerances = [
     40        1e-12,1e-11,1e-12,
     41        1e-12,1e-10,1e-12,
     42        1e-12,1e-9,1e-12]
     43field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',100000.)
     12md = setmask(md,'../Exp/SquareShelf.exp','')
     13md = parameterize(md,'../Par/SquareSheetShelf.py')
     14md.initialization.vx[:] = 1.
     15md.initialization.vy[:] = 1.
     16md.geometry.thickness[:] = 500. - md.mesh.x / 10000.
     17md.geometry.bed = -100. - md.mesh.x / 1000.
     18md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water
     19md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed
     20pos = np.where(md.mask.groundedice_levelset >= 0)
     21md.geometry.base[pos] = md.geometry.bed[pos]
     22md.geometry.surface = md.geometry.base + md.geometry.thickness
     23md = md.extrude(4,1.)
     24md = setflowequation(md,'HO','all')
     25
     26#Boundary conditions:
     27md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
     28md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0.
     29md.stressbalance.spcvx[:] = float('Nan')
     30md.stressbalance.spcvy[:] = float('Nan')
     31md.stressbalance.spcvz[:] = float('Nan')
     32posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9)))
     33posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1)))
     34pos = np.unique(np.concatenate((posA,posB)))
     35md.stressbalance.spcvy[pos] = 0.
     36pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1)))
     37md.stressbalance.spcvx[pos2] = 0.
     38md.stressbalance.spcvy[pos2] = 0.
     39
     40md.materials.rheology_B = 1. / ((10**-25)**(1./3.)) * np.ones((md.mesh.numberofvertices,))
     41md.materials.rheology_law = 'None'
     42md.friction.coefficient[:] = np.sqrt(1e7) * np.ones((md.mesh.numberofvertices,))
     43md.friction.p = 3. * np.ones((md.mesh.numberofelements,))
     44md.smb.mass_balance[:] = 1.
     45md.basalforcings.groundedice_melting_rate[:] = 0.
     46md.basalforcings.floatingice_melting_rate[:] = 30.
     47md.transient.isthermal = 0
     48md.transient.isstressbalance = 1
     49md.transient.isgroundingline = 1
     50md.transient.ismasstransport = 1
     51md.transient.issmb = 1
     52md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate']
     53md.groundingline.migration = 'SubelementMigration'
     54md.timestepping.final_time = 30
     55md.timestepping.time_step = 10
     56
     57md.cluster = generic('name',gethostname(),'np',3)
     58md = solve(md,'Transient')
     59
     60#Fields and tolerances to track changes
     61field_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']
     65field_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]
     69field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',150000.)
     12md = setmask(md,'../Exp/SquareShelf.exp','')
     13md = parameterize(md,'../Par/SquareSheetShelf.py')
     14md = setflowequation(md,'SSA','all')
     15md.cluster = generic('name',gethostname(),'np',3)
     16md.transient.isstressbalance = 1
     17md.transient.ismasstransport = 1
     18md.transient.issmb = 0
     19md.transient.isthermal = 0
     20md.transient.isgroundingline = 0
     21#amr bamg settings, just field
     22md.amr.hmin = 10000
     23md.amr.hmax = 100000
     24md.amr.fieldname = 'Vel'
     25md.amr.keepmetric = 1
     26md.amr.gradation = 1.2
     27md.amr.groundingline_resolution = 2000
     28md.amr.groundingline_distance = 0
     29md.amr.icefront_resolution = 1000
     30md.amr.icefront_distance = 0
     31md.amr.thicknesserror_resolution = 1000
     32md.amr.thicknesserror_threshold = 0
     33md.amr.deviatoricerror_resolution = 1000
     34md.amr.deviatoricerror_threshold = 0
     35md.transient.amr_frequency = 1
     36md.timestepping.start_time = 0
     37md.timestepping.final_time = 3
     38md.timestepping.time_step = 1
     39md = solve(md,'Transient')
     40
     41#Fields and tolerances to track changes
     42field_names     = ['Vx','Vy','Vel','Pressure']
     43field_tolerances = [1e-13,1e-13,1e-13,1e-13]
     44field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',150000.)
     12md = setmask(md,'../Exp/SquareShelf.exp','')
     13md = parameterize(md,'../Par/SquareSheetShelf.py')
     14md = md.extrude(3,2.)
     15md = setflowequation(md,'HO','all')
     16md.cluster = generic('name',gethostname(),'np',3)
     17md.timestepping.time_step = 0.
     18md.thermal.isenthalpy = 1
     19md.initialization.waterfraction = np.zeros((md.mesh.numberofvertices,))
     20md.initialization.watercolumn = np.zeros((md.mesh.numberofvertices,))
     21
     22#Go solve
     23field_names = []
     24field_tolerances = []
     25field_values = []
     26for 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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',150000.)
     12md = setmask(md,'../Exp/SquareShelf.exp','')
     13md = parameterize(md,'../Par/SquareSheetShelf.py')
     14md = setflowequation(md,'SSA','all')
     15md.cluster = generic('name',gethostname(),'np',3)
     16md.transient.isstressbalance = 1
     17md.transient.ismasstransport = 1
     18md.transient.issmb = 0
     19md.transient.isthermal = 0
     20md.transient.isgroundingline = 0
     21#amr bamg settings, just grounding line
     22md.amr.hmin = 10000
     23md.amr.hmax = 100000
     24md.amr.fieldname = 'None'
     25md.amr.keepmetric = 0
     26md.amr.gradation = 1.2
     27md.amr.groundingline_resolution = 12000
     28md.amr.groundingline_distance = 100000
     29md.amr.icefront_resolution = 1000
     30md.amr.icefront_distance = 0
     31md.amr.thicknesserror_resolution = 1000
     32md.amr.thicknesserror_threshold = 0
     33md.amr.deviatoricerror_resolution = 1000
     34md.amr.deviatoricerror_threshold = 0
     35md.transient.amr_frequency = 1
     36md.timestepping.start_time = 0
     37md.timestepping.final_time = 3
     38md.timestepping.time_step = 1
     39md = solve(md,'Transient')
     40
     41#Fields and tolerances to track changes
     42field_names     = ['Vx','Vy','Vel','Pressure']
     43field_tolerances = [1e-8,1e-8,1e-8,1e-8]
     44field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',300000.)
     12md = setmask(md,'','')
     13md = parameterize(md,'../Par/SquareThermal.py')
     14
     15h = 100.
     16md.geometry.thickness = h * np.ones((md.mesh.numberofvertices,))
     17md.geometry.base = -h * np.ones((md.mesh.numberofvertices,))
     18md.geometry.surface = md.geometry.base + md.geometry.thickness
     19
     20md.extrude(41,2.)
     21md = setflowequation(md,'HO','all')
     22md.thermal.isenthalpy = True
     23md.thermal.isdynamicbasalspc = True
     24
     25#Basal forcing
     26Ts = 273.15-3.
     27Tb = 273.15-1.
     28Tsw = Tb
     29qgeo = md.materials.thermalconductivity / max(md.geometry.thickness) * (Tb - Ts) #qgeo=kappa*(Tb-Ts)/H
     30md.basalforcings.geothermalflux[np.where(md.mesh.vertexonbase)] = qgeo
     31md.initialization.temperature = qgeo / md.materials.thermalconductivity * (md.geometry.surface - md.mesh.z) + Ts
     32
     33#Surface forcing
     34pos = np.where(md.mesh.vertexonsurface)
     35SPC_cold = float('NaN') * np.ones((md.mesh.numberofvertices,))
     36SPC_warm = float('NaN') * np.ones((md.mesh.numberofvertices,))
     37SPC_cold[pos] = Ts
     38SPC_warm[pos] = Tsw
     39md.thermal.spctemperature = SPC_cold
     40md.timestepping.time_step = 5.
     41t0 = 0.
     42t1 = 10.
     43t2 = 100.
     44md.timestepping.final_time = 400.
     45md.thermal.spctemperature = np.array([SPC_cold,SPC_cold,SPC_warm,SPC_warm,SPC_cold]).T
     46md.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
     51md.transient.ismasstransport = False
     52md.transient.isstressbalance = False
     53md.transient.issmb = True
     54md.transient.isthermal = True
     55md.thermal.stabilization = False
     56
     57#Go solve
     58md.verbose = verbose(0)
     59md.cluster = generic('name',gethostname(),'np',3)
     60md = solve(md,'Transient')
     61
     62#Fields and tolerances to track changes
     63field_names = ['Enthalpy1','Temperature1','Waterfraction1','BasalMeltingRate1','Watercolumn1',
     64                   'Enthalpy2','Temperature2','Waterfraction2','BasalMeltingRate2','Watercolumn2',
     65                   'Enthalpy3','Temperature3','Waterfraction3','BasalMeltingRate3','Watercolumn3',
     66                   'Enthalpy4','Temperature4','Waterfraction4','BasalMeltingRate4','Watercolumn4']
     67field_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]
     71i1 = 0
     72i2 = int(np.ceil(t2 / md.timestepping.time_step) + 2)-1
     73i3 = int(np.ceil(md.timestepping.final_time / (2. * md.timestepping.time_step)))-1
     74i4 = np.shape(md.results.TransientSolution)[0]-1
     75field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',150000.)
     12md = setmask(md,'../Exp/SquareShelf.exp','')
     13md = parameterize(md,'../Par/SquareSheetShelf.py')
     14md = setflowequation(md,'SSA','all')
     15md.cluster = generic('name',gethostname(),'np',3)
     16md.transient.isstressbalance = 1
     17md.transient.ismasstransport = 1
     18md.transient.issmb = 0
     19md.transient.isthermal = 0
     20md.transient.isgroundingline = 0
     21#amr bamg settings, just ice front
     22md.amr.hmin = 10000
     23md.amr.hmax = 100000
     24md.amr.fieldname = 'None'
     25md.amr.keepmetric = 0
     26md.amr.gradation = 1.2
     27md.amr.groundingline_resolution = 12000
     28md.amr.groundingline_distance = 0
     29md.amr.icefront_resolution = 12000
     30md.amr.icefront_distance = 100000
     31md.amr.thicknesserror_resolution = 1000
     32md.amr.thicknesserror_threshold = 0
     33md.amr.deviatoricerror_resolution = 1000
     34md.amr.deviatoricerror_threshold = 0
     35md.transient.amr_frequency = 1
     36md.timestepping.start_time = 0
     37md.timestepping.final_time = 3
     38md.timestepping.time_step = 1
     39md = solve(md,'Transient')
     40
     41#Fields and tolerances to track changes
     42field_names     = ['Vx','Vy','Vel','Pressure']
     43field_tolerances = [1e-13,1e-13,1e-13,1e-13]
     44field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from frictionwaterlayer import *
     11
     12md = triangle(model(),'../Exp/Square.exp',150000.)
     13md = setmask(md,'../Exp/SquareShelf.exp','')
     14md = parameterize(md,'../Par/SquareSheetShelf.py')
     15md = setflowequation(md,'SSA','all')
     16md.friction = frictionwaterlayer(md)
     17md.friction.water_layer = np.zeros((md.mesh.numberofvertices+1,2))
     18md.friction.water_layer[:,1] = 1.
     19md.friction.water_layer[md.mesh.numberofvertices,:] = [1.,2.]
     20md.friction.f = 0.8
     21md.cluster = generic('name',gethostname(),'np',3)
     22md = solve(md,'Transient')
     23
     24#Fields and tolerances to track changes
     25field_names =['Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1',
     26              'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2',
     27              'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3']
     28field_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]
     31field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',150000.)
     12md = setmask(md,'../Exp/SquareShelf.exp','')
     13md = parameterize(md,'../Par/SquareSheetShelf.py')
     14md = setflowequation(md,'SSA','all')
     15md.cluster = generic('name',gethostname(),'np',3)
     16md.transient.isstressbalance = 1
     17md.transient.ismasstransport = 1
     18md.transient.issmb = 0
     19md.transient.isthermal = 0
     20md.transient.isgroundingline = 0
     21#amr bamg settings, field, grounding line and ice front
     22md.amr.hmin = 20000
     23md.amr.hmax = 100000
     24md.amr.fieldname = 'Vel'
     25md.amr.keepmetric = 0
     26md.amr.gradation = 1.2
     27md.amr.groundingline_resolution = 10000
     28md.amr.groundingline_distance = 100000
     29md.amr.icefront_resolution = 15000
     30md.amr.icefront_distance = 100000
     31md.amr.thicknesserror_resolution = 1000
     32md.amr.thicknesserror_threshold = 0
     33md.amr.deviatoricerror_resolution = 1000
     34md.amr.deviatoricerror_threshold = 0
     35md.transient.amr_frequency = 1
     36md.timestepping.start_time = 0
     37md.timestepping.final_time = 3
     38md.timestepping.time_step = 1
     39md = solve(md,'Transient')
     40
     41#Fields and tolerances to track changes
     42field_names     = ['Vx','Vy','Vel','Pressure']
     43field_tolerances = [1e-8,1e-8,1e-8,1e-8]
     44field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from frictionwaterlayer import *
     11
     12md = triangle(model(),'../Exp/Square.exp',150000.)
     13md = setmask(md,'../Exp/SquareShelf.exp','')
     14md = parameterize(md,'../Par/SquareSheetShelf.py')
     15md = md.extrude(4,1.)
     16md = setflowequation(md,'HO','all')
     17md.friction = frictionwaterlayer(md)
     18md.friction.water_layer = np.zeros((md.mesh.numberofvertices+1,2))
     19md.friction.water_layer[:,1] = 1.
     20md.friction.water_layer[md.mesh.numberofvertices,:] = [1.,2.]
     21md.friction.f = 0.8
     22md.cluster = generic('name',gethostname(),'np',3)
     23md = solve(md,'Transient')
     24
     25#Fields and tolerances to track changes
     26field_names =['Vx1','Vy1','Vel1','Pressure1','Bed1','Surface1','Thickness1',
     27              'Vx2','Vy2','Vel2','Pressure2','Bed2','Surface2','Thickness2',
     28              'Vx3','Vy3','Vel3','Pressure3','Bed3','Surface3','Thickness3']
     29field_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]
     32field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from taoinversion import *
     11
     12md = triangle(model(),'../Exp/Square.exp',200000.)
     13md = setmask(md,'','')
     14md = parameterize(md,'../Par/SquareSheetConstrained.py')
     15md.extrude(3,1.)
     16md = setflowequation(md,'HO','all')
     17
     18#control parameters
     19md.inversion = taoinversion()
     20md.inversion.iscontrol = 1
     21md.inversion.control_parameters = ['FrictionCoefficient']
     22md.inversion.min_parameters = 1. * np.ones((md.mesh.numberofvertices,))
     23md.inversion.max_parameters = 200. * np.ones((md.mesh.numberofvertices,))
     24md.inversion.maxsteps = 2
     25md.inversion.maxiter = 6
     26md.inversion.cost_functions = [102,501]
     27md.inversion.cost_functions_coefficients = np.ones((md.mesh.numberofvertices,2))
     28md.inversion.cost_functions_coefficients[:,1] = 2. * 1e-7
     29md.inversion.vx_obs = md.initialization.vx
     30md.inversion.vy_obs = md.initialization.vy
     31
     32md.cluster = generic('name',gethostname(),'np',3)
     33md = solve(md,'Stressbalance')
     34
     35#Fields and tolerances to track changes
     36field_names      = ['Gradient','Misfits','FrictionCoefficient','Pressure','Vel','Vx','Vy']
     37field_tolerances = [3e-08,1e-07,5e-10,1e-10,1e-09,1e-09,1e-09]
     38field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10
     11md = triangle(model(),'../Exp/Square.exp',100000.)
     12md = setmask(md,'../Exp/SquareShelf.exp','')
     13md = parameterize(md,'../Par/SquareSheetShelf.py')
     14md.initialization.vx[:] = 1.
     15md.initialization.vy[:] = 1.
     16md.geometry.thickness[:] = 500. - md.mesh.x / 10000.
     17md.geometry.bed = -100. - md.mesh.x / 1000.
     18md.geometry.base = -md.geometry.thickness * md.materials.rho_ice / md.materials.rho_water
     19md.mask.groundedice_levelset = md.geometry.thickness + md.materials.rho_water / md.materials.rho_ice * md.geometry.bed
     20pos = np.where(md.mask.groundedice_levelset >= 0.)
     21md.geometry.base[pos] = md.geometry.bed[pos]
     22md.geometry.surface = md.geometry.base + md.geometry.thickness
     23md = setflowequation(md,'SSA','all')
     24
     25#Boundary conditions:
     26md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
     27md.mask.ice_levelset[np.where(md.mesh.x == max(md.mesh.x))] = 0.
     28md.stressbalance.spcvx[:] = float('NaN')
     29md.stressbalance.spcvy[:] = float('NaN')
     30md.stressbalance.spcvz[:] = float('NaN')
     31posA = np.intersect1d(np.array(np.where(md.mesh.y < 1000000.1)),np.array(np.where(md.mesh.y > 999999.9)))
     32posB = np.intersect1d(np.array(np.where(md.mesh.y < 0.1)),np.array(np.where(md.mesh.y > -0.1)))
     33pos = np.unique(np.concatenate((posA,posB)))
     34md.stressbalance.spcvy[pos] = 0.
     35pos2 = np.intersect1d(np.array(np.where(md.mesh.x < 0.1)), np.array(np.where(md.mesh.x > -0.1)))
     36md.stressbalance.spcvx[pos2] = 0.
     37md.stressbalance.spcvy[pos2] = 0.
     38
     39md.materials.rheology_B = 1. / ((10**-25)**(1. / 3.)) * np.ones((md.mesh.numberofvertices,))
     40md.materials.rheology_law = 'None'
     41md.friction.coefficient[:] = np.sqrt(10**7) * np.ones((md.mesh.numberofvertices,))
     42md.friction.p = 3. * np.ones((md.mesh.numberofelements,))
     43md.smb.mass_balance[:] = 1.
     44md.basalforcings.groundedice_melting_rate[:] = 0.
     45md.basalforcings.floatingice_melting_rate[:] = 30.
     46md.transient.isthermal = 0
     47md.transient.isstressbalance = 1
     48md.transient.isgroundingline = 1
     49md.transient.ismasstransport = 1
     50md.transient.issmb = 1
     51md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate']
     52md.groundingline.migration = 'SubelementMigration'
     53md.timestepping.final_time = 30
     54md.timestepping.time_step = 10
     55
     56md.cluster = generic('name',gethostname(),'np',3)
     57md = 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
     63field_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']
     67field_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]
     70field_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
     2from model import *
     3from socket import gethostname
     4from triangle import *
     5from setmask import *
     6from parameterize import *
     7from setflowequation import *
     8from solve import *
     9import numpy as np
     10from calvingminthickness import *
     11
     12md = triangle(model(),'../Exp/Square.exp',30000.)
     13md = setmask(md,'all','')
     14md = parameterize(md,'../Par/SquareShelf.py')
     15md = setflowequation(md,'SSA','all')
     16md.cluster = generic('name',gethostname(),'np',3)
     17
     18x = md.mesh.x
     19xmin = min(x)
     20xmax = max(x)
     21Lx = (xmax - xmin)
     22alpha = 2. / 3.
     23md.mask.ice_levelset = -1 + 2 * (md.mesh.y > 9e5)
     24
     25md.timestepping.time_step = 1
     26md.timestepping.final_time = 30
     27
     28#Transient
     29md.transient.isstressbalance = 1
     30md.transient.ismasstransport = 1
     31md.transient.issmb = 1
     32md.transient.isthermal = 0
     33md.transient.isgroundingline = 0
     34md.transient.isgia = 0
     35md.transient.ismovingfront = 1
     36
     37md.calving = calvingminthickness()
     38md.calving.min_thickness = 400
     39md.calving.meltingrate = np.zeros((md.mesh.numberofvertices,))
     40md.levelset.spclevelset = float('NaN')* np.ones((md.mesh.numberofvertices,))
     41md.levelset.reinit_frequency = 1
     42
     43md = solve(md,'Transient')
     44
     45#Fields and tolerances to track changes
     46field_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']
     50field_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]
     54field_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.
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from newforcing import *
     11
     12md = triangle(model(),'../Exp/Square.exp',150000.)
     13md = setmask(md,'../Exp/SquareShelf.exp','')
     14md = parameterize(md,'../Par/SquareSheetShelf.py')
     15md = setflowequation(md,'SSA','all')
     16md.initialization.vx[:] = 0.
     17md.initialization.vy[:] = 0.
     18md.smb.mass_balance[:] = 0.
     19
     20md.geometry.base = -700. - np.abs(md.mesh.y-500000.) / 1000.
     21md.geometry.bed = -700. - np.abs(md.mesh.y-500000.) / 1000.
     22md.geometry.thickness[:] = 1000.
     23md.geometry.surface = md.geometry.base + md.geometry.thickness
     24
     25md.transient.isstressbalance = 0
     26md.transient.isgroundingline = 1
     27md.transient.isthermal = 0
     28md.groundingline.migration = 'AggressiveMigration'
     29md.transient.requested_outputs = ['IceVolume','IceVolumeAboveFloatation','Sealevel']
     30
     31md.timestepping.time_step = .1
     32md.slr.sealevel = newforcing(md.timestepping.start_time, md.timestepping.final_time,
     33                             md.timestepping.time_step, -200., 200., md.mesh.numberofvertices)
     34
     35md.cluster = generic('name',gethostname(),'np',3)
     36md = 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
     41nsteps = len(md.results.TransientSolution)
     42field_names = []
     43field_tolerances = []
     44field_values = []
     45#time is off by the year constant
     46for 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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from matenhancedice import *
     11
     12md = triangle(model(),'../Exp/Square.exp',150000.)
     13md = setmask(md,'all','')
     14md.materials = matenhancedice()
     15md.materials.rheology_B = 3.15e8 * np.ones(md.mesh.numberofvertices,)
     16md.materials.rheology_n = 3 * np.ones(md.mesh.numberofelements,)
     17md.materials.rheology_E = np.ones(md.mesh.numberofvertices,)
     18md = parameterize(md,'../Par/SquareShelf.py')
     19md = setflowequation(md,'SSA','all')
     20md.cluster = generic('name',gethostname(),'np',3)
     21md = solve(md,'Stressbalance')
     22
     23#Fields and tolerances to track changes
     24field_names      = ['Vx','Vy','Vel','Pressure']
     25field_tolerances = [1e-13,1e-13,1e-13,1e-13]
     26field_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
     2from operator import itemgetter
     3import numpy as np
     4from model import *
     5from socket import gethostname
     6from triangle import *
     7from setmask import *
     8from parameterize import *
     9from setflowequation import *
     10from solve import *
     11from frictionsommers import *
     12from hydrologysommers import *
     13from transient import *
     14
     15md = triangle(model(),'../Exp/Square.exp',50000.)
     16md.mesh.x = md.mesh.x / 1000
     17md.mesh.y = md.mesh.y / 1000
     18md = setmask(md,'','')
     19md = parameterize(md,'../Par/SquareSheetConstrained.py')
     20md.transient = transient().deactivateall()
     21md.transient.ishydrology = 1
     22md = setflowequation(md,'SSA','all')
     23md.cluster = generic('name',gethostname(),'np',2)
     24
     25#Use hydroogy coupled friciton law
     26md.friction = frictionsommers(md)
     27
     28#Change hydrology class to Sommers' model
     29md.hydrology = hydrologysommers()
     30
     31#Change geometry
     32md.geometry.base = -.02 * md.mesh.x + 20.
     33md.geometry.thickness = 300. * np.ones((md.mesh.numberofvertices,))
     34md.geometry.bed = md.geometry.base
     35md.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
     38md.hydrology.head = 0.5 * md.materials.rho_ice / md.materials.rho_freshwater * md.geometry.thickness + md.geometry.base
     39md.hydrology.gap_height = 0.01 * np.ones((md.mesh.numberofelements,))
     40md.hydrology.bump_spacing = 2 * np.ones((md.mesh.numberofelements,))
     41md.hydrology.bump_height = 0.05 * np.ones((md.mesh.numberofelements,))
     42md.hydrology.englacial_input = 0.5 * np.ones((md.mesh.numberofvertices,))
     43md.hydrology.reynolds= 1000. * np.ones((md.mesh.numberofelements,))
     44md.hydrology.spchead = float('NaN') * np.ones((md.mesh.numberofvertices,))
     45pos = np.intersect1d(np.array(np.where(md.mesh.vertexonboundary)), np.array(np.where(md.mesh.x == 1000)))
     46md.hydrology.spchead[pos] = md.geometry.base[pos]
     47
     48#Define velocity
     49md.initialization.vx = 1e-6 * md.constants.yts * np.ones((md.mesh.numberofvertices,))
     50md.initialization.vy = np.zeros((md.mesh.numberofvertices,))
     51
     52md.timestepping.time_step = 3. * 3600. / md.constants.yts
     53md.timestepping.final_time = .5 / 365.
     54md.materials.rheology_B = (5e-25)**(-1. / 3.) * np.ones((md.mesh.numberofvertices,))
     55
     56#Add one moulin and Neumann BC, varying in time
     57a = np.sqrt((md.mesh.x - 500.)**2 + (md.mesh.y - 500.)**2)
     58pos = min(enumerate(a), key=itemgetter(1))[0]
     59time = np.arange(0,md.timestepping.final_time+1,md.timestepping.time_step)
     60md.hydrology.moulin_input = np.zeros((md.mesh.numberofvertices+1,np.size(time)))
     61md.hydrology.moulin_input[-1,:] = time
     62md.hydrology.moulin_input[pos,:] = 5. * (1. - np.sin(2. * np.pi / (1. / 365.) * time))
     63md.hydrology.neumannflux = np.zeros((md.mesh.numberofelements+1,np.size(time)))
     64md.hydrology.neumannflux[-1,:] = time
     65segx = md.mesh.x[md.mesh.segments[:,0]-1]
     66segy = md.mesh.y[md.mesh.segments[:,0]-1]
     67posA = np.intersect1d(np.intersect1d(np.array(np.where(segx < 1.)),np.array(np.where(segy > 400.))), np.array(np.where(segy < 600.)))
     68pos = (md.mesh.segments[posA]-1)[:,2]
     69md.hydrology.neumannflux[pos,:] = np.tile(0.05*(1.-np.sin(2.*np.pi/(1./365.)*time)),(len(pos),1))
     70
     71md = solve(md,'Transient')
     72
     73#Fields and tolerances to track changes
     74field_names = [
     75        'HydrologyHead1','HydrologyGapHeight1',
     76        'HydrologyHead2','HydrologyGapHeight2',
     77        'HydrologyHead3','HydrologyGapHeight3',
     78        'HydrologyHead4','HydrologyGapHeight4']
     79field_tolerances = [
     80        1e-13, 1e-13,
     81        1e-13, 1e-13,
     82        1e-13, 1e-13,
     83        1e-13, 1e-12]
     84field_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
     2import numpy as np
     3import scipy.io as spio
     4from model import *
     5from socket import gethostname
     6from triangle import *
     7from setmask import *
     8from parameterize import *
     9from setflowequation import *
     10from solve import *
     11from SMBgemb import *
     12
     13md = triangle(model(),'../Exp/Square.exp',200000.)
     14md = setmask(md,'all','')
     15md = parameterize(md,'../Par/SquareShelf.py')
     16md = setflowequation(md,'SSA','all')
     17md.materials.rho_ice = 910
     18md.cluster = generic('name',gethostname(),'np',3)
     19
     20#Use of Gemb method for SMB computation
     21md.smb = SMBgemb()
     22md.smb.setdefaultparameters(md.mesh,md.geometry)
     23
     24#load hourly surface forcing date from 1979 to 2009:
     25inputs = spio.loadmat('../Data/gemb_input.mat',squeeze_me=True)
     26
     27#setup the inputs:
     28md.smb.Ta = np.append(np.tile(np.conjugate(inputs['Ta0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
     29md.smb.V = np.append(np.tile(np.conjugate(inputs['V0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
     30md.smb.dswrf = np.append(np.tile(np.conjugate(inputs['dsw0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
     31md.smb.dlwrf = np.append(np.tile(np.conjugate(inputs['dlw0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
     32md.smb.P = np.append(np.tile(np.conjugate(inputs['P0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
     33md.smb.eAir = np.append(np.tile(np.conjugate(inputs['eAir0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
     34md.smb.pAir = np.append(np.tile(np.conjugate(inputs['pAir0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
     35md.smb.pAir = np.append(np.tile(np.conjugate(inputs['pAir0']),(md.mesh.numberofelements,1)),np.conjugate([inputs['dateN']]),axis=0)
     36md.smb.Vz = np.tile(np.conjugate(inputs['LP']['Vz']),(md.mesh.numberofelements,1)).flatten()
     37md.smb.Tz = np.tile(np.conjugate(inputs['LP']['Tz']),(md.mesh.numberofelements,1)).flatten()
     38md.smb.Tmean = np.tile(np.conjugate(inputs['LP']['Tmean']),(md.mesh.numberofelements,1)).flatten()
     39md.smb.C = np.tile(np.conjugate(inputs['LP']['C']),(md.mesh.numberofelements,1)).flatten()
     40
     41#smb settings
     42md.smb.requested_outputs = ['SmbDz','SmbT','SmbD','SmbRe','SmbGdn','SmbGsp','SmbEC','SmbA','SmbMassBalance']
     43
     44#only run smb core:
     45md.transient.isstressbalance = 0
     46md.transient.ismasstransport = 0
     47md.transient.isthermal = 0
     48
     49#time stepping:
     50md.timestepping.start_time = 1965.
     51md.timestepping.final_time = 1966.
     52md.timestepping.time_step = 1. / 365.0
     53md.timestepping.interp_forcings = 0.
     54
     55#Run transient
     56md = solve(md,'Transient')
     57
     58#Fields and tolerances to track changes
     59field_names      = ['SmbDz','SmbT' ,'SmbD' ,'SmbRe','SmbGdn','SmbGsp','SmbA' ,'SmbEC','SmbMassBalance']
     60field_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:
     62field_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

     
    5050        if np.size(data) > 1 and np.size(data,0)==timeserieslength:
    5151                yts = options.getfieldvalue('yts')
    5252                if np.ndim(data) > 1:
    53                         data[-1,:] = data[-1,:]*yts
     53                        data[-1,:] = yts*data[-1,:]
    5454                else:
    55                         data[-1] = data[-1]*yts
     55                        data[-1] = yts*data[-1]
    5656
    5757        #Step 1: write the enum to identify this record uniquely
    5858        fid.write(struct.pack('i',len(name)))
  • ../trunk-jpl/src/m/solve/parseresultsfromdisk.py

     
    174174                yts=md.constants.yts
    175175                if fieldname=='BalancethicknessThickeningRate':
    176176                        field = field*yts
    177                 elif fieldname=='Time':
    178                         field = field/yts
    179177                elif fieldname=='HydrologyWaterVx':
    180178                        field = field*yts
    181179                elif fieldname=='HydrologyWaterVy':
     
    190188                        field = field*yts
    191189                elif fieldname=='BasalforcingsGroundediceMeltingRate':
    192190                        field = field*yts
     191                elif fieldname=='BasalforcingsFloatingiceMeltingRate':
     192                        field = field*yts
    193193                elif fieldname=='TotalFloatingBmb':
    194                         field = field/10.**12.*yts #(GigaTon/year)
     194                        field = field/10.**12*yts #(GigaTon/year)
    195195                elif fieldname=='TotalGroundedBmb':
    196                         field = field/10.**12.*yts #(GigaTon/year)
     196                        field = field/10.**12*yts #(GigaTon/year)
    197197                elif fieldname=='TotalSmb':
    198                         field = field/10.**12.*yts #(GigaTon/year)
     198                        field = field/10.**12*yts #(GigaTon/year)
    199199                elif fieldname=='SmbMassBalance':
    200200                        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
    201215                elif fieldname=='CalvingCalvingrate':
    202216                        field = field*yts
    203217
     218                if time !=-9999:
     219                        time = time/yts
     220
    204221                saveres=OrderedDict()
    205222                saveres['fieldname']=fieldname
    206223                saveres['time']=time
  • ../trunk-jpl/src/m/geometry/NowickiProfile.py

     
     1import numpy as np
     2
     3def 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

     
    8383        #Check numel
    8484        if options.exist('numel'):
    8585                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):
    8787                        if   len(fieldnumel)==1:
    8888                                md = md.checkmessage(options.getfieldvalue('message',\
    8989                                        "field '%s' size should be %d" % (fieldname,fieldnumel)))
     
    100100                        md = md.checkmessage(options.getfieldvalue('message',\
    101101                                "NaN values found in field '%s'" % fieldname))
    102102
     103
    103104        #check Inf
    104105        if options.getfieldvalue('Inf',0):
    105106                if np.any(np.isinf(field)):
     
    106107                        md = md.checkmessage(options.getfieldvalue('message',\
    107108                                "Inf values found in field '%s'" % fieldname))
    108109
     110
    109111        #check cell
    110112        if options.getfieldvalue('cell',0):
    111113                if not isinstance(field,(tuple,list,dict)):
     
    128130
    129131        #check greater
    130132        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):
    133142                        md = md.checkmessage(options.getfieldvalue('message',\
    134143                                "field '%s' should have values above %d" % (fieldname,lowerbound)))
     144
    135145        if options.exist('>'):
    136146                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):
    138155                        md = md.checkmessage(options.getfieldvalue('message',\
    139156                                "field '%s' should have values above %d" % (fieldname,lowerbound)))
    140157
     
    141158        #check smaller
    142159        if options.exist('<='):
    143160                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):
    145169                        md = md.checkmessage(options.getfieldvalue('message',\
    146170                                "field '%s' should have values below %d" % (fieldname,upperbound)))
    147171        if options.exist('<'):
    148172                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):
    150181                        md = md.checkmessage(options.getfieldvalue('message',\
    151182                                "field '%s' should have values below %d" % (fieldname,upperbound)))
    152183
     
    163194
    164195        #Check forcings (size and times)
    165196        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:
    167198                        if np.ndim(field)>1 and not np.size(field,1)==1:
    168199                                md = md.checkmessage(options.getfieldvalue('message',\
    169200                                        "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 not 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,:])):
    172203                                md = md.checkmessage(options.getfieldvalue('message',\
    173204                                        "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:]):
    175206                                md = md.checkmessage(options.getfieldvalue('message',\
    176207                                        "field '%s' columns must not contain duplicate timesteps" % fieldname))
    177208                else:
     
    197228
    198229        return md
    199230
     231
  • ../trunk-jpl/src/m/mech/newforcing.py

     
     1import numpy as np
     2
     3def newforcing(t0,t1,deltaT,f0,f1,nodes):
     4        '''
     5FUNCTION 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

     
    3030
    3131#Manual imports for commonly used functions
    3232from plotmodel import plotmodel
     33from runme import runme
    3334
    3435#c = get_ipython().config
    3536#c.InteractiveShellApp.exec_lines = []
  • ../trunk-jpl/src/m/print/printmodel.py

     
     1
     2import 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 *
     10from pairoptions import *
     11
     12def 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:
     39options = pairoptions(*args)
     40
     41#set defaults
     42options = addfielddefault(options,'figure','gcf')
     43options = addfielddefault(options,'format','tiff')
     44options = addfielddefault(options,'resolution',1)
     45options = addfielddefault(options,'margin','on')
     46options = addfielddefault(options,'marginsize',25)
     47options = addfielddefault(options,'frame','on')
     48options = addfielddefault(options,'framesize',3)
     49options = addfielddefault(options,'framecolor','black')
     50options = addfielddefault(options,'trim','on')
     51options = addfielddefault(options,'hardcopy','off')
     52
     53#get fig:
     54fig = getfieldvalue(options,'figure')
     55if len(fig) == 1:
     56        fig=gcf
     57else:
     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
     62set(fig, 'PaperPositionMode', 'auto');
     63
     64#InvertHardcopy off imposes MATLAB to use the same colors
     65set(fig, 'InvertHardcopy', getfieldvalue(options,'hardcopy'));
     66
     67#we could have several formats, as a cell array of strings.
     68formats=format;
     69if ~iscell(formats),
     70        formats={formats};
     71end
     72
     73#loop on formats:
     74for 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
     109end
  • ../trunk-jpl/src/m/classes/thermal.py

     
    100100                md = checkfield(md,'fieldname','thermal.requested_outputs','stringrow',1)
    101101
    102102                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))
    104105                        try:
    105106                                spccol=np.size(md.thermal.spctemperature,1)
    106107                        except IndexError:
    107108                                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")
    111115                        md = checkfield(md,'fieldname','thermal.isenthalpy','numel',[1],'values',[0,1])
    112116                        md = checkfield(md,'fieldname','thermal.isdynamicbasalspc','numel',[1],'values',[0,1]);
    113117                        if(md.thermal.isenthalpy):
  • ../trunk-jpl/src/m/classes/calvingminthickness.py

     
     1from fielddisplay import fielddisplay
     2from checkfield import checkfield
     3from WriteData import WriteData
     4
     5class 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

     
     1from fielddisplay import fielddisplay
     2from project3d import project3d
     3from checkfield import checkfield
     4from WriteData import WriteData
     5
     6class 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

     
    3939    #}}}
    4040    def initialize(self,md): # {{{
    4141        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))
    4343            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"
    4447        return self
    4548    #}}}
    4649    def setdefaultparameters(self): # {{{
     
    8386            print 'WARNING: value of yts for MISMIP+ runs different from ISSM default!'
    8487
    8588        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)
    8790
    8891        WriteData(fid,prefix,'name','md.basalforcings.model','data',3,'format','Integer')
    8992        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

     
    88        SMBgradientsela Class definition
    99
    1010           Usage:
    11               SMBgradientsela=SMBgradientsela();
     11              SMBgradientsela=SMBgradientsela()
    1212        """
    1313
    1414        def __init__(self): # {{{
     
    1818                self.b_max   = float('NaN')
    1919                self.b_min   = float('NaN')
    2020                self.requested_outputs      = []
     21                self.setdefaultparameters()
    2122                #}}}
    2223        def __repr__(self): # {{{
    23                 string="   surface forcings parameters:"
     24                string = "   surface forcings parameters:"
     25                string+= '\n   SMB gradients ela parameters:'
    2426
    25                 string="%s\n%s"%(string,fielddisplay(self,'issmbgradientsela','is smb gradients ela method activated (0 or 1, default is 0)'))
    2627                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.]'))
    2728                string="%s\n%s"%(string,fielddisplay(self,'b_pos',' vertical smb gradient (dB/dz) above ela'))
    2829                string="%s\n%s"%(string,fielddisplay(self,'b_neg',' vertical smb gradient (dB/dz) below ela'))
     
    4647
    4748                return self
    4849        #}}}
     50        def setdefaultparameters(self): # {{{
     51                self.b_max=9999.
     52                self.b_min=-9999.
     53                return self
     54        #}}}
    4955        def checkconsistency(self,md,solution,analyses):    # {{{
    5056
    5157                if 'MasstransportAnalysis' in analyses:
     
    5561                        md = checkfield(md,'fieldname','smb.b_max','timeseries',1,'NaN',1,'Inf',1)
    5662                        md = checkfield(md,'fieldname','smb.b_min','timeseries',1,'NaN',1,'Inf',1)
    5763
    58                 md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1)
     64                md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1)
    5965                return md
    6066        # }}}
    6167        def marshall(self,prefix,md,fid):    # {{{
  • ../trunk-jpl/src/m/classes/constants.py

     
    1111        """
    1212
    1313        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.
    1818               
    1919                #set defaults
    2020                self.setdefaultparameters()
     
    4848        #}}}
    4949        def checkconsistency(self,md,solution,analyses):    # {{{
    5050
    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])
    5555
    5656                return md
    5757        # }}}
  • ../trunk-jpl/src/m/classes/hydrologysommers.py

     
     1from fielddisplay import fielddisplay
     2from checkfield import checkfield
     3from WriteData import WriteData
     4
     5class 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

     
    9191                md = checkfield(md,'fieldname','flowequation.isFS','numel',[1],'values',[0,1])
    9292                md = checkfield(md,'fieldname','flowequation.fe_SSA','values',['P1','P1bubble','P1bubblecondensed','P2','P2bubble'])
    9393                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'])
    9595                md = checkfield(md,'fieldname','flowequation.borderSSA','size',[md.mesh.numberofvertices],'values',[0,1])
    9696                md = checkfield(md,'fieldname','flowequation.borderHO','size',[md.mesh.numberofvertices],'values',[0,1])
    9797                md = checkfield(md,'fieldname','flowequation.borderFS','size',[md.mesh.numberofvertices],'values',[0,1])
     
    103103                if m.strcmp(md.mesh.domaintype(),'2Dhorizontal'):
    104104                        md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',[1,2])
    105105                        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])
    106109                elif m.strcmp(md.mesh.domaintype(),'3D'):
    107110                        md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',np.arange(0,8+1))
    108111                        md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',np.arange(0,8+1))
  • ../trunk-jpl/src/m/classes/basalforcings.py

     
    4444                if np.all(np.isnan(self.floatingice_melting_rate)):
    4545                        self.floatingice_melting_rate=np.zeros((md.mesh.numberofvertices))
    4646                        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"
    4750
    4851                return self
    4952        #}}}
  • ../trunk-jpl/src/m/classes/calvingvonmises.py

     
     1from fielddisplay import fielddisplay
     2from project3d import project3d
     3from checkfield import checkfield
     4from WriteData import WriteData
     5
     6class 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

     
    1111        """
    1212
    1313        def __init__(self): # {{{
    14                 self.issmb   = False
     14                self.issmb             = False
    1515                self.ismasstransport   = False
    1616                self.isstressbalance   = False
    1717                self.isthermal         = False
     
    2222                self.ismovingfront     = False
    2323                self.ishydrology       = False
    2424                self.isslr             = False
     25                self.iscoupler         = False
     26                self.amr_frequency     = 0
    2527                self.isoceancoupling   = False
    26                 self.iscoupler         = False
    27                 amr_frequency                     = 0
    2828                self.requested_outputs = []
    2929
    3030                #set defaults
     
    8080                self.requested_outputs=[]
    8181                return self
    8282        #}}}
     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        #}}}
    83103        def setdefaultparameters(self): # {{{
    84104               
    85105                #full analysis: Stressbalance, Masstransport and Thermal but no groundingline migration for now
  • ../trunk-jpl/src/m/classes/mesh2dvertical.py

     
     1import numpy as np
     2from fielddisplay import fielddisplay
     3from checkfield import checkfield
     4import MatlabFuncs as m
     5from WriteData import WriteData
     6
     7class 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

     
     1from fielddisplay import fielddisplay
     2from project3d import project3d
     3from checkfield import checkfield
     4from WriteData import WriteData
     5
     6class 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

     
    2727        self.deviatoricerror_resolution= 0.
    2828        self.deviatoricerror_threshold = 0.
    2929        self.deviatoricerror_maximum    = 0.
     30        self.restart=0.
    3031        #set defaults
    3132        self.setdefaultparameters()
    3233    #}}}
     
    4748        string="%s\n%s"%(string,fielddisplay(self,"deviatoricerror_resolution","element length when deviatoric stress error estimator is used"))
    4849        string="%s\n%s"%(string,fielddisplay(self,"deviatoricerror_threshold","maximum threshold deviatoricstress error permitted"))
    4950        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']))
    5052        return string
    5153    #}}}
    5254    def setdefaultparameters(self): # {{{
     
    6668        self.deviatoricerror_resolution= 500.
    6769        self.deviatoricerror_threshold = 0
    6870        self.deviatoricerror_maximum    = 0
     71        self.restart = 0.
    6972        return self
    7073    #}}}
    7174    def checkconsistency(self,md,solution,analyses):    # {{{
     
    8386        md = checkfield(md,'fieldname','amr.deviatoricerror_resolution','numel',[1],'>',0,'<',self.hmax,'NaN',1);
    8487        md = checkfield(md,'fieldname','amr.deviatoricerror_threshold','numel',[1],'>=',0,'<=',1,'NaN',1);       
    8588        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)
    8690        return md
    8791    # }}}
    8892    def marshall(self,prefix,md,fid):    # {{{
     
    103107        WriteData(fid,prefix,'object',self,'fieldname','deviatoricerror_resolution','format','Double');
    104108        WriteData(fid,prefix,'object',self,'fieldname','deviatoricerror_threshold','format','Double');
    105109        WriteData(fid,prefix,'object',self,'fieldname','deviatoricerror_maximum','format','Double');
     110        WriteData(fid,prefix,'object',self,'class','amr','fieldname','restart','format','Integer')
    106111    # }}}
  • ../trunk-jpl/src/m/classes/matestar.py

     
     1import numpy as np
     2from fielddisplay import fielddisplay
     3from project3d import project3d
     4from checkfield import checkfield
     5from WriteData import WriteData
     6
     7class 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

     
     1from fielddisplay import fielddisplay
     2from project3d import project3d
     3from checkfield import checkfield
     4from WriteData import WriteData
     5
     6class 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

     
     1import numpy as np
     2from fielddisplay import fielddisplay
     3from checkfield import checkfield
     4from WriteData import WriteData
     5from project3d import project3d
     6
     7class 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

     
    55from fielddisplay import fielddisplay
    66from IssmConfig import IssmConfig
    77from marshallcostfunctions import marshallcostfunctions
     8from supportedcontrols import *
     9from supportedcostfunctions import *
    810
    9 
    10 class taoinversion:
     11class taoinversion(object):
    1112        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()
    3335
    3436        def __repr__(self):
    3537                string = '   taoinversion parameters:'
     
    9799               
    98100                #several responses can be used:
    99101                self.cost_functions=101;
    100 
    101102                return self
    102103
    103104        def extrude(self,md):
     
    118119                return self
    119120
    120121        def checkconsistency(self,md,solution,analyses):
    121                 if not self.control:
     122                if not self.iscontrol:
    122123                        return md
    123124                if not IssmConfig('_HAVE_TAO_')[0]:
    124125                        md = checkmessage(md,['TAO has not been installed, ISSM needs to be reconfigured and recompiled with TAO'])
    125126
    126127
    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)
    129130
    130131                md = checkfield(md,'fieldname','inversion.iscontrol','values',[0, 1])
    131                 md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0, 1])
     132                md = checkfield(md,'fieldname','inversion.incomplete_adjoint','values',[0,1])
    132133                md = checkfield(md,'fieldname','inversion.control_parameters','cell',1,'values',supportedcontrols())
    133134                md = checkfield(md,'fieldname','inversion.maxsteps','numel',1,'>=',0)
    134135                md = checkfield(md,'fieldname','inversion.maxiter','numel',1,'>=',0)
     
    142143                PETSCMAJOR = IssmConfig('_PETSC_MAJOR_')[0]
    143144                PETSCMINOR = IssmConfig('_PETSC_MINOR_')[0]
    144145                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'])
    146147                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'])
    148149
    149150
    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())
    151152                md = checkfield(md,'fieldname','inversion.cost_functions_coefficients','size',[md.mesh.numberofvertices, num_costfunc],'>=',0)
    152153                md = checkfield(md,'fieldname','inversion.min_parameters','size',[md.mesh.numberofvertices, num_controls])
    153154                md = checkfield(md,'fieldname','inversion.max_parameters','size',[md.mesh.numberofvertices, num_controls])
     
    161162                        md = checkfield(md,'fieldname','inversion.vx_obs','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
    162163                        md = checkfield(md,'fieldname','inversion.vy_obs','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
    163164
    164                 def marshall(self, md, fid):
     165        def marshall(self,prefix,md,fid):
    165166
    166                         yts=md.constants.yts;
    167                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','iscontrol','format','Boolean')
    168                         WriteData(fid,prefix,'name','md.inversion.type','data',1,'format','Integer')
    169                         if not self.iscontrol:
    170                                 return
    171                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','incomplete_adjoint','format','Boolean')
    172                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','maxsteps','format','Integer')
    173                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','maxiter','format','Integer')
    174                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','fatol','format','Double')
    175                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','frtol','format','Double')
    176                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','gatol','format','Double')
    177                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','grtol','format','Double')
    178                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','gttol','format','Double')
    179                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','algorithm','format','String')
    180                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','cost_functions_coefficients','format','DoubleMat','mattype',1)
    181                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','min_parameters','format','DoubleMat','mattype',3)
    182                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','max_parameters','format','DoubleMat','mattype',3)
    183                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vx_obs','format','DoubleMat','mattype',1,'scale',1./yts)
    184                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vy_obs','format','DoubleMat','mattype',1,'scale',1./yts)
    185                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','vz_obs','format','DoubleMat','mattype',1,'scale',1./yts)
    186                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','thickness_obs','format','DoubleMat','mattype',1)
    187                         WriteData(fid,prefix,'object',self,'class','inversion','fieldname','surface_obs','format','DoubleMat','mattype',1)
     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)
    188189
    189                         #process control parameters
    190                         num_control_parameters = np.numel(self.control_parameters)
    191                         WriteData(fid,prefix,'object',self,'fieldname','control_parameters','format','StringArray')
    192                         WriteData(fid,prefix,'data',num_control_parameters,'name','md.inversion.num_control_parameters','format','Integer')
     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')
    193194
    194                         #process cost functions
    195                         num_cost_functions = np.size(self.cost_functions,2)
    196                         data= marshallcostfunctions(self.cost_functions)
    197                         WriteData(fid,prefix,'data',data,'name','md.inversion.cost_functions','format','StringArray')
    198                         WriteData(fid,prefix,'data',num_cost_functions,'name','md.inversion.num_cost_functions','format','Integer')
     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

     
    357357                        dt=min(dtime);
    358358           
    359359                        WriteData(fid,prefix,'data',dt,'name','md.smb.dt','format','Double','scale',yts);
    360            
     360
    361361                        % Check if smb_dt goes evenly into transient core time step
    362362                        if (mod(md.timestepping.time_step,dt) >= 1e-10)
    363363                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

     
     1from fielddisplay import fielddisplay
     2from checkfield import checkfield
     3from WriteData import WriteData
     4from project3d import project3d
     5
     6class 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
     2import numpy as np
     3from scipy.interpolate import interp1d
     4from model import *
     5from solve import *
     6from setflowequation import *
     7from bamgflowband import *
     8from paterson import *
     9
     10x = np.arange(1,3001,100).T
     11h = np.linspace(1000,300,np.size(x)).T
     12b = -917./1023.*h
     13
     14md = bamgflowband(model(),x,b+h,b,'hmax',80.)
     15print md.mesh.numberofvertices
     16
     17#Geometry           #interp1d returns a function to be called on md.mesh.x
     18md.geometry.surface = interp1d(x,b+h)(md.mesh.x)
     19md.geometry.base = interp1d(x,b)(md.mesh.x)
     20md.geometry.thickness = md.geometry.surface-md.geometry.base
     21
     22#mask
     23md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
     24md.mask.ice_levelset[np.where(md.mesh.vertexflags(2))] = 0.
     25md.mask.groundedice_levelset = np.zeros((md.mesh.numberofvertices,)) - 0.5
     26
     27#materials
     28md.initialization.temperature = (273.-20.)*np.ones((md.mesh.numberofvertices,))
     29md.materials.rheology_B = paterson(md.initialization.temperature)
     30md.materials.rheology_n = 3.*np.ones((md.mesh.numberofelements,))
     31
     32#friction
     33md.friction.coefficient = np.zeros((md.mesh.numberofvertices,))
     34md.friction.coefficient[np.where(md.mesh.vertexflags(1))] = 20.
     35md.friction.p = np.ones((md.mesh.numberofelements,))
     36md.friction.q = np.ones((md.mesh.numberofelements,))
     37
     38#Boundary conditions
     39md.stressbalance.referential = float('NaN')*np.ones((md.mesh.numberofvertices,6))
     40md.stressbalance.loadingforce = 0. * np.ones((md.mesh.numberofvertices,3))
     41md.stressbalance.spcvx = float('NaN') * np.ones((md.mesh.numberofvertices,))
     42md.stressbalance.spcvy = float('NaN') * np.ones((md.mesh.numberofvertices,))
     43md.stressbalance.spcvz = float('NaN') * np.ones((md.mesh.numberofvertices,))
     44md.stressbalance.spcvx[np.where(md.mesh.vertexflags(4))] = 0.
     45md.stressbalance.spcvy[np.where(md.mesh.vertexflags(4))] = 0.
     46
     47#Misc
     48md = setflowequation(md,'FS','all')
     49md.stressbalance.abstol = float('NaN')
     50#md.stressbalance.reltol = 10**-16
     51md.stressbalance.FSreconditioning = 1.
     52md.stressbalance.maxiter = 20
     53md.flowequation.augmented_lagrangian_r = 10000.
     54md.miscellaneous.name  =  'test701'
     55md.verbose = verbose('convergence',True)
     56md.cluster = generic('np',2)
     57
     58#Go solve
     59field_names = []
     60field_tolerances = []
     61field_values = []
     62#md.initialization.pressure = md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.y)
     63for 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
     2import numpy as np
     3from scipy.interpolate import interp1d
     4import copy
     5from model import  *
     6from socket import gethostname
     7from triangle import  *
     8from meshconvert import  *
     9from setmask import  *
     10from parameterize import  *
     11from setflowequation import  *
     12from solve import  *
     13from NowickiProfile import *
     14from bamgflowband import *
     15from paterson import *
     16
     17#mesh parameters
     18x  = np.arange(-5,5.5,.5).T
     19[b,h,sea] = NowickiProfile(x)
     20x = x * 10**3
     21h = h * 10**3
     22b = (b-sea) * 10**3
     23
     24#mesh domain
     25md = bamgflowband(model(),x,b+h,b,'hmax',150)
     26print md.mesh.numberofvertices
     27
     28#geometry
     29md.geometry.surface = interp1d(x,b+h)(md.mesh.x)
     30md.geometry.base = interp1d(x,b)(md.mesh.x)
     31md.geometry.thickness = md.geometry.surface - md.geometry.base
     32
     33#mask
     34md.mask.ice_levelset = -np.ones((md.mesh.numberofvertices,))
     35md.mask.ice_levelset[np.where(md.mesh.vertexflags(2))] = 0
     36md.mask.groundedice_levelset = np.zeros((md.mesh.numberofvertices,)) - 0.5
     37
     38#materials
     39md.initialization.temperature = (273. - 20.) * np.ones((md.mesh.numberofvertices,))
     40md.materials.rheology_B = paterson(md.initialization.temperature)
     41md.materials.rheology_n = 3 * np.ones((md.mesh.numberofelements,))
     42
     43#friction
     44md.friction.coefficient = np.zeros((md.mesh.numberofvertices,))
     45md.friction.coefficient[np.where(md.mesh.vertexflags(1))] = 20
     46md.friction.p = np.ones((md.mesh.numberofelements,))
     47md.friction.q = np.ones((md.mesh.numberofelements,))
     48
     49#boundary conditions
     50md.stressbalance.spcvx = float('NaN') * np.ones((md.mesh.numberofvertices,))
     51md.stressbalance.spcvy = float('NaN') * np.ones((md.mesh.numberofvertices,))
     52md.stressbalance.spcvz = float('NaN') * np.ones((md.mesh.numberofvertices,))
     53md.stressbalance.referential = float('NaN') * np.ones((md.mesh.numberofvertices,6))
     54md.stressbalance.loadingforce = 0 * np.ones((md.mesh.numberofvertices,3))
     55md.stressbalance.spcvx[np.where(md.mesh.vertexflags(4))] = 800.
     56md.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
     70md = setflowequation(md,'FS','all')
     71md.flowequation.fe_FS = 'TaylorHood'
     72md.stressbalance.abstol = float('NaN')
     73md.miscellaneous.name = 'test703'
     74
     75#Transient settings
     76md.timestepping.time_step = 0.000001
     77md.timestepping.final_time = 0.000005
     78md.stressbalance.shelf_dampening = 1.
     79md.smb.mass_balance = np.zeros((md.mesh.numberofvertices,))
     80md.basalforcings.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices,))
     81md.basalforcings.floatingice_melting_rate = np.zeros((md.mesh.numberofvertices,))
     82md.basalforcings.geothermalflux = np.zeros((md.mesh.numberofvertices,))
     83posb = np.intersect1d(np.where(md.mesh.x > 0.), np.where(md.mesh.vertexonbase))
     84md.basalforcings.groundedice_melting_rate[posb] = 18.
     85md.basalforcings.floatingice_melting_rate[posb] = 18.
     86md.initialization.vx = np.zeros((md.mesh.numberofvertices,))
     87md.initialization.vy = np.zeros((md.mesh.numberofvertices,))
     88md.initialization.pressure = np.zeros((md.mesh.numberofvertices,))
     89md.masstransport.spcthickness = float('NaN') * np.ones((md.mesh.numberofvertices,))
     90md.thermal.spctemperature = float('NaN') * np.ones((md.mesh.numberofvertices,))
     91md.transient.isthermal = 0
     92md.masstransport.isfreesurface = 1
     93
     94#Go solve
     95md.cluster = generic('np',3)
     96md.stressbalance.shelf_dampening = 1
     97md1 = solve(md,'Transient')
     98
     99md.stressbalance.shelf_dampening = 0
     100md = solve(md,'Transient')
     101
     102#Fields and tolerances to track changes
     103field_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']
     110field_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]
     117field_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
     2import numpy as np
     3from model import *
     4from socket import gethostname
     5from triangle import *
     6from setmask import *
     7from parameterize import *
     8from setflowequation import *
     9from solve import *
     10from mismipbasalforcings import *
     11
     12md = triangle(model(),'../Exp/Square.exp',150000.)
     13md = setmask(md,'all','')
     14md = parameterize(md,'../Par/SquareShelf.py')
     15md = setflowequation(md,'SSA','all')
     16md.cluster = generic('name',gethostname(),'np',3)
     17md.constants.yts = 365.2422 * 24. * 3600.
     18md.basalforcings = mismipbasalforcings()
     19md.basalforcings = md.basalforcings.initialize(md)
     20md.transient.isgroundingline = 1
     21md.geometry.bed = min(md.geometry.base) * np.ones(md.mesh.numberofvertices,)
     22md.transient.requested_outputs = ['default','BasalforcingsFloatingiceMeltingRate']
     23print md.constants.yts
     24
     25md = solve(md,'Transient')
     26
     27#Fields and tolerances to track changes
     28field_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']
     31field_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]
     35field_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

     
     1import numpy as  np
     2from model import *
     3from collections import OrderedDict
     4from bamg import *
     5from mesh2dvertical import *
     6
     7def 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

     
    11import os.path
    22import numpy as  np
    3 from mesh2d import mesh2d
     3from mesh2dvertical import *
    44from collections import OrderedDict
    55from pairoptions import pairoptions
    66from bamggeom import bamggeom
     
    7979
    8080                #Check that file exists
    8181                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
    8588
    8689                #Build geometry
    8790                count=0
     
    8891                for i,domaini in enumerate(domain):
    8992
    9093                        #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]):
    9295                                raise RuntimeError("bamg error message: all contours provided in ''domain'' should be closed")
    9396
    9497                        #Checks that all holes are INSIDE the principle domain outline
    9598                        if i:
    96                                 flags=ContourToNodes(domaini['x'],domaini['y'],domainfile,0)[0]
     99                                flags=ContourToNodes(domaini.x,domaini.y,domainfile,0)[0]
    97100                                if np.any(np.logical_not(flags)):
    98101                                        raise RuntimeError("bamg error message: All holes should be strictly inside the principal domain")
    99102
    100103                        #Add all points to bamg_geometry
    101                         nods=domaini['nods']-1    #the domain are closed 0=end
    102                         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))
    103106                        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))
    104107                        if i:
    105108                            bamg_geometry.SubDomains=np.vstack((bamg_geometry.SubDomains,[2,count+1,1,-subdomain_ref]))
     
    115118                        #update counter
    116119                        count+=nods
    117120
     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
    118127                #take care of rifts
    119128                if options.exist('rifts'):
    120129
     
    322331        bamgmesh_out,bamggeom_out=BamgMesher(bamg_mesh.__dict__,bamg_geometry.__dict__,bamg_options)
    323332
    324333        # 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
    325389        md.private.bamg=OrderedDict()
    326390        md.private.bamg['mesh']=bamgmesh(bamgmesh_out)
    327391        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]=True
    342392        md.mesh.elementconnectivity=md.private.bamg['mesh'].ElementConnectivity
    343393        md.mesh.elementconnectivity[np.nonzero(np.isnan(md.mesh.elementconnectivity))]=0
    344394        md.mesh.elementconnectivity=md.mesh.elementconnectivity.astype(int)
Note: See TracBrowser for help on using the repository browser.