mech2d package

mech2d.info()[source]

Subpackages

Submodules

mech2d.analysis module

class mech2d.analysis.Analysis(structure, elastic_tensor, plot=False, approach=None)[source]

Bases: object

A module to analysis the Young’s modulus , Poisson’s ratio and Shear modulus

Attributes:
Y_zz

return Y_zz = C11*C22-C12**2)/C22

d1

return d1=C11/C22+1-(C11*C22-C12**2)/C22/C66;

d2

return d2=-(2*C12/C22-(C11*C22-C12**2)/C22/C66);

d3

return d3 =C11/C22

lattice_type
v_zz

return vzz=C12/C22

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]

get_gamma()

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

get_EV(npoints=360, fname='EV_theta.dat', fmt='jpg', dpi=100)[source]
get_G2d()[source]

2D shear modulus; G2d = C66

Args:

None

Returns:

shear modulus

get_Y01()[source]

2D Young’s modulus or in-plane stiffness: Y[01] = [c11c22 - c12^2]/[c11]

get_Y10()[source]

return 2D Young’s modulus or in-plane stiffness: Y[10] = [c11c22 - c12^2]/[c22]

get_brav_lattice()[source]
get_gamma()[source]

return the layer modulus.

get_nu01()[source]

2D Poisson’s ratio; nu01 = c12/c11

get_nu10()[source]

2D Poisson’s ratio; nu10 = c12/c22

get_stability()[source]
property lattice_type
references()[source]
summary(fmt='jpg', dpi=100)[source]
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: object

2D 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
plot()[source]
property unit_cell_area

mech2d.constants module

This module used to control the convert the unit

mech2d.main module

mech2d.main.get_version()[source]
mech2d.main.main()[source]

mech2d.mechanics module

class mech2d.mechanics.Elastic(structure, approach='energy', properties='elc', workdir=None, verbose=False)[source]

Bases: MSONable

A elastic object for initializaion and post-process.

Attributes:
C_mult_eta_Matrix

The relation between lagrangian stress and strain : tao=C*yeta

approach

Approach for calculation

lagrangian_strain_list

lagrangian strain list

lattice_type

Two dimensional lattice type

number_elastic_tensor

number of the independent elastic tensor

properties

Property for calculation

structure

Structure object

verbose

Verbose 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

as_dict()[source]

Json-serialization dict representation of the Elastic.

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

get_brav_lattice()[source]
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.mechanics.init_elastic(args)[source]

init process function entry point

mech2d.mechanics.parsing_input(finput)[source]

Parsing the structure and elastic tensor from file

Args:

finput (str): input file name

Returns:

structure (Obj): pymatgen Strcture obj. C(matrix): elastic tensor.

mech2d.mechanics.post_elastic(args)[source]

post process function entry point

mech2d.parser module

mech2d.parser.vaspparser(finput='OUTCAR')[source]

mech2d.plot module

class mech2d.plot.Plot(data='result.json', fmt='jpg', dpi=100)[source]

Bases: object

Methods

energy_strain_plot([font_dict, figsize, ...])

plot energy strain figure

load_data(data)

load json txt data or convert list to np.array

load_result()

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

load_data(data)[source]

load json txt data or convert list to np.array

load_result()[source]

load json format data

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

mech2d.utils module

mech2d.utils.box_center(ch='', fill='-', sp='-')[source]

put the string at the center of | |

mech2d.utils.create_path(path, back=False)[source]
mech2d.utils.prettyprint(c, precision=3)[source]
mech2d.utils.sepline(ch='-', sp='-')[source]

seperate the output by ‘-’