Skip to main content

package for PFC (phase field crystal) simulations

Project description

PFC simulation in python

created by michael in 2022/04

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

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.2 and mu = 0.26'''
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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pfc_util-0.4.11.tar.gz (95.3 kB view details)

Uploaded Source

Built Distribution

pfc_util-0.4.11-py3-none-any.whl (119.8 kB view details)

Uploaded Python 3

File details

Details for the file pfc_util-0.4.11.tar.gz.

File metadata

  • Download URL: pfc_util-0.4.11.tar.gz
  • Upload date:
  • Size: 95.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pfc_util-0.4.11.tar.gz
Algorithm Hash digest
SHA256 f132d39fecca7930c140a9696e899b3b8ea5aa8817c2a0253c3b33f291cf1c3d
MD5 4bf41d07c76c7a70e13b69e082f961be
BLAKE2b-256 88fcc40f141a3cd621ab41cfb152b5ecc0b2272085abc1daf16af1dcd9da98c5

See more details on using hashes here.

File details

Details for the file pfc_util-0.4.11-py3-none-any.whl.

File metadata

  • Download URL: pfc_util-0.4.11-py3-none-any.whl
  • Upload date:
  • Size: 119.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pfc_util-0.4.11-py3-none-any.whl
Algorithm Hash digest
SHA256 78521463b7c9a5462f2c1ecb0705fd8971a86f34556a00d181c1e986438650fc
MD5 73bec1911082388927e23a80398fe233
BLAKE2b-256 f917d6d4bfcfbadb8b35a6975d9d3a372b29a4cbf0ca5ea860b91d92882a1be7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page