Ejemplo n.º 1
0
Archivo: model.py Proyecto: 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()
Ejemplo n.º 2
0
def test_linear_single_dispatch():
    class A(int): pass
    class B(A): pass
    
    f = generic(lambda: None)
    register(f, object)
    register(f, int)
    register(f, A)

    x = object()
    assert f(x) == object
    assert f(0) == int 
    assert f(A(0)) == A
    assert f(B(0)) == A
    assert f(0.0) == object
Ejemplo n.º 3
0
def test_linear_multiple_dispatch():
    class A(int): pass
    class B(A): pass
    
    f = generic(lambda: None)
    register(f, object, object)
    register(f, int, int)
    register(f, int, A)
    register(f, A, A)

    x = object()
    assert f(x, x) == (object, object)
    assert f(0, 0) == (int, int) 
    assert f(0, A(0)) == (int, A)
    assert f(0, B(0)) == (int, A)
    assert f(A(0), 0) == (int, int)
    assert f(A(0), B(0)) == (A, A)
    assert f(0, x) == (object, object)
Ejemplo n.º 4
0
############################################################################
#Function Name  : compileFileName                                          #
#Input          : Nil                                                      #
#Return Value   : just sets the suffix fileName for logs                   #
############################################################################
def compileFileName():
    dayTime = generic.dateTimeFields()
    dayTime += '_' + 'wowgic'
    return dayTime


############################################################################

globalS.init()  #intialize the global variables
generic = generic.generic()

#==============================================================================#
#           Opening log file to record all the cli outputs                     #
#==============================================================================#
sufFileName = compileFileName()
logFileName = "/tmp/" + sufFileName + ".log"
logger = loggerRecord.loggerInit(logFileName, args.logLevel)
logger.debug('Log file# %s & TestBed file ', logFileName)

#keys from twitter is stored here temp will be removed once we access the user credentials
#chella's credentials
consumer_key = 'HwvpHtsPt3LmOZocZXwtn72Zv'
consumer_secret = 'afVEAR0Ri3ZluVItqbDi0kfm7BHSxjwRXbpw9m9kFhXGjnzHKh'
access_token = '419412786-cpS2hDmR6cuIf8BD2kSSri0BAWAmXBA3pzcB56Pw'
access_secret = 'pRx5MNKkmxyImwuhUFMNVOr1NrAWcRmOGUgGTLVYFAjsJ'
Ejemplo n.º 5
0
#Test Name: SquareShelfConstrainedStressSSA2d
from model import *
from socket import gethostname
from triangle import *
from setmask import *
from parameterize import *
from setflowequation import *
from solve import *
from massfluxatgate import massfluxatgate
from generic import generic

md=triangle(model(),'../Exp/Square.exp',50000)
md=setmask(md,'all','')
md=parameterize(md,'../Par/SquareShelfConstrained.py')
md=setflowequation(md,'SSA','all')
md.cluster=generic('name',gethostname(),'np',3)

#outputs
md.stressbalance.requested_outputs=['default','DeviatoricStressxx','DeviatoricStressyy','DeviatoricStressxy','MassFlux1','MassFlux2','MassFlux3','MassFlux4','MassFlux5','MassFlux6']
md.outputdefinition.definitions=[massfluxatgate('name','MassFlux1','profilename','../Exp/MassFlux1.exp','definitionstring','Outputdefinition1'),
																 massfluxatgate('name','MassFlux2','profilename','../Exp/MassFlux2.exp','definitionstring','Outputdefinition2'),
																 massfluxatgate('name','MassFlux3','profilename','../Exp/MassFlux3.exp','definitionstring','Outputdefinition3'),
																 massfluxatgate('name','MassFlux4','profilename','../Exp/MassFlux4.exp','definitionstring','Outputdefinition4'),
																 massfluxatgate('name','MassFlux5','profilename','../Exp/MassFlux5.exp','definitionstring','Outputdefinition5'),
																 massfluxatgate('name','MassFlux6','profilename','../Exp/MassFlux6.exp','definitionstring','Outputdefinition6')]

md=solve(md,'Stressbalance')

#Fields and tolerances to track changes
field_names     =['Vx','Vy','Vel','Pressure',
									'DeviatoricStressxx','DeviatoricStressyy','DeviatoricStressxy',
Ejemplo n.º 6
0
from fibonacci import fibonacci
from generic import generic


def make_fibonacci(f):
    def result(x):
        if x == 0:
            return 0
        elif x == 1:
            return 1
        else:
            return f(x - 1) + f(x - 2)

    return result


for n in range(0, 10):
    print(n, fibonacci(n), generic(make_fibonacci)(n))
Ejemplo n.º 7
0
############################################################################
# Function Name  : compileFileName                                          #
# Input          : Nil                                                      #
# Return Value   : just sets the suffix fileName for logs                   #
############################################################################
def compileFileName():
    dayTime = generic.dateTimeFields()
    dayTime = "wowgic" + "_" + "flask"
    return dayTime


############################################################################

globalS.init()  # intialize the global variables
globalS.dictDb = app.config
generic = generic.generic()

# ==============================================================================#
#           Opening log file to record all the cli outputs                     #
# ==============================================================================#
sufFileName = compileFileName()
logFileName = "/tmp/" + sufFileName + ".log"
logger, fhandler = loggerRecord.loggerInit(logFileName, args.logLevel)
logger.debug("Log file# %s & TestBed file", logFileName)
logger.debug("global dictDB file# %s", globalS.dictDb)
# logger.debug('global app file# %s',app.config)
logger.info(
    """
.----------------.  .----------------.  .----------------.  .----------------.  .----------------.  .----------------.
| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
| | _____  _____ | || |     ____     | || | _____  _____ | || |    ______    | || |     _____    | || |     ______   | |
Ejemplo n.º 8
0
    # Controls
    md.inversion.control_parameters = ["FrictionCoefficient"]
    md.inversion.min_parameters = 1 * np.ones(shape=(md.mesh.numberofvertices,
                                                     1))
    md.inversion.max_parameters = 200 * np.ones(
        shape=(md.mesh.numberofvertices, 1))

    # Additional parameters
    md.stressbalance.restol = 0.01
    md.stressbalance.reltol = 0.1
    md.stressbalance.abstol = np.NaN

    # Solve
    md.toolkits = toolkits()
    md.cluster = generic("name",
                         os.uname()[1], "np", 2, "executionpath",
                         os.path.abspath("Pig/Models"))
    md = solve(md, "Stressbalance")
    md.inversion.control_parameters

    md.materials.rheology_B
    # Update model friction fields accordingly
    md.friction.coefficient = md.results.StressbalanceSolution.FrictionCoefficient

    plotmodel(md, "data", md.friction.coefficient, "data",
              md.materials.rheology_B)

    # Save model
    savevars("Pig/Models/PIG_Control_drag_py.dat", {"md": md})

elif step == 5:
Ejemplo n.º 9
0
 class GenericBaseType(metaclass=generic()):
     @classmethod
     def _get_param_names(cls):
         return cls.__name__
Ejemplo n.º 10
0
 class U(metaclass=generic('TParams')):
     def get_param(self):
         return self.TParams