pypfc 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
__init__.py ADDED
@@ -0,0 +1,7 @@
1
+ # This file marks the directory as a Python package.
2
+ # It can be left empty, or you can import modules/classes for convenience.
3
+
4
+ # Example: (optional)
5
+ # from .pypfc import simulation_setup, do_single_crystal
6
+
7
+ # If you want to expose specific functions/classes at package level, uncomment above.
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.4
2
+ Name: pypfc
3
+ Version: 0.0.1
4
+ Summary: Python-based Phase Field Crystal (PFC) simulation tools
5
+ Author-email: Håkan Hallberg <hakan.hallb@protonmail.com>
6
+ License-Expression: GPL-3.0-or-later
7
+ Project-URL: Homepage, https://github.com/HHallb/pyPFC
8
+ Project-URL: Repository, https://github.com/HHallb/pyPFC
9
+ Keywords: phase field crystal,simulation,atomistic simulation
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.12
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: license-file
16
+
17
+
18
+ # pyPFC: An Open-Source Python Package for Phase Field Crystal Simulations
19
+ A Python software package for setting up, running and processing Phase Field Crystal (PFC) simulations. The code uses PyTorch to allow execution on both CPUs and GPUs, depending on the available hardware. The PFC implementation in pyPFC relies on heavy use of FFTs and is set on a regular Cartesian 3D grid. Periodic boundary conditions are assumed along all coordinate axes.
20
+
21
+ ![PFC atoms](/images/PFC_atoms.png)
22
+
23
+ ## Control parameters
24
+ The general behavior of pyPFC is controlled by a set of parameters, collected in a Python dictionary. The parameters are described in the table below.
25
+
26
+ | Parameter name | Defaults to | Description
27
+ | ---------------------- | --------------------------------- | ---------------------------------------------------------------------------------
28
+ | alat | 1.0 | Lattice parameter (non-dimensional)
29
+ | alpha | [1, 1] | C2 Gaussian peak widths, excluding the zero-mode peak
30
+ | C20_amplitude | 0.0 | Amplitude of the zero-mode Gaussian peak in C2
31
+ | C20_alpha | 1.0 | Width of the zero-mode Gaussian peak in C2
32
+ | density_interp_order | 2 | Interpolation order for density maxima localization
33
+ | density_merge_distance | 0.1 | Distance for merging density maxima (in units of lattice parameters)
34
+ | density_threshold | 0.5 | Threshold for density maxima detection
35
+ | device_number | 0 | GPU device number (if multiple GPUs are available)
36
+ | device_type | 'gpu' | PyTorch device ('cpu' or 'gpu')
37
+ | dtime | 1.0e-3 | Non-dimensional time increment
38
+ | dtype_cpu | np.double | Floating-point precision of numpy arrays
39
+ | dtype_gpu | torch.float64 | Floating-point precision of PyTorch tensors
40
+ | evaluate_phase_field | True | Evaluate phase field (or not)
41
+ | normalize_pf | True | Normalize the phase fields to [0,1], or not
42
+ | npeaks | 2 | Number of Gaussian peaks, excluding the zero-mode peak, to use in C2
43
+ | pf_gauss_var | 0.1 | Variance (sigma) of the Gaussian smoothing kernel used in phase field evaluations
44
+ | pf_iso_level | 0.5 | Iso-level for phase field contouring
45
+ | sigma | 0.0 | Temperature-like parameter (non-dimensional)
46
+ | struct | 'FCC' | Crystal structure
47
+ | torch_threads | 8 | Number of CPU threads to use if device_type is 'cpu'
48
+ | torch_threads_interop | 8 | Number of interop threads to use if device_type is 'cpu'
49
+ | update_scheme | '1st_order' | Time integration scheme ('1st_order', '2nd_order' or 'exponential')
50
+ | update_scheme_params | [1.0, 1.0, 1.0, None, None, None] | Parameters in the time integration scheme: [g1, g2, g3, alpha, beta, gamma]
51
+ | verbose | True | Verbose output (or not)
52
+
53
+ ## Description of Source Files
54
+ The software is built on classes, contained in separate modules/files, with an inheritance chain (from top to bottom) comprising:
55
+
56
+ | File (*.py) | Description
57
+ | --------------- | ----------------------
58
+ | **pypfc_grid** | Grid methods
59
+ | **pypfc_base** | Base methods
60
+ | **pypfc_pre** | Pre-processing methods
61
+ | **pypfc_io** | Data IO methods
62
+ | **pypfc** | Main class
63
+
64
+ In addition, **pypfc_ovito.py** provides custom interfaces to selected functionalities in [OVITO](https://www.ovito.org/), useful for post-processing of pyPFC simulation output.
65
+
66
+ Methods in the different classes are described in individual subsections below.
67
+
68
+ ### The class `pypfc_grid`
69
+ The class is initiated by supplying the arguments `ndiv = [nx,ny,nz]` and `ddiv=[dx,dy,dz]`, where `[nx,ny,nz]` are the number of grid points and `[dx,dy,dz]` the grid spacing along each coordinate direction.
70
+
71
+ #### Class methods and their arguments
72
+
73
+ | Method | Description
74
+ | ----------------- | ----------------------------------------------
75
+ | `set_ndiv(ndiv)` | Sets the number of grid points `nx,ny,nz`
76
+ | `get_ndiv` | Returns `ndiv`
77
+ | `set_ddiv(ddiv)` | Sets the grid spacing `dx,dy,dz`
78
+ | `get_ddiv` | Returns `ddiv`
79
+ | `get_dSize` | Returns the grid size `dSize=ndiv*ddiv`
80
+ | `copy_from(grid)` | Makes a duplicate of a grid class object
81
+
82
+ ### The class `pypfc_base`
83
+ The class is initiated by supplying the arguments `ndiv` and `ddiv`. A dictionary of configuration parameters can also be supplied through `config`.
84
+
85
+ #### Class methods and their arguments
86
+
87
+ | Method | Description
88
+ | ------------------------------------------------------------- | ----------------------------------------------
89
+ | `set_verbose(verbose)` | Set verbose output flag
90
+ | `get_verbose` | Get verbose output flag
91
+ | `set_dtype_cpu(dtype)` | Set the cpu floating point precision
92
+ | `get_dtype_cpu` | Get the cpu floating point precision
93
+ | `set_dtype_gpu(dtype)` | Set the gpu floating point precision
94
+ | `get_dtype_gpu` | Get the gpu floating point precision
95
+ | `set_device_type(device_type)` | Set the device type (cpu or gpu)
96
+ | `get_device_type` | Get the device type (cpu or gpu)
97
+ | `set_device_number(device_number)` | Set the GPU device number
98
+ | `get_device_number` | Get the GPU device number
99
+ | `set_k2_d(k2_d)` | Set sum of squared wave vector (on the device)
100
+ | `get_k2_d` | Get sum of squared wave vector (on the device)
101
+ | `set_torch_threads` | Set torch.get_num_threads() and torch.get_num_interop_threads()
102
+ | `get_torch_threads` | Get torch.get_num_threads() and torch.get_num_interop_threads()
103
+ | `get_time_stamp` | Get time stamp string: YYYY-MM-DD H:M
104
+ | `get_k(npoints, dspacing)` | Define a 1D wave vector at npoint points with spacing dspacing
105
+ | `evaluate_k2_d` | Evaluate the sum of squared wave vectors
106
+ | `get_integrated_field_in_volume(field, limits)` | Integrate a field variable within a volume defined by lower and upper coordinate limits
107
+ | `get_field_average_along_axis(field, axis)` | Evaluate the mean value of a field variable along a certain axis ('x', 'y' or 'z')
108
+ | `get_integrated_field_along_axis(field, axis)` | Integrate a field variable along a certain axis ('x', 'y' or 'z')
109
+ | `interpolate_atoms(intrpPos, pos, values, num_nnb, power)` | Interpolate values at given positions
110
+ | `interpolate_density_maxima(self, den, ene, pf)` | Interpolate density field maxima, plus energy and (optionally) also phase field(s)
111
+ | `get_phase_field_contour(self, pf, pf_zoom, evaluate_volume)` | Find the iso-contour surface of a 3D phase field using marching cubes and (optionally) the enclosed volume
112
+ | `get_rlv(struct, alat)` | Get the reciprocal lattice vectors for a particular crystal structure
113
+ | `evaluate_reciprocal_planes` | Establish the reciprocal vectors/planes for a particular crystal structure
114
+ | `evaluate_C2_d` | Establish the two-point correlation function (on the device) for a particular crystal structure
115
+ | `evaluate_directional_correlation_kernel(self, H0, Rot)` | Establish the directional correlation kernel for a particular crystal structure
116
+
117
+ ### The class `pypfc_pre`
118
+ The class is initiated by supplying the arguments `ndiv` and `ddiv`. A dictionary of configuration parameters can also be supplied through `config`.
119
+
120
+ #### Class methods and their arguments
121
+
122
+ | Method | Description
123
+ | ------------------------------------------------------------- | ----------------------------------------------
124
+ | `set_struct(struct)` | Set crystal structure
125
+ | `get_struct` | Get crystal structure
126
+ | `set_density(den)` | Set PFC density field
127
+ | `get_density` | Get PFC density field
128
+ | `set_energy(ene)` | Set PFC energy field
129
+ | `get_energy(ene)` | Get PFC energy field
130
+ | `get_ampl` | Get amplitudes of the density field approximation
131
+ | `get_nlns` | Get liquid/solid densities in the density field approximation
132
+ | `set_sigma(sigma)` | Set sigma
133
+ | `get_sigma` | Get sigma
134
+ | `set_npeaks(npeaks)` | Set the number of Gaussian peaks in the pair correlation function
135
+ | `get_npeaks` | Set the number of Gaussian peaks in the pair correlation function
136
+ | `do_single_crystal(xtalRot, params, model)` | Define a centered crystal in a periodic 3D domain
137
+ | `do_bicrystal(xtalRot, params, liq_width, model)` | Define a centered crystal, embedded inside a matrix crystal, in a periodic 3D domain
138
+ | `do_polycrystal(xtalRot, params, liq_width, model)` | Define a polycrystal in a periodic 3D domain
139
+ | `generate_density_field(crd, g)` | Define a 3D PFC density field
140
+ | `evaluate_ampl_dens` | Get the amplitudes and densities for different density field expansions
141
+
142
+ ### The class `pypfc_io`
143
+ The class is initiated by supplying the arguments `ndiv` and `ddiv`. A dictionary of configuration parameters can also be supplied through `config`.
144
+
145
+ #### Class methods and their arguments
146
+
147
+ | Method |Description
148
+ | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------
149
+ | `write_extended_xyz(filename, coord, atom_data, atom_data_labels, simulation_time, gz)` | Save PFC data in extended XYZ format
150
+ | `read_extended_xyz(filename, nfields)` | Read PFC data in extended XYZ format from file
151
+ | `write_vtk_points(filename, coord, scalarData, scalarDataName, vectorData, vectorDataName, tensorData, tensorDataName)` | Save 3D point data to a VTK file
152
+ | `write_vtk_structured_grid(filename, arrayData, arrayName)` | Save 3D field data to a VTK file
153
+ | `save_pickle(filename, data)` | Save a list of data objects to a binary pickle file
154
+ | `load_pickle(filename, ndata)` | Load data objetcs from a binary pickle file
155
+ | `write_info_file(filename=, output_path)` | Write simulation setup information to a file
156
+ | `append_to_info_file(info, filename=, output_path)` | Append linea to a text file
157
+
158
+ ### The class `pypfc`
159
+ The class is initiated by supplying the arguments `ndiv` and `ddiv`. A dictionary of configuration parameters can also be supplied through `config`.
160
+
161
+ #### Class methods and their arguments
162
+
163
+ | Method | Description
164
+ | -------------------------------------------------------------------------------------------- | ----------------------------------------------
165
+ | `set_alat(alat)` | Set lattice parameter (non-dimensional)
166
+ | `get_alat` | Get lattice parameter (non-dimensional)
167
+ | `set_dtime(dtime)` | Set time increment (non-dimensional)
168
+ | `get_dtime` | Get time increment (non-dimensional)
169
+ | `set_alpha(alpha)` | Set peak widths in C2
170
+ | `get_alpha` | Get peak widths in C2
171
+ | `set_C2_d(C2_d)` | Set C2 (on the device)
172
+ | `get_C2_d` | Get C2 (on the device)
173
+ | `set_H2_d(H0, Rot)` | Set H2 (in Fourier space, on the device)
174
+ | `set_update_scheme(update_scheme)` | Set time integration scheme
175
+ | `get_update_scheme` | Get time integration scheme
176
+ | `set_update_scheme_params(params)` | Set time integration scheme parameters
177
+ | `get_update_scheme_params` | Get time integration scheme parameters
178
+ | `get_energy` | Get the PFC energy field and its mean value
179
+ | `set_density(density)` | Set the PFC density field
180
+ | `get_density` | Get the PFC density field and its mean value
181
+ | `set_phase_field_kernel(H0, Rot)` | Set phase field kernel
182
+ | `set_phase_field_smoothing_kernel(pf_gauss_var)` | Set phase field smoothing kernel
183
+ | `cleanup` | Clean up variables
184
+ | `do_step_update` | Update the (X)PFC density field using the chosen time integration scheme
185
+ | `evaluate_energy` | Evaluate the PFC energy field
186
+ | `get_phase_field` | Evaluate the phase field using wavelet filtering
187
+
188
+ ## Package dependencies
189
+ The following Python packages are required:
190
+
191
+ * ovito (if pypfc_ovito is to be used)
192
+ * pyvtk
193
+ * scikit-image
194
+ * scipy
195
+ * torch
196
+
197
+ ## Installation and Usage
198
+ Install using `pip install pypfc` and import with `import pypfc` and (optionally) `import pypfc_ovito`.
199
+
200
+ ## Licencing and Acknowledgment
201
+ This software is released under a [GNU GPLv3 license](https://www.gnu.org/licenses/).
202
+
203
+ ## References
204
+ Further details on PFC modeling and example applications can be found in:
205
+
206
+ 1. [K.H. Blixt and H. Hallberg, **Phase Field Crystal Modeling of Grain Boundary Migration: Mobility, Energy and Structural Variability**, *Acta Materialia*, 297:121318, 2025](https://doi.org/10.1016/j.actamat.2025.121318)
207
+ 2. [H. Hallberg and K.H. Blixt, **Assessing grain boundary variability through phase field crystal simulations**, *Physical Review Materials*, 8(3):113605, 2024](https://doi.org/10.1103/PhysRevMaterials.8.113605)
208
+ 3. [K.H. Blixt and H. Hallberg, **Phase field crystal modeling of grain boundary structures in diamond cubic systems**, *Physical Review Materials*, 8(3):033606, 2024](https://doi.org/10.1103/PhysRevMaterials.8.033606)
209
+ 4. [H. Hallberg and K.H. Blixt, **Multiplicity of grain boundary structures and related energy variations**, *Materials Today Communications*, 38:107724, 2024](https://doi.org/10.1016/j.mtcomm.2023.107724)
210
+ 5. [H. Hallberg and K.H. Blixt, **Evaluation of Nanoscale Deformation Fields from Phase Field Crystal Simulations**, *Metals*, 12(10):1630, 2022](https://doi.org/10.3390/met12101630)
211
+ 6. [K.H. Blixt and H. Hallberg, **Grain boundary and particle interaction: Enveloping and pass-through mechanisms studied by 3D phase field crystal simulations**, *Materials & Design*, 220:110845, 2022](https://doi.org/10.1016/j.matdes.2022.110845)
212
+ 7. [K.H. Blixt and H. Hallberg, **Grain boundary stiffness based on phase field crystal simulations**, *Materials Letters*, 318:132178, 2022](https://doi.org/10.1016/j.matlet.2022.132178)
213
+ 8. [K.H. Blixt and H. Hallberg, **Evaluation of grain boundary energy, structure and stiffness from phase field crystal simulations**, *Modelling and Simulation in Materials Science and Engineering*, 30(1):014002, 2022](https://doi.org/10.1088/1361-651X/ac3ca1)
@@ -0,0 +1,12 @@
1
+ __init__.py,sha256=EEGMTiS1U_NksrUR10uN347_yUrPeEOOwy-j1_XWr7k,294
2
+ pypfc.py,sha256=MSMCOmYjxAQ9nxqyDVRipc1LECjdVvOfHDPP-ufmvk0,24005
3
+ pypfc_base.py,sha256=63cS--dQWSXjZfbUXQIChkY0qS9U7xohjo7SFZyQ4UI,32224
4
+ pypfc_grid.py,sha256=ZV4v5vpa11t0fnmNvsbyrXEKSCsuR9K4jPd_H8vZW7U,2301
5
+ pypfc_io.py,sha256=7G7OkC10shxion2GVQqNo1Y7R4opkgFlGKR0QjDGPIs,24058
6
+ pypfc_ovito.py,sha256=8flsE_KD0uPwE71rkQX_yUl27P6qsX7UMDqo6HXhjLI,18350
7
+ pypfc_pre.py,sha256=akX5bkLvpu5U-pWvNL7v_T8m37Vw6G3sdoRfSO7X_0U,17190
8
+ pypfc-0.0.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
9
+ pypfc-0.0.1.dist-info/METADATA,sha256=fOr8Qxm32H1XFqGvRUrxWF3QGKd_0giudhMCjW6Rkpk,19098
10
+ pypfc-0.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ pypfc-0.0.1.dist-info/top_level.txt,sha256=DiV0c-isfXPK1_2o0uFJMzRaSki6wqSG1nc75xkUpOs,68
12
+ pypfc-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+