Phase-Field#

Input Class#

Input: Phase-Field#

class phasefieldx.Element.Phase_Field.Input.Input(l=1.0, save_solution_xdmf=False, save_solution_vtu=True, results_folder_name='results')[source]#

Bases: object

Class for managing phase-field simulation parameters.

This class encapsulates parameters related to phase-field fracture simulations and provides methods for setting, logging, and exporting these parameters.

Attributes:
lfloat

Length scale parameter.

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__(l=1.0, 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: Phase-field#

phasefieldx.Element.Phase_Field.solver.solver.solve(Data, msh, final_time, V_Φ, bc_list_phi=[], update_boundary_conditions=None, update_loading=None, ds_bound=None, dt=1.0, path=None, quadrature_degree=2, case='AT2', V_gradient_Φ=None)[source]#

Solver for phase-field 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_Φdolfinx.fem.FunctionSpace

Function space for the phase field variable Φ.

bc_list_philist of dolfinx.fem.DirichletBC, optional

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

update_boundary_conditionsfunction, optional

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

update_loadingfunction, optional

Function to update external loading conditions based on time and spatial coordinates (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 current working directory).

quadrature_degreeint, optional

Quadrature degree for numerical integration (default is 2).

Returns:
None

Notes

This function initializes and solves the phase-field problem for the given phase-field variable Φ, 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_Φ, bc_list_phi, and optionally update functions solve(Data, msh, 10.0, V_Φ, bc_list_phi, update_boundary_conditions, update_loading)

# This will simulate the phase-field evolution in time, saving results in the current directory.

Energy#

Energy#

phasefieldx.Element.Phase_Field.energy.calculate_crack_surface_energy(Φ, l, comm, case='AT2', dx=Measure('cell', subdomain_id='everywhere'))[source]#

Calculates the total crack surface energy in a phase-field model.

This function computes the integral of the crack surface energy density functional, which regularizes a sharp crack over a finite width. The functional is expressed as:

Ψ_c = ∫_Ω [ (1 / (c₀ * l)) * w(Φ) + (l / c₀) * |∇Φ|² ] dΩ

where w(Φ) is the geometric crack function (e.g., Φ² for the AT2 model, Φ for the AT1 model), l is the length scale parameter, and Φ is the phase-field variable. The calculation is performed in parallel using the provided MPI communicator.

Φdolfinx.fem.Function

The phase-field variable, representing the crack state.

lfloat

The length scale parameter, controlling the regularization width.

commmpi4py.MPI.Comm

The MPI communicator for parallel computation.

casestr, optional

The phase-field model type, which determines the geometric crack function. Common values are ‘AT1’ or ‘AT2’. Defaults to ‘AT2’.

dxufl.Measure, optional

The UFL integration measure over the domain. Defaults to ufl.dx.

tuple[float, float, float]

A tuple containing: - The total crack surface energy (scalar value). - The contribution from the geometric crack function term. - The contribution from the phase-field gradient term.

Geometric Crack#

Geometric Crack functions#

phasefieldx.Element.Phase_Field.geometric_crack.geometric_crack_coefficient(case='AT2')[source]#

Returns the geometric coefficient c_w for the crack surface density function.

This coefficient ensures that the integral of the dissipation function w(phi) over the crack length equals 1.

Parameters:
casestr, optional

The phase-field model. Supported values are ‘AT2’, ‘AT1’, ‘Wu’, ‘DOUBLE’. Default is ‘AT2’.

Returns:
float

The geometric coefficient.

phasefieldx.Element.Phase_Field.geometric_crack.geometric_crack_function(phi, case='AT2')[source]#

Computes the geometric function alpha(phi) for various phase-field models.

Parameters:
phifloat or array_like

Phase-field variable.

casestr, optional

The phase-field model. Supported values are ‘AT2’, ‘AT1’, ‘WU’, ‘DOUBLE’. Default is ‘AT2’.

Returns:
float or array_like

The value of the geometric function.

phasefieldx.Element.Phase_Field.geometric_crack.geometric_crack_function_derivative(phi, case='AT2')[source]#

Computes the derivative of the geometric function, alpha’(phi).

Parameters:
phifloat or array_like

Phase-field variable.

casestr, optional

The phase-field model. Supported values are ‘AT2’, ‘AT1’, ‘WU’, ‘DOUBLE’. Default is ‘AT2’.

Returns:
float or array_like

The derivative of the geometric function.