Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusgh committed Jul 16, 2023
1 parent c96a415 commit cf28738
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions ntfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import h5py
from utilities import *
from material_parameters import *
from tqdm import tqdm

def read_snapshots(file_name, data_path):
"""
Expand Down Expand Up @@ -84,22 +85,17 @@ def mode_identification(plastic_snapshots, vol_frac, r_min=1e-8):

def compute_ntfa_matrices(strain_localization, stress_localization, plastic_modes, mat_thermal_strain, mesh):
"""
Processing of the plastic strain modes µ to compute the matrices A_bar, D_xi, C_bar and the vector tau_theta
as tabular data at given temperatures
Compute the ntfa matrices C_bar, A_bar, D_xi, the vectors tau_theta, tau_xi and the scalar D_theta
for given strain_localization, stress_localization, plastic_modes and mat_thermal_strain
:param strain_localization: strain localization 3D array
with shape (n_integration_points, strain_dof, 7 + n_modes)
:param stress_localization: stress localization 3D array
with shape (n_integration_points, strain_dof, 7 + n_modes)
:param mat_stiffness: stiffness tensors of the phases
with shape (n_phases, strain_dof, strain_dof)
:param mat_id: material phase identification
with shape (n_elements,)
:param mesh:
:param plastic_modes: plastic strain modes µ
with shape (n_integration_points, strain_dof, N_modes)
:param eigen_strains: solutions of the auxiliary eigenstress problems eps_star
with shape (n_integration_points, strain_dof, N_modes)
:param ...:
:param plastic_modes: plastic strain modes
with shape (n_integration_points, strain_dof, n_modes)
:param mat_thermal_strain: thermal strains of the phases
with shape (n_phases, strain_dof, 1)
:param mesh: dict with mesh information
:return:
C_bar with shape (strain_dof, strain_dof)
tau_theta with shape (strain_dof,)
Expand All @@ -113,19 +109,18 @@ def compute_ntfa_matrices(strain_localization, stress_localization, plastic_mode
n_modes = plastic_modes.shape[2]
n_gp = mesh['n_integration_points']
n_gauss = mesh['n_gauss']
I = np.eye(6)

# slice strain localization operator E into E_eps, E_theta, E_xi
E_eps = strain_localization[:, :, :strain_dof]
E_theta = strain_localization[:, :, strain_dof]
E_xi = strain_localization[:, :, strain_dof + 1:]


# slice stress localization operator S into S_eps, S_theta, S_xi
S_eps = stress_localization[:, :, :strain_dof]
S_theta = stress_localization[:, :, strain_dof]
S_xi = stress_localization[:, :, strain_dof + 1:]

I = np.eye(6)
# Compute C_bar via < (E_eps + I).T @ S_eps >
C_bar = volume_average((E_eps + I).transpose((0, 2, 1)) @ S_eps)

Expand All @@ -140,7 +135,7 @@ def compute_ntfa_matrices(strain_localization, stress_localization, plastic_mode
tau_xi = np.zeros((1, n_modes))
for gp_id in prange(n_gp):
phase_id = mat_id[gp_id // n_gauss]
tau_xi += (E_theta[gp_id] - mat_thermal_strain[phase_id].T) @ S_xi[gp_id] / n_gp
tau_xi += (np.expand_dims(E_theta[gp_id], axis=1) - mat_thermal_strain[phase_id]).T @ S_xi[gp_id] / n_gp

# Compute D_xi via < (E_xi - P_xi).T @ S_xi >
D_xi = volume_average((E_xi - plastic_modes).transpose((0, 2, 1)) @ S_xi)
Expand All @@ -150,9 +145,9 @@ def compute_ntfa_matrices(strain_localization, stress_localization, plastic_mode
D_theta = 0.
for gp_id in prange(n_gp):
phase_id = mat_id[gp_id // n_gauss]
D_theta += (E_theta[gp_id] - mat_thermal_strain[phase_id].T) @ S_theta[gp_id] / n_gp
D_theta += (np.expand_dims(E_theta[gp_id], axis=1) - mat_thermal_strain[phase_id]).T @ S_theta[gp_id] / n_gp

return C_bar, tau_theta, A_bar, tau_xi, D_xi, D_theta
return C_bar, tau_theta.ravel(), A_bar, tau_xi.ravel(), D_xi, D_theta


def compute_phase_average_stresses(strain_localization, mat_stiffness, mat_thermal_strain, plastic_modes, zeta, mesh):
Expand Down Expand Up @@ -223,7 +218,7 @@ def compute_tabular_data(samples, mesh, temperatures):
sample_temperatures = np.array([sample['temperature'] for sample in samples])
temp1, temp2 = min(sample_temperatures), max(sample_temperatures)
sample_alphas = (sample_temperatures - temp1) / (temp2 - temp1)
for idx in prange(n_temps):
for idx in tqdm(range(n_temps)):
temperature = temperatures[idx]
ref_C = np.stack(([stiffness_cu(temperature), stiffness_wsc(temperature)]))
ref_eps = np.expand_dims(np.stack(([thermal_strain_cu(temperature), thermal_strain_wsc(temperature)])), axis=2)
Expand Down

0 comments on commit cf28738

Please sign in to comment.