Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# 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
# \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)
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)
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()
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)
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 )
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.)
# \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
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
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)