pyphasefield.Engines package — pyphasefield documentation

# pyphasefield.Engines package

## Submodules

## pyphasefield.Engines.AnisoDorrGPU module

class pyphasefield.Engines.AnisoDorrGPU.AnisoDorrGPU(**kwargs)

  Bases: `Simulation`

  init_fields()

    Initializes the Field class instances for a given simulation. Deprecated, use the initialize_engine pathway instead!

    Notes

    Exclusively used by the subclass, base Simulation class does not initialize fields! This and initialize_fields_and_imported_data are both inherited by the subclass, with the second requiring

    > calling super.initialize_fields_and_imported_data()

    This function is meant to initialize the number (and potentially contents) of the field The second is meant for actions that must be taken after everything else is initialized (setting values in the boundary

    > condition array, as an example)

  init_tdb_params()

    Initializes the .tdb file, and associated codegen functions to compute the thermodynamics

    Notes

    The function will load from a given TDBContainer first. Only if one isn’t given, will it try and load from the tdb_path. Order of phases and compositions is always alphabetical. Can be overridden (call super.init_tdb_params() first!) to define model-specific TDB functionality

  just_before_simulating()
  simulation_loop()

    This function will run once every time step. Override this in the subclass to put simulation code here!

pyphasefield.Engines.AnisoDorrGPU.AnisoDorr_helper_kernel(fields, T, transfer, rng_states)

pyphasefield.Engines.AnisoDorrGPU.AnisoDorr_kernel(fields, T, transfer, fields_out, rng_states)

pyphasefield.Engines.AnisoDorrGPU.divagradb(a, axp, axm, ayp, aym, b, bxp, bxm, byp, bym, idx)

pyphasefield.Engines.AnisoDorrGPU.engine_AnisoDorrGPU(sim)

pyphasefield.Engines.AnisoDorrGPU.f_ori_term(D_q, D_q_xp, D_q_xm, D_q_yp, D_q_ym, mgq_xp, mgq_xm, mgq_yp, mgq_ym, q, q_xp, q_xm, q_yp, q_ym, idx)

pyphasefield.Engines.AnisoDorrGPU.get_thermodynamics(ufunc, array)

pyphasefield.Engines.AnisoDorrGPU.grad2(a, axp, axm, ayp, aym, idx)

pyphasefield.Engines.AnisoDorrGPU.init_AnisoDorrGPU(sim, dim=[200, 200], sim_type='seed', number_of_seeds=1, tdb_path='Ni-Cu_Ideal.tdb', temperature_type='isothermal', initial_temperature=1574, temperature_gradient=0, cooling_rate=0, temperature_file_path='T.xdmf', initial_concentration_array=[0.40831], cell_spacing=4.6e-06, d_ratio=1.0638297872340425, solver='explicit', nbc=['periodic', 'periodic'], cuda_blocks=(16, 16), cuda_threads_per_block=(256, 1))

pyphasefield.Engines.AnisoDorrGPU.make_seed(phi, q1, q4, x, y, angle, seed_radius)

## pyphasefield.Engines.CahnAllen module

class pyphasefield.Engines.CahnAllen.CahnAllen(**kwargs)

  Bases: `Simulation`

  init_fields()

    Initializes the Field class instances for a given simulation. Deprecated, use the initialize_engine pathway instead!

    Notes

    Exclusively used by the subclass, base Simulation class does not initialize fields! This and initialize_fields_and_imported_data are both inherited by the subclass, with the second requiring

    > calling super.initialize_fields_and_imported_data()

    This function is meant to initialize the number (and potentially contents) of the field The second is meant for actions that must be taken after everything else is initialized (setting values in the boundary

    > condition array, as an example)

  just_before_simulating()
  simulation_loop()

    This function will run once every time step. Override this in the subclass to put simulation code here!

pyphasefield.Engines.CahnAllen.engine_CahnAllenCrankNicolson2D_ADI(sim)

pyphasefield.Engines.CahnAllen.engine_CahnAllenExplicit(sim)

pyphasefield.Engines.CahnAllen.engine_CahnAllenIMEX1D(sim)

pyphasefield.Engines.CahnAllen.engine_CahnAllenImplicit1D(sim)

pyphasefield.Engines.CahnAllen.engine_CahnAllenImplicit1D_GMRES(sim)

pyphasefield.Engines.CahnAllen.engine_CahnAllenImplicit2D_ADI(sim)

pyphasefield.Engines.CahnAllen.engine_CahnAllenImplicit2D_ADI_GMRES(sim)

pyphasefield.Engines.CahnAllen.engine_CahnAllenImplicit2D_GMRES(sim)

pyphasefield.Engines.CahnAllen.engine_CahnAllenImplicit3D_ADI(sim)

pyphasefield.Engines.CahnAllen.functional_CahnAllen()

pyphasefield.Engines.CahnAllen.implicit_matrix_1d(xsize, centervalue, neighborvalue)

  Creates a matrix for the solution of 1d implicit or crank nickolson discretizations

  Because the exact format changes between implicit and C-N, and this method is reused in 2D and 3D cases, centervalue and neighbor value must be explicitly specified

  Matrix shows periodic boundary conditions!

  Parameters:

    - xsize (int) – Size of one dimension of the square NxN implicit matrix, equal to the number of elements in the 1D phase field model

    - centervalue (float) – Value inserted into the central diagonal of the implicit matrix.

    - neighborvalue (float) – Value inserted into the two just-off-center diagonals of the implicit matrix.

  Return type:

    2D NumPy ndarray representation of implicit matrix, with shape [xsize*ysize, xsize*ysize]

  Notes

  Consider the implicit 1D diffusion matrix with generic discretization term equal to the following:

  $$(c_{x}^{t+1} - c_{x}^{t})/dt = (D/(Delta x^2))(c_{x+1}^{t+1} + c_{x-1}^{t+1} - 2c_{x}^{t+1})$$

  This can be rearranged as to express c_{x}^{t} as a function of c_{x}^{t+1}, c_{x-1}^{t+1}, and c_{x+1}^{t+1} (Also, let a = D*dt/(Delta x^2) ):

  $$c_{x}^{t} = (-a)c_{x+1}^{t+1} + (-a)c_{x-1}^{t+1} + (1+2a)c_{x}^{t+1}$$

  The implicit matrix composed of these terms is defined as follows: The central diagonal (centervalue) equals the coefficient of c_{x}^{t+1}: 1+2a, or 1+2*D*Delta t/(Delta x^2) The neighboring diagonals to the center (neighborvalue) equals the coefficient of c_{x-1}^{t+1} or c_{x+1}^{t+1}: -a, or -D*Delta t/(Delta x^2)

pyphasefield.Engines.CahnAllen.implicit_matrix_2d(ysize, xsize, centervalue, neighborvalue)

  Creates a matrix for the solution of 2d implicit or crank nickolson discretizations

  Because the exact format changes between implicit and C-N, and this method is reused in 3D cases, centervalue and neighbor value must be explicitly specified

  Parameter order is specified as ysize then xsize, because the dimensional order of 2d arrays is [y, x]

  Matrix shows periodic boundary conditions!

  Parameters:

    - ysize (int) – Equal to the number of elements along the y-axis in the 2D phase field model xsize*ysize is equal to the length of one dimension of the square NxN implicit matrix

    - xsize (int) – Equal to the number of elements along the x-axis in the 2D phase field model xsize*ysize is equal to the length of one dimension of the square NxN implicit matrix

    - centervalue (float) – Value inserted into the central diagonal of the implicit matrix.

    - neighborvalue (float) – Value inserted into the four just-off-center diagonals of the 2D implicit matrix.

  Return type:

    2D NumPy ndarray representation of implicit matrix, with shape [xsize*ysize, xsize*ysize]

  Notes

  Consider the implicit 2D diffusion matrix with generic discretization term equal to the following:

  $$(c_{x, y}^{t+1} - c_{x, y}^{t})/dt = (D/(Delta x^2))(c_{x+1, y}^{t+1} + c_{x-1, y}^{t+1} + c_{x, y+1}^{t+1} + c_{x, y-1}^{t+1} - 4c_{x, y}^{t+1})$$

  This can be rearranged as to express c_{x, y}^{t} as a function of c_{x, y}^{t+1}, c_{x-1, y}^{t+1}, c_{x+1, y}^{t+1}, c_{x, y-1}^{t+1}, and c_{x, y+1}^{t+1} (Also, let a = D*dt/(Delta x^2) ):

  $$c_{x, y}^{t} = (-a)c_{x+1, y}^{t+1} + (-a)c_{x-1, y}^{t+1} + (-a)c_{x, y+1}^{t+1} + (-a)c_{x, y-1}^{t+1} + (1+4a)c_{x, y}^{t+1}$$

  The implicit matrix composed of these terms is defined as follows: The central diagonal (centervalue) equals the coefficient of c_{x, y}^{t+1}: 1+4a, or 1+4*D*Delta t/(Delta x^2) The neighboring diagonals to the center (neighborvalue) equals the coefficient of c_{x-1, y}^{t+1} (or other similar terms): -a, or -D*Delta t/(Delta x^2)

  Note that two of the “neighboring” diagonals are separated by a significant number of cells in the matrix, however they are still considered to be “neighbors” conceptually

## pyphasefield.Engines.CahnHilliard module

class pyphasefield.Engines.CahnHilliard.CahnHilliard(**kwargs)

  Bases: `Simulation`

  init_fields()

    Initializes the Field class instances for a given simulation. Deprecated, use the initialize_engine pathway instead!

    Notes

    Exclusively used by the subclass, base Simulation class does not initialize fields! This and initialize_fields_and_imported_data are both inherited by the subclass, with the second requiring

    > calling super.initialize_fields_and_imported_data()

    This function is meant to initialize the number (and potentially contents) of the field The second is meant for actions that must be taken after everything else is initialized (setting values in the boundary

    > condition array, as an example)

  just_before_simulating()
  simulation_loop()

    This function will run once every time step. Override this in the subclass to put simulation code here!

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardCrankNicolson1D(sim)

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardCrankNicolson1D_GMRES(sim)

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardCrankNicolson2D_ADI(sim)

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardExplicit(sim)

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardIMEX1D(sim)

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardImplicit1D(sim)

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardImplicit1D_GMRES(sim)

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardImplicit2D_ADI(sim)

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardImplicit2D_ADI_GMRES(sim)

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardImplicit2D_GMRES(sim)

pyphasefield.Engines.CahnHilliard.engine_CahnHilliardImplicit3D_ADI(sim)

pyphasefield.Engines.CahnHilliard.functional_CahnHilliard()

pyphasefield.Engines.CahnHilliard.implicit_matrix_1d(xsize, centervalue, neighborvalue, farneighborvalue)

  Creates a matrix for the solution of 1d implicit or crank nickolson discretizations

  Because the exact format changes between implicit and C-N, and this method is reused in 2D and 3D cases, centervalue and neighbor value must be explicitly specified

  Matrix shows periodic boundary conditions!

  Parameters:

    - xsize (int) – Size of one dimension of the square NxN implicit matrix, equal to the number of elements in the 1D phase field model

    - centervalue (float) – Value inserted into the central diagonal of the implicit matrix.

    - neighborvalue (float) – Value inserted into the two just-off-center diagonals of the implicit matrix.

  Return type:

    2D NumPy ndarray representation of implicit matrix, with shape [xsize, xsize]

  Notes

  Consider the implicit 1D diffusion matrix with generic discretization term equal to the following:

  $$(c_{x}^{t+1} - c_{x}^{t})/dt = (D/(Delta x^2))(c_{x+1}^{t+1} + c_{x-1}^{t+1} - 2c_{x}^{t+1})$$

  This can be rearranged as to express c_{x}^{t} as a function of c_{x}^{t+1}, c_{x-1}^{t+1}, and c_{x+1}^{t+1} (Also, let a = D*dt/(Delta x^2) ):

  $$c_{x}^{t} = (-a)c_{x+1}^{t+1} + (-a)c_{x-1}^{t+1} + (1+2a)c_{x}^{t+1}$$

  The implicit matrix composed of these terms is defined as follows: The central diagonal (centervalue) equals the coefficient of c_{x}^{t+1}: 1+2a, or 1+2*D*Delta t/(Delta x^2) The neighboring diagonals to the center (neighborvalue) equals the coefficient of c_{x-1}^{t+1} or c_{x+1}^{t+1}: -a, or -D*Delta t/(Delta x^2)

pyphasefield.Engines.CahnHilliard.implicit_matrix_2d(ysize, xsize, centervalue, neighborvalue, farneighborvalue)

  Creates a matrix for the solution of 2d implicit or crank nickolson discretizations

  Because the exact format changes between implicit and C-N, and this method is reused in 3D cases, centervalue and neighbor value must be explicitly specified

  Parameter order is specified as ysize then xsize, because the dimensional order of 2d arrays is [y, x]

  Matrix shows periodic boundary conditions!

  Parameters:

    - ysize (int) – Equal to the number of elements along the y-axis in the 2D phase field model xsize*ysize is equal to the length of one dimension of the square NxN implicit matrix

    - xsize (int) – Equal to the number of elements along the x-axis in the 2D phase field model xsize*ysize is equal to the length of one dimension of the square NxN implicit matrix

    - centervalue (float) – Value inserted into the central diagonal of the implicit matrix.

    - neighborvalue (float) – Value inserted into the four just-off-center diagonals of the 2D implicit matrix.

  Return type:

    2D NumPy ndarray representation of implicit matrix, with shape [xsize*ysize, xsize*ysize]

  Notes

  Consider the implicit 2D diffusion matrix with generic discretization term equal to the following:

  $$(c_{x, y}^{t+1} - c_{x, y}^{t})/dt = (D/(Delta x^2))(c_{x+1, y}^{t+1} + c_{x-1, y}^{t+1} + c_{x, y+1}^{t+1} + c_{x, y-1}^{t+1} - 4c_{x, y}^{t+1})$$

  This can be rearranged as to express c_{x, y}^{t} as a function of c_{x, y}^{t+1}, c_{x-1, y}^{t+1}, c_{x+1, y}^{t+1}, c_{x, y-1}^{t+1}, and c_{x, y+1}^{t+1} (Also, let a = D*dt/(Delta x^2) ):

  $$c_{x, y}^{t} = (-a)c_{x+1, y}^{t+1} + (-a)c_{x-1, y}^{t+1} + (-a)c_{x, y+1}^{t+1} + (-a)c_{x, y-1}^{t+1} + (1+4a)c_{x, y}^{t+1}$$

  The implicit matrix composed of these terms is defined as follows: The central diagonal (centervalue) equals the coefficient of c_{x, y}^{t+1}: 1+4a, or 1+4*D*Delta t/(Delta x^2) The neighboring diagonals to the center (neighborvalue) equals the coefficient of c_{x-1, y}^{t+1} (or other similar terms): -a, or -D*Delta t/(Delta x^2)

  Note that two of the “neighboring” diagonals are separated by a significant number of cells in the matrix, however they are still considered to be “neighbors” conceptually

## pyphasefield.Engines.Diffusion module

class pyphasefield.Engines.Diffusion.Diffusion(**kwargs)

  Bases: `Simulation`

  init_fields()

    Initializes the Field class instances for a given simulation. Deprecated, use the initialize_engine pathway instead!

    Notes

    Exclusively used by the subclass, base Simulation class does not initialize fields! This and initialize_fields_and_imported_data are both inherited by the subclass, with the second requiring

    > calling super.initialize_fields_and_imported_data()

    This function is meant to initialize the number (and potentially contents) of the field The second is meant for actions that must be taken after everything else is initialized (setting values in the boundary

    > condition array, as an example)

  just_before_simulating()
  simulation_loop()

    This function will run once every time step. Override this in the subclass to put simulation code here!

pyphasefield.Engines.Diffusion.diffusion_kernel_1D(fields, fields_out, D, dx, dt)

pyphasefield.Engines.Diffusion.diffusion_kernel_2D(fields, fields_out, D, dx, dt)

pyphasefield.Engines.Diffusion.diffusion_kernel_3D(fields, fields_out, D, dx, dt)

pyphasefield.Engines.Diffusion.diffusion_matrix_1d(xsize, centervalue, neighborvalue)

  Creates a matrix for the solution of 1d implicit or crank nickolson discretizations

  Because the exact format changes between implicit and C-N, and this method is reused in 2D and 3D cases, centervalue and neighbor value must be explicitly specified

  Matrix shows periodic boundary conditions!

  Parameters:

    - xsize (int) – Size of one dimension of the square NxN implicit matrix, equal to the number of elements in the 1D phase field model

    - centervalue (float) – Value inserted into the central diagonal of the implicit matrix.

    - neighborvalue (float) – Value inserted into the two just-off-center diagonals of the implicit matrix.

  Return type:

    2D NumPy ndarray representation of implicit matrix, with shape [xsize, xsize]

  Notes

  Consider the implicit 1D diffusion matrix with generic discretization term equal to the following:

  $$(c_{x}^{t+1} - c_{x}^{t})/dt = (D/(Delta x^2))(c_{x+1}^{t+1} + c_{x-1}^{t+1} - 2c_{x}^{t+1})$$

  This can be rearranged as to express c_{x}^{t} as a function of c_{x}^{t+1}, c_{x-1}^{t+1}, and c_{x+1}^{t+1} (Also, let a = D*dt/(Delta x^2) ):

  $$c_{x}^{t} = (-a)c_{x+1}^{t+1} + (-a)c_{x-1}^{t+1} + (1+2a)c_{x}^{t+1}$$

  The implicit matrix composed of these terms is defined as follows: The central diagonal (centervalue) equals the coefficient of c_{x}^{t+1}: 1+2a, or 1+2*D*Delta t/(Delta x^2) The neighboring diagonals to the center (neighborvalue) equals the coefficient of c_{x-1}^{t+1} or c_{x+1}^{t+1}: -a, or -D*Delta t/(Delta x^2)

pyphasefield.Engines.Diffusion.diffusion_matrix_2d(ysize, xsize, centervalue, neighborvalue)

  Creates a matrix for the solution of 2d implicit or crank nickolson discretizations

  Because the exact format changes between implicit and C-N, and this method is reused in 3D cases, centervalue and neighbor value must be explicitly specified

  Parameter order is specified as ysize then xsize, because the dimensional order of 2d arrays is [y, x]

  Matrix shows periodic boundary conditions!

  Parameters:

    - ysize (int) – Equal to the number of elements along the y-axis in the 2D phase field model xsize*ysize is equal to the length of one dimension of the square NxN implicit matrix

    - xsize (int) – Equal to the number of elements along the x-axis in the 2D phase field model xsize*ysize is equal to the length of one dimension of the square NxN implicit matrix

    - centervalue (float) – Value inserted into the central diagonal of the implicit matrix.

    - neighborvalue (float) – Value inserted into the four just-off-center diagonals of the 2D implicit matrix.

  Return type:

    2D NumPy ndarray representation of implicit matrix, with shape [xsize*ysize, xsize*ysize]

  Notes

  Consider the implicit 2D diffusion matrix with generic discretization term equal to the following:

  $$(c_{x, y}^{t+1} - c_{x, y}^{t})/dt = (D/(Delta x^2))(c_{x+1, y}^{t+1} + c_{x-1, y}^{t+1} + c_{x, y+1}^{t+1} + c_{x, y-1}^{t+1} - 4c_{x, y}^{t+1})$$

  This can be rearranged as to express c_{x, y}^{t} as a function of c_{x, y}^{t+1}, c_{x-1, y}^{t+1}, c_{x+1, y}^{t+1}, c_{x, y-1}^{t+1}, and c_{x, y+1}^{t+1} (Also, let a = D*dt/(Delta x^2) ):

  $$c_{x, y}^{t} = (-a)c_{x+1, y}^{t+1} + (-a)c_{x-1, y}^{t+1} + (-a)c_{x, y+1}^{t+1} + (-a)c_{x, y-1}^{t+1} + (1+4a)c_{x, y}^{t+1}$$

  The implicit matrix composed of these terms is defined as follows: The central diagonal (centervalue) equals the coefficient of c_{x, y}^{t+1}: 1+4a, or 1+4*D*Delta t/(Delta x^2) The neighboring diagonals to the center (neighborvalue) equals the coefficient of c_{x-1, y}^{t+1} (or other similar terms): -a, or -D*Delta t/(Delta x^2)

  Note that two of the “neighboring” diagonals are separated by a significant number of cells in the matrix, however they are still considered to be “neighbors” conceptually

pyphasefield.Engines.Diffusion.diffusion_matrix_3d(zsize, ysize, xsize, centervalue, neighborvalue)

  Creates a matrix for the solution of 3d implicit or crank nickolson discretizations

  Because the exact format changes between implicit and C-N, centervalue and neighbor value must be explicitly specified

  Parameter order is specified as zsize then ysize then xsize, because the dimensional order of 3d arrays is [z, y, x]

  Matrix shows periodic boundary conditions!

  Parameters:

    - zsize (int) – Equal to the number of elements along the z-axis in the 3D phase field model xsize*ysize*zsize is equal to the length of one dimension of the square NxN implicit matrix

    - ysize (int) – Equal to the number of elements along the y-axis in the 3D phase field model xsize*ysize*zsize is equal to the length of one dimension of the square NxN implicit matrix

    - xsize (int) – Equal to the number of elements along the x-axis in the 3D phase field model xsize*ysize*zsize is equal to the length of one dimension of the square NxN implicit matrix

    - centervalue (float) – Value inserted into the central diagonal of the implicit matrix.

    - neighborvalue (float) – Value inserted into the six just-off-center diagonals of the 3D implicit matrix.

  Return type:

    2D NumPy ndarray representation of implicit matrix, with shape [xsize*ysize*zsize, xsize*ysize*zsize]

  Warning

  Non-ADI, non-GMRES 3d implicit or C-N solvers will be extremely slow unless they are very small!

  Notes

  Consider the implicit 3D diffusion matrix with generic discretization term equal to the following:

  $$(c_{x, y, z}^{t+1} - c_{x, y, z}^{t})/dt = (D/(Delta x^2))(c_{x+1, y, z}^{t+1} + c_{x-1, y, z}^{t+1} + c_{x, y+1, z}^{t+1} + c_{x, y-1, z}^{t+1} + c_{x, y, z+1}^{t+1} + c_{x, y, z-1}^{t+1} - 6c_{x, y, z}^{t+1})$$

  This can be rearranged as to express c_{x, y, z}^{t} as a function of c_{x, y, z}^{t+1}, c_{x-1, y, z}^{t+1}, c_{x+1, y, z}^{t+1}, c_{x, y-1, z}^{t+1}, and c_{x, y+1, z}^{t+1} (Also, let a = D*dt/(Delta x^2) ):

  $$c_{x, y, z}^{t} = (-a)c_{x+1, y, z}^{t+1} + (-a)c_{x-1, y, z}^{t+1} + (-a)c_{x, y+1, z}^{t+1} + (-a)c_{x, y-1, z}^{t+1} + (-a)c_{x, y, z+1}^{t+1} + (-a)c_{x, y, z-1}^{t+1} + (1+6a)c_{x, y, z}^{t+1}$$

  The implicit matrix composed of these terms is defined as follows: The central diagonal (centervalue) equals the coefficient of c_{x, y, z}^{t+1}: 1+6a, or 1+6*D*Delta t/(Delta x^2) The neighboring diagonals to the center (neighborvalue) equals the coefficient of c_{x-1, y, z}^{t+1} (or other similar terms): -a, or -D*Delta t/(Delta x^2)

  Note that four of the “neighboring” diagonals are separated by a significant number of cells in the matrix, however they are still considered to be “neighbors” conceptually

pyphasefield.Engines.Diffusion.engine_CrankNicolsonDiffusion1D(sim)

  Computes the discretization of the diffusion equation using the Crank-Nicolson method in 1D

  Uses the function np.linalg.solve(A, b) to solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_CrankNicolsonDiffusion1D_GMRES(sim)

  Computes the discretization of the diffusion equation using the Crank-Nicolson method in 1D

  Uses the function scipy.sparse.linalg.gmres(A, b) to quickly but approximately solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_CrankNicolsonDiffusion2D(sim)

  Computes the discretization of the diffusion equation using the Crank-Nicolson method in 2D

  Uses the function np.linalg.solve(A, b) to solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_CrankNicolsonDiffusion2D_ADI(sim)

  Computes the discretization of the diffusion equation using the Alternating Direction Implicit method for 2D, extended to use the Crank-Nicolson scheme

  Uses the Peaceman-Rachford discretization (explicit x + implicit y, then explicit y + implicit x)

  Uses the function np.linalg.inv(A) to compute A^-1 directly, since it is reused several times

pyphasefield.Engines.Diffusion.engine_CrankNicolsonDiffusion2D_ADI_GMRES(sim)

  Computes the discretization of the diffusion equation using the Alternating Direction Implicit method for 2D, extended to use the Crank-Nicolson scheme

  Uses the Peaceman-Rachford discretization (explicit x + implicit y, then explicit y + implicit x)

  Uses the function scipy.sparse.linalg.gmres(A, b) to quickly but approximately solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_CrankNicolsonDiffusion2D_GMRES(sim)

  Computes the discretization of the diffusion equation using the Crank-Nicolson method in 2D

  Uses the function scipy.sparse.linalg.gmres(A, b) to quickly but approximately solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_CrankNicolsonDiffusion3D(sim)

  Computes the discretization of the diffusion equation using the Crank-Nicolson method in 3D

  Uses the function np.linalg.solve(A, b) to solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_CrankNicolsonDiffusion3D_ADI(sim)

  Computes the discretization of the diffusion equation using the Alternating Direction Implicit method for 3D, extended to use the Crank-Nicolson scheme

  Uses an extended Peaceman-Rachford discretization (explicit x + implicit y, then explicit y + implicit z, then explicit z + implicit x)

  Uses the function np.linalg.inv(A) to compute A^-1 directly, since it is reused several times

pyphasefield.Engines.Diffusion.engine_CrankNicolsonDiffusion3D_ADI_GMRES(sim)

  Computes the discretization of the diffusion equation using the Alternating Direction Implicit method for 3D, extended to use the Crank-Nicolson scheme

  Uses an extended Peaceman-Rachford discretization (explicit x + implicit y, then explicit y + implicit z, then explicit z + implicit x)

  Uses the function scipy.sparse.linalg.gmres(A, b) to quickly but approximately solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_CrankNicolsonDiffusion3D_GMRES(sim)

  Computes the discretization of the diffusion equation using the Crank-Nicolson method in 3D

  Uses the function scipy.sparse.linalg.gmres(A, b) to quickly but approximately solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_DiffusionGPU(sim)

pyphasefield.Engines.Diffusion.engine_ExplicitDiffusion(sim)

  Computes the discretization of the diffusion equation using a purely explicit scheme

  Valid for 1, 2, or 3D simulations

pyphasefield.Engines.Diffusion.engine_ImplicitDiffusion1D(sim)

  Computes the discretization of the diffusion equation using a purely implicit scheme in 1D

  Uses the function np.linalg.solve(A, b) to solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_ImplicitDiffusion1D_GMRES(sim)

  Computes the discretization of the diffusion equation using a purely implicit scheme in 1D

  Uses the function scipy.sparse.linalg.gmres(A, b) to quickly but approximately solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_ImplicitDiffusion2D(sim)

  Computes the discretization of the diffusion equation using a purely implicit scheme in 2D

  Uses the function np.linalg.solve(A, b) to solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_ImplicitDiffusion2D_ADI(sim)

  Computes the discretization of the diffusion equation using the Alternating Direction Implicit method for 2D

  Uses the function np.linalg.inv(A) to compute A^-1 directly, since it is reused several times

pyphasefield.Engines.Diffusion.engine_ImplicitDiffusion2D_ADI_GMRES(sim)

  Computes the discretization of the diffusion equation using the Alternating Direction Implicit method for 2D

  Uses the function scipy.sparse.linalg.gmres(A, b) to quickly but approximately solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_ImplicitDiffusion2D_GMRES(sim)

  Computes the discretization of the diffusion equation using a purely implicit scheme in 2D

  Uses the function scipy.sparse.linalg.gmres(A, b) to quickly but approximately solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_ImplicitDiffusion3D(sim)

  Computes the discretization of the diffusion equation using a purely implicit scheme in 3D

  Uses the function np.linalg.solve(A, b) to solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_ImplicitDiffusion3D_ADI(sim)

  Computes the discretization of the diffusion equation using the Alternating Direction Implicit method for 2D

  Uses the function np.linalg.inv(A) to compute A^-1 directly, since it is reused several times

pyphasefield.Engines.Diffusion.engine_ImplicitDiffusion3D_ADI_GMRES(sim)

  Computes the discretization of the diffusion equation using the Alternating Direction Implicit method for 2D

  Uses the function scipy.sparse.linalg.gmres(A, b) to quickly but approximately solve the equation Ax=b for the matrix A and vectors x and b

pyphasefield.Engines.Diffusion.engine_ImplicitDiffusion3D_GMRES(sim)

  Computes the discretization of the diffusion equation using a purely implicit scheme in 3D

  Uses the function scipy.sparse.linalg.gmres(A, b) to quickly but approximately solve the equation Ax=b for the matrix A and vectors x and b

## pyphasefield.Engines.DiffusionGPU module

## pyphasefield.Engines.NCGPU module

class pyphasefield.Engines.NCGPU.NCGPU(**kwargs)

  Bases: `Simulation`

  init_fields()

    Initializes the Field class instances for a given simulation. Deprecated, use the initialize_engine pathway instead!

    Notes

    Exclusively used by the subclass, base Simulation class does not initialize fields! This and initialize_fields_and_imported_data are both inherited by the subclass, with the second requiring

    > calling super.initialize_fields_and_imported_data()

    This function is meant to initialize the number (and potentially contents) of the field The second is meant for actions that must be taken after everything else is initialized (setting values in the boundary

    > condition array, as an example)

  init_tdb_params()

    Initializes the .tdb file, and associated codegen functions to compute the thermodynamics

    Notes

    The function will load from a given TDBContainer first. Only if one isn’t given, will it try and load from the tdb_path. Order of phases and compositions is always alphabetical. Can be overridden (call super.init_tdb_params() first!) to define model-specific TDB functionality

  just_before_simulating()
  simulation_loop()

    This function will run once every time step. Override this in the subclass to put simulation code here!

pyphasefield.Engines.NCGPU.NComponent_helper_kernel(fields, T, transfer, rng_states, ufunc_array, params, c_params)

pyphasefield.Engines.NCGPU.NComponent_kernel(fields, T, transfer, fields_out, rng_states, params, c_params)

pyphasefield.Engines.NCGPU.NComponent_noise_kernel(fields, T, transfer, rng_states, ufunc_array, params, c_params)

pyphasefield.Engines.NCGPU.divagradb(a, axp, axm, ayp, aym, b, bxp, bxm, byp, bym, idx)

pyphasefield.Engines.NCGPU.f_ori_term(D_q, D_q_xp, D_q_xm, D_q_yp, D_q_ym, mgq_xp, mgq_xm, mgq_yp, mgq_ym, q, q_xp, q_xm, q_yp, q_ym, idx)

pyphasefield.Engines.NCGPU.get_thermodynamics(ufunc, array)

pyphasefield.Engines.NCGPU.make_seed(phi, q1, q4, x, y, angle, seed_radius)

pyphasefield.Engines.NCGPU.npvalue(var, string, tdb)

  Returns a numpy float from the sympy expression gotten from pycalphad Reason: some numpy functions (i.e. sqrt) are incompatible with sympy floats!

## pyphasefield.Engines.NCGPU_new module

class pyphasefield.Engines.NCGPU_new.NCGPU_new(**kwargs)

  Bases: `Simulation`

  init_fields()

    Initializes the Field class instances for a given simulation. Deprecated, use the initialize_engine pathway instead!

    Notes

    Exclusively used by the subclass, base Simulation class does not initialize fields! This and initialize_fields_and_imported_data are both inherited by the subclass, with the second requiring

    > calling super.initialize_fields_and_imported_data()

    This function is meant to initialize the number (and potentially contents) of the field The second is meant for actions that must be taken after everything else is initialized (setting values in the boundary

    > condition array, as an example)

  init_tdb_params()

    Initializes the .tdb file, and associated codegen functions to compute the thermodynamics

    Notes

    The function will load from a given TDBContainer first. Only if one isn’t given, will it try and load from the tdb_path. Order of phases and compositions is always alphabetical. Can be overridden (call super.init_tdb_params() first!) to define model-specific TDB functionality

  just_before_simulating()
  save_simulation()

    Saves all fields in a .hdf5 in either the user-specified save path or a default path.

    Step number is saved in the file name. TODO: save data for simulation instance in header file

  simulation_loop()

    This function will run once every time step. Override this in the subclass to put simulation code here!

pyphasefield.Engines.NCGPU_new.NComponent_helper_kernel_2D(fields, T, transfer, rng_states, ufunc_array, params, c_params)

pyphasefield.Engines.NCGPU_new.NComponent_helper_kernel_3D(fields, T, transfer, rng_states, ufunc_array, params, c_params)

pyphasefield.Engines.NCGPU_new.NComponent_kernel_2D(fields, T, transfer, fields_out, rng_states, params, c_params)

pyphasefield.Engines.NCGPU_new.NComponent_kernel_3D(fields, T, transfer, fields_out, rng_states, params, c_params)

pyphasefield.Engines.NCGPU_new.NComponent_noise_kernel_2D(fields, T, transfer, rng_states, ufunc_array, params, c_params)

pyphasefield.Engines.NCGPU_new.NComponent_noise_kernel_3D(fields, T, transfer, rng_states, ufunc_array, params, c_params)

pyphasefield.Engines.NCGPU_new.NComponent_sp_kernel_2D(fields, T, spa_gpu, save_points, timestep)

pyphasefield.Engines.NCGPU_new.NComponent_sp_kernel_3D(fields, T, spa_gpu, save_points, timestep)

pyphasefield.Engines.NCGPU_new.divagradb(a, axp, axm, ayp, aym, b, bxp, bxm, byp, bym, idx)

pyphasefield.Engines.NCGPU_new.divagradb_3D(a, axp, axm, ayp, aym, azp, azm, b, bxp, bxm, byp, bym, bzp, bzm, idx)

pyphasefield.Engines.NCGPU_new.f_ori_term(D_q, D_q_xp, D_q_xm, D_q_yp, D_q_ym, mgq_xp, mgq_xm, mgq_yp, mgq_ym, q, q_xp, q_xm, q_yp, q_ym, idx)

pyphasefield.Engines.NCGPU_new.f_ori_term_3D(D_q, D_q_xp, D_q_xm, D_q_yp, D_q_ym, D_q_zp, D_q_zm, mgq_xp, mgq_xm, mgq_yp, mgq_ym, mgq_zp, mgq_zm, q, q_xp, q_xm, q_yp, q_ym, q_zp, q_zm, idx)

pyphasefield.Engines.NCGPU_new.get_thermodynamics(ufunc, array)

pyphasefield.Engines.NCGPU_new.npvalue(var, string, tdb)

  Returns a numpy float from the sympy expression gotten from pycalphad Reason: some numpy functions (i.e. sqrt) are incompatible with sympy floats!

## pyphasefield.Engines.NComponent module

pyphasefield.Engines.NComponent.add_nuclei(phi, q1, q4, p11, size)

pyphasefield.Engines.NComponent.compute_tdb_energy_nc(sim, temps, c, phase)

  Computes Gibbs Free Energy and its derivative*S* w.r.t. composition, for a given temperature field and list of composition fields Derivatives are computed by holding all other explicit composition variables constant c_i is increased, c_N is decreased (the implicitly-defined last composition variable which equals 1-sum(c_i) )

  Input parameters:
    - sim: the Simulation object. The method retrieves the TDB pycalphad object (sim._tdb) and the components used (sim._components)

        from this variable.

    - temps: the temperature array. Could also be retrieved as sim.temperature

    - c: the list of composition arrays. The format is a python list of numpy ndarrays

    - phase: the String which corresponds to a particular phase in the TDB file. E.g.: “FCC_A1” or “LIQUID”

  Returns GM (Molar Gibbs Free Energy) and dGdci (list of derivatives of GM, w.r.t. c_i)

pyphasefield.Engines.NComponent.compute_tdb_energy_nc_rev(sim, temps, c, phase)

  Computes Gibbs Free Energy and its derivative*S* w.r.t. composition, for a given temperature field and list of composition fields Derivatives are computed by holding all other explicit composition variables constant c_i is increased, c_N is decreased (the implicitly-defined last composition variable which equals 1-sum(c_i) )

  Input parameters:
    - sim: the Simulation object. The method retrieves the TDB pycalphad object (sim._tdb) and the components used (sim._components)

        from this variable.

    - temps: the temperature array. Could also be retrieved as sim.temperature

    - c: the list of composition arrays. The format is a python list of numpy ndarrays

    - phase: the String which corresponds to a particular phase in the TDB file. E.g.: “FCC_A1” or “LIQUID”

  Returns GM (Molar Gibbs Free Energy) and dGdci (list of derivatives of GM, w.r.t. c_i)

pyphasefield.Engines.NComponent.discretization_NComponent()

pyphasefield.Engines.NComponent.divagradb(a, b, dx, dim)

pyphasefield.Engines.NComponent.engine_NComponent_ADI(sim)

pyphasefield.Engines.NComponent.engine_NComponent_AnisoM(sim)

pyphasefield.Engines.NComponent.engine_NComponent_Explicit(sim)

pyphasefield.Engines.NComponent.engine_NComponent_FrozenOrientation(sim)

pyphasefield.Engines.NComponent.engine_params_NComponent(sim)

pyphasefield.Engines.NComponent.find_Pn(T_M, T, Q, dt)

pyphasefield.Engines.NComponent.functional_NComponent()

pyphasefield.Engines.NComponent.gaq(gql, gqr, rgqsl, rgqsr, dqc, dx, dim)

pyphasefield.Engines.NComponent.grad2(phi, dx, dim)

pyphasefield.Engines.NComponent.grad_c(phi, dx, dim)

pyphasefield.Engines.NComponent.grad_l(phi, dx, dim)

pyphasefield.Engines.NComponent.grad_r(phi, dx, dim)

pyphasefield.Engines.NComponent.init_NComponent(sim, dim=[200, 200], sim_type='seed', number_of_seeds=1, tdb_path='Ni-Cu_Ideal.tdb', tdb_phases=['FCC_A1', 'LIQUID'], tdb_components=None, temperature_type='isothermal', initial_temperature=1574, temperature_gradient=0, cooling_rate=0, temperature_file_path='T.xdmf', initial_concentration_array=[0.40831], cell_spacing=4.6e-06, d_ratio=1.0638297872340425, solver='explicit', nbc=['periodic', 'periodic'])

pyphasefield.Engines.NComponent.init_tdb_parameters(sim)

  Modifies the global vars which are parameters for the engine. Called from the function utils.preinitialize Returns True if variables are loaded successfully, False if certain variables dont exist in the TDB If false, preinitialize will print an error saying the TDB doesn’t have enough info to run the sim

pyphasefield.Engines.NComponent.make_seed(phi, q1, q4, x, y, angle, seed_radius)

pyphasefield.Engines.NComponent.npvalue(var, string, tdb)

  Returns a numpy float from the sympy expression gotten from pycalphad Reason: some numpy functions (i.e. sqrt) are incompatible with sympy floats!

pyphasefield.Engines.NComponent.quaternion_implicit_matrix(ac, ap, an, dc, dp, dn, adc, adp, adn)

  Makes a quaternion implicit matrix a = q1 central rows, d = q4 central rows, ad = off-center coupling rows c = central value, p = positive neighbor, n = negative neighbor

pyphasefield.Engines.NComponent.quaternion_implicit_method(q1, q4, alpha, HTp2, epsilon2, dx, beta)

  Makes a quaternion implicit matrix, then applies it to q1 and q4 using the Peaceman-Rachford method

  q1 and q4 are a and d

  alpha is one of the primary parameters of the matrix: M*dt/(2dx^2)

  D is the pseudo-diffusivity of the quaternion field, ${2HTp/ | nabla q | }$, recomputed after the half step. HTp2 is given numerator

  beta is the cutoff parameter for gradq, values below beta will be clipped to equal beta

  returns q1 and q4

pyphasefield.Engines.NComponent.renormalize(q1, q4)

## pyphasefield.Engines.Template module

class pyphasefield.Engines.Template.Template(**kwargs)

  Bases: `Simulation`

  init_fields()

    Initializes the Field class instances for a given simulation. Deprecated, use the initialize_engine pathway instead!

    Notes

    Exclusively used by the subclass, base Simulation class does not initialize fields! This and initialize_fields_and_imported_data are both inherited by the subclass, with the second requiring

    > calling super.initialize_fields_and_imported_data()

    This function is meant to initialize the number (and potentially contents) of the field The second is meant for actions that must be taken after everything else is initialized (setting values in the boundary

    > condition array, as an example)

  init_tdb_params()

    Initializes the .tdb file, and associated codegen functions to compute the thermodynamics

    Notes

    The function will load from a given TDBContainer first. Only if one isn’t given, will it try and load from the tdb_path. Order of phases and compositions is always alphabetical. Can be overridden (call super.init_tdb_params() first!) to define model-specific TDB functionality

  just_before_simulating()
  simulation_loop()

    This function will run once every time step. Override this in the subclass to put simulation code here!

## pyphasefield.Engines.Warren1995 module

class pyphasefield.Engines.Warren1995.Warren1995(**kwargs)

  Bases: `Simulation`

  init_fields()

    Initializes the Field class instances for a given simulation. Deprecated, use the initialize_engine pathway instead!

    Notes

    Exclusively used by the subclass, base Simulation class does not initialize fields! This and initialize_fields_and_imported_data are both inherited by the subclass, with the second requiring

    > calling super.initialize_fields_and_imported_data()

    This function is meant to initialize the number (and potentially contents) of the field The second is meant for actions that must be taken after everything else is initialized (setting values in the boundary

    > condition array, as an example)

  just_before_simulating()
  simulation_loop()

    This function will run once every time step. Override this in the subclass to put simulation code here!

pyphasefield.Engines.Warren1995.Warren1995_helper_kernel(fields, T, transfer, rng_states, params, c_params)

pyphasefield.Engines.Warren1995.Warren1995_kernel(fields, T, transfer, fields_out, rng_states, params, c_params)

pyphasefield.Engines.Warren1995.engine_Warren1995(sim)

pyphasefield.Engines.Warren1995.gradx(phi, dx)

pyphasefield.Engines.Warren1995.gradxx(phi, dx)

pyphasefield.Engines.Warren1995.grady(phi, dx)

pyphasefield.Engines.Warren1995.gradyy(phi, dx)

pyphasefield.Engines.Warren1995.init_Warren1995(sim, dim, diamond_size=15)

## Module contents