Page MenuHomec4science

apply_strain.py
No OneTemporary

File Metadata

Created
Mon, Aug 26, 16:15

apply_strain.py

#!/usr/bin/env python
import numpy as np
name = "bound_pos"
shift = (0., .1, 0.)
length = 1.
def compute(**kwargs):
keys = kwargs.keys()
if name in keys:
key = name
try:
pos0 = kwargs[key]
except UnboundLocalError as err:
raise UnboundLocalError(
"{0}\nThe only available keys are {1}. The key '{2}' wasn't found!".format(err, keys, name))
#disp = np.array(np.matrix(pos0) * grad_u) + solid_body_disp
disp = np.zeros(pos0.shape)
if pos0.shape[0] == 0:
return disp
for i in range(3):
disp[:,i] = shift[i]*pos0[:, i]
print("When dealing with {0}, computed displacement within the ranges:".format(key))
print(" u_x_min = {0}, \tu_x_max = {1}".format(disp.min(0)[0], disp.max(0)[0]))
print(" u_y_min = {0}, \tu_y_max = {1}".format(disp.min(0)[1], disp.max(0)[1]))
print(" u_z_min = {0}, \tu_z_max = {1}".format(disp.min(0)[2], disp.max(0)[2]))
return disp

Event Timeline