Example #1
0
File: model.py Project: pf4d/issm
    def __init__(self):  #{{{

        # classtype=model.properties

        # for classe in dict.keys(classtype):
        # 	print classe
        # 	self.__dict__[classe] = classtype[str(classe)]

        self.mesh = mesh2d()
        self.mask = mask()
        self.geometry = geometry()
        self.constants = constants()
        self.smb = SMBforcing()
        self.basalforcings = basalforcings()
        self.materials = matice()
        self.damage = damage()
        self.friction = friction()
        self.flowequation = flowequation()
        self.timestepping = timestepping()
        self.initialization = initialization()
        self.rifts = rifts()
        self.slr = slr()

        self.debug = debug()
        self.verbose = verbose()
        self.settings = settings()
        self.toolkits = toolkits()
        self.cluster = generic()

        self.balancethickness = balancethickness()
        self.stressbalance = stressbalance()
        self.groundingline = groundingline()
        self.hydrology = hydrologyshreve()
        self.masstransport = masstransport()
        self.thermal = thermal()
        self.steadystate = steadystate()
        self.transient = transient()
        self.levelset = levelset()
        self.calving = calving()
        self.gia = giaivins()

        self.autodiff = autodiff()
        self.inversion = inversion()
        self.qmu = qmu()
        self.amr = amr()

        self.results = results()
        self.outputdefinition = outputdefinition()
        self.radaroverlay = radaroverlay()
        self.miscellaneous = miscellaneous()
        self.private = private()
def test_m_110():
    theta = np.pi/4
    m = df.project(df.Constant((1, 0, 1)), VV)
    u, j, i = amr(mesh, m, DirichletBoundary, g, mesh2d, s0=1, alpha=1)
    # Check the potential in the middle of the sample.
    assert abs(u(d/2., d/2., d/2.) - 0.5) < tol
    # Check electric field.
    E = df.project(-df.grad(u), VV)
    assert abs(E(0.5, 0.5, 0.5)[0] - 1./d) < tol
    assert abs(E(0.5, 0.5, 0.5)[1] - 0) < tol
    assert abs(E(0.5, 0.5, 0.5)[2] - 0) < tol
    # Check current density.
    rho = 1 + np.cos(theta)**2
    assert abs(j(0.5, 0.5, 0.5)[0] - 1./(d*rho)) < tol
    assert abs(j(0.5, 0.5, 0.5)[1] - 0) < tol
    assert abs(j(0.5, 0.5, 0.5)[2] - 0) < tol
    # Check current (current density flux).
    assert abs(i - d/rho) < tol
def test_m_101():
    theta = np.pi / 4
    m = df.project(df.Constant((1, 0, 1)), VV)
    u, j, i = amr(mesh, m, DirichletBoundary, g, mesh2d, s0=1, alpha=1)
    # Check the potential in the middle of the sample.
    assert abs(u(d / 2., d / 2., d / 2.) - 0.5) < tol
    # Check electric field.
    E = df.project(-df.grad(u), VV)
    assert abs(E(0.5, 0.5, 0.5)[0] - 1. / d) < tol
    assert abs(E(0.5, 0.5, 0.5)[1] - 0) < tol
    assert abs(E(0.5, 0.5, 0.5)[2] - 0) < tol
    # Check current density.
    rho = 1 + np.cos(theta)**2
    assert abs(j(0.5, 0.5, 0.5)[0] - 1. / (d * rho)) < tol
    assert abs(j(0.5, 0.5, 0.5)[1] - 0) < tol
    assert abs(j(0.5, 0.5, 0.5)[2] - 0) < tol
    # Check current (current density flux).
    assert abs(i - d / rho) < tol
def test_m_001():
    theta = np.pi/2
    m = df.project(df.Constant((0, 0, 1)), VV)
    u, j, i = amr(mesh, m, DirichletBoundary, g, mesh2d, s0=1, alpha=1)
    # Check the potential in the middle of the sample.
    # The correct solution should be one half of applied potential (0.5).
    assert abs(u(d/2., d/2., d/2.) - 0.5) < tol
    # Check electric field.
    # The electric field magnitude can be computed as U/d where U
    # is the applied voltage and d is the sample length.
    # In this case the correct E = (1/d, 0, 0)
    E = df.project(-df.grad(u), VV)
    assert abs(E(0.5, 0.5, 0.5)[0] - 1./d) < tol
    assert abs(E(0.5, 0.5, 0.5)[1] - 0) < tol
    assert abs(E(0.5, 0.5, 0.5)[2] - 0) < tol
    # Check current density.
    # Current density is the conductivity * electric field.
    rho = 1 + np.cos(theta)**2
    assert abs(j(0.5, 0.5, 0.5)[0] - 1./(d*rho)) < tol
    assert abs(j(0.5, 0.5, 0.5)[1] - 0) < tol
    assert abs(j(0.5, 0.5, 0.5)[2] - 0) < tol
    # Check current (current density flux).
    assert abs(i - d/rho) < tol
def test_m_001():
    theta = np.pi / 2
    m = df.project(df.Constant((0, 0, 1)), VV)
    u, j, i = amr(mesh, m, DirichletBoundary, g, mesh2d, s0=1, alpha=1)
    # Check the potential in the middle of the sample.
    # The correct solution should be one half of applied potential (0.5).
    assert abs(u(d / 2., d / 2., d / 2.) - 0.5) < tol
    # Check electric field.
    # The electric field magnitude can be computed as U/d where U
    # is the applied voltage and d is the sample length.
    # In this case the correct E = (1/d, 0, 0)
    E = df.project(-df.grad(u), VV)
    assert abs(E(0.5, 0.5, 0.5)[0] - 1. / d) < tol
    assert abs(E(0.5, 0.5, 0.5)[1] - 0) < tol
    assert abs(E(0.5, 0.5, 0.5)[2] - 0) < tol
    # Check current density.
    # Current density is the conductivity * electric field.
    rho = 1 + np.cos(theta)**2
    assert abs(j(0.5, 0.5, 0.5)[0] - 1. / (d * rho)) < tol
    assert abs(j(0.5, 0.5, 0.5)[1] - 0) < tol
    assert abs(j(0.5, 0.5, 0.5)[2] - 0) < tol
    # Check current (current density flux).
    assert abs(i - d / rho) < tol