MDFactoryMDFactory

setup_utilities

System setup utilities for bilayer and mixedbox construction.

funcgenerate_lipid_structure_legacy(smiles, head_indices, tail_indices, num_conformers=5)
paramsmiles
paramhead_indices
paramtail_indices
paramnum_conformers
= 5

Returns

None
funcgenerate_lipid_structure(smiles, head_indices, tail_indices, store_trajectory=False, trajectory_path=None)

Generate a 3D lipid conformer with extended head-to-tail geometry.

Embed multiple RDKit conformers, select the one with maximal head-tail separation, then minimize with UFF distance constraints to produce a stretched lipid structure suitable for bilayer construction.

paramsmilesstr

SMILES string of the lipid molecule.

paramhead_indiceslist of int

Atom indices belonging to the head group.

paramtail_indiceslist of int

Atom indices belonging to the tail termini.

paramstore_trajectorybool
= False

If True, write intermediate minimization frames to an XYZ file. Default is False.

paramtrajectory_pathstr or None
= None

Path for the trajectory XYZ file. Only used when store_trajectory is True. Defaults to "trajectory.xyz".

Returns

rdkit.Chem.Mol

RDKit molecule with a single optimized conformer.

funcrotation_matrix(axis, theta)

Compute a 3D rotation matrix using Rodrigues' rotation formula.

paramaxisarray_like of float

Rotation axis vector (will be normalized).

paramthetafloat

Rotation angle in radians.

Returns

numpy.ndarray

3x3 rotation matrix.

funcalign_lipid_with_z_axis(lipid_universe, tail_atom_ids, head_atom_ids, z_axis)

Align a lipid so the tail-to-head vector points along a given axis.

paramlipid_universemda.Universe

Universe containing the lipid structure.

paramtail_atom_idslist of int

Atom indices corresponding to the lipid tails.

paramhead_atom_idslist of int

Atom indices corresponding to the lipid head group.

paramz_axisarray_like of float

Target alignment vector.

Returns

MDAnalysis.Universe

Copy of the lipid universe with atoms rotated so the tail-to-head direction is aligned with z_axis.

funccreate_bilayer_from_model(bilayer_composition, check_clashes=True)

Build a lipid bilayer (or monolayer) from a composition specification.

Place lipids on a 2D grid for each leaflet, align them along the z-axis, resolve inter-leaflet clashes, and merge into a single Universe with contiguous residue numbering.

parambilayer_compositionBilayerComposition

Specification of lipid species, counts, monolayer flag, and z-padding.

paramcheck_clashesbool
= True

If True, perform an all-residue pairwise clash check after assembly and raise on failure. Default is True.

Returns

MDAnalysis.Universe

Assembled bilayer system with box dimensions set.

funcplace_lipids_on_monolayer(grid_points, z_axis, lipid_data, is_top_layer=True, lipid_headgroup_target=0.0)

Place lipids onto grid positions for one leaflet of a bilayer.

Each lipid is aligned along z_axis, translated so its head group reaches lipid_headgroup_target, positioned at a grid point in the xy-plane, and randomly rotated around z.

paramgrid_pointslist of tuple of float

(x, y) positions on the grid where lipids will be placed.

paramz_axisnumpy.ndarray

Unit vector defining the leaflet orientation (e.g. [0,0,1] for top).

paramlipid_datalist of LipidSpecies

Lipid species with counts and structural metadata.

paramis_top_layerbool
= True

If True, head groups point toward +z. Default is True.

paramlipid_headgroup_targetfloat
= 0.0

Target z-coordinate for the head group center of geometry. Default is 0.0.

Returns

list of mda.AtomGroup

Positioned lipid atom groups, one per grid point used.

funccreate_mixed_box_universe(composition)tuple[mda.Universe, Topology]

Pack multiple molecular species into a rectangular simulation box.

Use packmol to place molecules at the target density, then load the result into an MDAnalysis Universe with correct residue names and box dimensions.

paramcompositionMixedBoxComposition

Species list with counts and target density.

Returns

tuple of (mda.Universe, openff.toolkit.Topology)

The packed system as an MDAnalysis Universe and the corresponding OpenFF Topology.

func_pack_molecules_into_box(molecules, number_of_copies, working_dir, target_density=1.0)

Pack molecules into a box using packmol.

parammoleculeslist

List of molecule objects.

paramnumber_of_copieslist

Number of copies for each molecule.

paramworking_dirstr

Working directory for packmol outputs.

paramtarget_densityfloat
= 1.0

Target density in g/cm^3. Default is 1.0.

Returns

openff.toolkit.Topology

Packed box topology.