| 1 |
# This example looks complicated because I split the |
| 2 |
# hexadecane molecule into individual CH2 and CH3 monomers. |
| 3 |
# |
| 4 |
# I defined it this way so that you can easily modify |
| 5 |
# it to change the length of the alkane chain. |
| 6 |
|
| 7 |
|
| 8 |
import "ch2.lt" # load the definition of the "CH2" object |
| 9 |
import "ch3.lt" # load the definition of the "CH3" object |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
Hexadecane inherits OPLSAA { |
| 14 |
|
| 15 |
create_var {$mol} # optional:force all monomers to share the same molecule-ID |
| 16 |
|
| 17 |
# Now create an array of 14 "CH2" monomers and 2 "CH3" monomers |
| 18 |
|
| 19 |
## --- Method 1: Specify the position of each monomer manually --- |
| 20 |
monomers[0] = new CH3.rot(0,1,0,0).move(0.0,0,0) |
| 21 |
monomers[1] = new CH2.rot(180,1,0,0).move(1.2533223,0,0) |
| 22 |
monomers[2] = new CH2.rot(360,1,0,0).move(2.5066446,0,0) |
| 23 |
monomers[3] = new CH2.rot(540,1,0,0).move(3.7599669,0,0) |
| 24 |
monomers[4] = new CH2.rot(720,1,0,0).move(5.0132892,0,0) |
| 25 |
monomers[5] = new CH2.rot(900,1,0,0).move(6.2666115,0,0) |
| 26 |
monomers[6] = new CH2.rot(1080,1,0,0).move(7.5199338,0,0) |
| 27 |
monomers[7] = new CH2.rot(1260,1,0,0).move(8.7732561,0,0) |
| 28 |
monomers[8] = new CH2.rot(1440,1,0,0).move(10.0265784,0,0) |
| 29 |
monomers[9] = new CH2.rot(1620,1,0,0).move(11.2799007,0,0) |
| 30 |
monomers[10] = new CH2.rot(1800,1,0,0).move(12.533223,0,0) |
| 31 |
monomers[11] = new CH2.rot(1980,1,0,0).move(13.7865453,0,0) |
| 32 |
monomers[12] = new CH2.rot(2160,1,0,0).move(15.0398676,0,0) |
| 33 |
monomers[13] = new CH2.rot(2340,1,0,0).move(16.2931899,0,0) |
| 34 |
monomers[14] = new CH2.rot(2520,1,0,0).move(17.5465122,0,0) |
| 35 |
monomers[15] = new CH3.rot(2700,1,0,0).rot(180,0,1,0).move(18.7998345,0,0) |
| 36 |
# (See below for a python script to generate this long list of commands.) |
| 37 |
|
| 38 |
## Alternative strategies: |
| 39 |
## |
| 40 |
## --- Method 2: Create many monomers with a single "new" command --- |
| 41 |
## The first monomer is of type "CH3" |
| 42 |
# monomers[0] = new CH3 |
| 43 |
## The monomers in the middle of the polymer (indices 1-14) are of type "CH2" |
| 44 |
## We can create them all with a single command. |
| 45 |
# monomers[1-14] = new CH2[14].rot(180,1,0,0).move(1.2533223,0,0) |
| 46 |
## Note: Each monomer is rotated 180 degrees with respect to the previous |
| 47 |
## monomer, and then moved 1.2533223 Angstroms down the X axis. |
| 48 |
## Now move monomers 1-14 to avoid overlap with the first monomer(monomers[0]) |
| 49 |
# monomers[1-14].rot(180,1,0,0).move(1.2533223,0,0) |
| 50 |
## The final monomer is of type "CH3" and we want to position it at the end: |
| 51 |
# monomers[15] = new CH3.rot(180.0,0,0,1).move(18.7998345,0,0) |
| 52 |
## Note: 18.7998345 = (16-1) * 1.2533223 |
| 53 |
## |
| 54 |
## --- Method 3: create polymer and redefine the ends: ---- |
| 55 |
## Create a long polymer consisting only of monomers of type "CH2" |
| 56 |
# monomers = new CH2 [16].rot(180,1,0,0).move(1.2533223,0,0) |
| 57 |
## Delete the CH2 monomers at the beginning and end, and replace them with CH3 |
| 58 |
# delete monomers[0] |
| 59 |
# delete monomers[15] |
| 60 |
# monomers[0] = new CH3 |
| 61 |
# monomers[15] = new CH3 |
| 62 |
## Move the final CH3 monomer to the correct location at the end of the chain: |
| 63 |
# monomers[15].rot(180.0,0,0,1).move(18.7998345,0,0) |
| 64 |
## (Note: This approach changes the order of the atoms in the DATA file.) |
| 65 |
|
| 66 |
|
| 67 |
# Now add a list of bonds connecting the carbon atoms together: |
| 68 |
|
| 69 |
write('Data Bond List') { |
| 70 |
$bond:b1 $atom:monomers[0]/c $atom:monomers[1]/c |
| 71 |
$bond:b2 $atom:monomers[1]/c $atom:monomers[2]/c |
| 72 |
$bond:b3 $atom:monomers[2]/c $atom:monomers[3]/c |
| 73 |
$bond:b4 $atom:monomers[3]/c $atom:monomers[4]/c |
| 74 |
$bond:b5 $atom:monomers[4]/c $atom:monomers[5]/c |
| 75 |
$bond:b6 $atom:monomers[5]/c $atom:monomers[6]/c |
| 76 |
$bond:b7 $atom:monomers[6]/c $atom:monomers[7]/c |
| 77 |
$bond:b8 $atom:monomers[7]/c $atom:monomers[8]/c |
| 78 |
$bond:b9 $atom:monomers[8]/c $atom:monomers[9]/c |
| 79 |
$bond:b10 $atom:monomers[9]/c $atom:monomers[10]/c |
| 80 |
$bond:b11 $atom:monomers[10]/c $atom:monomers[11]/c |
| 81 |
$bond:b12 $atom:monomers[11]/c $atom:monomers[12]/c |
| 82 |
$bond:b13 $atom:monomers[12]/c $atom:monomers[13]/c |
| 83 |
$bond:b14 $atom:monomers[13]/c $atom:monomers[14]/c |
| 84 |
$bond:b15 $atom:monomers[14]/c $atom:monomers[15]/c |
| 85 |
} |
| 86 |
|
| 87 |
} # Hexadecane |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
# ------------------------------------------------------------------------- |
| 92 |
# Note: The following short python script was used to generate the text above: |
| 93 |
#N=16 |
| 94 |
#print(' monomers[0] = new CH3') |
| 95 |
#for i in range(1,N-1): |
| 96 |
# print(' monomers['+str(i)+'] = new CH2.rot('+str(180*i)+',1,0,0).move('+str(i*1.2533223)+',0,0)') |
| 97 |
#i=N-1 |
| 98 |
#print(' monomers['+str(i)+'] = new CH3.rot('+str(180*i)+',1,0,0).rot(180,0,1,0).move('+str(i*1.2533223)+',0,0)') |
| 99 |
## generate the list of bonds |
| 100 |
#print(' write("Data Bond List") {') |
| 101 |
#for i in range(0,N-1): |
| 102 |
# print(' $bond:b'+str(i+1)+' $atom:monomers['+str(i)+']/c $atom:monomers['+str(i+1)+']/c') |
| 103 |
#print(' }') |
| 104 |
# ---------- (scratchwork calculations for the atomic coordinates) ---------- |
| 105 |
# Lcc = 1.5350 # length of the C-C bond (Sp3) |
| 106 |
# Lch = 1.0930 # length of the C-H bond |
| 107 |
# theta=2*atan(sqrt(2)) # ~= 109.5 degrees = tetrahedronal angle (C-C-C angle) |
| 108 |
# DeltaXc = Lcc*sin(theta/2) # = 1.2533222517240594 |
| 109 |
# DeltaYc = Lcc*cos(theta/2) # = 0.8862326632060754 |
| 110 |
# # 0.5*DeltaYc = 0.4431163316030377 |
| 111 |
# DeltaZh = Lch*sin(theta/2) # = 0.8924307629540046 |
| 112 |
# DeltaYh = Lch*cos(theta/2) # = 0.6310438442242609 |
| 113 |
# ------------------------------------------------------------------------- |