def E2S(E_PD, E_XD, E_phi, sigma, W0, b0, W1, b1, W2, b2): |
″″″Compute the stress components using the NN material model. |
Wi and bi (i = 0,1,2) are the weights and biases of the NN model.″″″
|
# An element–wise softplus function
|
def softplus (x, beta = 1., threshold = 20.): |
def _elem_softplus (x, beta=beta, threshold=threshold): |
return 1./beta*ln(exp(beta*x) + 1) |
y = elem_op (_elem_softplus, x) |
return y |
|
# The NN model prediction
|
inputs = as_vector ([E_PD, E_XD, E_phi, sigma]) |
y1 = softplus (dot(W0, inputs) + b0) |
y2 = softplus (dot(W1, y1) + b1) |
outputs = dot (W2, y2) + b2 |
|
# Impose zero shear stresses for zero shear strains
|
multiplier = as_vector ([1., 1., E[2]]) |
S = elem_mult (multiplier, outputs) |
|
return S |