Elasticity#

Input Class#

Input: Elasticity#

class phasefieldx.Element.Elasticity.Input.Input(E=210.0, nu=0.3, save_solution_xdmf=False, save_solution_vtu=True, results_folder_name='results')[source]#

Bases: object

Class for managing elasticity simulation parameters.

This class encapsulates parameters related to elasticity simulations and provides methods for setting, logging, and exporting these parameters.

Attributes:
Efloat

Young’s modulus of the material.

nufloat

Poisson’s ratio of the material.

lambda_float

Lame’s first parameter calculated from E and nu.

mufloat

Shear modulus calculated from E and nu.

save_solution_xdmfbool

Indicates whether to save solutions in XDMF format.

save_solution_vtubool

Indicates whether to save solutions in VTU format.

results_folder_namestr

Name of the folder to save simulation results.

Methods

__init__(E=210.0, nu=0.3, save_solution_xdmf=False, save_solution_vtu=True, results_folder_name=”results”)

Initialize the Input class with default parameters.

save_log_info(logger)

Log the simulation parameters using the provided logger.

save_parameters_to_csv(filename=”parameters.input”)

Save the simulation parameters to a two-column text file (tab-separated) for easy loading with pandas.

__str__()

Return a string representation of the simulation parameters.

save_log_info(logger)[source]#

Log the simulation parameters using the provided logger.

Parameters:

logger: An instance of a logging object.

save_parameters_to_csv(filename='parameters.input')[source]#

Save the simulation parameters to a CSV file for easy loading with pandas.

Parameters:

filename (str): The name of the CSV file to save the parameters.

Solver#

Solver: Elasticity#

phasefieldx.Element.Elasticity.solver.solver.solve(Data, msh, final_time, V_u, bc_list_u=[], update_boundary_conditions=None, f_list_u=None, T_list_u=None, update_loading=None, ds_bound=None, dt=1.0, path=None, quadrature_degree=2, bcs_list_u_names=None)[source]#

Solver for elasticity problems.

Parameters:
Dataphasefieldx.Data

Data object containing simulation parameters.

mshdolfinx.cpp.mesh.Mesh

Mesh object defining the computational domain.

final_timefloat

Final pseudo time for the simulation.

V_udolfinx.fem.FunctionSpace

Function space for the displacement field u.

bc_list_ulist of dolfinx.fem.DirichletBC, optional

List of Dirichlet boundary conditions for u (default is []).

update_boundary_conditionsfunction, optional

Function to update boundary conditions based on time (default is None).

f_list_ulist of dolfinx.fem.Function, optional

List of body forces (default is None).

T_list_ulist of tuples, optional

List of tuples (force, measure) for surface forces (default is None).

update_loadingfunction, optional

Function to update external loading conditions based on time (default is None).

ds_boundnumpy.ndarray, optional

Array containing boundary descriptions for reaction forces (default is None).

dtfloat, optional

Time step size (default is 1.0).

pathstr, optional

Path to store simulation results (default is the current working directory).

Returns:
None
Raises:
None

Notes

This function initializes and solves the elasticity problem for the displacement field u, updating it over the specified time period using a Newton-type solver. It logs simulation progress, saves results, and manages output using Paraview-compatible formats.

Examples

# Initialize Data, msh, V_u, bc_list_u, and optionally update functions solve(Data, msh, 10.0, V_u, bc_list_u, update_boundary_conditions, T_list_u=T_list_u, path=’/path/to/results’)

# This will simulate the elasticity problem in time, saving results in the specified directory.

Energy#

Energy#

phasefieldx.Element.Elasticity.energy.calculate_elastic_energy(u, Data, comm, dx=Measure('cell', subdomain_id='everywhere'))[source]#

Calculate the total elastic energy by integrating the isotropic elastic energy density over the entire domain.

Parameters:
udolfinx.fem.Function

Displacement field function.

Dataobject

Material properties container with attributes lambda_ and mu representing Lamé parameters.

commMPI.Comm

MPI communicator for parallel reduction.

dxufl.Measure, optional

Integration measure over the domain (default is ufl.dx).

Returns:
float

The total elastic energy integrated over the domain.

Notes

This function computes the isotropic elastic energy density using the provided displacement field and material properties, then integrates it over the whole domain. The result is summed across all MPI processes to obtain the global elastic energy.