morphogen.io.solvers

Inputs of other programs: periodic boundary conditions for Abaqus and CalculiX, grids and materials for DAMASK, seeds for Neper.

  • write_periodic_equations() ties every node of the upper faces of a mesh with matching opposite faces (conforming tetrahedra or voxels) to its image on the lower faces and to three reference nodes, whose displacements (temperatures) are the macroscopic strain (gradient) times the edges of the box. Meshes of whole periodic cells tie the translates of every node of their boundary alike.

  • write_damask() writes the grid of a polycrystal (.vti with the material of each voxel) and its material.yaml: one material per grain, with the quaternion of its orientation (DAMASK convention, P = -1) and its phase.

  • write_neper() writes the seeds, weights and orientations of a tessellation, and the Neper command that builds it.

morphogen.io.solvers.periodic_images(mesh) → tuple[ndarray, ndarray, ndarray][source]

Nodes of the upper faces (slaves), their images on the lower faces (masters, translated along every axis whose upper face holds the node) and the periods between them, x_slave = x_master + shift * edges (shift: 0 or 1 along each axis). Meshes of whole periodic cells: every node of their boundary that is a translate of another, mesh.periodic_links().

morphogen.io.solvers.write_periodic_equations(path, mesh, *, physics: str = 'elastic') → Path[source]

Abaqus/CalculiX include file of periodic boundary conditions (*INCLUDE it after the mesh): reference nodes REF_X, REF_Y, REF_Z (numbered after the nodes of the mesh), the node set CORNER (a node to fix against translation) and *EQUATION blocks u(n) - u(image of n) - sum_d s_d u(REF_d) = 0, with s_d the periods from the image to the node along each axis (1 for the upper faces of a mesh of the box holding the node; -1, 0 or 1 for whole periodic cells), degrees of freedom 1-3, or 11 for physics='thermal'.

morphogen.io.solvers.euler_to_quaternion(euler) → ndarray[source]

Unit quaternions (w, x, y, z), w >= 0, of Bunge Euler angles in degrees, with the conventions of DAMASK (passive rotation, P = -1; Rowenhorst et al. 2015).

morphogen.io.solvers.write_damask(stem, grains: VoxelImage, orientations, grain_phases=None, *, phase_names: dict | None = None, materials: dict | None = None) → list[Path][source]

DAMASK grid solver inputs: <stem>.vti (material of each voxel: its grain, numbered from 0 over the grains present) and <stem>_material.yaml (homogenization SX, one material per grain with its orientation and phase). grain_phases gives the phase of each grain label (default 1); phase_names the names of the phases; materials (phase -> Material) fills the elastic constants of the crystals (Hooke, in the units of the materials: DAMASK expects pascals); the plastic behaviour is left to the user.

morphogen.io.solvers.write_neper(stem, tessellation) → list[Path][source]

Seeds (<stem>_seeds.txt, coordinates in the box), weights (_weights.txt: the radii of a Laguerre tessellation, sqrt of the morphoGen weights) and orientations (_ori.txt: Bunge angles in degrees) of a tessellation, and <stem>_neper.sh, the command building it with Neper (-morphooptiini). Germs outside the box (the window of a non-periodic tessellation) have no Neper equivalent: they are left out, which changes the cells next to the faces.

morphogen.io.solvers.write_fenicsx(path, mesh: TetMesh) → Path[source]

XDMF file of a tetrahedral mesh and its tags, as written and read by FEniCSx (dolfinx.io.XDMFFile, ASCII encoding): the grid mesh (linear tetrahedra), the cell tags phase (and grain for polycrystals) and the facet tags faces (the faces of the box: 1-6 for x0, x1, y0, y1, z0, z1; 1 for the faces bounding whole periodic cells). Reading:

with XDMFFile(MPI.COMM_WORLD, path, "r") as f:
    mesh = f.read_mesh(name="mesh")
    phase = f.read_meshtags(mesh, name="phase")
    mesh.topology.create_connectivity(2, 3)
    faces = f.read_meshtags(mesh, name="faces")