How to use the underworld.function.misc.constant function in underworld

To help you get started, we’ve selected a few underworld examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github underworldcode / underworld2 / docs / publications / LemialeEtAl2008 / Lemiale-Parallel.py View on Github external
# and
# \begin{equation}
# c = c_0 + \left( c_\infty - c_0 \right) \min \left( 1, \frac{\gamma^P}{\gamma^0} \right)
# \end{equation}
# where $\gamma^0 = 0.1$ is a reference strain. The plastic strain ($\gamma^P$) is calculated by the previous strain rate integrated up to the current time, i.e.
# \begin{equation}
# \gamma^P_{rel} = \int \left( \dot{\gamma}^P - \beta \frac{\tau_s}{\eta} \right) dt
# \end{equation}
# where $\beta$ is a parameter between 0 and 1 to describe the diminishing and healing of strain. For now we take $\beta = 0$.
# 
# 

# In[14]:

cohesionInf     = fn.misc.constant(cinf) # from table 2 of paper
cohesion0       = fn.misc.constant(cohesion)
referenceStrain = fn.misc.constant(0.1)

cosPhi = fn.math.cos(fn.misc.constant(phi)) # phi defined at the start based on entered tanPhi
sinPhi = fn.math.sin(fn.misc.constant(phi))

alpha = sinPhi/3.0

cohesionFn =  cohesion0 + (cohesionInf - cohesion0) * fn.exception.SafeMaths( 
                                                        fn.misc.min(1.0, plasticStrain / referenceStrain ))
kFn = cohesionFn * cosPhi

# first define strain rate tensor
strainRateFn = fn.tensor.symmetric( velocityField.fn_gradient )
strainRate_2ndInvariantFn = fn.tensor.second_invariant(strainRateFn)

# DeviatoricStress
github underworldcode / underworld2 / docs / development / models_broken / LemialeEtAl2008 / data_comp / Lemiale-Parallel.py View on Github external
# \end{equation}
# and
# \begin{equation}
# c = c_0 + \left( c_\infty - c_0 \right) \min \left( 1, \frac{\gamma^P}{\gamma^0} \right)
# \end{equation}
# where $\gamma^0 = 0.1$ is a reference strain. The plastic strain ($\gamma^P$) is calculated by the previous strain rate integrated up to the current time, i.e.
# \begin{equation}
# \gamma^P_{rel} = \int \left( \dot{\gamma}^P - \beta \frac{\tau_s}{\eta} \right) dt
# \end{equation}
# where $\beta$ is a parameter between 0 and 1 to describe the diminishing and healing of strain. For now we take $\beta = 0$.
# 
# 

# In[14]:

cohesionInf     = fn.misc.constant(cinf) # from table 2 of paper
cohesion0       = fn.misc.constant(cohesion)
referenceStrain = fn.misc.constant(0.1)

cosPhi = fn.math.cos(fn.misc.constant(phi)) # phi defined at the start based on entered tanPhi
sinPhi = fn.math.sin(fn.misc.constant(phi))

alpha = sinPhi/3.0

cohesionFn =  cohesion0 + (cohesionInf - cohesion0) * fn.exception.SafeMaths( 
                                                        fn.misc.min(1.0, plasticStrain / referenceStrain ))
kFn = cohesionFn * cosPhi

# first define strain rate tensor
strainRateFn = fn.tensor.symmetric( velocityField.fn_gradient )
strainRate_2ndInvariantFn = fn.tensor.second_invariant(strainRateFn)
github underworldcode / underworld2 / unsupported / geodynamics / Model.py View on Github external
def solve_temperature_steady_state(self):
        
        if self.materials:
            DiffusivityMap = {}
            for material in self.materials:
                DiffusivityMap[material.index] = nd(material.diffusivity)
            
            self.DiffusivityFn = fn.branching.map(fn_key = self.materialField, mapping = DiffusivityMap)
       
            HeatProdMap = {}
            for material in self.materials:
                HeatProdMap[material.index] = nd(material.radiogenicHeatProd)/(nd(material.density)*nd(material.capacity))
            
            self.HeatProdFn = fn.branching.map(fn_key = self.materialField, mapping = HeatProdMap)
        else:
            self.DiffusivityFn = fn.misc.constant(nd(self.diffusivity))
            self.HeatProdFn = fn.misc.constant(nd(self.radiogenicHeatProd))

        conditions = self._temperatureBCs
        heatequation = uw.systems.SteadyStateHeat(temperatureField=self.temperature,
                                                  fn_diffusivity=self.DiffusivityFn,
                                                  fn_heating=self.HeatProdFn,
                                                  conditions=conditions)
        heatsolver = uw.systems.Solver(heatequation)
        heatsolver.solve(nonLinearIterate=True)
github underworldcode / underworld2 / docs / development / models_inprogress / uw3 / cube_stokesSinker3D.py View on Github external
fn_conds = []   # geometric condition for each sphere, if true, return 1.2
for s_i, centre, in enumerate(spheres):
    fn_pos = fn.coord() - centre
    fn_conds.append( (fn.math.dot( fn_pos, fn_pos ) < sphereRadius**2, 1.5) )

fn_conds.append( (True, 1.0) )
fn_density = fn.branching.conditional( fn_conds )


fn_gravity =  fn.misc.constant(9.8) * (0., 0., -1.)

fn_buoyancy = fn_gravity * fn_density

v_const = fn.misc.constant([4.0,2.,0.])
f_const = fn.misc.constant([1.0,2.,0.])
e_const = fn.misc.constant(1.0)

model = uw.systems.pl_StokesModel(filename=None)
model.SetViscosity(f_const[0])
model.SetRHS(fn_buoyancy)
model.Solve()
github underworldcode / underworld2 / unsupported / geodynamics / rheologyDatabase / yielding_criteria.py View on Github external
def linearCohesionWeakening(cumulativeTotalStrain, Cohesion, CohesionSw, epsilon1=0.5, epsilon2=1.5, **kwargs):

    cohesionVal = [(cumulativeTotalStrain < epsilon1, fn.misc.constant(Cohesion)),
                   (cumulativeTotalStrain > epsilon2, fn.misc.constant(CohesionSw)),
                   (True, Cohesion + ((Cohesion - CohesionSw)/(epsilon1 - epsilon2)) * (cumulativeTotalStrain - epsilon1))]

    return fn.branching.conditional(cohesionVal)
github underworldcode / underworld2 / underworld / systems / _petsc_uw.py View on Github external
def __init__(self, elementRes=None, filename=None, dim=3, forceTerm=0.):
        self._filename = filename
        self.dim = dim
        zero = (0.,)
        
        self._cmodel = pl.StokesModel_Setup( filename )
        
        self.fn_v = fn.misc.constant(zero*dim)
        self.fn_p = fn.misc.constant(zero)
        pl.prob_fnSetter(self._cmodel, 0, self.fn_v._fncself )
        pl.prob_fnSetter(self._cmodel, 1, self.fn_p._fncself )
github underworldcode / underworld2 / underworld / systems / _petsc_uw.py View on Github external
def __init__(self, filename=None):
        self._filename = filename
        zero = (0.,)
        
        self._cmodel = pl.PoissonModel_Setup( filename )
        
        self.fn_temperature = fn.misc.constant(zero)
        pl.prob_fnSetter(self._cmodel, 0, self.fn_temperature._fncself )

        '''
        self.fn_c0 = fn.misc.constant(1.)
github underworldcode / underworld2 / docs / publications / LemialeEtAl2008 / Lemiale-Parallel.py View on Github external
# \begin{equation}
# c = c_0 + \left( c_\infty - c_0 \right) \min \left( 1, \frac{\gamma^P}{\gamma^0} \right)
# \end{equation}
# where $\gamma^0 = 0.1$ is a reference strain. The plastic strain ($\gamma^P$) is calculated by the previous strain rate integrated up to the current time, i.e.
# \begin{equation}
# \gamma^P_{rel} = \int \left( \dot{\gamma}^P - \beta \frac{\tau_s}{\eta} \right) dt
# \end{equation}
# where $\beta$ is a parameter between 0 and 1 to describe the diminishing and healing of strain. For now we take $\beta = 0$.
# 
# 

# In[14]:

cohesionInf     = fn.misc.constant(cinf) # from table 2 of paper
cohesion0       = fn.misc.constant(cohesion)
referenceStrain = fn.misc.constant(0.1)

cosPhi = fn.math.cos(fn.misc.constant(phi)) # phi defined at the start based on entered tanPhi
sinPhi = fn.math.sin(fn.misc.constant(phi))

alpha = sinPhi/3.0

cohesionFn =  cohesion0 + (cohesionInf - cohesion0) * fn.exception.SafeMaths( 
                                                        fn.misc.min(1.0, plasticStrain / referenceStrain ))
kFn = cohesionFn * cosPhi

# first define strain rate tensor
strainRateFn = fn.tensor.symmetric( velocityField.fn_gradient )
strainRate_2ndInvariantFn = fn.tensor.second_invariant(strainRateFn)

# DeviatoricStress
devStressFn = 2.0 * viscosityFn * strainRateFn
github underworldcode / underworld2 / unsupported / geodynamics / rheology.py View on Github external
def _cohesion(self):
        if self.plasticStrain:
            cohesion = self.cohesionWeakeningFn(
                self.plasticStrain,
                Cohesion=nd(self.cohesion),
                CohesionSw=nd(self.cohesionAfterSoftening))
        else:
            cohesion = fn.misc.constant(self.cohesion)
        return cohesion
github underworldcode / underworld2 / underworld / function / misc.py View on Github external
def __init__(self, value, *args, **kwargs):

        # lets try and convert
        self._ioguy = self._GetIOForPyInput(value)
        self._value = value
        self._fncself = _cfn.Constant(self._ioguy)
        # build parent
        super(constant,self).__init__(argument_fns=None,**kwargs)