Skip to main content

PFC simulation in python

created by michael in 2022/04

pfc_util is a python package for PFC (phase field crystal) simulations.

Documentation

Documentation is available on https://pfc-util.readthedocs.io .

Dependencies

  • numpy

  • scipy

  • matplotlib

  • pyfftw

  • torusgrid

  • rich

Installation

Install via pip:

pip install pfc-util

Modules

pfc_util.core - Core module; definitions of PFC free energy functional, state functions, as well as minimizers

pfc_util.extra - Extensions to vanilla PFC. Currently includes pfc6, which is a 6th-order generalization to the PFC functional

pfc_util.toolkit - Static preminimized solid/liquid profiles & utility functions.

Minimizers

The package provides three main means of minimizing/evolving a PFC system:

  • Constant chemical potential - The grand potential \(\Omega \equiv F - \mu \int d\mathbf{r} \psi\) is minimized with fixed \(\mu\)

  • Stress relaxer - The grand potential density \(\omega \equiv \Omega / V\) is minimized with respect to the density field and system size with fixed \(\mu\)

  • Conserved dynamics - The free energy \(F\) is minimized with fixed \(\bar\psi\)

Example Code Snippet

The following code snippet will retrieve a preminimized solid unit cell, evolve it under \(\epsilon=0.05\) and \(\mu=0.08\) until \(\bar\psi\) barely changes, and save the newly minimized unit cell to solid_eps0.05_mu0.08.field

import pfc_util as pfc
import torusgrid as tg

'''Get a preminimized solid profile at epsilon = 0.1'''
solid = pfc.toolkit.get_unit_cell(eps='0.1')


'''Minimize this profile at epsilon = 0.05 and mu = 0.08'''
pfc.ConstantMuMinimizer(solid, dt=0.001, eps=0.05, mu=0.08).run(
        n_steps=31, # n_steps means the number of evolution steps between hook calls
                    # hooks are invoked to update display, monitor values, etc
        hooks= (
            tg.dynamics.Display() # add display capability
            + tg.dynamics.Panel() # add a panel to live display
            + tg.dynamics.MonitorValues(
                {'psibar': lambda e: e.field.psi.mean()},
                period=8
            ) # tell the minimizer that psi.mean() should be monitored and stored as "psibar"
              # here e refers to the minimizer instance
              # period = 8 means that the values are logged every 8 hook calls
              # so in this case we would be calculating the values every 31*8 = 248 time steps
            + tg.dynamics.Text('psibar={psibar:.8f}')
            + tg.dynamics.DetectSlow(
                'psibar', rtol=1e-9, atol=0, period=8, patience=200
            ) # make the minimizer stop if psibar varies sufficiently slowly
        )
    )

tg.save(solid, './solid_eps0.05_mu0.08.field') # save the minimized field

Metadata

Release files for pfc-util 0.4.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pfc-util 0.4.12
File Size Uploaded
pfc_util-0.4.12.tar.gz 96.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pfc-util 0.4.12
File Interpreter ABI Platform
pfc_util-0.4.12-py3-none-any.whl Python 3 none any Details

Total release size: 218.0 kB

Release files / pfc_util-0.4.12.tar.gz

Download URL pfc_util-0.4.12.tar.gz
Size 96.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fc578e13df03da6330d416a11a98e97772b193662b1de18424db11a897f1b90a
BLAKE2b-256 checksum
How to use checksums
c405679630cc88dd7d5567739bf97978c3e7ca192f68719e1274068e2c8d82e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / pfc_util-0.4.12-py3-none-any.whl

Download URL pfc_util-0.4.12-py3-none-any.whl
Size 121.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
999f4f5dcaa2aeff367fe5ed66818e81fcaa32f93c4428a293cbbf7f54847866
BLAKE2b-256 checksum
How to use checksums
faeb5b3792284281aead7189f16deb75a34e9fcfa8e8335a85ad41e48dddf986
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.4.12 This release

2 release files

0.4.11

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page