コード例 #1
0
ファイル: transient.py プロジェクト: JacobDowns/cslvr
thklim = 50.0

vara = DataFactory.get_searise(thklim=thklim)
mesh = MeshFactory.get_greenland_coarse()
dsr = DataInput(vara, mesh=mesh)

S = dsr.get_spline_expression('S')
B = dsr.get_spline_expression('B')
SMB = dsr.get_spline_expression('adot')
T_s = dsr.get_spline_expression('T')
q_geo = dsr.get_spline_expression('q_geo')
U_ob = dsr.get_spline_expression('U_ob')
Tn = vara['Tn']['map_data']

# create the model :
model = Model()

model.set_mesh(mesh)
model.set_geometry(S, B, deform=True)
model.set_parameters(IceParameters())
model.calculate_boundaries()
model.initialize_variables()

# specify solver parameters :
nonlin_solver_params = default_nonlin_solver_params()
nonlin_solver_params['newton_solver']['relaxation_parameter'] = 0.7
nonlin_solver_params['newton_solver']['relative_tolerance'] = 1e-3
nonlin_solver_params['newton_solver']['maximum_iterations'] = 20
nonlin_solver_params['newton_solver']['error_on_nonconvergence'] = False
nonlin_solver_params['newton_solver']['linear_solver'] = 'gmres'
nonlin_solver_params['newton_solver']['preconditioner'] = 'hypre_amg'
コード例 #2
0
# Load the transect data from a file
transect_xs = loadtxt("transect_data/transect_xs.txt")
transect_zs = loadtxt("transect_data/transect_zs.txt")

# Get the range of transect xs 
xmin = transect_xs.min()
xmax = transect_xs.max()
# Also get the z range for reference
zmin = transect_zs.min()
zmax = transect_zs.max()

# Interpolate the transect data
bed = interp1d(transect_xs, transect_zs, kind = 3)

model = Model()
# Number of subdivisions for the uniform mesh
nx = 200
ny = 25
nz = 15
# The model will be about 400 km (x) across flow and 100km with flow (y)
model.generate_uniform_mesh(nx, ny, nz, xmin=xmin, xmax=xmax, ymin=0, ymax=100000, 
                            generate_pbcs=False)                          

# Expression for the bed elevation
class BedExpression(Expression):
  def eval(self, values, x):
    # Get the z coordinate for this x value
    values[0] = bed(x[0])
  
# The minimum height of the surface above the bed
コード例 #3
0
ファイル: EISMINT_II_A.py プロジェクト: whigg/varglas_scripts
config = default_config()
config['log'] = True
config['mode'] = 'transient'
config['model_order'] = 'L1L2'
config['output_path'] = out_dir
config['t_start'] = 0.0
config['t_end'] = 200000.0
config['time_step'] = 10.0
config['periodic_boundary_conditions'] = False
config['velocity']['poly_degree'] = 2
config['enthalpy']['on'] = True
config['enthalpy']['N_T'] = 8
config['free_surface']['on'] = True
config['free_surface']['thklim'] = thklim

model = Model(config)
model.set_mesh(mesh)

model.rhoi = 910.0


# GEOMETRY AND INPUT DATA
class Surface(Expression):
    def eval(self, values, x):
        values[0] = thklim


S = Surface(element=model.Q.ufl_element())


class Bed(Expression):
コード例 #4
0
from varglas.physical_constants import IceParameters
from varglas.helper             import default_nonlin_solver_params
from fenics                     import set_log_active, File, Expression, pi, \
                                       sin, tan

set_log_active(True)

alpha = 0.1 * pi / 180
L     = 40000

nx = 40
ny = 40
nz = 10


model = Model()
model.generate_uniform_mesh(nx, ny, nz, xmin=0, xmax=L, ymin=0, ymax=L, 
                            generate_pbcs=True)

Surface = Expression('- x[0] * tan(alpha)', alpha=alpha, 
                     element=model.Q.ufl_element())
Bed     = Expression('- x[0] * tan(alpha) - 1000.0', alpha=alpha, 
                     element=model.Q.ufl_element())
Beta2   = Expression(  '1000 + 1000 * sin(2*pi*x[0]/L) * sin(2*pi*x[1]/L)',
                     alpha=alpha, L=L, element=model.Q.ufl_element())

model.set_geometry(Surface, Bed, deform=True)
model.set_parameters(IceParameters())
model.calculate_boundaries()
model.initialize_variables()
コード例 #5
0
config['velocity']['poly_degree'] = 2
config['enthalpy']['on'] = True
config['enthalpy']['N_T'] = 8
config['free_surface']['on'] = True
config['free_surface']['thklim'] = thklim
config['velocity']['transient_beta'] = 'stats'

bedmap2 = DataFactory.get_bedmap2()
db2 = DataInput(bedmap2, mesh=mesh)

db2.data['Sn'] = db2.data['S'] + thklim

B = db2.get_expression("B", near=True)
S = db2.get_expression("Sn", near=True)

model = Model(config)
model.set_mesh(mesh)


class Adot(Expression):
    Rel = 450000
    s = 1e-5

    def eval(self, values, x):
        values[0] = min(
            0.5, self.s * (self.Rel - sqrt((x[0] - x0)**2 + (x[1] - y0)**2)))


adot = Adot(element=model.Q.ufl_element())

コード例 #6
0
    'adjoint': {
        'alpha': None,
        'beta': None,
        'max_fun': None,
        'objective_function': 'logarithmic',
        'animate': False
    }
}

alpha = 0.5 * pi / 180
L = 40000
nx = 50
ny = 50
nz = 10

model = Model()
model.generate_uniform_mesh(nx,
                            ny,
                            nz,
                            xmin=0,
                            xmax=L,
                            ymin=0,
                            ymax=L,
                            generate_pbcs=True)

Surface = Expression('- x[0] * tan(alpha)',
                     alpha=alpha,
                     element=model.Q.ufl_element())
Bed     = Expression(  '- x[0] * tan(alpha) - 1000.0 + 500.0 * ' \
                     + ' sin(2*pi*x[0]/L) * sin(2*pi*x[1]/L)',
                     alpha=alpha, L=L, element=model.Q.ufl_element())
コード例 #7
0
# Load the transect data from a file
transect_xs = loadtxt("transect_data/transect_xs.txt")
transect_zs = loadtxt("transect_data/transect_zs.txt")

# Get the range of transect xs 
xmin = transect_xs.min()
xmax = transect_xs.max()
# Also get the z range for reference
zmin = transect_zs.min()
zmax = transect_zs.max()

# Interpolate the transect data
bed = interp1d(transect_xs, transect_zs, kind = 3)

model = Model()
# Load in a flat, unstructured mesh
flat_mesh = Mesh('meshes/transect_mesh_1H.xml')
model.set_mesh(flat_mesh)             

# Expression for the bed elevation
class BedExpression(Expression):
  def eval(self, values, x):
    # Get the z coordinate for this x value
    values[0] = bed(x[0])
  
# The minimum height of the surface above the bed
min_surface = 200
# Angle of the surface slope in the y direction
alpha = 0.2 * pi / 180
# Surface slope
コード例 #8
0
config['log_history']                  = True
config['mode']                         = 'transient'
config['model_order']                  = 'L1L2'
config['output_path']                  = out_dir
config['t_start']                      = 0.0
config['t_end']                        = 5000.0
config['time_step']                    = 10.0
config['periodic_boundary_conditions'] = False
config['velocity']['poly_degree']      = 2
config['enthalpy']['on']               = True
config['enthalpy']['N_T']              = 8
config['free_surface']['on']           = True
config['free_surface']['thklim']       = thklim
#config['velocity']['transient_beta']   = 'stats'

model = Model(config)
model.set_mesh(mesh)

model.rhoi = 910.0

S = Function(model.Q)
B = Function(model.Q)

File(in_dir + 'S.xml') >> S
File(in_dir + 'B.xml') >> B

class Adot(Expression):
  Rel = 450000
  s   = 1e-5
  def eval(self,values,x):
    values[0] = min(0.5,self.s*(self.Rel-sqrt(x[0]**2 + x[1]**2)))