pfc

package
v0.0.0-...-6493f53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2021 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreaModulusWeight

func AreaModulusWeight(miller Miller, Q *mat.Dense) float64

AreaModulusWeight return the weight associated with area compression this is the 2D equivalent of the bulk modulus. The modulus is obtained as follows. The area modulus is defined via B_A = A*dE^2/dA^2, where E is the total elastic energy

func BuildCrystal

func BuildCrystal(ucell UnitCell, kernel AtomicKernel, grid *pfutil.Grid)

BuildCrystal constructs a field that is organized as a crystal ucell is the unit cell, kernel is the functional form used to represent the field form one atom and grid is a computational grid that will be assigned the field corresponding to the crystal structure

func BulkModWeight

func BulkModWeight(miller Miller, Q *mat.Dense) float64

BulkModWeight returns the weight (e.g. value in design matrix) needed to fit a bulk modulus. Miller is the mode, Q is that matrix product C^TC, where each column in C represents a reciprocal lattice vector The Reuss formula for the bulk modulus is applied https://wiki.materialsproject.org/Elasticity_calculations

func CornersScaledCrd

func CornersScaledCrd(cell Cell, domainSize []int) *mat.Dense

CornersScaledCrd returns the positions of the corners in scaled coordinates Cell represents the unit cell and domainSize gives the size of the domain which is assumed to be the box [0, domainSize[0]] x [0, domainSize[1]] (x [0, domainSize[2]] if in 3D)

func CubicUnitCellDensity

func CubicUnitCellDensity(miller Miller) float64

CubicUnitCellDensity returns the density of a plane when the underlying Bravais lattice is cubic.

func NumEquivalent

func NumEquivalent(miller Miller, dim int) int

NumEquivalent returns the number of equivalent indices

func NumEquivalent2D

func NumEquivalent2D(miller Miller) int

NumEquivalent2D returns the number of equivalent miller indices in 2D

func NumEquivalent3D

func NumEquivalent3D(miller Miller) int

NumEquivalent3D returns the number of equivalent planes

func QuadCube

func QuadCube(f func(float64, float64, float64) float64, n int) float64

QuadCube calculates the 3D integral over a unit cube [0, 1] x [0, 1] x [0, 1] using tensorial Legendre quadrature. The tensorial Legendre quadrature, is not optimal with respect to function evaluations, but does the job.

func QuadSquare

func QuadSquare(f func(float64, float64) float64, n int) float64

QuadSquare calculates the 2D integral over a unit square [0, 1] x [0, 1] using tensorial Legendre quadrature. The tensorial Legendre quadrature, is not optimal with respect to function evaluations, but does the job.

func ShearModWeight

func ShearModWeight(m Miller, Q *mat.Dense) float64

ShearModWeight calcualtes the weight needed to fit the shear modulus Miller is the mode, Q is that matrix product C^TC, where each column in C represents a reciprocal lattice vector The Reuss formula for the shear modulus is applied https://wiki.materialsproject.org/Elasticity_calculations

func TiltGB

func TiltGB(grid *pfutil.Grid, angle float64)

TiltGB creates a tilt grain boundary from a grid that is already initialized as a single crystal. The grain boundary is centered at the computational cell

func XYPlaneShearWeight

func XYPlaneShearWeight(miller Miller, Q *mat.Dense) float64

XYPlaneShearWeight returns the shear modulus associated with shear in the XY plane. The values for the averages is obtained from

Meille, S. and Garboczi, E.J., 2001. Linear elastic properties of 2D and 3D models of porous materials made from elongated objects. Modelling and Simulation in Materials Science and Engineering, 9(5), p.371.

Types

type AtomicKernel

type AtomicKernel interface {
	// Eval evaluates the kernel at the given coordinate
	Eval(x float64) float64

	// Cutoff specifies a maximum value beyond which Eval returns
	// essentially zero
	Cutoff() float64
}

AtomicKernel is a function type that returns a density

type Cell

type Cell struct {
	CellVec *mat.Dense
}

Cell is a type used to represent a unit cell. In the underlying CellVec matrix, each column represents a cell vector

func BCC

func BCC(a float64) Cell

BCC returns a primitive cell for the BCC structure

func FCC

func FCC(a float64) Cell

FCC construct a FCC cell

func SC2D

func SC2D(a float64) Cell

SC2D returns the primitive cell of a 2D cubical system

func SC3D

func SC3D(a float64) Cell

SC3D returns the primitive unit cell for a simple cubic structure with lattice parameter a in 3D

func Triangular2D

func Triangular2D(a float64) Cell

Triangular2D returns the primitive cell of a triangular lattice in 2D

func (*Cell) Reciprocal

func (c *Cell) Reciprocal() ReciprocalCell

Reciprocal returns a cell object representing the reciprocal cell The underlying matrix of the reciprocal lattice is given by

M^T = 2*pi*C^{-1}

where each column of M is a reciprocal lattice vector and each column if C is a real lattice vector

func (*Cell) Volume

func (c *Cell) Volume() float64

Volume returns the volume of the cell. For 2D lattices this would be the surface area

type CircleKernel

type CircleKernel struct {
	Radius float64
}

CircleKernel represents the field from one atom as a square

func (*CircleKernel) Area

func (ck *CircleKernel) Area() float64

Area returns the of the circle

func (*CircleKernel) Cutoff

func (ck *CircleKernel) Cutoff() float64

Cutoff returns the width of the square

func (*CircleKernel) Eval

func (ck *CircleKernel) Eval(x float64) float64

Eval return 1 if -width/2 <= x < width/2, and zero otherwise

type ElasticPropResult

type ElasticPropResult struct {
	Amp []float64
	Fit map[string]float64
}

ElasticPropResult returns the obtained amplitide as well as the elastic tensor that corresponds to the solution

type ElasticPropertyTarget

type ElasticPropertyTarget struct {
	Bulk  float64
	Shear float64

	TargetType ElasticTargetType
}

ElasticPropertyTarget is a type that holds target values for fitting widths of peak heights. The default is to fit an isotropic material (in which case the bulk modules and shear modulus are matched)

type ElasticTargetType

type ElasticTargetType int

ElasticTargetType is an integer type used to tune peak widths

const (
	// ISOTROPIC is used together with ElasticPropertyTarget type to indicate
	// that the bulk and shear modulus should be fitted
	ISOTROPIC ElasticTargetType = iota
)

type GaussianKernel

type GaussianKernel struct {
	// Width is the "standard deviation" of the gaussian
	Width float64
}

GaussianKernel is a type that represents the field from one atoms as a Gaussian centered at position of the atom

func (*GaussianKernel) Cutoff

func (gk *GaussianKernel) Cutoff() float64

Cutoff returns a cutoff where the kernel is essentiall zero

func (*GaussianKernel) Eval

func (gk *GaussianKernel) Eval(x float64) float64

Eval evaluates the gaussian kernel

type HyperOctantExplorer

type HyperOctantExplorer struct {
	// Starting positions
	X0 []float64
	// contains filtered or unexported fields
}

HyperOctantExplorer tries initial conditions starting from all combinations of +- X0

func (*HyperOctantExplorer) Next

func (hoe *HyperOctantExplorer) Next() []float64

Next returns the next hyper parameter

func (*HyperOctantExplorer) OnMinimizationFinished

func (hoe *HyperOctantExplorer) OnMinimizationFinished(res *optimize.Result)

OnMinimizationFinished does nothing (included to satisfy the InitialGuessExplorer interface)

type IdealMix

type IdealMix struct {
	C3 float64
	C4 float64
}

IdealMix is a type used to represent the ideal mixing entropy with respect to a reference state. The polynomial is used together with a dimensionless density field n = rho/rho_0 - 1, where rho is the real density field and rho_0 is the reference density. The real mixing free energy is given by

F_id = (1 + n)*ln(1 + n) - n

An expansion of this around the reference state (n = 0) yields

F_id = (n^2/2 - C3*n^3/6 + C4*n^4/12)

where C3 and C4 are treated as free parameters that can be used to stabilize particular structures of interest. Reference

Greenwood, M., Provatas, N. and Rottler, J., 2010. Free energy functionals for efficient phase field crystal modeling of structural phase transformations. Physical review letters, 105(4), p.045702.

func (*IdealMix) Deriv

func (im *IdealMix) Deriv(n float64) float64

Deriv returns the derivative with respect to the density

func (*IdealMix) Eval

func (im *IdealMix) Eval(n float64) float64

Eval evaluates the mixing entropy at a given dimensionless density

func (*IdealMix) FourthOrderPrefactor

func (im *IdealMix) FourthOrderPrefactor() float64

FourthOrderPrefactor returns the prefactor in front of the fourth order term

func (*IdealMix) QuadraticPrefactor

func (im *IdealMix) QuadraticPrefactor() float64

QuadraticPrefactor returns the prefactor in front of the quadratic term

func (*IdealMix) ThirdOrderPrefactor

func (im *IdealMix) ThirdOrderPrefactor() float64

ThirdOrderPrefactor returns the prefactor in front of the third order term

type InitialGuessExplorer

type InitialGuessExplorer interface {
	// Next return the next initial guess. It should return
	// nil when all initial guess has been explored
	Next() []float64

	// OnMinimzationFinished is a callback method that is called everytime
	// the local minimizer finds a solution
	OnMinimizationFinished(res *optimize.Result)
}

InitialGuessExplorer is a type that is used to generate initial guesses for local minimzation algorithms

type Miller

type Miller struct {
	H, K, L int
}

Miller is a struct used to represent the Miller indices of a crystal plane

func EquivalentMiller

func EquivalentMiller(miller Miller) []Miller

EquivalentMiller returns a array with all miller indices that are equivalent to the one passed (including the one passed)

func EquivalentMillerNoPermutations

func EquivalentMillerNoPermutations(miller Miller) []Miller

EquivalentMillerNoPermutations returns all equivalent miller indices without taking permutations into account

func (*Miller) At

func (m *Miller) At(i int) int

Return the Miller index as if it was an array. H is the zeroth element K is the first element and L is the last element

func (*Miller) Equal

func (m *Miller) Equal(m2 Miller) bool

Equal checks if two miller indices are equal

type ModeResult

type ModeResult struct {
	Energy     float64
	Amplitudes []float64
}

ModeResult is a type that is returned by the mode optimizer

type ModeSolver

type ModeSolver struct {
	IdealMix IdealMix

	// Miller is a list of miller corresponding to each mode
	Miller []Miller

	// ReciprocalCell is a type that represents the reciprocal lattice
	ReciprocalCell ReciprocalCell
}

ModeSolver directly solves the phase field equations by expanding the density field into modes. The modes are assumed to correspond to peaks in the free energy spectrum

func (*ModeSolver) MatchElasticProp

func (ms *ModeSolver) MatchElasticProp(properties map[string]float64) ElasticPropResult

MatchElasticProp calculates a set of prefactors associated with each mode peak such that it matches the passed elastic tensor. The expressions are obtained as follows are obtained by taking second derivatives with respect to the strain tensor. From the n^2 term in the ideal mixture term and the excess energy we obtain the following relation for the contribution to the the total energy F_q = 0.5*beta_q*A_q*(1 - (1 - dk_q^2/2(w_q))) where V_cell is the volume of the unit cell, q is a multiindex representing a hkl tuple. beta_q is the number of equivalent planes, A_eq is the amplitude associated with the mode. Finally, the gaussian peak as been expanded around the maximum to leading order in dk_q, which is the change in mode location due to the strain. w_q is width of the peak. In the following we introduce a set of factors h_q^2 = 0.5*beta_q*A_q/w_q. The contribution to the free energy from mode q is therefore given by F_q = 0.5*h_q^2*dk^2 The change in reciprocal lattice originating from a small strain is to first order dC = -C*e, where e is the strain tensor and C is the original reciprocal lattice A given hkl vector is given by dk_q = C*m_q, where m_q is a vector of miller indices. Further, the length of the dk_q square is given by dk_q^Tdk_q = m^T*e^T*C^T*C*e*m Differentiation twice with respect to an element in the strain tensor (let's say st and uv) we get that C_{stuv} = -h_q*m_t*Q_su*m_v, where Q = C^TC has been introduced. To obtain the total free energy, we sum over all modes q. This leaves, a linear system of equations to be solved. It is possible to fit the following properties 1. Bulk - bulk modulus in 3D 2. shear - shear modulus in 3D 3. area - area modulus (the equivalent of bulk modulus, but in 2D) 4. xyshear - shear modulus in 2D (e.g. shear in xy plane)

func (*ModeSolver) ModeDensity

func (ms *ModeSolver) ModeDensity(mode int, scaledPosition []float64) float64

ModeDensity returns the contribution to the total density from the mode being passed. The position should be given in scaled coordinates. The contribution to the total density from onde mode is given by sum_{hkl} cos(g_{hkl}*r), where the sum runs over all equivalent miller indices. r is the position vector.

func (*ModeSolver) PeakWidths

func (ms *ModeSolver) PeakWidths(target map[string]float64, modeAmp []float64) PeakWidthResult

PeakWidths returns the width of the different peaks in the correlation function. The widths are obtained by matching elastic properties specified in target.

func (*ModeSolver) Solve

func (ms *ModeSolver) Solve(initGuess InitialGuessExplorer) ModeResult

Solve returns the coefficients that minimizes the free energy. initGuess provised an explorer such that the method can try many different starting positions, and then return the best. If nil, the HyperOctantSearcher will be used.

func (*ModeSolver) UnitcellIntegral

func (ms *ModeSolver) UnitcellIntegral(powers []int, order int) float64

UnitcellIntegral integrates powers of mode contributions over the unitcell. Powers is a an array of the powers of each term in the same order as the modes are listed in the Miller attribute. The order of the Gauss-Quadrature rule used internally is passed as order

Example: If the density consists of three modes, let's say [[100], [111], [200]] denotet n_{100}, n_{111} and n_{200}, respectively. If power = [1, 2, 3] this corresponds to the integral

     **
1   *

----- * dV n_{100}^1 * n_{111}^2 * n_{200}^3

V   *
  **unit cell

where V is the volume of the unit cell

type Peak

type Peak struct {
	PlaneDensity float64
	Location     float64
	Width        float64
	NumPlanes    int
}

Peak represent one peak in the reciprocal space pair correlation function

func SquareLattice2D

func SquareLattice2D(width float64, a float64) []Peak

SquareLattice2D construct the two peaks with the lowest frequency peaks for the square lattice in 2D. The width of the two peaks is given as an array and the lattice parameter is given via a. The unit of both width and a is pixels.

func TriangularLattice2D

func TriangularLattice2D(width float64, a float64) []Peak

TriangularLattice2D returns the peaks nessecary to describe a triangular lattice in 2D

type PeakWidthResult

type PeakWidthResult struct {
	Widths []float64
	Fit    map[string]float64
}

PeakWidthResult a type that contains the widths of the correlation function peaks as well as the fitted elastic properties resulting from the fit

type ReciprocalCell

type ReciprocalCell struct {
	CellVec *mat.Dense
}

ReciprocalCell is a type used to represent the reciprocal lattice. In underlying CellVec matrix, each column represents a cell vector. The easiest way to initialize this type is via the Reciprocal method of the Cell type.

func (*ReciprocalCell) CellChange

func (rc *ReciprocalCell) CellChange(realSpaceChange *mat.Dense) *mat.Dense

CellChange returns the change in the reciprocal lattice resulting from a given change in the real space lattice. It is assumed that the change is small and the function relies on a first order series expansion of the inverse real space cell

func (*ReciprocalCell) ChangeHKLVector

func (rc *ReciprocalCell) ChangeHKLVector(miller Miller, realSpaceChange *mat.Dense) []float64

ChangeHKLVector returns the change in the HKL vector originating from a change in the real space lattice

func (*ReciprocalCell) HKLVector

func (rc *ReciprocalCell) HKLVector(miller Miller) []float64

HKLVector returns a vector correslonding to the passed miller indices

type ReciprocalSpacePairCorrelation

type ReciprocalSpacePairCorrelation struct {
	EffTemp float64
	Peaks   []Peak
}

ReciprocalSpacePairCorrelation implements the type of correlation function presented by Greenwood et al.

Greenwood, M., Provatas, N. and Rottler, J., 2010. Free energy functionals for efficient phase field crystal modeling of structural phase transformations. Physical review letters, 105(4), p.045702.

func (ReciprocalSpacePairCorrelation) Eval

Eval evaluates the pair correlation function

type SinglePointExplorer

type SinglePointExplorer struct {
	X0 []float64
	// contains filtered or unexported fields
}

SinglePointExplorer explores single initial guess

func (*SinglePointExplorer) Next

func (spe *SinglePointExplorer) Next() []float64

Next returns X0 the first time it is called. Subsequent calls will return nil

func (*SinglePointExplorer) OnMinimizationFinished

func (spe *SinglePointExplorer) OnMinimizationFinished(res *optimize.Result)

OnMinimizationFinished does nothing (included to satisfy the InitialGuessExplorer interface)

type UnitCell

type UnitCell struct {
	// Cell represents where each column is a cell vector
	Cell Cell

	// Basis represents the positions inside the unit cell.
	// It is assumed that the basis is given in scaled coordinates.
	// Cartesian coordinates can thus be obtained by C = Cell.dot(Basis)
	Basis *mat.Dense
}

UnitCell is a type that represents a unit cell of a crystal structure

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL