mech2d package
Subpackages
Submodules
mech2d.analysis module
- class mech2d.analysis.Analysis(structure, elastic_tensor, plot=False, approach=None)[source]
Bases:
objectA module to analysis the Young’s modulus , Poisson’s ratio and Shear modulus
- Attributes:
Methods
get_G2d()2D shear modulus; G2d = C66
get_Y01()2D Young's modulus or in-plane stiffness: Y[01] = [c11c22 - c12^2]/[c11]
get_Y10()return 2D Young's modulus or in-plane stiffness: Y[10] = [c11c22 - c12^2]/[c22]
return the layer modulus.
get_nu01()2D Poisson's ratio; nu01 = c12/c11
get_nu10()2D Poisson's ratio; nu10 = c12/c22
get_EV
get_brav_lattice
get_stability
references
summary
- property Y_zz
return Y_zz = C11*C22-C12**2)/C22
- property d1
return d1=C11/C22+1-(C11*C22-C12**2)/C22/C66;
- property d2
return d2=-(2*C12/C22-(C11*C22-C12**2)/C22/C66);
- property d3
return d3 =C11/C22
- property lattice_type
- property v_zz
return vzz=C12/C22
mech2d.bravais module
- class mech2d.bravais.Bravais2D(struct, eps_r=0.2, eps_a=1.0, numpoints=16)[source]
Bases:
object2D bravais lattice obj to check the lattice type
- Args
a: (float) The magnitude of the first primitive vector (default is 1.0). b: (float) The magnitude of the second primitive vector (default is 1.0). angle: (float) The angle between the two primitive vectors; can’t be 0 or 180 degrees (default is 120.0). centered: (bool) True if the lattice is a centered rectangular (default is False). numpoints: (int) The number of desired points to plot and must be a square number larger than 4; will be the number of ‘non-centered’ points if centered rectangular lattice (default is 16). plot: (bool) If True, will plot the lattice (default is True). a_vec: (numpy array) The first primitive vector. b_vec: (numpy array) The second primitive vector. lattice: (str) The name of the type of Bravais lattice (depends on a, b, angle, and centered). unit_cell_area: (float) The area of the unit cell.
- Functions:
plot: Creates a 2D scatter plot.
- Attributes:
- a_vec
- b_vec
- lattice_type
- numpoints
- unit_cell_area
Methods
plot
- property a_vec
- property b_vec
- property lattice_type
- property numpoints
- property unit_cell_area
mech2d.constants module
This module used to control the convert the unit
mech2d.logo module
mech2d.main module
mech2d.mechanics module
- class mech2d.mechanics.Elastic(structure, approach='energy', properties='elc', workdir=None, verbose=False)[source]
Bases:
MSONableA elastic object for initializaion and post-process.
- Attributes:
C_mult_eta_MatrixThe relation between lagrangian stress and strain : tao=C*yeta
approachApproach for calculation
lagrangian_strain_listlagrangian strain list
lattice_typeTwo dimensional lattice type
number_elastic_tensornumber of the independent elastic tensor
propertiesProperty for calculation
structureStructure object
verboseVerbose information
Methods
as_dict()Json-serialization dict representation of the Elastic.
calc_elastic_constant([poly_order, skip, ...])Calculate the elstic constant using the different approach.
calc_elastic_constant_from_energy(...[, ...])Calculate the elstic constant based on energy-strain approach.
calc_elastic_constant_from_stress(...[, ...])Calculate the elstic constant based on stress-strain approach.
calc_stress_strain([skip, finput, plot, ...])Calculate the stress train curve.
from_dict(d)Reconstitute a Molecule object from a dict representation created using as_dict().
set_deformed_structure_for_elc(numb_points, ...)set the deformed structure for elastic constant calculation by using 'stress' or 'energy' approach
set_deformed_structure_for_ss(numb_points[, ...])set the deformed structure for stress-strain curve calculation
to(filename[, option, fmt, indent])Outputs the Elastic to a file.
to_json()Returns a json string representation of the MSONable object.
unsafe_hash()Returns an hash of the current object.
validate_monty_v1(_MSONable__input_value)Pydantic validator with correct signature for pydantic v1.x
validate_monty_v2(_MSONable__input_value, _)Pydantic validator with correct signature for pydantic v2.x
get_brav_lattice
- property C_mult_eta_Matrix
The relation between lagrangian stress and strain : tao=C*yeta
- property approach
Approach for calculation
- calc_elastic_constant(poly_order=4, skip=False, finput='input.yaml', plot=False, fmt='jpg', dpi=100)[source]
Calculate the elstic constant using the different approach.
- Args:
poly_order (int): the order of polynomial for fitting skip (str): skip the data parsing by Mech2d parser finput (str): input file name for basic parameter about machine, task, resources, and code plot (bool): whether plot the figure, default is False
- calc_elastic_constant_from_energy(poly_order, skip, numb_points, max_lag_strain, workdir, code, plot, fmt='jpg', dpi=100)[source]
Calculate the elstic constant based on energy-strain approach.
- calc_elastic_constant_from_stress(poly_order, skip, numb_points, max_lag_strain, workdir, code, plot, fmt='jpg', dpi=100)[source]
Calculate the elstic constant based on stress-strain approach.
- calc_stress_strain(skip=False, finput='input.yaml', plot=False, fmt='jpg', dpi=100)[source]
Calculate the stress train curve.
- Args:
skip (str): skip the data parsing by Mech2d parser finput (str): input file name for basic parameter about machine, task, resources, and code plot (bool): whether plot the figure, default is False
- classmethod from_dict(d)[source]
Reconstitute a Molecule object from a dict representation created using as_dict().
- Args:
d (dict): dict representation of Elastic
- Returns:
Elastic object
- property lagrangian_strain_list
lagrangian strain list
- property lattice_type
Two dimensional lattice type
- property number_elastic_tensor
number of the independent elastic tensor
- property properties
Property for calculation
- set_deformed_structure_for_elc(numb_points, max_lag_strain, back=True)[source]
set the deformed structure for elastic constant calculation by using ‘stress’ or ‘energy’ approach
- Args:
numb_points (int): Number of deformed structures max_lag_strain (float): The maximum Lagrangian strain, the range will be set to [-max_lag_strain,+max_lag_strain] back (bool) : back the old folder. Default True
- set_deformed_structure_for_ss(numb_points, max_lag_strain=None, lag_strain_range=None, direction=['xx'], back=True)[source]
set the deformed structure for stress-strain curve calculation
- Args:
numb_points (int): Number of deformed structures max_lag_strain (float): The maximum Lagrangian strain, the range will be set to [-max_lag_strain,+max_lag_strain] lag_strain_range (array): Set the Lagrangian strain manually direction (list): Which direction to calculate the stress-strain curve back (bool) : back the old folder. Default True
- Returns:
None
- property structure
Structure object
- to(filename, option={}, fmt=None, indent=4)[source]
Outputs the Elastic to a file.
- Args:
fmt (str): Format to output to. Defaults to JSON filename (str): Output filename option (dict): The optional parameters in dict will be append to Elastic.as_dict() indent (int): Used for format output
- Returns:
None
- property verbose
Verbose information
mech2d.parser module
mech2d.plot module
- class mech2d.plot.Plot(data='result.json', fmt='jpg', dpi=100)[source]
Bases:
objectMethods
energy_strain_plot([font_dict, figsize, ...])plot energy strain figure
load_data(data)load json txt data or convert list to np.array
load json format data
polar_plot_EV([font_dict, figsize, skip, fname])plot the orientation dependent Young's Modulus and Poission's Ratio
stress_strain_plot([font_dict, figsize, ...])plot energy strain figure
stress_strain_plot_nonefit([font_dict, ...])plot stress strain figure without fitting (for stress-strain curve calculation)
- energy_strain_plot(font_dict={}, figsize=(8, 6), order=4, fname='Energy_Strain')[source]
plot energy strain figure
- Args:
font_dict (dict): dict parameter for figure plot figsize (tuple): dicide the figure size order (int): fitting order for polynomial fname (str): output filename for figure
- Returns:
None
- polar_plot_EV(font_dict={}, figsize=(8, 6), skip=[1, 1, 1], fname='EV')[source]
plot the orientation dependent Young’s Modulus and Poission’s Ratio
- Args:
font_dict (dict): dict parameter for figure plot figsize (tuple): dicide the figure size order (int): fitting order for polynomial fname (str): output filename for figure
- Returns:
None
- stress_strain_plot(font_dict={}, figsize=(18, 6), order=[3, 3, 3], fname='LStress_Strain')[source]
plot energy strain figure
- Args:
font_dict (dict): dict parameter for figure plot figsize (tuple): dicide the figure size order (int): fitting order for polynomial fname (str): output filename for figure
- Returns:
None
- stress_strain_plot_nonefit(font_dict={}, figsize=(16, 16), fname='LStress_Strain')[source]
plot stress strain figure without fitting (for stress-strain curve calculation)
- Args:
font_dict (dict): dict parameter for figure plot figsize (tuple): dicide the figure size order (int): fitting order for polynomial fname (str): output filename for figure
- Returns:
None