setup_utilities
System setup utilities for bilayer and mixedbox construction.
funcgenerate_lipid_structure_legacy(smiles, head_indices, tail_indices, num_conformers=5)paramsmilesparamhead_indicesparamtail_indicesparamnum_conformers= 5Returns
Nonefuncgenerate_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.
paramsmilesstrSMILES string of the lipid molecule.
paramhead_indiceslist of intAtom indices belonging to the head group.
paramtail_indiceslist of intAtom indices belonging to the tail termini.
paramstore_trajectorybool= FalseIf True, write intermediate minimization frames to an XYZ file. Default is False.
paramtrajectory_pathstr or None= NonePath for the trajectory XYZ file. Only used when store_trajectory
is True. Defaults to "trajectory.xyz".
Returns
rdkit.Chem.MolRDKit molecule with a single optimized conformer.
funcrotation_matrix(axis, theta)Compute a 3D rotation matrix using Rodrigues' rotation formula.
paramaxisarray_like of floatRotation axis vector (will be normalized).
paramthetafloatRotation angle in radians.
Returns
numpy.ndarray3x3 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.UniverseUniverse containing the lipid structure.
paramtail_atom_idslist of intAtom indices corresponding to the lipid tails.
paramhead_atom_idslist of intAtom indices corresponding to the lipid head group.
paramz_axisarray_like of floatTarget alignment vector.
Returns
MDAnalysis.UniverseCopy 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_compositionBilayerCompositionSpecification of lipid species, counts, monolayer flag, and z-padding.
paramcheck_clashesbool= TrueIf True, perform an all-residue pairwise clash check after assembly and raise on failure. Default is True.
Returns
MDAnalysis.UniverseAssembled 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.ndarrayUnit vector defining the leaflet orientation (e.g. [0,0,1] for top).
paramlipid_datalist of LipidSpeciesLipid species with counts and structural metadata.
paramis_top_layerbool= TrueIf True, head groups point toward +z. Default is True.
paramlipid_headgroup_targetfloat= 0.0Target z-coordinate for the head group center of geometry. Default is 0.0.
Returns
list of mda.AtomGroupPositioned 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.
paramcompositionMixedBoxCompositionSpecies 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.
parammoleculeslistList of molecule objects.
paramnumber_of_copieslistNumber of copies for each molecule.
paramworking_dirstrWorking directory for packmol outputs.
paramtarget_densityfloat= 1.0Target density in g/cm^3. Default is 1.0.
Returns
openff.toolkit.TopologyPacked box topology.
