Skip to content

Commit 1bb50fb

Browse files
committedMay 26, 2024·
continue to filter the conf tutorial
1 parent 2c7e036 commit 1bb50fb

File tree

1 file changed

+62
-87
lines changed

1 file changed

+62
-87
lines changed
 

‎docs/doc-sphinx/source/non-tutorials/createconfgro.rst

+62-87
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ Creating the GRO file
140140

141141
.. container:: justify
142142

143-
Here we first define the basic parameters, such as
144-
the number of residues we want, or the box size, and
145-
initialize some lists and counters.
143+
Here, we define some of the basic parameters of the simulation, such as
144+
the number of residues and the box size.
145+
146+
.. container:: justify
146147

147148
Next to *molecule.py*, create a new Python file called
148149
*generategro.py*, and copy the following lines into it:
149150

150151
.. code-block:: python
151-
:caption: *to be copied in generategro.py*
152152
153153
import numpy as np
154154
from molecules import SO4_ion, Na_ion, H20_molecule
@@ -159,15 +159,18 @@ Creating the GRO file
159159
160160
.. container:: justify
161161

162-
Here box is an array containing the box size along all 3 coordinates of space,
163-
respectively Lx, Ly, and Lz. Here a cubic box of lateral dimension 3.6 nm is used.
162+
Here, *box* is an array containing the box size along all 3 coordinates of space,
163+
respectively *Lx*, *Ly*, and *Lz*. A cubic box of lateral dimension
164+
:math:`3.6 ~ \text{nm}` is used.
165+
166+
.. container:: justify
164167

165-
Now, let us choose a salt concentration, and calculate the number of
168+
Let us choose a salt concentration, and calculate the number of
166169
ions and water molecules accordingly, while also choosing the total
167-
number of residues (here I call residue either a molecule or an ion):
170+
number of residues (here I call residue either a molecule or an ion).
171+
Add the following to *generategro.py*:
168172

169173
.. code-block:: python
170-
:caption: *to be copied in generategro.py*
171174
172175
Mh2o = 0.018053 # kg/mol - water
173176
ntotal = 720 # total number of molecule
@@ -177,24 +180,22 @@ Creating the GRO file
177180
178181
.. container:: justify
179182

180-
Let us also choose typical cutoff distances (in nanometer) for each species. These
181-
cutoffs will be used to ensure that no species are inserted too close
182-
from one another:
183+
Let us also choose typical cutoff distances (in nanometer) for each
184+
species. These cutoffs will be used to ensure that no species are inserted
185+
too close from one another, as it would make the simulation crashed later:
183186

184187
.. code-block:: python
185-
:caption: *to be copied in generategro.py*
186188
187189
dSO4 = 0.45
188190
dNa = 0.28
189191
dSol = 0.28
190192
191193
.. container:: justify
192194

193-
Let us initialized counters and lists for storing
194-
all the necessary data:
195+
Let us initialized several counters and several lists. The lists will be
196+
used for storing all the data about the atoms:
195197

196198
.. code-block:: python
197-
:caption: *to be copied in generategro.py*
198199
199200
cpt_residue = 0
200201
cpt_atoms = 0
@@ -209,12 +210,11 @@ Creating the GRO file
209210
210211
.. container:: justify
211212

212-
Let us add a number *nion* of :math:`\text{SO}_4^{2-}` ions at random locations.
213+
Let us first add a number *nion* of :math:`\text{SO}_4^{2-}` ions at random locations.
213214
To avoid overlap, let us only insert ion if no other ions is already located at
214215
a distance closer than *dSO4*:
215216

216217
.. code-block:: python
217-
:caption: *to be copied in generategro.py*
218218
219219
# add SO4 randomly
220220
atpositions, attypes, resname, atnames = SO4_ion()
@@ -244,7 +244,6 @@ Creating the GRO file
244244
and copy the following lines in it:
245245

246246
.. code-block:: python
247-
:caption: *to be copied in utils.py*
248247
249248
import numpy as np
250249
from numpy.linalg import norm
@@ -274,10 +273,12 @@ Creating the GRO file
274273
within the box. The *search_closest_neighbor* looks for the minimum distance
275274
between existing atoms (if any) and the new residue.
276275

277-
Let us do the same for the :math:`\text{Na}^{+}` ion :
276+
.. container:: justify
277+
278+
Let us do the same for the :math:`\text{Na}^{+}`
279+
ion :
278280

279281
.. code-block:: python
280-
:caption: *to be copied in generategro.py*
281282
282283
# Import the functions from the utils file
283284
from utils import generate_random_location, search_closest_neighbor
@@ -309,7 +310,6 @@ Creating the GRO file
309310
spacing of *dSol* (only if no overlap exists):
310311

311312
.. code-block:: python
312-
:caption: *to be copied in generategro.py*
313313
314314
# add water randomly
315315
atpositions, attypes, resname, atnames = H20_molecule()
@@ -342,7 +342,6 @@ Creating the GRO file
342342
actual concentration:
343343

344344
.. code-block:: python
345-
:caption: *to be copied in generategro.py*
346345
347346
print('Lx = '+str(Lx)+' nm, Ly = '+str(Ly)+' nm, Lz = '+str(Lz)+' nm')
348347
print(str(cpt_Na)+' Na ions')
@@ -382,15 +381,13 @@ Creating the GRO file
382381
f.write("\n")
383382
f.close()
384383
385-
.. include:: ../contact/supportme.rst
386-
387384
Final system
388385
------------
389386

390387
.. container:: justify
391388

392389
Run the *generategro.py* file using Python.
393-
This is what I in the terminal:
390+
This is what appear in the terminal:
394391

395392
.. code-block:: bw
396393
@@ -403,8 +400,7 @@ Final system
403400
404401
.. container:: justify
405402

406-
You can look at the final system using vmd (or any other MD visualization software)
407-
by typing in a terminal:
403+
You can check the final system using VMD by typing in a terminal:
408404

409405
.. code-block:: bash
410406
@@ -418,16 +414,15 @@ Final system
418414
:alt: Gromacs tutorial - generated topology
419415
:class: only-dark
420416

417+
.. container:: figurelegend
418+
421419
The primary system is located within the blue box. The replicated periodic
422420
images are also represented.
423421

424422
.. container:: justify
425423

426-
There is some vacuum left in the box. It is not a big problem and
427-
the initial configuration we created is good enough.
428-
The topology file *conf.gro* will be used as the initial
429-
configuration for the :ref:`bulk-solution-label` tutorial.
430-
424+
There is some vacuum left in the box. It is not an issue as energy
425+
minimization and molecular dynamics will help equilibrate the system.
431426

432427
Creating the TOP file
433428
=====================
@@ -443,7 +438,6 @@ Creating the TOP file
443438
Within the same Python script, write:
444439

445440
.. code-block:: python
446-
:caption: *to be copied in generategro.py*
447441
448442
# write topol.top
449443
f = open('topol.top', 'w')
@@ -459,31 +453,12 @@ Creating the TOP file
459453
f.write('SOL '+ str(cpt_Sol)+'\n')
460454
f.close()
461455
462-
.. container:: justify
463-
464-
All the parameter files located in the *ff* folder
465-
will be written in the :ref:`create-topol-label` tutorial.
466-
467-
.. include:: ../contact/contactme.rst
468-
469456
Write parameters
470457
----------------
471458

472-
.. container:: hatnote
473-
474-
Writing the topology file for GROMACS.
475-
476459
.. container:: justify
477460

478-
The objective of this tutorial is to write
479-
the force field parameters (.itp files) for a simple system.
480-
If follows directly the writing of the gro file in :ref:`create-conf-label` tutorial.
481-
482-
The parameter files created here will be used in :ref:`bulk-solution-label`.
483-
If you are only interested in running GROMACS, jump directly
484-
to :ref:`bulk-solution-label`.
485-
486-
.. include:: ../contact/needhelp.rst
461+
Here, the force field parameters (i.e. the *.itp* files) are written.
487462

488463
Default parameters
489464
------------------
@@ -494,7 +469,6 @@ Default parameters
494469
*forcefield.itp*, and copy the following in it:
495470

496471
.. code-block:: bw
497-
:caption: *to be copied in ff/forcefield.itp*
498472
499473
[ defaults ]
500474
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ
@@ -522,18 +496,32 @@ Default parameters
522496
The |forcefield.itp| file is used to define basic combination rules, as well as
523497
atom types, bond types, and angle types.
524498

499+
.. |forcefield.itp| raw:: html
500+
501+
<a href="../../../../inputs/bulksolution/ff/forcefield.itp" target="_blank">forcefield.itp</a>
502+
503+
.. container:: justify
504+
525505
With comb-rule = 2, the mixing rule is calculated as
526506
:math:`\epsilon_{ij} = \sqrt{\epsilon_{ii} \epsilon_{jj}}`,
527507
:math:`\sigma_{ij} = (\sigma_{ii}+\sigma_{jj})/2`.
528508
FudgeLJ and fudgeQQ are the factors by which to multiply Lennard-Jones
529509
and Coulomb 1-4 interactions, respectively.
530510
You can refer to the |gromacs-manual| for more information.
531511

512+
.. |gromacs-manual| raw:: html
513+
514+
<a href="https://manual.gromacs.org/current/reference-manual/topologies/parameter-files.html" target="_blank">GROMACS manual</a>
515+
516+
.. container:: justify
517+
532518
The |forcefield.itp| file also contains information about the atoms,
533519
such their masses and Lennard-Jones parameters sigma and epsilon,
534520
as well as some parameters for the bond and angle constraints that will be
535521
necessary for the SO4 ions.
536522

523+
.. container:: justify
524+
537525
Notice that the particle with name MW is of type 'D' when all the other particles
538526
are of type 'A' for atoms. This is because MW is the virtual massless site of our 4 points
539527
rigid water model, see this |tip4p-wiki| page for details.
@@ -542,19 +530,18 @@ Default parameters
542530

543531
<a href="http://www.sklogwiki.org/SklogWiki/index.php/TIP4P_model_of_water" target="_blank">wiki</a>
544532

545-
.. |gromacs-manual| raw:: html
546-
547-
<a href="https://manual.gromacs.org/current/reference-manual/topologies/parameter-files.html" target="_blank">GROMACS manual</a>
548-
549533
Sodium ion
550534
----------
551535

552536
.. container:: justify
553537

554-
Let us create a file named *na.itp* for the Sodium ion:
538+
Let us create a file named *na.itp* for the Sodium ion (|na.itp|):
539+
540+
.. |na.itp| raw:: html
541+
542+
<a href="../../../../inputs/bulksolution/ff/na.itp" target="_blank">na.itp</a>
555543

556544
.. code-block:: bw
557-
:caption: *to be copied in ff/na.itp*
558545
559546
[ moleculetype ]
560547
; molname nrexcl
@@ -574,15 +561,20 @@ Sulfate ion
574561

575562
.. container:: justify
576563

577-
The file *so4.itp* for the sulfate ion is more complicated,
564+
The file *so4.itp* for the sulfate ion is more complex than the one for the sodium ion,
578565
as the residue is made of 5 atoms that are bonded together
579-
and maintained by angular constrained.
566+
and maintained by angular constrained (|so4.itp|).
567+
568+
.. |so4.itp| raw:: html
569+
570+
<a href="../../../../inputs/bulksolution/ff/so4.itp" target="_blank">so4.itp</a>
571+
572+
.. container:: justify
580573

581574
The *exclusions* ensures that atoms from the same residue do not
582575
interact through LJ and Coulomb interactions.
583576

584577
.. code-block:: bw
585-
:caption: *to be copied in ff/so4.itp*
586578
587579
[moleculetype]
588580
; name nrexcl
@@ -619,19 +611,20 @@ Sulfate ion
619611
4 1 2 3 5
620612
5 1 2 3 4
621613
622-
.. include:: ../contact/supportme.rst
623-
624614
Water molecule
625615
--------------
626616

627617
.. container:: justify
628618

629-
Finally, create a file named *h2o.itp* for the water molecule.
630-
Settle parameters are added to ensure that the residue remains
619+
Finally, create a file named *h2o.itp* for the water molecule (|h2o.itp|).
620+
Settle parameters are added to ensure that the water molecule remains
631621
rigid:
632622

623+
.. |h2o.itp| raw:: html
624+
625+
<a href="../../../../inputs/bulksolution/ff/h2o.itp" target="_blank">h2o.itp</a>
626+
633627
.. code-block:: bw
634-
:caption: *to be copied in ff/h2o.itp*
635628
636629
[ moleculetype ]
637630
; molname nrexcl
@@ -658,25 +651,7 @@ Water molecule
658651
3 1 2 4
659652
4 1 2 3
660653
661-
.. |forcefield.itp| raw:: html
662-
663-
<a href="../../../../inputs/bulksolution/ff/forcefield.itp" target="_blank">forcefield.itp</a>
664-
665-
.. |h2o.itp| raw:: html
666-
667-
<a href="../../../../inputs/bulksolution/ff/h2o.itp" target="_blank">h2o.itp</a>
668-
669-
.. |na.itp| raw:: html
670-
671-
<a href="../../../../inputs/bulksolution/ff/na.itp" target="_blank">na.itp</a>
672-
673-
.. |so4.itp| raw:: html
674-
675-
<a href="../../../../inputs/bulksolution/ff/so4.itp" target="_blank">so4.itp</a>
676-
677654
.. container:: justify
678655

679656
To continue and use those files for running a molecular dynamics simulation
680657
with GROMACS, go to :ref:`bulk-solution-label`.
681-
682-
.. include:: ../contact/contactme.rst

0 commit comments

Comments
 (0)
Please sign in to comment.