Skip to content

Commit

Permalink
KM model should be scaled
Browse files Browse the repository at this point in the history
  • Loading branch information
reverendbedford committed Jan 17, 2024
1 parent e06af04 commit b2027e9
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions pyoptmat/flowrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,38 +402,43 @@ class SoftKocksMeckingRegimeFlowRule(FlowRule):
Args:
model1 (flowrules.FlowRule): first flow rule
model2 (flowrules.FlowRule): second flow rule
g0 (torch.tensor): activation energy threshold
A, B, C (torch.tensor): Kocks-Mecking parameters
mu (temperature.TemperatureParameter): shear modulus
b (torch.tensor): burgers vector
eps0 (torch.tensor): reference strain rate
k (torch.tensor): Boltzmann constant
sf (torch.tensor): sharpness parameter
Keyword Args:
A_scale, B_scale, C_scale: scaling functions for K-M parameters
eps (float): default 1e-20, offset to
avoid divide-by-zero
g0_scale (function): scaling function for g0,
defaults to no scaling
"""

def __init__(
self,
model1,
model2,
g0,
A,
B,
C,
mu,
b,
eps0,
k,
sf,
A_scale = lambda x: x,
B_scale = lambda x: x,
C_scale = lambda x: x,
eps=torch.tensor(1e-20),
g0_scale=lambda x: x,
):
super().__init__()

self.model1 = model1
self.model2 = model2
self.g0 = g0
self.A = A
self.B = B
self.C = C

self.mu = mu
self.b = b
Expand All @@ -443,7 +448,9 @@ def __init__(
self.sf = sf

self.eps = eps
self.g0_scale = g0_scale
self.A_scale = A_scale
self.B_scale = B_scale
self.C_scale = C_scale

# Check for conformal history vectors
if self.model1.nhist != self.model2.nhist:
Expand Down Expand Up @@ -505,9 +512,12 @@ def f(self, T, e):
torch.tensor: value of the weighting function
"""
return (
torch.tanh(self.sf * (self.g(T, e) - self.g0_scale(self.g0))) + 1.0
torch.tanh(self.sf * (self.g(T, e) - self.g0())) + 1.0
) / 2.0

def g0(self):
return (self.C_scale.scale(self.C) - self.B_scale.scale(self.B)) / self.A_scale(self.A)

def df_e(self, T, e):
"""
The derivative of the weight function with respect to
Expand All @@ -524,7 +534,7 @@ def df_e(self, T, e):
self.sf
/ (
2.0
* torch.cosh(self.sf * (self.g(T, e) - self.g0_scale(self.g0))) ** 2.0
* torch.cosh(self.sf * (self.g(T, e) - self.g0())) ** 2.0
)
* self.dg_e(T, e)
)
Expand Down

0 comments on commit b2027e9

Please sign in to comment.