Class pypfc_pre

Bases: setup_base
Functions¶
__init__ ¶
__init__(
domain_size: Union[List[float], ndarray],
ndiv: Union[List[int], ndarray],
config: Dict[str, Any],
) -> None
Initialize the class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain_size
|
array_like of int, shape (3,)
|
Number of grid divisions along each coordinate axis [nx, ny, nz]. |
required |
ndiv
|
array_like of int, shape (3,)
|
Number of grid divisions along each coordinate axis [nx, ny, nz]. |
required |
config
|
dict
|
Configuration parameters as key-value pairs. See the pyPFC overview for a complete list of the configuration parameters. |
required |
do_bicrystal ¶
do_bicrystal(
xtal_rot: ndarray,
params: Optional[List[float]] = None,
liq_width: float = 0.0,
model: int = 0,
) -> np.ndarray
Define a bicrystal with two different crystal orientations.

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xtal_rot
|
ndarray of float, shape (3,3,2)
|
Crystal orientations (rotation matrices) for the two grains. |
required |
params
|
list
|
List containing parameters for the bicrystal model.
|
None
|
liq_width
|
float
|
Width of the liquid band along the grain boundary. |
0.0
|
model
|
int
|
Density field layout.
|
0
|
Returns:
| Name | Type | Description |
|---|---|---|
density |
ndarray of float, shape (nx,ny,nz)
|
Density field. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the value of |
do_polycrystal ¶
do_polycrystal(
xtal_rot: ndarray,
params: Optional[List[float]] = None,
liq_width: float = 0.0,
model: int = 0,
) -> np.ndarray
Define a polycrystal in a periodic 3D domain.

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xtal_rot
|
ndarray of float, shape (3,3,n_xtal)
|
Crystal orientations (rotation matrices) for n_xtal crystals. |
required |
params
|
list
|
List containing parameters for the polycrystal model.
|
None
|
liq_width
|
float
|
Width of the liquid band along the grain boundaries. |
0.0
|
model
|
int
|
Density field layout.
|
0
|
Returns:
| Name | Type | Description |
|---|---|---|
density |
ndarray of float, shape (nx,ny,nz)
|
Polycrystal density field. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the value of |
do_single_crystal ¶
do_single_crystal(
xtal_rot: Optional[ndarray] = None,
params: Optional[List[float]] = None,
model: int = 0,
) -> np.ndarray
Define a single crystal in a periodic 3D domain.

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xtal_rot
|
ndarray of float, shape (3,3)
|
Crystal orientation (rotation matrix). Default is an identity matrix. |
None
|
params
|
list
|
List containing parameters for the single crystal model:
|
None
|
model
|
(int, optional)
|
Density field layout.
|
0
|
Returns:
| Name | Type | Description |
|---|---|---|
density |
ndarray of float, shape (nx,ny,nz)
|
Density field. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the value of |
evaluate_ampl_dens ¶
Get density field amplitudes and phase densities for PFC simulations.

Returns:
| Name | Type | Description |
|---|---|---|
ampl |
ndarray of float, shape (npeaks,)
|
Density field amplitudes for the specified crystal structure and number of peaks. |
nLnS |
ndarray of float, shape (2,)
|
Densities in the liquid (nL) and solid (nS) phases. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
ValueError
|
If |
ValueError
|
If |
Notes
This method provides pre-calculated density field amplitudes and phase
densities for different crystal structures (SC, BCC, FCC) and numbers of
Fourier peaks in the two-point correlation function. The values depend
on the temperature-like parameter sigma.
Fore efficiency, the method uses lookup tables of pre-computed values.
Supported configurations:
struct |
npeaks |
sigma range |
|---|---|---|
| SC | 1 | [0.0, 0.25] |
| 2 | [0.0, 0.22] | |
| 3 | [0.0, 0.22] | |
| BCC | 1 | [0.0, 0.33] |
| 2 | [0.0, 0.30] | |
| 3 | [0.0, 0.25] | |
| FCC | 1 | [0.0, 0.25] |
| 2 | [0.0, 0.25] | |
| 3 | [0.0, 0.25] |
generate_density_field ¶
Define a 3D density field for (X)PFC modeling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
crd
|
ndarray of float, shape (3,...)
|
Grid point coordinates [x,y,z]. |
required |
g
|
ndarray of float, shape (3,3)
|
Rotation matrix for crystal orientation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
density |
ndarray of float
|
Density field for the specified crystal structure with appropriate Fourier modes and amplitudes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
The density field is generated based on the current crystal structure
(struct) and density field amplitudes (ampl) settings.
get_ampl ¶
Get the amplitudes in the density approximation.
Returns:
| Name | Type | Description |
|---|---|---|
ampl |
ndarray of float, shape (N,)
|
Amplitudes. |
get_density ¶
Get the density field.
Returns:
| Name | Type | Description |
|---|---|---|
den |
ndarray of float, shape (nx,ny,nz)
|
Density field. |
get_nlns ¶
Get the liquid and solid phase densities.
Returns:
| Name | Type | Description |
|---|---|---|
nlns |
ndarray of float, shape (2,)
|
\([n_{l},n_{s}]\) where \(n_{l}\) is liquid phase density and \(n_{s}\) is solid phase density. |
get_npeaks ¶
Get the number of peaks in the density field approximation.
Returns:
| Name | Type | Description |
|---|---|---|
npeaks |
int
|
Number of peaks in the density field approximation. |
get_sigma ¶
Get the temperature-like parameter sigma.
Returns:
| Name | Type | Description |
|---|---|---|
sigma |
float
|
Temperature-like parameter sigma |
get_struct ¶
Get the crystal structure.
Returns:
| Name | Type | Description |
|---|---|---|
struct |
str
|
Crystal structure type: |
set_ampl ¶
Set the amplitudes in the density approximation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ampl
|
array_like of float, shape (N,)
|
Amplitudes. |
required |
set_density ¶
Set the density field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
den
|
ndarray of float, shape (nx,ny,nz)
|
Density field. |
required |
set_energy ¶
Set the PFC energy field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ene
|
ndarray of float, shape (nx,ny,nz)
|
PFC energy field. |
required |
set_nlns ¶
Set the liquid and solid phase densities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nlns
|
array_like of float, shape (2,)
|
\([n_{l},n_{s}]\) where \(n_{l}\) is liquid phase density and \(n_{s}\) is solid phase density. |
required |
set_npeaks ¶
Set the number of peaks in the density field approximation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
npeaks
|
int
|
Number of peaks in the density field approximation. |
required |
set_sigma ¶
Set the temperature-like parameter sigma.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sigma
|
float
|
Temperature-like parameter sigma. |
required |
set_struct ¶
Set the crystal structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
struct
|
(FCC, BCC)
|
Crystal structure type: |
'FCC'
|