CMM 3/16/2026
you will HAVE TO PUT THOUGHT INTO ACTUAL PRODUCTION SIMULATIONS!

Roughly follows Lipid Bilayer tutorial
Tarball for this how-to

PRELUDE: Creating the primary files



You must have the topology files of your new/non-standard molecules. in order to start this process. For example, for TTA, (martini_v3.0.0_TTA.itp):

;;;;;; Martini 3.0 lipid topology for TTA (dodecyl trimethyl ammonium)
;
; CMM 10/2025
;
; Molecular topology and mapping of indices:
; +NC3-C1A-C2A-C3A-C4A
;
; 1 - 2 - 3 - 4 - 5
;
; Name
; n-dodecyltrimethylammonium (TTA)
;
; Alias
; TTA
;
; Force field
; martini3
;
; Version
; 1.0
;
; Category
; Lipids
;
; INSANE BLOCK NEEDS TO ACTUALLY BE FORMED!!!!!!
;
;@INSANE alhead=C P, allink=G G, altail=CC CC, alname=DTPC, charge=0.0
;@RESNTEST DTP==DTPC if: atoms[0]==NC3
;@BEADS NC3 PO4 GL1 GL2 C1A C2A C1B C2B
;@BONDS NC3-PO4 PO4-GL1 PO4-GL2 GL1-GL2 GL1-C1A C1A-C2A GL2-C1B C1B-C2B
;

[moleculetype]
; molname nrexcl
TTA 1

[atoms] ; same as martini2
; id type resnr residu atom cgnr charge (mass)
1 Q1 1 TTA NC3 1 1.0
2 SC1 1 TTA C1A 2 0
3 SC1 1 TTA C2A 3 0
4 C1 1 TTA C3A 4 0
5 C1 1 TTA C4A 5 0

[bonds]
; i j funct length force c.
; taken from Badhe https://doi.org/10.1007/s00894-024-05952-x
; MARTINI3 :
;[bonds]
; i j name (using named bondtypes from martini_v3.0.0_ffbonded_v2.itp)
; i j funct force.c.
;
1 2 b_NC3_GL_def ; uncertain about this one!
2 3 b_SC1_C1_mid
3 4 b_SC1_C1_mid
4 5 b_SC1_C1_end

[ angles ]
; i j k funct angle force.c.
3 4 5 a_NC3_GL_C_def ; uncertain about this one!
1 3 4 a_C1_C1_C1_def
2 3 4 a_C1_C1_C1_def


The values/parameters from the .itp file may be found in the literature or other files — you may use an existing topology from the Martini Lipodome as a guide. The bond/force constant/angle values for this particular .itp file were found/inferred from Badhe, et al https://doi.org/10.1007/s00894-024-05952-x.

You must decide how to translate the molecule into martini3 beads; In this case it is easy as a Q1 bead is charged, and the NC3 name is commonly used for trimethylammonium ion. C1 beads represent 4 carbons, and SC1 represent 3, so C14 = 2xSC1 + 2xC1, Even with this mapping, different amphiphiles may not turn out to be unique; see the discussion in the tutorial, and realize that Martini3 makes this much less of a problem.

Using this particular set of files as a guide, it should be relatively simple to construct the corresponding gemini surfactant.

Building the simulation box


you must have the following files to make this work:
  • TTA-em.gro -- the coordinates in .gro format of your surfactant
  • martini_v3.0.0_TTA.itp -- the itp file for that surfactant
  • martini_v3.0.0.itp -- the main martini2 itp file
  • martini_v3.0.0_ions_v1.itp
  • martini_v3.0.0_BzO.itp
  • martini_v3.0.0_solvents_v1.itp
  • water.gro -- an equilibrated water box
  • various .mdp files as supplied in the tutorial
  • TTA.top -- the topology file (easy to make)

1) assemble the TTA. adjust box size and number depending on what system (standard disclaimer)
/bin/bash $ gmx insert-molecules -ci TTA-em.gro -box 7.5 7.5 7.5 -nmol 128 -radius 0.21 -try 500 -o 128_noW.gro

NOTE: If you are adding polyatomic anions such as benzoate or sulfate, you must use insert-molecules successively (instead of genion, below):
/bin/bash $ gmx insert-molecules -ci TTA-em.gro -box 10 10 10 -nmol 128 -radius 0.21 -try 500 -o 128_TTA.gro
/bin/bash $ gmx insert-molecules -ci BzO-0.gro -f 128_TTA.gro -box 10 10 10 -nmol 128 -radius 0.21 -try 500 -o 128_TTA_BzO.gro


Solvating with water beads


2) Add martini water using solvate:
/bin/bash $ gmx solvate -cp 128_noW.gro -cs water.gro -o system.gro -maxsol 5000 -radius 0.21
or
/bin/bash $ gmx solvate -cp 128_TTA_BzO.gro -cs water.gro -o system.gro -maxsol 5000 -radius 0.21

The bilayer tutorial specification of 768 waters is not enough to create a realistic density; this creates an initial patchy association during minimization. For this reason, the 'maxsol' should be increased to some large number. It is not necessary to put too fine a point on this, as the process will stop at a reasonable density. You could do a rough calculation to decide on the total number of waters required for your box size. Here are some examples:
  • 50 TTA,L = 10, maxsol 10000, received 7695.
  • 10 TTA in L = 58.5 box; asked for 1,600,000 received ?
  • 2.0 mM: 20 TTA in 51.7 box asked for 1,200,000 received 1,130,463
  • 1.5 mM: 50 TTA in 46.4 box asked for 800,000 W received 795395 (inconsistent concentration calc)

Anytime you do actual grompp and/or mdrun, you TTA.top will be modified to add any new species.
So, at this point, you need to add a line into TTA.top to account for the newly-added waters ("W line only"): You need to determine what this number is by reading the previous outputs.
[ molecules ]
TTA 128
W 640

Adding bromide counter-ions


If your system only has small organic anions, you skip this step!!
3) add the bromide ions using genion. You could add positive or negative ions, but in this example we will neutralize with bromides only. A good example of genion use may be found at http://www.mdtutorials.com/gmx/lysozyme/04_ions.html
You must generate an "ions.mdp" despite the fact that you aren't going to actually run anything at this time.
'genion' will ask which group to affect; you should pick the W group (which is probably group 3).

/bin/bash $ gmx grompp -f ions.mdp -c waterbox.gro -p TTA.top -o ions.tpr
/bin/bash $ gmx genion -s ions.tpr -o waterbox_ions.gro -p TTA.top -nname BR- -neutral

If you examine your .top file, you should now see the BR- ions added to the end.

Minimization


4) now minimize this TTA + water + ion box as specified in the Bilayers tutorial. You may want to make the output file (minimized.gro) something more descriptive. If you are running on Apple Silicon, gromacs will try and grab all the processors by default. You may use the '-ntmpi' switch to tune this; for now, using '-ntmpi 4' is a good choice.

/bin/bash $ gmx grompp -f minimization.mdp -c waterbox_ions.gro -p TTA.top -o TTA-min-solvent.tpr
/bin/bash $ gmx mdrun -ntmpi 4 -s TTA-min-solvent.tpr -v -c minimized.gro

Heating/equilibration

5) Heat and equilibrate your system. This should be straight-forward, using the appropriate mdp file:

/bin/bash $ gmx grompp -f martini_eq.mdp -c minimized.gro -p TTA.top -o TTA-eq.tpr
/bin/bash $ gmx mdrun -ntmpi 4 -s TTA-eq.tpr -v -x TTA-eq.xtc -c TTA-eq.gro

Running dynamics


6) Now you should be able to run dynamics!

/bin/bash $ gmx grompp -f martini_md.mdp -c minimized.gro -p TTA.top -o TTA-md.tpr
/bin/bash $ gmx mdrun -ntmpi 4 -s TTA-md.tpr -v -x TTA-md.xtc -c TTA-md.gro

You can put all these commands into a file including some variables that allow you to change the concentration/box size, etc. Here is an example. You can save this file, make it executable, and call it like a program:

/bin/bash $ vi run_TTA_BzO_system.sh
…edit file appropriately
/bin/bash $ chmod 755 run_TTA_BzO_system.sh
… watch for output or errors


VISUALIZATION — Martiniglass and VMD



Use a python virtual environment to run martiniglass. The martiniglass GitHub page describes this. Assuming python (as python3) is installed on your (OS X) machine:

/bin/bash $ python3 -m venv venv && source venv/bin/activate
Once you've created this environment, a "(venv)" will be pre-prended to your cursor. Now you may install martiniglass:
(venv) /bin/bash $ pip install martiniglass

(you may be informed that pip could be upgraded; you could do this if you wanted to by following the instructions given.)

Here is a good example page. I'm assuming that your whole system (amphiphile + ion(s) + water) is described by the files system.top and system.gro. It is very important that your system.top file ONLY contains include entries that refer to molecules in your system! This is not really stated anywhere in the documentation. For example, for this TTA+/BzO/W system, my system.top file was:

#include "../../martini_v3.0.0_TTA.itp"
#include "../BzO_take2.itp"

[ system ]
TTA + BzO 10.0 mM (approx)

[ molecules ]
TTA 200
BzO 200
W 816266

Typically, you have a lot of water beads in your system that you want to eliminate from the visualization, and these steps will do it. The '-f' option start this process using the specified gromacs file (here, 'system.gro').

(venv) /bin/bash $ martiniglass -p system.top -f system.gro

This will create the files
  • index.ndx
  • TTA_vis.itp
  • BzO_vis.itp
  • vis.top

Importantly, index.ndx, indexes only the non-water parts of the system. Now, you must use this index file to strip out the waters from your original system.gro and put the result into a new file. There are a number of equivalent ways to do this, depending on whether you want to use a trajectory and tpr file, extract one frame from a trajectory, or convert a whole trajectory:

(venv) /bin/bash $ gmx trjconv -f system.gro -s system.gro -n index.ndx -o vis.gro
(venv) /bin/bash $ gmx trjconf -f system.xtc -s system.tpr -pbc mol -n index.ndx -e 0 -o vis.gro
(venv) /bin/bash $ gmx trjconf -f system.xtc -s system.tpr -pbc mol -n index.ndx -o vis.xtc


Now, create the vmd input file vis.vmd:

(venv) /bin/bash $ martiniglass -p vis.top -vf

Finally, you can load the files into vmd:

(venv) /bin/bash $ vmd vis.gro -e vis.vmd

(Additional information/examples may be found here and here.)

Martiniglass by default creates many representations; most are uneeded. Find the representation with the lipids (POPC, POPE, etc) and change all those names to "TTA" (or just add TTA). You should see the polar tetraammonium head as purple (from the "name NC3 PO42 PO41 PO4 COO ROH" representation), and the HC tail(s) as grey tubes. If your system includes ions (BzO, for example), you can enter them most conveniently in the "resname CHOL" representation. The other representations besides these three may be turned off. I personally do not like the default colors, so I tend to change them.

There can be a problem with visualizing trajectories. Sometimes atoms (beads) cross the periodic boundaries of the box and the molecule appears to stretch across the whole box, giving the appearance of box-length rods. See this link. This can be fixed by a form of periodic recentering (the proper -pbc setting was found by trial-and-error):

(venv) /bin/bash $ gmx trjconv -f TTA_50-md.xtc -s TTA_50-md.tpr -n TTA_50-md.ndx -pbc mol -ur compact -o vis-compact.xtc

(If you have problems of this sort, it is a good idea to test different combinations of the PBC/centering commands (of course .trr could be .xtc or .gro)

Commands are as follows:
(venv) /bin/bash $ gmx trjconv -s md.tpr -f md.trr -o md1.trr -center -pbc whole -n index.ndx
(venv) /bin/bash $ gmx trjconv -s md.tpr -f md1.trr -o md2.trr -pbc nojump -n index.ndx
(venv) /bin/bash $ gmx trjconv -s md.tpr -f md2.trr -o md3.trr -pbc mol -ur compact -n index.ndx

This trajectory file can be read into the previous (static) vmd molecule (which utilized the single-frame .gro file) in order to produce a trajectory and/or movies.