The following script places octane molecules on a grid in order to create a box of neat alkane. Extensive use is made of ?RAND to perturb the grid placement, via small displacements and molecular rotations. It is also used to choose conformations, from a Langevin dynamics simulation of a single octane with 1000 stored frames in the trajectory; the C4 atom of octane was fixed at the origin for the LD. I run scripts like this several times, with a different ID (1,2,3,...) and a different random seed.

* place 148 octanes in a 6x5x5 grid, random displacement from grid coords
* random configs from LD, random orientation; id @ID ; seed @SEED
*

open unit 1 read card name lipid27.rtf
read rtf card unit 1
close unit 1

open unit 1 read card name lipid27.prm
read param card unit 1
close unit 1

read sequ octa 148
gener O

open unit 2 write card name oct148.psf
write psf unit 2 card
* psf for 148 octanes, randomized setup for liquid phase
*

random uniform iseed @SEED

set xt -17.
set yt -17.
set zt -17.
set k 1

label kloop
calc ndx 1 + int( 1000. * ?RAND )
define kres sele resid @K end
open unit 22 read file name ldynf.trj
read coor file unit 22 ifile @NDX sele kres end
close unit 22
calc xd -1. + 2. * ?RAND
calc yd -1. + 2. * ?RAND
calc zd -1. + 2. * ?RAND
calc phi 360. * ?RAND
coor rota xdir @XD ydir @YD zdir @ZD phi @PHI sele kres end
coor tran xdir @XD ydir @YD zdir @ZD sele kres end
coor tran xdir @XT ydir @YT zdir @ZT sele kres end
incr k by 1
if k .gt. 148 goto kdone
incr xt by 7.
if xt .lt. 17. goto kloop
set xt -17.
incr yt by 7.
if yt .lt. 17. goto kloop
set yt -17.
incr zt by 7.
goto kloop

label kdone

crystal define cubic 36. 36. 36. 90. 90. 90.
open unit 21 read card name box.cry
crystal read unit 21 card
close unit 21
pressure init
image byres

mini sd nstep 50 nprint 5 cutnb 14. ctofnb 12.0 ctonnb 8.0 -
vfswitch cdie eps 1.0 atom vatom cutim 14. -
ewald pme fftx 32 ffty 32 fftz 32 order 6 spline kappa 0.32

pressure inst temp 293. volume ?VOLU

mini abnr nstep 50 nprint 5 lattice nocoor
mini abnr nstep 500 nprint 10 tolgrd 1.e-4
pressure inst temp 293. volume ?VOLU
mini abnr nstep 50 nprint 5 lattice nocoor
mini abnr nstep 500 nprint 10 tolgrd 1.e-4
pressure inst temp 293. volume ?VOLU

scalar mass stat
calc rho 1.66506 * ?STOT / ?VOLU

open unit 2 write card name oct148@ID.crd
write coor card unit 2
* neat octane model @ID, 148 molecules, construction seed @SEED
* edge ?XTLA ; rho @RHO ; ener ?ENER ; pressure ?PRSI
*

stop