
|
 |
ACD/ChemBasic
One little program for example
|
|
This program generates and 3D-optimizes molecules of general formula HO-(CH2)n-COOH,
n=1-5
Function Main As String
' Declarations
Dim n,i,ph,pw,l,t,w,h,k As Integer
' Molecular objects
Dim Ent,Mol,Struc ,Oh, Cox,O1ox,O2ox,AtomCurr,AtomPrev As Object
' Sketch objects
Dim Page,Diagram As Object
' Title for our messages
Const title="Example"
' Number of homologues
Const nmax=5
' DO SOME HOUSE-KEEPING
' Add an empty page to current document
Page=ActiveDocument.AddEmpty
' Read out the page dimensions
ph=Page.GetHeight
pw=Page.GetWidth
' IN A LOOP, GENERATE AND OPTIMIZE HOMOLOGS
For n=1 to nmax
' CREATE THE CURRENT MOLECULE
' 1. Create a new assembly
Ent=Assemblies.AddEmpty ' Ent is an assembly that holds atoms
Mol=Ent.Molecules.AddEmpty ' Mol contains valence bonds above assembly
' 2. Add OH to (now still empty) assembly
Oh=NewAtom(8) ' create isolated oxygen atom
Ent.Add(Oh) ' add it to assembly
' 3. Add COOH group
Cox=NewAtom(6) : Ent.Add(Cox)
O1ox=NewAtom(8) : Ent.Add(O1ox)
O2ox=NewAtom(8) : Ent.Add(O2ox)
' 4. Make bonds in that carboxy group
Mol.AddBond(Cox,O1ox,2) : Mol.AddBond(Cox,O2ox,1) :AtomPrev=Oh
' 5. Finally, add polymethelene chain (CH2)n atoms & bonds
For i=1 To n
AtomCurr=NewAtom(6)
Mol.AddBond(AtomCurr,AtomPrev,1)
AtomPrev=AtomCurr
Next i
Mol.AddBond(AtomPrev,Cox,1)
' MOLECULE IS READY. OPTIMIZE IT
' TO GRADIENT NORM OF 0.1
' AND GET THE RESULTING STRUCTURE
Struc=Mol.Do3DOptimize(0.1)
' DEPICT THE RESULT AS A
' CHEMSKETCH DIAGRAM
' Draw
Diagram=Page.Diagrams.AddEmpty
Diagram.Depict(Struc)
' Adjust the position
Diagram.GetBound(l,t,w,h)
l=Int(pw/3)
t=200+(n-1)*Int(ph/(nmax+1))
Diagram.SetBound(l,t,w,h)
Next n
' That's all!
Main="Demo completed"
End Function
|
| TOP |
This page was last updated
12 October 2006
|