1
/*****************************************************************************
2
TRAVIS - Trajectory Analyzer and Visualizer
3
http://www.travis-analyzer.de/
5
Copyright (c) 2009-2013 Martin Brehm
6
2012-2013 Martin Thomas
8
This file written by Martin Brehm.
10
This program is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*****************************************************************************/
28
void CTimeStep::CalcCenters()
39
// mprintf("** CalcCenters **");
41
if (m_vaCoords.GetSize() < g_iGesVirtAtomCount)
42
m_vaCoords.SetSize(g_iGesVirtAtomCount);
44
// mprintf("CalcCenters(): Size is now %d.\n",m_vaCoords.GetSize());
47
if (m_vaVelocities.GetSize() < g_iGesVirtAtomCount)
48
m_vaVelocities.SetSize(g_iGesVirtAtomCount);
51
if (m_vaForces.GetSize() < g_iGesVirtAtomCount)
52
m_vaForces.SetSize(g_iGesVirtAtomCount);
54
for (z=0;z<g_oaVirtualAtoms.GetSize();z++)
56
v = (CVirtualAtom*)g_oaVirtualAtoms[z];
57
m = (CMolecule*)g_oaMolecules[v->m_iMolecule];
58
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
60
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
61
if (v->m_iMode == 0) // Mittel aus Atompositionen
65
for (z3=0;z3<v->m_oCenterAtoms.m_baAtomType.GetSize();z3++)
67
for (z4=0;z4<((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetSize();z4++)
69
// mprintf("{%d:(%G|%G|%G) }\n",((CxIntArray*)sm->m_oaAtomOffset[v->m_oCenterAtoms.m_baAtomType[z3]])->GetAt(((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetAt(z4)),m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_oCenterAtoms.m_baAtomType[z3]])->GetAt(((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetAt(z4))][0],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_oCenterAtoms.m_baAtomType[z3]])->GetAt(((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetAt(z4))][1],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_oCenterAtoms.m_baAtomType[z3]])->GetAt(((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetAt(z4))][2]);
70
tv += m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_oCenterAtoms.m_baAtomType[z3]])->GetAt(((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetAt(z4))] * v->m_faWeight[c];
74
tv /= v->m_fGesWeight;
75
} else if (v->m_iMode == 1) // Abstand, Winkel, Dihedralwinkel
77
tv = PointFromRAD(m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_iAtomType[0]])->GetAt(v->m_iAtom[0])],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_iAtomType[1]])->GetAt(v->m_iAtom[1])],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_iAtomType[2]])->GetAt(v->m_iAtom[2])],v->m_fValues[0],v->m_fValues[1],v->m_fValues[2]);
78
} else if (v->m_iMode == 2) // Dipolvektor
82
eprintf("Cannot use dipole vectors.\n");
86
tv = sm->m_vDipole + m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[sm->m_baAtomIndex.GetSize()-1])->GetAt(0)];
87
} else if (v->m_iMode == 3) // Geschwindigkeitsvektor
89
} else if (v->m_iMode == 4) // Kraftvektor
92
// mprintf("%d:(%G|%G|%G), ",((CxIntArray*)sm->m_oaAtomOffset[sm->m_baAtomIndex.GetSize()-1])->GetAt(v->m_iMolVirtAtom),tv[0],tv[1],tv[2]);
93
m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[sm->m_baAtomIndex.GetSize()-1])->GetAt(v->m_iMolVirtAtom)] = tv;
100
bool CTimeStep::BondRange(int i1, int i2, double *f)
107
if (g_iScanMolStep == -1)
110
x = m_vaCoords[i1][0] - m_vaCoords[i2][0];
111
y = m_vaCoords[i1][1] - m_vaCoords[i2][1];
112
z = m_vaCoords[i1][2] - m_vaCoords[i2][2];
118
while (x < -g_fBoxX/2)
120
while (x > g_fBoxX/2)
126
while (y < -g_fBoxY/2)
128
while (y > g_fBoxY/2)
134
while (z < -g_fBoxZ/2)
136
while (z > g_fBoxZ/2)
141
d = (float)sqrt(x*x+y*y+z*z);
146
a = g_baAtomIndex[i1];
147
b = g_baAtomIndex[i2];
149
if ((a >= g_oaAtoms.GetSize()) || (b >= g_oaAtoms.GetSize()))
155
if (((CAtom*)g_oaAtoms[a])->m_pElement->m_fRadius == 0)
161
if (((CAtom*)g_oaAtoms[b])->m_pElement->m_fRadius == 0)
167
if (d < (((CAtom*)g_oaAtoms[a])->m_pElement->m_fRadius+((CAtom*)g_oaAtoms[b])->m_pElement->m_fRadius)*g_fBondFactor)
169
// printf(" \"%s\" br=%f, \"%s\" br=%f Hat Nachbarn %s%d im Abstand von %.3f.\n",m_pLabels[i1],c1,m_pLabels[i2],c2,m_pLabels[i2],i2+1,d);
180
bool CTimeStep::MirrorBond(int i1, int i2)
189
while (m_vaCoords[i1][0]-m_vaCoords[i2][0] > g_fBoxX/2)
191
m_vaCoords[i2][0] += g_fBoxX;
194
while (m_vaCoords[i2][0]-m_vaCoords[i1][0] > g_fBoxX/2)
196
m_vaCoords[i2][0] -= g_fBoxX;
203
while (m_vaCoords[i1][1]-m_vaCoords[i2][1] > g_fBoxY/2)
205
m_vaCoords[i2][1] += g_fBoxY;
208
while (m_vaCoords[i2][1]-m_vaCoords[i1][1] > g_fBoxY/2)
210
m_vaCoords[i2][1] -= g_fBoxY;
217
while (m_vaCoords[i1][2]-m_vaCoords[i2][2] > g_fBoxZ/2)
219
m_vaCoords[i2][2] += g_fBoxZ;
222
while (m_vaCoords[i2][2]-m_vaCoords[i1][2] > g_fBoxZ/2)
224
m_vaCoords[i2][2] -= g_fBoxZ;
239
void CTimeStep::RECURSION_ScanMolecules(int i, CxByteArray *ta, CSingleMolecule *sm, int depth, int *stack, unsigned long bmask, bool w)
247
// mprintf(" Rekursion fuer Atom %d.\n",i+1);
249
// mprintf("Depth=%d, i=%d.\n",depth,i);
253
for (z=1;z<depth;z++)
255
if ((bmask & (int)pow(2.0,z)) != 0)
262
mprintf(WHITE,"|--");
263
else mprintf(WHITE,"`--");
265
mprintf(CYAN,"%s",((CAtom*)g_oaAtoms[g_baAtomIndex[i]])->m_sName);
270
g_laAtomSMIndex[i] = (unsigned long)g_oaSingleMolecules.GetSize()-1;
272
// mprintf(" sm->m_baAtomIndex.GetSize()=%d\n",sm->m_baAtomIndex.GetSize());
273
for (z=0;z<sm->m_baAtomIndex.GetSize();z++)
275
if (sm->m_baAtomIndex[z] == g_baAtomIndex[i])
277
try { ma = new CMolAtom(); } catch(...) { ma = NULL; }
278
if (ma == NULL) NewException((double)sizeof(CMolAtom),__FILE__,__LINE__,__PRETTY_FUNCTION__);
282
sm->m_oaMolAtoms.Add(ma);
287
try { ma = new CMolAtom(); } catch(...) { ma = NULL; }
288
if (ma == NULL) NewException((double)sizeof(CMolAtom),__FILE__,__LINE__,__PRETTY_FUNCTION__);
291
ma->m_iType = sm->m_baAtomIndex.GetSize();
293
sm->m_oaMolAtoms.Add(ma);
295
sm->m_baAtomIndex.Add(g_baAtomIndex[i]);
300
if ((m_iConnectedAtoms % m_iGesAtomModulo)==0)
304
for (z=0;z<(long)m_iGesAtomCount;z++) // Schon mal alle Nachbarn raussuchen
308
if (((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_bExclude)
310
if (BondRange(i,z,&f))
314
if ((depth > 0) && (z != stack[depth-1]))
316
if (sm->m_oaRings.GetSize() < 100)
320
mprintf(GREEN," <-- Ring closure: ");
321
mprintf("%s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[stack[depth]]])->m_sName,stack[depth]+1);
324
try { wa = new CxIntArray("CTimeStep::RECURSION_ScanMolecules():wa"); } catch(...) { wa = NULL; }
325
if (wa == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
327
sm->m_oaRings.Add(wa);
328
wa->Add(stack[depth]);
330
while ((stack[z2] != z) && (z2 >= 0))
334
mprintf(" - %s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[stack[z2]]])->m_sName,stack[z2]+1);
339
mprintf(" - %s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_sName,z+1);
340
} else if (!m_bAbortRing)
343
eprintf("\n### More than 100 rings, aborting ring system scan for molecule %d.",sm->m_iIndex+1);
348
/* for (z2=0;z2<g_waBondBlackList.GetSize();z2+=2)
349
if (((g_waBondBlackList[z2] == i) && (g_waBondBlackList[z2+1] == z)) ||
350
((g_waBondBlackList[z2] == z) && (g_waBondBlackList[z2+1] == i)))
355
for (z2=1;z2<depth+1;z2++)
357
if ((bmask & (int)pow(2,z2)) != 0)
362
mprintf(WHITE,"|--");
364
mprintf("%s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_sName,z+1);
365
mprintf(GREEN," <-- This bond has been broken, skipping.\n");
367
g_iBondBlackListUsed++;
372
if (g_iCloseAtomCounter < 25)
373
eprintf("\n### The atoms %s(%d) and %s(%d) are VERY close to each other. (Distance=%.4f pm)",((CAtom*)g_oaAtoms[g_baAtomIndex[i]])->m_sName,i+1,((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_sName,z+1,f);
374
else if (g_iCloseAtomCounter == 25)
375
eprintf("\n### Suppressing further \"atoms close to each other\" warnings.");
377
g_iCloseAtomCounter++;
381
if (nbs >= MAX_BONDS)
383
eprintf("\n### Atom %s(%d) has more than %d bonds. Ignoring further bonds (defined via MAX_BONDS in config.h).",((CAtom*)g_oaAtoms[g_baAtomIndex[i]])->m_sName,i+1,MAX_BONDS);
391
for (z=0;z<nbs;z++) // Fuer das aktuelle Atom z2 alle Nachbarn durchgehen
393
for (z2=0;z2<g_laBondBlackList.GetSize();z2+=2)
395
if (((g_laBondBlackList[z2] == i) && (g_laBondBlackList[z2+1] == nblist[z])) ||
396
((g_laBondBlackList[z2] == nblist[z]) && (g_laBondBlackList[z2+1] == i)))
401
for (z2=1;z2<depth+1;z2++)
403
if ((bmask & (int)pow(2.0,z2)) != 0)
408
mprintf(WHITE,"|--");
409
else mprintf(WHITE,"`--");
410
mprintf(CYAN,"%s",((CAtom*)g_oaAtoms[g_baAtomIndex[nblist[z]]])->m_sName);
411
mprintf("(%d)",nblist[z]+1);
412
mprintf(GREEN," <-- This bond shall be broken, skipping.\n");
414
g_iBondBlackListUsed++;
419
sm->m_laBonds.Add(i);
420
sm->m_laBonds.Add(nblist[z]);
422
if ((*ta)[nblist[z]] == 0) // Der Nachbar ist noch immer frei
425
bmask -= (int)pow(2.0,depth+1);
426
RECURSION_ScanMolecules(nblist[z],ta,sm,depth+1,stack,bmask,(z+1==nbs)?false:true);
427
} else // Ringschluss
432
for (z2=1;z2<depth+1;z2++)
434
if ((bmask & (int)pow(2.0,z2)) != 0)
439
mprintf(WHITE,"|--");
440
else mprintf(WHITE,"`--");
441
mprintf(CYAN,"%s",((CAtom*)g_oaAtoms[g_baAtomIndex[nblist[z]]])->m_sName);
442
mprintf("(%d)",nblist[z]+1);
443
mprintf(GREEN," <-- Ring closure\n");
452
void CTimeStep::BuildAtomIndex()
459
g_baAtomIndex.SetSize(m_iGesAtomCount);
460
for (z=0;z<(long)m_iGesAtomCount;z++)
462
strcpy(buf,(char*)m_paLabels[z]);
464
for (z2=0;z2<g_oaAtoms.GetSize();z2++)
466
if (mystricmp(buf,((CAtom*)g_oaAtoms[z2])->m_sName)==0)
468
at = (CAtom*)g_oaAtoms[z2];
469
// mprintf("Atom %d: Type %d (%s).\n",z,z2,at->m_sName);
470
while (at->m_pMergedTo != NULL)
472
at = at->m_pMergedTo;
473
// mprintf(" ...was merged to %s.\n",at->m_sName);
475
// mprintf(" Index is %d.\n",at->m_iIndex);
476
g_baAtomIndex[z] = (unsigned char)at->m_iIndex;
480
g_baAtomIndex[z] = 255;
481
eprintf("Error: CTimeStep::BuildAtomIndex(): Atom type \"%s\" not known.\n",buf);
488
bool CTimeStep::ScanMolecules()
491
int z, z2, z3, z4, z5, i, i2, ti, ti2, i1;
493
CSingleMolecule *sm, *sm2;
494
CxIntArray *wa, *waz2, *waz3, *waneu;
496
CMolAtom *ma, *ma2, *ma3;
497
CMolBond *bond, *bond2;
499
CMolAngle *angle, *angle2;
510
try { stack = new int[g_iGesAtomCount]; } catch(...) { stack = NULL; }
511
if (stack == NULL) NewException((double)g_iGesAtomCount*sizeof(int),__FILE__,__LINE__,__PRETTY_FUNCTION__);
514
for (z=0;z<g_oaAtoms.GetSize();z++)
516
if (z == g_iVirtAtomType)
518
at = (CAtom*)g_oaAtoms[z];
519
if (at->m_pMergedTo != NULL)
521
if (at->m_pElement->m_fRadius == 0)
528
at->m_bExclude = AskYesNo(" Atom type \"%s\" has bond radius 0. Exclude it from the system (y/n)? [yes] ",true,at->m_sName);
529
// if (!at->m_bExclude)
530
// at->m_pElement->m_fRadius = AskFloat_ND(" Please enter covalent bond radius for %s (in pm): ",at->m_sName);
534
ta.SetSize(g_iGesAtomCount);
535
g_laAtomSMIndex.SetSize(g_iGesAtomCount);
536
for (z=0;z<g_iGesAtomCount;z++)
539
g_laAtomSMIndex[z] = -1;
541
g_iBondBlackListUsed = 0;
542
g_oaSingleMolecules.RemoveAll();
543
g_oaMolecules.RemoveAll();
544
m_iConnectedAtoms = 0;
545
m_iGesAtomModulo = (m_iGesAtomCount / 60)+1;
546
if (g_iScanMolStep == -1)
548
mprintf(WHITE,"\n Skipping molecule recognition, using atoms as molecules...\n\n");
549
for (z=0;z<(long)m_iGesAtomCount;z++)
551
if (((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_bExclude)
554
try { sm = new CSingleMolecule(); } catch(...) { sm = NULL; }
555
if (sm == NULL) NewException((double)sizeof(CSingleMolecule),__FILE__,__LINE__,__PRETTY_FUNCTION__);
557
sm->m_iIndex = g_oaSingleMolecules.GetSize();
559
g_oaSingleMolecules.Add(sm);
561
g_laAtomSMIndex[z] = (unsigned long)g_oaSingleMolecules.GetSize()-1;
563
try { ma = new CMolAtom(); } catch(...) { ma = NULL; }
564
if (ma == NULL) NewException((double)sizeof(CMolAtom),__FILE__,__LINE__,__PRETTY_FUNCTION__);
567
ma->m_iType = sm->m_baAtomIndex.GetSize();
569
sm->m_oaMolAtoms.Add(ma);
570
sm->m_baAtomIndex.Add(g_baAtomIndex[z]);
572
mprintf(" %d molecules found.\n\n",g_oaSingleMolecules.GetSize());
577
mprintf(WHITE,"\n Molecule recognition...\n\n");
578
mprintf(WHITE,">>> Output of the molecule tree >>>\n");
579
} else mprintf("\n Molecule recognition [");
581
for (z=0;z<(long)m_iGesAtomCount;z++)
583
if (ta[z] != 0) // Dieses Atom wurde bereits in irgendein Molekuel eingebaut
585
// mprintf("> Atom %d: Schon vergeben.\n",z+1);
588
// mprintf("# Atom %d: Starte Rekursion.\n",z+1);
590
if (((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_bExclude)
593
try { sm = new CSingleMolecule(); } catch(...) { sm = NULL; }
594
if (sm == NULL) NewException((double)sizeof(CSingleMolecule),__FILE__,__LINE__,__PRETTY_FUNCTION__);
596
sm->m_iIndex = g_oaSingleMolecules.GetSize();
598
g_oaSingleMolecules.Add(sm);
600
// sm->m_iAtomGes = 0;
601
/* for (z2=0;z2<16;z2++)
602
sm->m_iAtomCount[z2] = 0;
603
sm->m_iElements = 0;*/
605
mprintf(YELLOW,"\nThe next molecule starts with %s(%d):\n",m_paLabels[z],z+1);
607
m_bAbortRing = false;
609
RECURSION_ScanMolecules(z,&ta,sm,0,stack,0xFFFFFFFF,true);
611
// printf("%d Atome in diesem Molekuel.\n",g_pSingleMolecules[g_oaSingleMolecules.GetSize()].AtomGes);
613
// g_oaSingleMolecules.GetSize()++;
617
mprintf(WHITE,"\n<<< Output of the molecule tree <<<\n\n");
618
mprintf("%d molecules found.\n\n",g_oaSingleMolecules.GetSize());
619
} else mprintf("]\n\n %d molecules found.\n\n",g_oaSingleMolecules.GetSize());
622
if (g_iCloseAtomCounter != 0)
624
mprintf(RED,"\n*** Warning: ");
625
mprintf("Some of the atoms were found to be very close to each other (distance < 50 pm).\n");
626
mprintf(" This usually indicates a problem, e.g. an incorrect cell vector.\n\n");
627
if (!AskYesNo(" Continue with molecule recognition anyways (y/n)? [yes] ",true))
632
mprintf(" Sorting atom types...\n");
633
SortSingleMolAtomTypes();
638
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
641
((CSingleMolecule*)g_oaSingleMolecules[z])->Dump();
644
mprintf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");*/
647
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
650
((CSingleMolecule*)g_oaSingleMolecules[z])->Dump();
652
mprintf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");*/
653
if (g_iBondBlackListUsed != 0)
654
mprintf(" %d bonds have been broken.\n",g_iBondBlackListUsed);
656
/* if (g_oaSingleMolecules.GetSize() >= 4096)
658
mprintf("\n>>> Mehr als 4096 Molekuele! Dies wird nicht unterstuetzt. <<<\n\n");
659
// g_oaSingleMolecules.GetSize() = 4096;
662
mprintf(" Setting up bond lists...\n");
663
// Die Bindungen in m_oaMolAtoms aufbauen
664
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
666
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
667
for (z2=0;z2<sm->m_laBonds.GetSize()/2;z2++)
669
i = sm->m_laBonds[z2*2];
670
i2 = sm->m_laBonds[z2*2+1];
672
for (z3=0;z3<sm->m_oaMolAtoms.GetSize();z3++)
674
if (((CMolAtom*)sm->m_oaMolAtoms[z3])->m_iOffset == i)
682
eprintf("CTimeStep::ScanMolecules(): Atom 1 of bond (%d) not found.\n",i);
686
for (z3=0;z3<sm->m_oaMolAtoms.GetSize();z3++)
688
if (((CMolAtom*)sm->m_oaMolAtoms[z3])->m_iOffset == i2)
696
eprintf("CTimeStep::ScanMolecules(): Atom 2 of bond (%d) not found.\n",i2);
699
((CMolAtom*)sm->m_oaMolAtoms[ti])->m_oaBonds.Add((CMolAtom*)sm->m_oaMolAtoms[ti2]);
700
((CMolAtom*)sm->m_oaMolAtoms[ti2])->m_oaBonds.Add((CMolAtom*)sm->m_oaMolAtoms[ti]);
704
// Die AtomCodes berechnen
705
mprintf(" Building atom codes...\n");
706
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
708
// mprintf("Molecule %d: ",z+1);
709
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
711
mprintf(YELLOW,"\n*** Singlemolecule %d ***\n\n",z+1);
712
sm->BuildAtomCodes();
715
mprintf(" Creating topological atom order...\n");
716
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
718
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
719
for (z2=0;z2<sm->m_baAtomIndex.GetSize();z2++)
721
try { wa = new CxIntArray("CTimeStep::ScanMolecules():wa"); } catch(...) { wa = NULL; }
722
if (wa == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
724
sm->m_oaAtomOffset.Add(wa);
725
for (z3=0;z3<sm->m_oaMolAtoms.GetSize();z3++)
727
ma = (CMolAtom*)sm->m_oaMolAtoms[z3];
728
if (ma->m_iType != z2)
730
ma->m_iNumber = wa->GetSize();
731
wa->Add(ma->m_iOffset);
736
mprintf(" Creating bond list...\n");
737
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
739
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
740
// mprintf("%d:\n",z+1);
741
for (z2=0;z2<sm->m_oaMolAtoms.GetSize();z2++)
743
ma = (CMolAtom*)sm->m_oaMolAtoms[z2];
744
for (z3=0;z3<ma->m_oaBonds.GetSize();z3++)
746
ma2 = (CMolAtom*)ma->m_oaBonds[z3];
747
if (ma2->m_iMolAtomNumber < z2 /* == ma->m_iMolAtomNumber*/)
750
// mprintf(" %s%2d <--> %s%2d\n",((CAtom*)g_oaAtoms[sm->m_baAtomIndex[ma->m_iType]])->m_sName,ma->m_iNumber+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[ma2->m_iType]])->m_sName,ma2->m_iNumber+1);
752
try { bond = new CMolBond(); } catch(...) { bond = NULL; }
753
if (bond == NULL) NewException((double)sizeof(CMolBond),__FILE__,__LINE__,__PRETTY_FUNCTION__);
755
bond->m_iAtom[0] = ma->m_iNumber;
756
bond->m_iAtom[1] = ma2->m_iNumber;
757
bond->m_iAtomType[0] = ma->m_iType;
758
bond->m_iAtomType[1] = ma2->m_iType;
759
bond->m_iMolAtom[0] = z2;
760
bond->m_iMolAtom[1] = ma2->m_iMolAtomNumber;
761
bond->m_iAtomOffset[0] = ma->m_iOffset;
762
bond->m_iAtomOffset[1] = ma2->m_iOffset;
763
sm->m_oaBonds.Add(bond);
767
mprintf(" %d Bonds added.\n",oatemp.GetSize());*/
768
for (z2=0;z2<sm->m_oaBonds.GetSize();z2++)
770
bond = (CMolBond*)sm->m_oaBonds[z2];
771
for (z3=0;z3<sm->m_oaBondGroups.GetSize();z3++)
773
bg = (CMolBondGroup*)sm->m_oaBondGroups[z3];
774
for (z4=0;z4<bg->m_oaBonds.GetSize();z4++)
776
bond2 = (CMolBond*)bg->m_oaBonds[z4];
777
if (((((CMolAtom*)sm->m_oaMolAtoms[bond->m_iMolAtom[0]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[bond2->m_iMolAtom[0]])->m_fAtomCode) &&
778
(((CMolAtom*)sm->m_oaMolAtoms[bond->m_iMolAtom[1]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[bond2->m_iMolAtom[1]])->m_fAtomCode)) ||
779
((((CMolAtom*)sm->m_oaMolAtoms[bond->m_iMolAtom[0]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[bond2->m_iMolAtom[1]])->m_fAtomCode) &&
780
(((CMolAtom*)sm->m_oaMolAtoms[bond->m_iMolAtom[1]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[bond2->m_iMolAtom[0]])->m_fAtomCode)))
782
bg->m_oaBonds.Add(bond);
788
try { bg = new CMolBondGroup(); } catch(...) { bg = NULL; }
789
if (bg == NULL) NewException((double)sizeof(CMolBondGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
791
bg->m_oaBonds.Add(bond);
792
sm->m_oaBondGroups.Add(bg);
797
mprintf(" %d Bond groups found:\n",sm->m_oaBondGroups.GetSize());
798
for (z2=0;z2<sm->m_oaBondGroups.GetSize();z2++)
801
bg = (CMolBondGroup*)sm->m_oaBondGroups[z2];
802
for (z3=0;z3<bg->m_oaBonds.GetSize();z3++)
804
bond = (CMolBond*)bg->m_oaBonds[z3];
805
mprintf("%s%2d <--> %s%2d",((CAtom*)g_oaAtoms[sm->m_baAtomIndex[bond->m_iAtomType[0]]])->m_sName,bond->m_iAtom[0]+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[bond->m_iAtomType[1]]])->m_sName,bond->m_iAtom[1]+1);
806
if (z3 < bg->m_oaBonds.GetSize()-1)
814
mprintf(" Creating angle list...\n");
815
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
817
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
818
// mprintf("%d:\n",z+1);
819
for (z2=0;z2<sm->m_oaMolAtoms.GetSize();z2++)
821
ma = (CMolAtom*)sm->m_oaMolAtoms[z2];
822
for (z3=0;z3<ma->m_oaBonds.GetSize();z3++)
824
ma2 = (CMolAtom*)ma->m_oaBonds[z3];
825
for (z4=z3+1;z4<ma->m_oaBonds.GetSize();z4++)
827
ma3 = (CMolAtom*)ma->m_oaBonds[z4];
828
// mprintf(" (%s%2d, %s%2d, %s%2d)\n",((CAtom*)g_oaAtoms[sm->m_baAtomIndex[ma2->m_iType]])->m_sName,ma2->m_iNumber+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[ma->m_iType]])->m_sName,ma->m_iNumber+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[ma3->m_iType]])->m_sName,ma3->m_iNumber+1);
830
try { angle = new CMolAngle(); } catch(...) { angle = NULL; }
831
if (angle == NULL) NewException((double)sizeof(CMolAngle),__FILE__,__LINE__,__PRETTY_FUNCTION__);
833
angle->m_iAtom[0] = ma2->m_iNumber;
834
angle->m_iAtom[1] = ma->m_iNumber;
835
angle->m_iAtom[2] = ma3->m_iNumber;
836
angle->m_iAtomType[0] = ma2->m_iType;
837
angle->m_iAtomType[1] = ma->m_iType;
838
angle->m_iAtomType[2] = ma3->m_iType;
839
angle->m_iMolAtom[0] = ma2->m_iMolAtomNumber;
840
angle->m_iMolAtom[1] = z2;
841
angle->m_iMolAtom[2] = ma3->m_iMolAtomNumber;
842
angle->m_iAtomOffset[0] = ma2->m_iOffset;
843
angle->m_iAtomOffset[1] = ma->m_iOffset;
844
angle->m_iAtomOffset[2] = ma3->m_iOffset;
845
sm->m_oaAngles.Add(angle);
850
mprintf(" %d Angles added.\n",oatemp.GetSize());*/
851
if (sm->m_oaAngles.GetSize() > 1000)
853
tfs = sm->m_oaAngles.GetSize() / 50.0;
854
for (z2=0;z2<sm->m_oaAngles.GetSize();z2++)
856
if (sm->m_oaAngles.GetSize() > 1000)
857
if (fmod(z2,tfs) < 1)
859
angle = (CMolAngle*)sm->m_oaAngles[z2];
860
for (z3=0;z3<sm->m_oaAngleGroups.GetSize();z3++)
862
ag = (CMolAngleGroup*)sm->m_oaAngleGroups[z3];
863
for (z4=0;z4<ag->m_oaAngles.GetSize();z4++)
865
angle2 = (CMolAngle*)ag->m_oaAngles[z4];
866
if (( ((CMolAtom*)sm->m_oaMolAtoms[angle->m_iMolAtom[1]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[angle2->m_iMolAtom[1]])->m_fAtomCode) &&
867
(((( ((CMolAtom*)sm->m_oaMolAtoms[angle->m_iMolAtom[0]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[angle2->m_iMolAtom[0]])->m_fAtomCode) &&
868
( ((CMolAtom*)sm->m_oaMolAtoms[angle->m_iMolAtom[2]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[angle2->m_iMolAtom[2]])->m_fAtomCode))) ||
869
(( ((CMolAtom*)sm->m_oaMolAtoms[angle->m_iMolAtom[0]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[angle2->m_iMolAtom[2]])->m_fAtomCode) &&
870
( ((CMolAtom*)sm->m_oaMolAtoms[angle->m_iMolAtom[2]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[angle2->m_iMolAtom[0]])->m_fAtomCode))))
872
ag->m_oaAngles.Add(angle);
878
try { ag = new CMolAngleGroup(); } catch(...) { ag = NULL; }
879
if (ag == NULL) NewException((double)sizeof(CMolAngleGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
881
ag->m_oaAngles.Add(angle);
882
sm->m_oaAngleGroups.Add(ag);
885
if (sm->m_oaAngles.GetSize() > 1000)
886
mprintf(WHITE,"]\n");
889
mprintf(" %d Angle groups found:\n",sm->m_oaAngleGroups.GetSize());
890
for (z2=0;z2<sm->m_oaAngleGroups.GetSize();z2++)
893
ag = (CMolAngleGroup*)sm->m_oaAngleGroups[z2];
894
for (z3=0;z3<ag->m_oaAngles.GetSize();z3++)
896
angle = (CMolAngle*)ag->m_oaAngles[z3];
897
mprintf(" (%s%2d, %s%2d, %s%2d)",((CAtom*)g_oaAtoms[sm->m_baAtomIndex[angle->m_iAtomType[0]]])->m_sName,angle->m_iAtom[0]+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[angle->m_iAtomType[1]]])->m_sName,angle->m_iAtom[1]+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[angle->m_iAtomType[2]]])->m_sName,angle->m_iAtom[2]+1);
898
if (z3 < ag->m_oaAngles.GetSize()-1)
906
mprintf(" Grouping together equivalent molecules...\n");
907
for (z=0;z<g_oaSingleMolecules.GetSize();z++) // Alle Molekuelvertreter durchgehen
909
// mprintf("Pruefe SM %d...\n",z+1);
910
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
911
for (z2=0;z2<g_oaMolecules.GetSize();z2++) // Alle schon vorhandenen Molekueltemplates durchgehen
913
m = (CMolecule*)g_oaMolecules[z2];
914
sm2 = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[0]];
915
/* if (m->m_baAtomIndex.GetSize() != sm->m_baAtomIndex.GetSize())
916
goto _cont; // Nich die Gleiche Anzahl verschiedener Elemente -> Keine Uebereinstimmung
917
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
919
if (m->m_baAtomIndex[z3] != sm->m_baAtomIndex[z3])
920
goto _cont; // Elemente an Position z3 unterscheiden sich -> keine Uebereinstimmung
921
if (m->m_waAtomCount[z3] != ((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize())
922
goto _cont; // Anzahl an Atomen dieser Elementsorte unterscheidet sich -> Keine Uebereinstimmung*/
923
// mprintf(" Stimmt mit M%d ueberein.\n",z2);
924
// ((CMolecule*)g_oaMolecules[z2])->Count++;
925
// g_pSingleMolecules[z].m_iMoleculeOffset = z2;
927
if (sm->m_oaMolAtoms.GetSize() != sm2->m_oaMolAtoms.GetSize())
929
for (z3=0;z3<sm->m_oaMolAtoms.GetSize();z3++)
930
if (((CMolAtom*)sm->m_oaMolAtoms[z3])->m_fAtomCode != ((CMolAtom*)sm2->m_oaMolAtoms[z3])->m_fAtomCode)
932
sm->m_iMolSMIndex = m->m_laSingleMolIndex.GetSize();
933
m->m_laSingleMolIndex.Add(z);
934
// sm->m_iMolType = z2;
939
try { m = new CMolecule(); } catch(...) { m = NULL; }
940
if (m == NULL) NewException((double)sizeof(CMolecule),__FILE__,__LINE__,__PRETTY_FUNCTION__);
942
g_oaMolecules.Add(m);
943
// m->Count = 1; // Neues Molekueltemplate hinzufuegen
944
// m->Elements = ((CSingleMolecule*)g_oaSingleMolecules[z])->m_iElements;
947
for (z2=0;z2<sm->m_oaAtomOffset.GetSize();z2++)
949
m->m_iAtomGes += ((CxIntArray*)sm->m_oaAtomOffset[z2])->GetSize();
950
f += ((CAtom*)g_oaAtoms[sm->m_baAtomIndex[z2]])->m_pElement->m_fMass * ((CxIntArray*)sm->m_oaAtomOffset[z2])->GetSize();
952
m->m_iAtomGesNoVirt = m->m_iAtomGes;
954
((CSingleMolecule*)g_oaSingleMolecules[z])->m_iMolType = g_oaMolecules.GetSize()-1;
955
for (z2=0;z2<((CSingleMolecule*)g_oaSingleMolecules[z])->m_baAtomIndex.GetSize();z2++)
957
m->m_baAtomIndex.Add(((CSingleMolecule*)g_oaSingleMolecules[z])->m_baAtomIndex[z2]);
958
m->m_waAtomCount.Add(((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[z])->m_oaAtomOffset[z2])->GetSize());
959
// m->AtomCount[z2] = ((CSingleMolecule*)g_oaSingleMolecules[z])->m_iAtomCount[z2];
961
sm->m_iMolSMIndex = m->m_laSingleMolIndex.GetSize();
962
m->m_laSingleMolIndex.Add(z);
963
// g_pSingleMolecules[z].m_iMoleculeOffset = g_oaMolecules.GetSize();
966
// Standardmaessig geom. Zentrum als Dipolzentrum
967
m->m_iDipoleCenterType = m->m_baAtomIndex.GetSize();
968
m->m_iDipoleCenterIndex = 0;
970
// mprintf("### Erzeuge neues Molekuel %d \"%s\".\n",g_oaMolecules.GetSize(),m->Name);
971
// g_oaMolecules.GetSize()++;
974
mprintf(" Found %d unique molecule types.\n",g_oaMolecules.GetSize());
976
// Sort by molecular mass
977
mprintf(" Sorting molecule types by molecular mass...\n");
978
for (z=0;z<g_oaMolecules.GetSize();z++)
980
// mprintf("@ z=%d\n",z);
983
for (z2=z;z2<g_oaMolecules.GetSize();z2++)
985
// mprintf("@ z2=%d\n",z2);
986
if (((CMolecule*)g_oaMolecules[z2])->m_fMass > f)
988
// mprintf("@ %f > %f --> z3 = %d\n",((CMolecule*)g_oaMolecules[z2])->m_fMass,f,z2);
989
f = ((CMolecule*)g_oaMolecules[z2])->m_fMass;
997
// mprintf("@ Swapping %d with %d.\n",z,z3);
998
m = (CMolecule*)g_oaMolecules[z3];
999
g_oaMolecules[z3] = g_oaMolecules[z];
1000
g_oaMolecules[z] = m;
1004
for (z=0;z<g_oaMolecules.GetSize();z++)
1006
((CMolecule*)g_oaMolecules[z])->m_iIndex = z;
1007
for (z2=0;z2<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z2++)
1008
((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[z2]])->m_iMolType = z;
1012
/* for (z=0;z<g_oaMolecules.GetSize();z++)
1014
m = (CMolecule*)g_oaMolecules[z];
1015
sm = (CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[0]];
1016
mprintf("Molecule %d Ring systems:\n",z+1);
1017
for (z2=0;z2<sm->m_oaRings.GetSize();z2++)
1019
wa = (CxIntArray*)sm->m_oaRings[z2];
1020
mprintf(" - Ring %d: ",z2+1);
1021
for (z3=0;z3<wa->GetSize();z3++)
1023
mprintf("%d",(*wa)[z3]);
1024
if (z3+1 < wa->GetSize())
1033
for (z=0;z<g_oaMolecules.GetSize();z++)
1035
sm = (CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[0]];
1036
ti += sm->m_oaRings.GetSize();
1039
mprintf(" Found %d rings.\n",ti);
1042
mprintf(" Refining ring systems...\n");
1044
try { wa = new CxIntArray("CTimeStep::ScanMolecules():wa"); } catch(...) { wa = NULL; }
1045
if (wa == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1047
// Process ring systems
1048
for (z=0;z<g_oaMolecules.GetSize();z++)
1050
m = (CMolecule*)g_oaMolecules[z];
1051
sm = (CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[0]];
1052
if (sm->m_oaRings.GetSize() > 100)
1054
eprintf(" More than 100 rings in molecule %d, skipping refinement. Ring system may be improper.\n",z+1);
1062
eprintf(" Too many iterations in molecule %d, aborting refinement. Ring system may be improper.\n",z+1);
1065
// mprintf("### again\n");
1066
for (z2=0;z2<sm->m_oaRings.GetSize();z2++)
1068
waz2 = (CxIntArray*)sm->m_oaRings[z2];
1069
for (z3=z2+1;z3<sm->m_oaRings.GetSize();z3++)
1071
waz3 = (CxIntArray*)sm->m_oaRings[z3];
1073
// mprintf("*A* Checking if %d(%d) contains %d(%d)...\n",z2+1,waz2->GetSize(),z3+1,waz3->GetSize());
1074
// Check if waz2 contains waz3
1075
wa->SetSize(waz2->GetSize());
1076
for (z4=0;z4<waz2->GetSize();z4++)
1078
for (z4=0;z4<waz3->GetSize();z4++)
1080
for (z5=0;z5<waz2->GetSize();z5++)
1082
if ((*waz3)[z4] == (*waz2)[z5])
1091
// mprintf(" Yes!\n");
1093
try { waneu = new CxIntArray("CTimeStep::ScanMolecules():waneu"); } catch(...) { waneu = NULL; }
1094
if (waneu == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1096
for (z4=0;z4<waz2->GetSize();z4++)
1100
if (((*wa)[z4] == 0) || ((*wa)[z4+1] == 0) || ((*wa)[waz2->GetSize()-1] == 0))
1101
waneu->Add((*waz2)[z4]);
1102
} else if (z4 == waz2->GetSize()-1)
1104
if (((*wa)[z4] == 0) || ((*wa)[z4-1] == 0) || ((*wa)[0] == 0))
1105
waneu->Add((*waz2)[z4]);
1108
if (((*wa)[z4] == 0) || ((*wa)[z4+1] == 0) || ((*wa)[z4-1] == 0))
1109
waneu->Add((*waz2)[z4]);
1112
// mprintf(" Took %d from %d atoms from waz2.\n",waneu->GetSize(),waz2->GetSize());
1113
i1 = waz2->GetSize();
1115
sm->m_oaRings[z2] = waneu;
1116
if (waneu->GetSize() != i1)
1120
// mprintf("*B* Checking if %d contains %d...\n",z3+1,z2+1);
1121
// Check if waz3 contains waz2
1122
wa->SetSize(waz3->GetSize());
1123
for (z4=0;z4<waz3->GetSize();z4++)
1125
for (z4=0;z4<waz2->GetSize();z4++)
1127
for (z5=0;z5<waz3->GetSize();z5++)
1129
if ((*waz2)[z4] == (*waz3)[z5])
1138
// mprintf(" Yes!\n");
1140
try { waneu = new CxIntArray("CTimeStep::ScanMolecules():waneu"); } catch(...) { waneu = NULL; }
1141
if (waneu == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1143
for (z4=0;z4<waz3->GetSize();z4++)
1147
if (((*wa)[z4] == 0) || ((*wa)[z4+1] == 0) || ((*wa)[waz3->GetSize()-1] == 0))
1148
waneu->Add((*waz3)[z4]);
1149
} else if (z4 == waz3->GetSize()-1)
1151
if (((*wa)[z4] == 0) || ((*wa)[z4-1] == 0) || ((*wa)[0] == 0))
1152
waneu->Add((*waz3)[z4]);
1155
if (((*wa)[z4] == 0) || ((*wa)[z4+1] == 0) || ((*wa)[z4-1] == 0))
1156
waneu->Add((*waz3)[z4]);
1159
// mprintf(" Took %d from %d atoms from waz3.\n",waneu->GetSize(),waz3->GetSize());
1160
i1 = waz3->GetSize();
1162
sm->m_oaRings[z3] = waneu;
1163
if (waneu->GetSize() != i1)
1171
mprintf(" Assigning ring systems to molecule types...\n");
1172
for (z=0;z<g_oaMolecules.GetSize();z++)
1174
m = (CMolecule*)g_oaMolecules[z];
1175
sm = (CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[0]];
1176
for (z2=0;z2<sm->m_oaRings.GetSize();z2++)
1178
wa = (CxIntArray*)sm->m_oaRings[z2];
1180
try { waz2 = new CxIntArray("CTimeStep::ScanMolecules():waz2"); } catch(...) { waz2 = NULL; }
1181
if (waz2 == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1183
try { waz3 = new CxIntArray("CTimeStep::ScanMolecules():waz3"); } catch(...) { waz3 = NULL; }
1184
if (waz3 == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1186
m->m_oaRingAtomTypes.Add(waz2);
1187
m->m_oaRingAtoms.Add(waz3);
1188
for (z3=0;z3<wa->GetSize();z3++)
1190
for (z4=0;z4<sm->m_baAtomIndex.GetSize();z4++)
1192
for (z5=0;z5<((CxIntArray*)sm->m_oaAtomOffset[z4])->GetSize();z5++)
1194
if (((CxIntArray*)sm->m_oaAtomOffset[z4])->GetAt(z5) == wa->GetAt(z3))
1207
mprintf(" Sorting rings by size...\n");
1208
for (z=0;z<g_oaMolecules.GetSize();z++)
1210
m = (CMolecule*)g_oaMolecules[z];
1212
for (z2=0;z2<m->m_oaRingAtoms.GetSize();z2++)
1216
for (z3=z2;z3<m->m_oaRingAtoms.GetSize();z3++)
1218
if (((CxIntArray*)m->m_oaRingAtoms[z3])->GetSize() > i1)
1220
i1 = ((CxIntArray*)m->m_oaRingAtoms[z3])->GetSize();
1224
if ((ti != -1) && (ti != z2))
1226
wa = (CxIntArray*)m->m_oaRingAtoms[z2];
1227
m->m_oaRingAtoms[z2] = m->m_oaRingAtoms[ti];
1228
m->m_oaRingAtoms[ti] = wa;
1229
wa = (CxIntArray*)m->m_oaRingAtomTypes[z2];
1230
m->m_oaRingAtomTypes[z2] = m->m_oaRingAtomTypes[ti];
1231
m->m_oaRingAtomTypes[ti] = wa;
1237
/* for (z=0;z<g_oaMolecules.GetSize();z++)
1239
m = (CMolecule*)g_oaMolecules[z];
1240
sm = (CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[0]];
1241
mprintf("Molecule %d Ring systems:\n",z+1);
1242
for (z2=0;z2<sm->m_oaRings.GetSize();z2++)
1244
wa = (CxIntArray*)sm->m_oaRings[z2];
1245
mprintf(" - Ring %d: ",z2+1);
1246
for (z3=0;z3<wa->GetSize();z3++)
1248
mprintf("%d",(*wa)[z3]);
1249
if (z3+1 < wa->GetSize())
1257
/* mprintf("\n%d Molekuelsorten gefunden.\n",g_oaMolecules.GetSize());
1258
for (z=0;z<g_oaMolecules.GetSize();z++)
1259
mprintf("Molekuel \"%s\": %d Atome gesamt, %d mal in der Simulation.\n",g_pMolecules[z].Name,g_pMolecules[z].AtomGes,g_pMolecules[z].Count);
1262
for (z=0;z<g_oaMolecules.GetSize();z++)
1265
((CMolecule*)g_oaMolecules[z])->Dump();
1267
mprintf(" Molecule recognition finished.\n");
1273
void CTimeStep::RECURSION_MegaTree(int i, char *ta, int depth, unsigned long bmask, bool w, int *stack)
1277
int nblist[20], nbs;
1281
for (z=1;z<depth;z++)
1283
if ((bmask & (int)pow(2.0,z)) != 0)
1284
mprintf(WHITE,"| ");
1290
mprintf(WHITE,"|--");
1291
else mprintf(WHITE,"`--");
1293
mprintf("%s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[i]])->m_sName,i+1);
1295
for (z=0;z<(long)m_iGesAtomCount;z++) // Schon mal alle Nachbarn raussuchen
1299
if (BondRange(i,z,NULL))
1303
if ((depth > 0) && (z != stack[depth-1]))
1305
mprintf(GREEN," <-- Ring closure: ");
1306
mprintf("%s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[stack[depth]]])->m_sName,stack[depth]+1);
1308
while ((stack[z2] != z) && (z2 >= 0))
1310
mprintf(" - %s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[stack[z2]]])->m_sName,stack[z2]+1);
1313
mprintf(" - %s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_sName,z+1);
1314
// mprintf("Ringschluss! [d-1=%d,d=%d,i=%d] %s(%d)\n",stack[depth-1]+1,stack[depth]+1,i+1,((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_sName,z+1);
1323
for (z=0;z<nbs;z++) // Fuer das aktuelle Atom z2 alle Nachbarn finden
1325
if (ta[nblist[z]] != 0) // Der Nachbar wurde uns weggeschnappt -> Ringschluss
1327
for (z2=1;z2<depth+1;z2++)
1329
if ((bmask & (int)pow(2.0,z2)) != 0)
1330
mprintf(WHITE,"| ");
1334
mprintf(WHITE,"|--");
1335
else mprintf("`--");
1336
mprintf("%s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[nblist[z]]])->m_sName,nblist[z]+1);
1337
mprintf(GREEN," <-- Ring closure\n");
1341
bmask -= (int)pow(2.0,depth+1);
1342
RECURSION_MegaTree(nblist[z],ta,/*sm,*/depth+1,bmask,(z+1==nbs)?false:true,stack);
1349
void CTimeStep::PrintMegaTree()
1356
for (z=0;z<16384;z++)
1358
for (z=0;z<(long)m_iGesAtomCount;z++)
1360
if (ta[z] != 0) // Dieses Atom wurde bereits in irgendein Molekuel eingebaut
1362
mprintf(YELLOW,"\nThe next molecule starts with %s(%d):\n",m_paLabels[z],z+1);
1363
RECURSION_MegaTree(z,ta,0,0xFFFFFFFF,true,stack);
1370
void CTimeStep::PrintMatrix(bool onlyfirst, bool onlybind)
1373
int z, z2, z3, z4, z5, z6, z7, z8, ti, ti2;
1376
CxVector3 vec1, vec2;
1377
CSingleMolecule *sm;
1380
CxIntArray *wa, *wat;
1382
for (z=0;z<g_oaMolecules.GetSize();z++)
1384
m = (CMolecule*)g_oaMolecules[z];
1385
for (z6=0;z6<(onlyfirst?1:m->m_laSingleMolIndex.GetSize());z6++)
1387
mprintf(YELLOW,"\n*** Molecule %d: %s; Representant %d; Distances in pm ***\n",z+1,m->m_sName,z6+1);
1388
if ((m->m_baAtomIndex.GetSize() == 1) && (m->m_waAtomCount[0] == 1))
1390
mprintf("[only 1 Atom]\n");
1393
if (m->m_iAtomGes > 200)
1395
mprintf(WHITE,"\n This molecule has > 200 atoms. Output would flood the screen. Skipping.\n");
1400
if (m->m_oaRingAtoms.GetSize() != 0)
1401
mprintf(GREEN," (ring bonds are shown in green)\n");
1404
for (z2=0;z2<m->m_baAtomIndex.GetSize();z2++)
1406
if (noh) // Skip H atoms
1407
if (mystricmp(((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,"H") == 0)
1409
for (z3=0;z3<m->m_waAtomCount[z2];z3++)
1411
if (((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName[1] == 0)
1413
mprintf(WHITE,"%s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,z3+1);
1419
for (z2=0;z2<m->m_baAtomIndex.GetSize();z2++)
1421
if (noh) // Skip H atoms
1422
if (mystricmp(((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,"H") == 0)
1424
for (z3=0;z3<m->m_waAtomCount[z2];z3++)
1426
mprintf(WHITE,"%s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,z3+1);
1427
if (((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName[1] == 0)
1431
for (z4=0;z4<m->m_baAtomIndex.GetSize();z4++)
1433
if (noh) // Skip H atoms
1434
if (mystricmp(((CAtom*)g_oaAtoms[m->m_baAtomIndex[z4]])->m_sName,"H") == 0)
1436
for (z5=0;z5<m->m_waAtomCount[z4];z5++)
1438
if ((z2 == z4) && (z3 == z5))
1440
mprintf(BLUE,"*** ");
1443
ti = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z6]])->m_oaAtomOffset[z2])->GetAt(z3);
1444
vec1 = g_TimeStep.m_vaCoords[ti];
1445
ti2 = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z6]])->m_oaAtomOffset[z4])->GetAt(z5);
1446
vec2 = g_TimeStep.m_vaCoords[ti2];
1448
tf = vec1.GetLength();
1449
if ((g_TimeStep.BondRange(ti,ti2,NULL)) || (!onlybind))
1451
for (z8=0;z8<m->m_oaRingAtomTypes.GetSize();z8++)
1453
wat = (CxIntArray*)m->m_oaRingAtomTypes[z8];
1454
wa = (CxIntArray*)m->m_oaRingAtoms[z8];
1455
for (z7=0;z7<wa->GetSize();z7++)
1457
if (((*wat)[z7] == z2) && ((*wa)[z7] == z3))
1461
if (((*wat)[z7+1] == z4) && ((*wa)[z7+1] == z5))
1463
if (((*wat)[wa->GetSize()-1] == z4) && ((*wa)[wa->GetSize()-1] == z5))
1465
} else if (z7 == wa->GetSize()-1)
1467
if (((*wat)[0] == z4) && ((*wa)[0] == z5))
1469
if (((*wat)[z7-1] == z4) && ((*wa)[z7-1] == z5))
1473
if (((*wat)[z7+1] == z4) && ((*wa)[z7+1] == z5))
1475
if (((*wat)[z7-1] == z4) && ((*wa)[z7-1] == z5))
1481
mprintf("%3.0f ",tf);
1484
mprintf(GREEN,"%3.0f ",tf);
1485
} else mprintf(" - ");
1491
if ((!noh) && (m->m_iAtomGes > 30))
1493
mprintf(WHITE,"\n This was a very large molecule.\n Printing the matrix again without H atoms.\n");
1497
// if (((!onlyfirst) && ((z2 < ((CMolecule*)g_oaMolecules[z])->Elements-1) || (g_oaMolecules.GetSize()-1))) || (z < g_oaMolecules.GetSize()-1))
1501
if (m->m_oaRingAtoms.GetSize() != 0)
1504
for (z2=0;z2<m->m_oaRingAtoms.GetSize();z2++)
1506
mprintf(" %d-ring: ",((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize());
1507
if (((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize() > 20)
1509
for (z3=0;z3<5;z3++)
1511
mprintf("%s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[((CxIntArray*)m->m_oaRingAtomTypes[z2])->GetAt(z3)]])->m_sName,((CxIntArray*)m->m_oaRingAtoms[z2])->GetAt(z3)+1);
1512
if (z3+1 < ((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize())
1517
for (z3=((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize()-5;z3<((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize();z3++)
1519
mprintf("%s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[((CxIntArray*)m->m_oaRingAtomTypes[z2])->GetAt(z3)]])->m_sName,((CxIntArray*)m->m_oaRingAtoms[z2])->GetAt(z3)+1);
1520
if (z3+1 < ((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize())
1525
for (z3=0;z3<((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize();z3++)
1527
mprintf("%s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[((CxIntArray*)m->m_oaRingAtomTypes[z2])->GetAt(z3)]])->m_sName,((CxIntArray*)m->m_oaRingAtoms[z2])->GetAt(z3)+1);
1528
if (z3+1 < ((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize())
1535
mprintf(RED,"\n Only showing the first 100 rings.\n");
1542
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[0]];
1543
for (z2=0;z2<m->m_baAtomIndex.GetSize();z2++)
1547
for (z3=0;z3<sm->m_oaMolAtoms.GetSize();z3++)
1549
if (((CMolAtom*)sm->m_oaMolAtoms[z3])->m_iType != z2)
1552
ma = (CMolAtom*)sm->m_oaMolAtoms[z3];
1555
z4 = ma0->m_iNumber;
1556
if (ma->m_fAtomCode == ma0->m_fAtomCode)
1560
mprintf(", %s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,ma->m_iNumber+1);
1568
mprintf(" Atoms %s%d, %s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,z4+1,((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,ma->m_iNumber+1);
1573
mprintf(" are equivalent.\n");
1578
mprintf(" are equivalent.\n");
1585
void CTimeStep::Transform(const CxMatrix3 &mat)
1591
for (z=0;z<g_iGesVirtAtomCount;z++)
1593
// if (z < g_iGesAtomCount)
1594
// mprintf("@ %2d: ( %g | %g | %g ) --> ",z,m_vaCoords[z][0],m_vaCoords[z][1],m_vaCoords[z][2]);
1595
m_vaCoords[z] = mat * m_vaCoords[z];
1596
// if (z < g_iGesAtomCount)
1597
// mprintf("( %g | %g | %g )\n",m_vaCoords[z][0],m_vaCoords[z][1],m_vaCoords[z][2]);
1600
if (g_bUseVelocities)
1601
for (z=0;z<g_iGesVirtAtomCount;z++)
1602
m_vaVelocities[z] = mat * m_vaVelocities[z];
1605
for (z=0;z<g_iGesVirtAtomCount;z++)
1606
m_vaForces[z] = mat * m_vaForces[z];
1611
void CTimeStep::Transform(const CxDMatrix3 &mat)
1616
for (z=0;z<g_iGesVirtAtomCount;z++)
1617
m_vaCoords[z] = mat * m_vaCoords[z];
1619
if (g_bUseVelocities)
1620
for (z=0;z<g_iGesVirtAtomCount;z++)
1621
m_vaVelocities[z] = mat * m_vaVelocities[z];
1624
for (z=0;z<g_iGesVirtAtomCount;z++)
1625
m_vaForces[z] = mat * m_vaForces[z];
1630
void CTimeStep::Transform(const CxQuaternion &q)
1635
for (z=0;z<g_iGesVirtAtomCount;z++)
1636
m_vaCoords[z] = q.Transform(m_vaCoords[z]);
1638
if (g_bUseVelocities)
1639
for (z=0;z<g_iGesVirtAtomCount;z++)
1640
m_vaVelocities[z] = q.Transform(m_vaVelocities[z]);
1643
for (z=0;z<g_iGesVirtAtomCount;z++)
1644
m_vaForces[z] = q.Transform(m_vaForces[z]);
1649
void CTimeStep::SubVelocities(const CxVector3 &vec)
1654
for (z=0;z<g_iGesVirtAtomCount;z++)
1655
m_vaVelocities[z] -= vec;
1660
void CTimeStep::FoldMolecules()
1666
CSingleMolecule *sm;
1671
// mprintf("*** Fold ***\n");
1673
for (z=0;z<g_oaMolecules.GetSize();z++)
1675
m = (CMolecule*)g_oaMolecules[z];
1678
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
1680
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
1682
// mprintf("\n%d, %d",m->m_baAtomIndex.GetSize(),((CxIntArray*)sm->m_oaAtomOffset[m->m_baAtomIndex.GetSize()-1])->GetAt(1));
1685
v = m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[m->m_baAtomIndex.GetSize()-1])->GetAt(1)];
1687
/* mprintf(" .Mol ");
1691
*/ vc = CxVector3(0,0,0);
1695
while (v[0] < -g_fBoxX/2) { v[0] += g_fBoxX; vc[0] += g_fBoxX; }
1696
while (v[0] >= g_fBoxX/2) { v[0] -= g_fBoxX; vc[0] -= g_fBoxX; }
1700
while (v[1] < -g_fBoxY/2) { v[1] += g_fBoxY; vc[1] += g_fBoxY; }
1701
while (v[1] >= g_fBoxY/2) { v[1] -= g_fBoxY; vc[1] -= g_fBoxY; }
1705
while (v[2] < -g_fBoxZ/2) { v[2] += g_fBoxZ; vc[2] += g_fBoxZ; }
1706
while (v[2] >= g_fBoxZ/2) { v[2] -= g_fBoxZ; vc[2] -= g_fBoxZ; }
1709
if ((vc[0] == 0) && (vc[1] == 0) && (vc[2] == 0))
1712
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
1713
for (z4=0;z4<m->m_waAtomCount[z3];z4++)
1714
m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)] += vc;
1717
for (z3=0;z3<sm->m_laWannier.GetSize();z3++)
1718
m_vaCoords[sm->m_laWannier[z3]] += vc;
1721
// mprintf(" Fold Done\n");
1726
void CTimeStep::FoldAtoms()
1734
for (z=0;z<g_iGesVirtAtomCount;z++)
1738
while (m_vaCoords[z][0] < -g_fBoxX/2) m_vaCoords[z][0] += g_fBoxX;
1739
while (m_vaCoords[z][0] >= g_fBoxX/2) m_vaCoords[z][0] -= g_fBoxX;
1744
while (m_vaCoords[z][1] < -g_fBoxY/2) m_vaCoords[z][1] += g_fBoxY;
1745
while (m_vaCoords[z][1] >= g_fBoxY/2) m_vaCoords[z][1] -= g_fBoxY;
1750
while (m_vaCoords[z][2] < -g_fBoxZ/2) m_vaCoords[z][2] += g_fBoxZ;
1751
while (m_vaCoords[z][2] >= g_fBoxZ/2) m_vaCoords[z][2] -= g_fBoxZ;
1758
void CTimeStep::CenterPos(const CxVector3 &vec)
1761
int z/*, z2, z3, z4*/;
1763
/* for (z=0;z<g_oaMolecules.GetSize();z++)
1764
for (z2=0;z2<((CMolecule*)g_oaMolecules[z])->Count;z2++)
1765
for (z3=0;z3<((CMolecule*)g_oaMolecules[z])->Elements;z3++)
1766
for (z4=0;z4<((CMolecule*)g_oaMolecules[z])->AtomCount[z3];z4++)
1767
m_vaCoords[((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->SingleMolIndex[z2]])->m_iAtomOffset[z3][z4]] -= vec;*/
1769
for (z=0;z<g_iGesVirtAtomCount;z++)
1770
m_vaCoords[z] -= vec;
1775
void CTimeStep::AddAtoms()
1780
// bool labeledatoms;
1782
// labeledatoms = false;
1783
for (z=0;z<(long)m_iGesAtomCount;z++)
1785
q = (char*)m_paLabels[z];
1787
/* while ((*q >= '0') && (*q <= '9'))
1791
mprintf(">>>\n>>> The atoms in the input file are numbered.\n>>> Ignoring this, using own numbers ;-)\n>>>\n");
1792
labeledatoms = true;
1797
// printf("AddAtoms: \"%s\"\n",q);
1798
xAddAtom((char*)m_paLabels[z]);
1804
void CTimeStep::WriteTimestep(FILE *a)
1807
int z, z2, z3, z4, z0;
1809
CSingleMolecule *sm;
1811
if (g_bSaveVirtAtoms)
1812
mfprintf(a," %d\n",g_iGesVirtAtomCount);
1813
else mfprintf(a," %d\n",g_iGesAtomCount);
1814
if (m_pComment != NULL)
1815
mfprintf(a,"%s\n",m_pComment);
1816
else mfprintf(a,"\n");
1818
if (g_bWriteAtomwise)
1820
for (z0=0;z0<g_oaAtoms.GetSize();z0++)
1822
for (z=0;z<g_oaMolecules.GetSize();z++)
1824
m = (CMolecule*)g_oaMolecules[z];
1827
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
1829
if (m->m_baAtomIndex[z3] != z0)
1831
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
1833
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
1835
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
1836
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
1837
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
1844
for (z=0;z<g_oaMolecules.GetSize();z++)
1846
m = (CMolecule*)g_oaMolecules[z];
1849
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
1851
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
1852
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
1854
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
1856
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
1857
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
1867
void CTimeStep::WriteTimestepNb(FILE *a, CNbSet *nbs, int singlemol)
1870
int z, z2, z3, z4, z0, n, ti;
1872
CSingleMolecule *sm;
1873
CConditionGroup *cg;
1874
CConditionSubGroup *cs;
1879
for (z=0;z<g_oaMolecules.GetSize();z++)
1881
if (nbs->m_oaConditionGroups[z] == NULL)
1883
m = (CMolecule*)g_oaMolecules[z];
1884
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
1886
if (((CConditionGroup*)nbs->m_oaConditionGroups[z])->Contains(z2))
1889
if (!g_bSaveVirtAtoms)
1890
n -= m->m_laVirtualAtoms.GetSize();
1895
mfprintf(a," %d\n",n);
1897
mfprintf(a,"# Step %d",((int)g_iSteps));
1901
sm = (CSingleMolecule*)g_oaSingleMolecules[singlemol];
1902
m = (CMolecule*)g_oaMolecules[sm->m_iMolType];
1903
if (!g_bSaveVirtAtoms)
1905
if (g_bWriteAtomwise)
1906
mfprintf(a,", RM=%s[%d]",m->m_sName,sm->m_iMolSMIndex+1);
1907
else mfprintf(a,", RM=%s[%d] (%d atoms)",m->m_sName,sm->m_iMolSMIndex+1,m->m_iAtomGes-m->m_laVirtualAtoms.GetSize());
1910
if (g_bWriteAtomwise)
1911
mfprintf(a,", RM=%s[%d]",m->m_sName,sm->m_iMolSMIndex+1);
1912
else mfprintf(a,", RM=%s[%d] (%d atoms)",m->m_sName,sm->m_iMolSMIndex+1,m->m_iAtomGes);
1916
if (g_bEnvWriteDetailedInfo)
1918
for (z=0;z<g_oaMolecules.GetSize();z++)
1920
if (nbs->m_oaConditionGroups[z] == NULL)
1922
m = (CMolecule*)g_oaMolecules[z];
1924
cg = (CConditionGroup*)nbs->m_oaConditionGroups[z];
1929
if (cg->m_oaConditionSubGroups.GetSize() == 1)
1931
cs = (CConditionSubGroup*)cg->m_oaConditionSubGroups[0];
1932
if (cs->m_oaConditions.GetSize() == 1)
1933
nb = (CNbSearch*)cs->m_oaConditions[0];
1938
if (nb->m_iNbCountMin <= -1)
1941
for (z2=nb->m_iNbCountMin;z2<=nb->m_iNbCountMax;z2++)
1943
ti = nb->m_pNbSort[z2].m_iOM;
1944
if (!g_bSaveVirtAtoms)
1946
if (m->m_laSingleMolIndex[ti] != singlemol)
1948
if (g_bWriteAtomwise)
1949
mfprintf(a,", %s[%d] d=%.3fpm",m->m_sName,z2+1,nb->m_pNbSort[z2].m_fMinDist);
1950
else mfprintf(a,", %s[%d] d=%.3fpm (%d atoms)",m->m_sName,ti+1,nb->m_pNbSort[z2].m_fMinDist,m->m_iAtomGes-m->m_laVirtualAtoms.GetSize());
1954
if (m->m_laSingleMolIndex[ti] != singlemol)
1956
if (g_bWriteAtomwise)
1957
mfprintf(a,", %s[%d] d=%.3fpm",m->m_sName,z2+1,nb->m_pNbSort[z2].m_fMinDist);
1958
else mfprintf(a,", %s[%d] d=%.3fpm (%d atoms)",m->m_sName,ti+1,nb->m_pNbSort[z2].m_fMinDist,m->m_iAtomGes);
1965
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
1967
if (cg->Contains(z2))
1969
if (!g_bSaveVirtAtoms)
1971
if (m->m_laSingleMolIndex[z2] != singlemol)
1973
if (g_bWriteAtomwise)
1974
mfprintf(a,", %s[%d]",m->m_sName,z2+1);
1975
else mfprintf(a,", %s[%d] (%d atoms)",m->m_sName,z2+1,m->m_iAtomGes-m->m_laVirtualAtoms.GetSize());
1979
if (m->m_laSingleMolIndex[z2] != singlemol)
1981
if (g_bWriteAtomwise)
1982
mfprintf(a,", %s[%d]",m->m_sName,z2+1);
1983
else mfprintf(a,", %s[%d] (%d atoms)",m->m_sName,z2+1,m->m_iAtomGes);
1994
if (g_bWriteAtomwise)
1996
for (z0=0;z0<g_oaAtoms.GetSize();z0++)
1998
for (z=0;z<g_oaMolecules.GetSize();z++)
2000
if (nbs->m_oaConditionGroups[z] == NULL)
2002
m = (CMolecule*)g_oaMolecules[z];
2003
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2005
if (m->m_baAtomIndex[z3] != z0)
2007
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
2009
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
2011
if (((CConditionGroup*)nbs->m_oaConditionGroups[z])->Contains(z2))
2013
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
2014
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
2015
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
2025
sm = (CSingleMolecule*)g_oaSingleMolecules[singlemol];
2026
m = (CMolecule*)g_oaMolecules[sm->m_iMolType];
2027
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2029
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
2031
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
2032
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
2036
for (z=0;z<g_oaMolecules.GetSize();z++)
2038
if (nbs->m_oaConditionGroups[z] == NULL)
2040
m = (CMolecule*)g_oaMolecules[z];
2041
cg = (CConditionGroup*)nbs->m_oaConditionGroups[z];
2046
if (cg->m_oaConditionSubGroups.GetSize() == 1)
2048
cs = (CConditionSubGroup*)cg->m_oaConditionSubGroups[0];
2049
if (cs->m_oaConditions.GetSize() == 1)
2050
nb = (CNbSearch*)cs->m_oaConditions[0];
2055
if (nb->m_iNbCountMin <= -1)
2058
for (z2=nb->m_iNbCountMin;z2<=nb->m_iNbCountMax;z2++)
2060
ti = nb->m_pNbSort[z2].m_iOM;
2062
if (m->m_laSingleMolIndex[ti] == singlemol)
2065
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[ti]];
2066
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2068
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
2070
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
2071
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
2077
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
2079
if (((CConditionGroup*)nbs->m_oaConditionGroups[z])->Contains(z2))
2081
if (m->m_laSingleMolIndex[z2] == singlemol)
2083
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
2084
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2086
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
2088
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
2089
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
2101
/*void CTimeStep::WriteTimestepNb(int refmol, FILE *a)
2104
int z, c, z2, z3, z4, z0;
2108
m = (CMolecule*)g_oaMolecules[g_iFixMol];
2113
for (z=0;z<g_oaMolecules.GetSize();z++)
2114
c += g_pNbAll->m_waScanNeighborCount[z]*((CMolecule*)g_oaMolecules[z])->m_iAtomGes;
2115
if (g_bSaveRefWithEnv)
2119
for (z=0;z<g_oaMolecules.GetSize();z++)
2120
c += g_pNbAll->m_waScanNeighborCount[z]*(((CMolecule*)g_oaMolecules[z])->m_iAtomGes-((CMolecule*)g_oaMolecules[z])->m_waVirtualAtoms.GetSize());
2121
if (g_bSaveRefWithEnv)
2122
c += m->m_iAtomGes - m->m_waVirtualAtoms.GetSize();
2125
mfprintf(a," %d\n\n",c);
2127
if (g_bRefEnvAtomwise)
2129
for (z0=0;z0<g_oaAtoms.GetSize();z0++)
2131
if (g_bSaveRefWithEnv)
2133
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2135
if (m->m_baAtomIndex[z3] != z0)
2138
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
2140
for (z4=0;z4<m->m_waAtomCount[z3];z4++)
2142
ti = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[refmol]])->m_oaAtomOffset[z3])->GetAt(z4);
2143
mfprintf(a," %s %f %f %f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0f,m_vaCoords[ti][1]/100.0f,m_vaCoords[ti][2]/100.0f);
2147
for (z=0;z<g_oaMolecules.GetSize();z++)
2149
m2 = (CMolecule*)g_oaMolecules[z];
2150
for (z2=0;z2<g_pNbAll->m_waScanNeighborCount[z];z2++)
2152
for (z3=0;z3<m2->m_baAtomIndex.GetSize();z3++)
2154
if (m2->m_baAtomIndex[z3] != z0)
2157
if (m2->m_baAtomIndex[z3] == g_iVirtAtomType)
2159
for (z4=0;z4<m2->m_waAtomCount[z3];z4++)
2161
ti = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m2->m_laSingleMolIndex[((CxIntArray*)g_pNbAll->m_oaScanNeighbors[z])->GetAt(z2)]])->m_oaAtomOffset[z3])->GetAt(z4);
2162
mfprintf(a," %s %f %f %f\n",((CAtom*)g_oaAtoms[m2->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0f,m_vaCoords[ti][1]/100.0f,m_vaCoords[ti][2]/100.0f);
2170
if (g_bSaveRefWithEnv)
2172
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2175
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
2177
for (z4=0;z4<m->m_waAtomCount[z3];z4++)
2179
ti = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[refmol]])->m_oaAtomOffset[z3])->GetAt(z4);
2180
mfprintf(a," %s %f %f %f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0,m_vaCoords[ti][1]/100.0,m_vaCoords[ti][2]/100.0);
2184
for (z=0;z<g_oaMolecules.GetSize();z++)
2186
m2 = (CMolecule*)g_oaMolecules[z];
2187
for (z2=0;z2<g_pNbAll->m_waScanNeighborCount[z];z2++)
2189
for (z3=0;z3<m2->m_baAtomIndex.GetSize();z3++)
2192
if (m2->m_baAtomIndex[z3] == g_iVirtAtomType)
2194
for (z4=0;z4<m2->m_waAtomCount[z3];z4++)
2196
ti = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m2->m_laSingleMolIndex[((CxIntArray*)g_pNbAll->m_oaScanNeighbors[z])->GetAt(z2)]])->m_oaAtomOffset[z3])->GetAt(z4);
2197
mfprintf(a," %s %f %f %f\n",((CAtom*)g_oaAtoms[m2->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0,m_vaCoords[ti][1]/100.0,m_vaCoords[ti][2]/100.0);
2207
/*float CTimeStep::MolDist(CSingleMolecule *ref, CSingleMolecule *sm2, CNbSearch *nb)
2215
for (z3=0;z3<nb->m_waRefElements.GetSize();z3++)
2216
for (z4=0;z4<((CxIntArray*)nb->m_oaNbElements[sm2->m_iMolType])->GetSize();z4++)
2218
vec = m_vaCoords[((CxIntArray*)ref->m_oaAtomOffset[nb->m_waRefElements[z3]])->GetAt(nb->m_waRefAtoms[z3])] - m_vaCoords[((CxIntArray*)sm2->m_oaAtomOffset[((CxIntArray*)nb->m_oaNbElements[sm2->m_iMolType])->GetAt(z4)])->GetAt(((CxIntArray*)nb->m_oaNbAtoms[sm2->m_iMolType])->GetAt(z4))];
2221
while (vec[0] >= g_fBoxX/2) vec[0] -= g_fBoxX;
2222
while (vec[0] < -g_fBoxX/2) vec[0] += g_fBoxX;
2223
while (vec[1] >= g_fBoxY/2) vec[1] -= g_fBoxY;
2224
while (vec[1] < -g_fBoxY/2) vec[1] += g_fBoxY;
2225
while (vec[2] >= g_fBoxZ/2) vec[2] -= g_fBoxZ;
2226
while (vec[2] < -g_fBoxZ/2) vec[2] += g_fBoxZ;
2228
if (vec.GetLength() < d)
2229
d = vec.GetLength();
2238
/*void CTimeStep::ScanNeighborhood(int fixmol, int refmol, CNbSearch *nb, CNbSearch *prev)
2245
CSingleMolecule *sm, *sm2;
2248
m = (CMolecule*)g_oaMolecules[fixmol];
2249
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[refmol]];
2250
del = new float[g_oaSingleMolecules.GetSize()];
2251
best = new int[g_oaSingleMolecules.GetSize()];
2253
// printf("Suche Nachbarschaft von Molekuel %d...\n",refmol+1);
2255
for (z=0;z<g_oaMolecules.GetSize();z++)
2257
if (((!nb->m_bDistMode) && (nb->m_waMolCount[z] == 0)) || (nb->m_bDistMode && (nb->m_faMolDist[z] == 0)))
2259
nb->m_waScanNeighborCount[z] = 0;
2262
m2 = (CMolecule*)g_oaMolecules[z];
2263
// printf("*** Molekuel %d: %s\n",z+1,m2->Name);
2264
for (z2=0;z2<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z2++)
2267
if ((z == fixmol) && (z2 == refmol))
2270
if (!prev->Contains(z,z2))
2272
// printf(" - Vertreter %d\n",z2+1);
2273
sm2 = (CSingleMolecule*)g_oaSingleMolecules[m2->m_laSingleMolIndex[z2]];
2274
del[z2] = MolDist(sm,sm2,nb);
2275
// printf(" - Finaler Abstand: %f\n",del[z2]);
2277
if (nb->m_bDistMode)
2279
// printf("**DistMode**\n");
2280
// mprintf("Die Nachbarn: ");
2282
for (z3=0;z3<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z3++)
2283
if ((del[z3] <= nb->m_faMolDist[z]) && (del[z3] >= nb->m_faMolMinDist[z]))
2285
// mprintf("%d (%f), ",z3+1,del[z3]);
2290
// printf(" # Die naechsten Nachbarn: ");
2291
for (z2=0;z2<c;z2++)
2293
// printf("%d, ",best[z2]+1);
2294
nb->m_iNeighbourCount++;
2295
for (z3=0;z3<nb->m_waScanNeighborCount[z];z3++)
2296
if (((CxIntArray*)nb->m_oaScanNeighbors[z])->GetAt(z3) == best[z2])
2298
((CxIntArray*)nb->m_oaScanNeighborHits[z])->GetAt(z3)++;
2301
((CxIntArray*)nb->m_oaScanNeighbors[z])->Add(best[z2]);
2302
((CxIntArray*)nb->m_oaScanNeighborHits[z])->Add(1);
2303
nb->m_waScanNeighborCount[z]++;
2309
// printf("**CountMode**\n");
2310
for (z2=0;z2<nb->m_waMolCount[z];z2++)
2314
for (z3=0;z3<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z3++)
2323
del[b] = 1000000.0f;
2325
// printf(" # Die naechsten Nachbarn: ");
2326
for (z2=nb->m_waMolCountMin[z]-1;z2<nb->m_waMolCount[z];z2++)
2328
// printf("%d, ",best[z2]);
2329
nb->m_iNeighbourCount++;
2330
for (z3=0;z3<nb->m_waScanNeighborCount[z];z3++)
2331
if (((CxIntArray*)nb->m_oaScanNeighbors[z])->GetAt(z3) == best[z2])
2333
((CxIntArray*)nb->m_oaScanNeighborHits[z])->GetAt(z3)++;
2336
((CxIntArray*)nb->m_oaScanNeighbors[z])->Add(best[z2]);
2337
((CxIntArray*)nb->m_oaScanNeighborHits[z])->Add(1);
2338
nb->m_waScanNeighborCount[z]++;
2350
/*void CTimeStep::ScanAngle(int fixmol, int refmol, CCondition *co, CNbSearch *prev)
2356
CSingleMolecule *sm, *sm2;
2357
CxVector3 vec0, vec1, vec2, vec3, vec4, vec5;
2361
// mprintf("*** ScanAngle ***\n");
2362
// mprintf(" FixMol = %d, RefMol = %d\n",fixmol,refmol);
2363
m = (CMolecule*)g_oaMolecules[fixmol];
2364
// mprintf(" m->m_laSingleMolIndex[refmol] = %d\n",m->m_laSingleMolIndex[refmol]);
2366
nb = co->m_pTempNbS;
2367
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[refmol]];
2369
// printf("Suche Nachbarschaft von Molekuel %d...\n",refmol+1);
2371
// mprintf(" SecondMol = %d\n",co->m_iSecondMol);
2372
m2 = (CMolecule*)g_oaMolecules[co->m_iSecondMol];
2374
// printf("*** Molekuel %d: %s\n",z+1,m2->Name);
2375
for (z2=0;z2<m2->m_laSingleMolIndex.GetSize();z2++)
2377
if ((co->m_iSecondMol == fixmol) && (z2 == refmol))
2380
if (!prev->Contains(co->m_iSecondMol,z2))
2382
// printf(" - Vertreter %d\n",z2+1);
2383
sm2 = (CSingleMolecule*)g_oaSingleMolecules[m2->m_laSingleMolIndex[z2]];
2385
co->m_pADF->BuildAtomList(sm,sm2,NULL,&tempwa);
2387
for (z4=0;z4<tempwa.GetSize();z4+=6)
2389
if (co->m_pADF->m_bOrtho[0])
2391
vec0 = m_vaCoords[tempwa[z4]];
2392
vec2 = m_vaCoords[tempwa[z4+1]];
2393
vec3 = m_vaCoords[tempwa[z4+2]];
2394
vec1 = CrossP(vec2-vec0,vec3-vec0);
2397
vec0 = m_vaCoords[tempwa[z4]];
2398
vec2 = m_vaCoords[tempwa[z4+1]];
2401
if (co->m_pADF->m_bOrtho[1])
2403
vec4 = m_vaCoords[tempwa[z4+3]];
2404
vec3 = m_vaCoords[tempwa[z4+4]];
2405
vec5 = m_vaCoords[tempwa[z4+5]];
2406
vec2 = CrossP(vec3-vec4,vec5-vec4);
2409
vec4 = m_vaCoords[tempwa[z4+3]];
2410
vec3 = m_vaCoords[tempwa[z4+4]];
2414
tf = Angle_Deg(vec1,vec2);
2416
if ((tf >= co->m_pADF->m_fMinAngle) && (tf <= co->m_pADF->m_fMaxAngle))
2418
nb->m_iNeighbourCount++;
2419
for (z3=0;z3<nb->m_waScanNeighborCount[co->m_iSecondMol];z3++)
2420
if (((CxIntArray*)nb->m_oaScanNeighbors[co->m_iSecondMol])->GetAt(z3) == z2)
2422
((CxIntArray*)nb->m_oaScanNeighborHits[co->m_iSecondMol])->GetAt(z3)++;
2425
((CxIntArray*)nb->m_oaScanNeighbors[co->m_iSecondMol])->Add(z2);
2426
((CxIntArray*)nb->m_oaScanNeighborHits[co->m_iSecondMol])->Add(1);
2427
nb->m_waScanNeighborCount[co->m_iSecondMol]++;
2435
/*void CTimeStep::GatherNbDiagram(int refmol, CNbSearch *nb)
2441
int z, z2, z3, z4, c, z0;
2443
CSingleMolecule *sm, *sm2;
2447
m = (CMolecule*)g_oaMolecules[g_iFixMol];
2448
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[refmol]];
2449
del = new float[g_oaSingleMolecules.GetSize()];
2450
best = new int[g_oaSingleMolecules.GetSize()];
2451
done = new bool[g_oaSingleMolecules.GetSize()];
2453
// printf("Suche Nachbarschaft von Molekuel %d...\n",refmol+1);
2455
for (z=0;z<g_oaMolecules.GetSize();z++)
2457
if (nb->m_bDistMode && (nb->m_faMolDist[z] == 0))
2459
nb->m_waScanNeighborCount[z] = 0;
2462
m2 = (CMolecule*)g_oaMolecules[z];
2463
// printf("*** Molekuel %d: %s\n",z+1,m2->Name);
2464
// for (z2=0;z2<=((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z2++)
2465
// del[z2] = 99999.0f;
2466
for (z2=0;z2<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z2++)
2469
if ((z == g_iFixMol) && (z2 == refmol))
2471
// printf(" - Vertreter %d\n",z2+1);
2472
sm2 = (CSingleMolecule*)g_oaSingleMolecules[m2->m_laSingleMolIndex[z2]];
2473
for (z3=0;z3<nb->m_waRefElements.GetSize();z3++)
2474
for (z4=0;z4<((CxIntArray*)nb->m_oaNbElements[z])->GetSize();z4++)
2476
vec = m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[nb->m_waRefElements[z3]])->GetAt(nb->m_waRefAtoms[z3])] - m_vaCoords[((CxIntArray*)sm2->m_oaAtomOffset[((CxIntArray*)nb->m_oaNbElements[z])->GetAt(z4)])->GetAt(((CxIntArray*)nb->m_oaNbAtoms[z])->GetAt(z4))];
2479
while (vec[0] >= g_fBoxX/2) vec[0] -= g_fBoxX;
2480
while (vec[0] < -g_fBoxX/2) vec[0] += g_fBoxX;
2481
while (vec[1] >= g_fBoxY/2) vec[1] -= g_fBoxY;
2482
while (vec[1] < -g_fBoxY/2) vec[1] += g_fBoxY;
2483
while (vec[2] >= g_fBoxZ/2) vec[2] -= g_fBoxZ;
2484
while (vec[2] < -g_fBoxZ/2) vec[2] += g_fBoxZ;
2486
d = vec.GetLength();
2487
// printf(" = m1 %d (%d|%d); m2 %d (%d|%d); Dist = %f\n",z3+1,m->m_waNbElements[z3]+1,m->m_waNbAtoms[z3]+1,z4+1,m2->m_waNbElements[z4]+1,m2->m_waNbAtoms[z4]+1,d);
2491
// printf(" - Finaler Abstand: %f\n",del[z2]);
2494
for (z0=0;z0<nb->m_pAF->m_iResolution;z0++)
2497
for (z2=0;z2<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z2++)
2503
for (z3=0;z3<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z3++)
2513
if (d > nb->m_pAF->m_fMaxVal*z0/nb->m_pAF->m_iResolution)
2518
// if (c >= ((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize())
2521
nb->m_pAF->AddToBin(nb->m_pAF->m_fMaxVal*z0/nb->m_pAF->m_iResolution,(float)c);
2522
// if (g_iSteps == 1)
2523
// mfprintf(a,"%f;%f\n",nb->m_pAF->m_fMaxVal*z0/nb->m_pAF->m_iResolution,(float)c);
2525
// if (g_iSteps == 1)
2534
int CTimeStep::REC_UniteMolecules(CSingleMolecule *sm, int i0, int depth)
2540
m = (CMolAtom*)sm->m_oaMolAtoms[i0];
2545
for (z2=0;z2<depth;z2++)
2547
mprintf(">>> REC_UniteMolecules MolAtom=%d, Offset=%d.\n",i0,m->m_iOffset);
2550
g_pUniteTemp[m->m_iOffset] = true;
2552
for (z=0;z<m->m_oaBonds.GetSize();z++)
2554
if (!g_pUniteTemp[((CMolAtom*)m->m_oaBonds[z])->m_iOffset])
2556
if (MirrorBond(m->m_iOffset,((CMolAtom*)m->m_oaBonds[z])->m_iOffset))
2561
for (z2=0;z2<depth;z2++)
2563
mprintf(" Bond %s(%d) <--> %s(%d) unwrapped.\n",((CAtom*)g_oaAtoms[g_baAtomIndex[m->m_iOffset]])->m_sName,m->m_iOffset+1,((CAtom*)g_oaAtoms[g_baAtomIndex[((CMolAtom*)m->m_oaBonds[z])->m_iOffset]])->m_sName,((CMolAtom*)m->m_oaBonds[z])->m_iOffset+1);
2567
n += REC_UniteMolecules(sm,((CMolAtom*)m->m_oaBonds[z])->m_iMolAtomNumber,depth+1);
2573
for (z2=0;z2<depth;z2++)
2575
mprintf("<<< REC_UniteMolecules MolAtom=%d, Offset=%d.\n",i0,m->m_iOffset);
2581
void CTimeStep::UniteMolecules(bool verbose)
2586
CSingleMolecule *sm;
2588
for (z=0;z<g_iGesAtomCount;z++)
2589
g_pUniteTemp[z] = false;
2590
for (z=0;z<g_oaMolecules.GetSize();z++)
2592
m = (CMolecule*)g_oaMolecules[z];
2595
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
2597
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
2600
// mprintf(" # UniteMolecules molecule %s (%d)\n",m->m_sName,z2+1);
2602
n = REC_UniteMolecules(sm,0,0);
2604
if ((n != 0) && verbose)
2605
mprintf(" - Molecule %s[%d] united, %d bonds unwrapped.\n",m->m_sName,z2+1,n);
2607
if ((n != 0) && (!verbose) && g_bVerbose)
2608
mprintf("\n # UniteMolecules: Molecule %s[%d] united, %d bonds unwrapped.",m->m_sName,z2+1,n);
2616
bool CTimeStep::ReadTimestep(FILE *a, bool needinfo)
2619
switch(g_iTrajFormat)
2622
if (!ReadXYZ(a,needinfo,&m_vaCoords))
2627
if (!ReadPDB(a,needinfo,&m_vaCoords))
2632
if (!ReadMol2(a,needinfo))
2637
if (!ReadLAMMPS(a,needinfo))
2642
if (!ReadDLPOLY(a,needinfo))
2653
bool CTimeStep::SkipTimestep(FILE *a)
2656
switch(g_iTrajFormat)
2688
bool CTimeStep::ReadTimestepVel(FILE *a)
2691
char buf[256], *p, *q;
2701
if (strlen(buf) > 0)
2702
buf[strlen(buf)-1] = 0;
2709
m_vaVelocities.SetSize(tc);
2711
fgets(buf,256,a); // Zeitschritt - egal hier
2712
if (strlen(buf) > 0)
2713
buf[strlen(buf)-1] = 0;
2714
for (z=0;z<tc;z++) // den ersten Zeitschritt einlesen
2723
if (strlen(buf) > 0)
2724
buf[strlen(buf)-1] = 0;
2731
eprintf("CTimeStep::ReadTimestepVel(): Error 1. %d, \"%s\"\n",z+1,buf);
2734
while (isdigit(*(p-1)) && (p > buf))
2738
eprintf("CTimeStep::ReadTimestepVel(): No Atom laben found. %d, \"%s\"\n",z+1,buf);
2746
eprintf("CTimeStep::ReadTimestepVel(): Error 2. %d, \"%s\"\n",z+1,p);
2754
eprintf("CTimeStep::ReadTimestepVel(): Error 3. %d, \"%s\"\n",z+1,q);
2758
m_vaVelocities[z][0] = (float)atof(q);
2765
eprintf("CTimeStep::ReadTimestepVel(): Error 4. %d, \"%s\"\n",z+1,q);
2769
m_vaVelocities[z][1] = (float)atof(q);
2776
m_vaVelocities[z][2] = (float)atof(q);
2779
DoubleBoxVelocity();
2785
bool CTimeStep::ReadTimestepForce(FILE *a)
2788
char buf[256], *p, *q;
2798
if (strlen(buf) > 0)
2799
buf[strlen(buf)-1] = 0;
2806
m_vaForces.SetSize(tc);
2808
fgets(buf,256,a); // Zeitschritt - egal hier
2809
if (strlen(buf) > 0)
2810
buf[strlen(buf)-1] = 0;
2811
for (z=0;z<tc;z++) // den ersten Zeitschritt einlesen
2820
if (strlen(buf) > 0)
2821
buf[strlen(buf)-1] = 0;
2828
eprintf("CTimeStep::ReadTimestepForce(): Error 1. %d, \"%s\"\n",z+1,buf);
2831
while (isdigit(*(p-1)) && (p > buf))
2835
eprintf("CTimeStep::ReadTimestepForce(): No Atom laben found. %d, \"%s\"\n",z+1,buf);
2843
eprintf("CTimeStep::ReadTimestepForce(): Error 2. %d, \"%s\"\n",z+1,p);
2851
eprintf("CTimeStep::ReadTimestepForce(): Error 3. %d, \"%s\"\n",z+1,q);
2855
m_vaForces[z][0] = (float)atof(q);
2862
eprintf("CTimeStep::ReadTimestepForce(): Error 4. %d, \"%s\"\n",z+1,q);
2866
m_vaForces[z][1] = (float)atof(q);
2873
m_vaForces[z][2] = (float)atof(q);
2882
bool CTimeStep::SkipXYZ(FILE *a)
2888
// mprintf("*** Skip Anfang ***\n");
2890
fgets_bin(buf,256,a);
2901
buf[strlen(buf)-1] = 0;
2903
// mprintf("SkipA: \"%s\".\n",buf);
2910
fgets_bin(buf,256,a); // Zeitschritt - egal hier
2911
// mprintf("SkipB: \"%s\".\n",buf);
2912
for (z=0;z<tc;z++) // den ersten Zeitschritt einlesen
2915
fgets_bin(buf,256,a);
2916
// mprintf("SkipC%d: \"%s\".\n",z,buf);
2923
// mprintf("*** Skip Ende ***\n");
2929
void CTimeStep::CopyFrom(CTimeStep *t)
2936
m_iGesAtomCount = t->m_iGesAtomCount;
2937
m_vaCoords.CopyFrom(&t->m_vaCoords);
2938
if (g_bKeepUnfoldedCoords)
2939
m_vaCoords_Unfolded.CopyFrom(&t->m_vaCoords_Unfolded);
2940
m_vaForces.CopyFrom(&t->m_vaForces);
2941
m_vaVelocities.CopyFrom(&t->m_vaVelocities);
2942
if (t->m_paLabels.GetSize() != 0)
2944
for (z=0;z<m_paLabels.GetSize();z++)
2945
delete[] (char*)m_paLabels[z];
2946
m_paLabels.RemoveAll();
2947
for (z=0;z<t->m_paLabels.GetSize();z++)
2949
try { p = new char[strlen((char*)t->m_paLabels[z])+1]; } catch(...) { p = NULL; }
2950
if (p == NULL) NewException((double)(strlen((char*)t->m_paLabels[z])+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2952
strcpy(p,(char*)t->m_paLabels[z]);
2956
if (t->m_pComment != NULL)
2958
if (m_pComment == NULL)
2960
try { m_pComment = new char[256]; } catch(...) { m_pComment = NULL; }
2961
if (m_pComment == NULL) NewException((double)256*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2963
strcpy(m_pComment,t->m_pComment);
2969
long CTimeStep::ExtractNumber(int i)
2972
char *p, *q, buf[20];
2976
if (m_pComment == NULL)
2981
while ((!isdigit(*p)) && (*p != 0))
2989
while ((isdigit(*q)) && (*q != 0))
2998
while ((!isdigit(*p)) && (*p != 0))
3006
while ((isdigit(*q)) && (*q != 0))
3021
int CTimeStep::GetCommentNumberCount()
3027
if (m_pComment == NULL)
3033
while ((!isdigit(*p)) && (*p != 0))
3037
// mprintf("GetCommentNumberCount 1: %d (p=\"%s\", q=\"%s\")\n",z,p,q);
3042
while ((isdigit(*q)) && (*q != 0))
3046
// mprintf("GetCommentNumberCount 2: %d (p=\"%s\", q=\"%s\")\n",z,p,q);
3053
// mprintf("GetCommentNumberCount 3: %d (p=\"%s\", q=\"%s\")\n",z,p,q);
3059
return 0; // Never happens
3063
bool CTimeStep::ScanWannier(bool verbose)
3067
float td, d, dx, dy, dz;
3072
mprintf(WHITE,"\n*** ScanWannier ***\n\n");
3076
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
3077
((CSingleMolecule*)g_oaSingleMolecules[z])->m_laWannier.RemoveAll_KeepSize();
3079
for (z=0;z<g_iGesAtomCount;z++)
3081
if (g_baAtomIndex[z] != g_iWannierAtomType)
3085
for (z2=0;z2<g_iGesAtomCount;z2++)
3087
if (g_baAtomIndex[z2] == g_iWannierAtomType)
3089
dx = m_vaCoords[z][0]-m_vaCoords[z2][0];
3090
dy = m_vaCoords[z][1]-m_vaCoords[z2][1];
3091
dz = m_vaCoords[z][2]-m_vaCoords[z2][2];
3094
while (dx > g_fBoxX/2.0f) dx -= g_fBoxX;
3095
while (dx < -g_fBoxX/2.0f) dx += g_fBoxX;
3099
while (dy > g_fBoxY/2.0f) dy -= g_fBoxY;
3100
while (dy < -g_fBoxY/2.0f) dy += g_fBoxY;
3104
while (dz > g_fBoxZ/2.0f) dz -= g_fBoxZ;
3105
while (dz < -g_fBoxZ/2.0f) dz += g_fBoxZ;
3107
td = (float)sqrt(dx*dx+dy*dy+dz*dz);
3118
while (m_vaCoords[z][0]-m_vaCoords[z3][0] > g_fBoxX/2.0f) m_vaCoords[z][0] -= g_fBoxX;
3119
while (m_vaCoords[z][0]-m_vaCoords[z3][0] < -g_fBoxX/2.0f) m_vaCoords[z][0] += g_fBoxX;
3123
while (m_vaCoords[z][1]-m_vaCoords[z3][1] > g_fBoxY/2.0f) m_vaCoords[z][1] -= g_fBoxY;
3124
while (m_vaCoords[z][1]-m_vaCoords[z3][1] < -g_fBoxY/2.0f) m_vaCoords[z][1] += g_fBoxY;
3128
while (m_vaCoords[z][2]-m_vaCoords[z3][2] > g_fBoxZ/2.0f) m_vaCoords[z][2] -= g_fBoxZ;
3129
while (m_vaCoords[z][2]-m_vaCoords[z3][2] < -g_fBoxZ/2.0f) m_vaCoords[z][2] += g_fBoxZ;
3131
z2 = g_laAtomSMIndex[z3];
3134
eprintf("Step %d: Wannier center at offset %d too far away from any atom (closest atom is %s[%d] %s%d, %.0f pm).\n",g_iSteps,z+1,((CMolecule*)g_oaMolecules[((CSingleMolecule*)g_oaSingleMolecules[z2])->m_iMolType])->m_sName,((CSingleMolecule*)g_oaSingleMolecules[z2])->m_iMolSMIndex+1,((CAtom*)g_oaAtoms[g_waAtomRealElement[z3]])->m_sName,g_waAtomMolNumber[z3]+1,d);
3136
mprintf(" - Wannier center %d belongs to %s[%d] %s%d (%.0f pm).\n",z+1,((CMolecule*)g_oaMolecules[((CSingleMolecule*)g_oaSingleMolecules[z2])->m_iMolType])->m_sName,((CSingleMolecule*)g_oaSingleMolecules[z2])->m_iMolSMIndex+1,((CAtom*)g_oaAtoms[g_waAtomRealElement[z3]])->m_sName,g_waAtomMolNumber[z3]+1,d);
3139
eprintf("Wannier center %d: Atom %d does not belong to any molecule.\n",z+1,z3+1);
3142
// mprintf("Wannier Center %d hat Abstand %.2f zu Atom %d in SM %d.\n",z+1,d,z3+1,z2+1);
3143
((CSingleMolecule*)g_oaSingleMolecules[z2])->m_laWannier.Add(z);
3147
for (z=0;z<g_oaMolecules.GetSize();z++)
3149
m = (CMolecule*)g_oaMolecules[z];
3150
if (m->m_iWannierCount == 0)
3152
m->m_iWannierCount = ((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[0]])->m_laWannier.GetSize();
3154
for (z2=0;z2<m->m_baAtomIndex.GetSize();z2++)
3156
if (m->m_baAtomIndex[z2] == g_iWannierAtomType)
3158
if (m->m_baAtomIndex[z2] == g_iVirtAtomType)
3160
td += ((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_fCharge * m->m_waAtomCount[z2];
3162
m->m_fCharge = td-m->m_iWannierCount*g_fWannierCharge;
3163
mprintf(" - Molecule %s contains %d wannier centers. Total charge is %.2f - %.2f = %.2f\n",m->m_sName,m->m_iWannierCount,td,m->m_iWannierCount*g_fWannierCharge,m->m_fCharge);
3164
if (m->m_fCharge > 5.0)
3166
eprintf("\n This molecular charge seems to be too high.\n\n");
3167
if (!AskYesNo(" Do you want to continue (y/n)? [yes] ",true))
3171
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
3173
if (m->m_iWannierCount != ((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]])->m_laWannier.GetSize())
3174
eprintf("Step %d: Molecule %s[%d] contains %d instead of %d wannier centers.\n",g_iSteps,m->m_sName,z2+1,((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]])->m_laWannier.GetSize(),m->m_iWannierCount);
3182
void CTimeStep::CalcDipoles()
3187
CSingleMolecule *sm;
3191
// mprintf("\n*** CalcDipoles ***");
3193
for (z=0;z<g_oaMolecules.GetSize();z++)
3195
m = (CMolecule*)g_oaMolecules[z];
3196
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
3199
mprintf("\nCalcDipoles %s (%d):\n",m->m_sName,z2+1);
3201
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
3203
sm->m_vDipole = CxVector3(0,0,0);
3205
if ((!g_bWannier) && (!m->m_bChargesAssigned))
3208
if (g_bDipoleRefFixed)
3209
dc = CxVector3(0,0,0);
3210
else dc = m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[m->m_iDipoleCenterType])->GetAt(m->m_iDipoleCenterIndex)];
3213
mprintf(" Ref. point is ( %f | %f | %f )\n",dc[0],dc[1],dc[2]);
3215
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
3217
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
3221
if (m->m_baAtomIndex[z3] == g_iWannierAtomType)
3224
a = (CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]];
3225
for (z4=0;z4<m->m_waAtomCount[z3];z4++)
3227
// mprintf(" %s%d %.2f x ",a->m_sName,z4+1,a->m_fCharge);
3228
// (m_vaCoords[sm->m_iAtomOffset[z3][z4]]-m_vaCoords[sm->m_iAtomOffset[m->Elements-1][0]]).Dump();
3230
// mprintf(" %s%d %.2f (%d)\n",a->m_sName,z4+1,a->m_fCharge,((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4));
3234
sm->m_vDipole += a->m_fCharge * (m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)] - dc);
3237
mprintf(" %.2f: ( %f | %f | %f )\n",a->m_fCharge,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]);
3240
if (g_bReadChargesFrom4thXYZ)
3242
// mprintf("Moep. z3=%d, z4=%d, c=%f.\n",z3,z4,m_faCharge[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)]);
3243
sm->m_vDipole += m_faCharge[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)] * (m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)] - dc);
3245
mprintf(" %.2f: ( %f | %f | %f )\n",m_faCharge[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]);
3248
sm->m_vDipole += ((CxFloatArray*)m->m_oaCharges[z3])->GetAt(z4) * (m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)] - dc);
3250
mprintf(" %.2f: ( %f | %f | %f )\n",((CxFloatArray*)m->m_oaCharges[z3])->GetAt(z4),m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]);
3255
for (z3=0;z3<sm->m_laWannier.GetSize();z3++)
3257
// mprintf(" - %.2f x ",g_fWannierCharge);
3258
// (m_vaCoords[sm->m_waWannier[z3]] - m_vaCoords[sm->m_iAtomOffset[m->Elements-1][0]]).Dump();
3260
sm->m_vDipole -= g_fWannierCharge * (m_vaCoords[sm->m_laWannier[z3]] - dc);
3263
mprintf(" %.2f: ( %f | %f | %f )\n",-g_fWannierCharge,m_vaCoords[sm->m_laWannier[z3]][0],m_vaCoords[sm->m_laWannier[z3]][1],m_vaCoords[sm->m_laWannier[z3]][2]);
3266
// sm->m_vDipole.Dump();
3268
sm->m_vDipole *= 0.048008f; // Conversion e*pm --> Debye
3271
mprintf(" Result: %f.\n",sm->m_vDipole.GetLength());
3273
// mprintf("Molecule %s - Dipole %.3f\n",m->Name,sm->m_vDipole.GetLength());
3280
void CTimeStep::DoubleBox()
3285
if (m_vaCoords.GetSize() < g_iGesAtomCount)
3286
m_vaCoords.SetSize(g_iGesAtomCount);
3288
if (m_paLabels.GetSize() != 0)
3289
m_paLabels.SetSize(g_iGesAtomCount);
3291
for (pz=0;pz<g_iDoubleBoxZ;pz++)
3293
for (py=0;py<g_iDoubleBoxY;py++)
3295
for (px=0;px<g_iDoubleBoxX;px++)
3297
if ((px == 0) && (py == 0) && (pz == 0))
3299
for (z=0;z<g_iGesAtomCount/g_iDoubleBoxFactor;z++)
3301
m_vaCoords[(pz*g_iDoubleBoxX*g_iDoubleBoxY+py*g_iDoubleBoxX+px)*g_iGesAtomCount/g_iDoubleBoxFactor+z] = m_vaCoords[z] + CxVector3(px*g_fBoxX/g_iDoubleBoxX,py*g_fBoxY/g_iDoubleBoxY,pz*g_fBoxZ/g_iDoubleBoxZ);
3302
if (m_paLabels.GetSize() != 0)
3304
try { p = new char[strlen((char*)m_paLabels[z])+1]; } catch(...) { p = NULL; }
3305
if (p == NULL) NewException((double)(strlen((char*)m_paLabels[z])+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3307
strcpy(p,(char*)m_paLabels[z]);
3308
m_paLabels[(pz*g_iDoubleBoxX*g_iDoubleBoxY+py*g_iDoubleBoxX+px)*g_iGesAtomCount/g_iDoubleBoxFactor+z] = p;
3314
m_iGesAtomCount = g_iGesAtomCount;
3318
void CTimeStep::DoubleBoxVelocity()
3322
if (m_vaVelocities.GetSize() < g_iGesAtomCount)
3323
m_vaVelocities.SetSize(g_iGesAtomCount);
3325
for (pz=0;pz<g_iDoubleBoxZ;pz++)
3327
for (py=0;py<g_iDoubleBoxY;py++)
3329
for (px=0;px<g_iDoubleBoxX;px++)
3331
if ((px == 0) && (py == 0) && (pz == 0))
3333
for (z=0;z<g_iGesAtomCount/g_iDoubleBoxFactor;z++)
3334
m_vaVelocities[(pz*g_iDoubleBoxX*g_iDoubleBoxY+py*g_iDoubleBoxX+px)*g_iGesAtomCount/g_iDoubleBoxFactor+z] = m_vaVelocities[z];
3341
void CTimeStep::DoubleBoxForce()
3345
if (m_vaForces.GetSize() < g_iGesAtomCount)
3346
m_vaForces.SetSize(g_iGesAtomCount);
3348
for (pz=0;pz<g_iDoubleBoxZ;pz++)
3350
for (py=0;py<g_iDoubleBoxY;py++)
3352
for (px=0;px<g_iDoubleBoxX;px++)
3354
if ((px == 0) && (py == 0) && (pz == 0))
3356
for (z=0;z<g_iGesAtomCount/g_iDoubleBoxFactor;z++)
3357
m_vaForces[(pz*g_iDoubleBoxX*g_iDoubleBoxY+py*g_iDoubleBoxX+px)*g_iGesAtomCount/g_iDoubleBoxFactor+z] = m_vaForces[z];
3364
bool CTimeStep::ReadXYZ(FILE *a, bool needinfo, CxVec3Array *v)
3367
char buf[256], obuf[256], *p, *q, *r;
3369
const char *separators = " ,;\"'\t";
3371
// mprintf("*** Read Anfang.\n");
3373
// m_iSizeBytes = 0;
3376
fgets_bin(buf,256,a);
3377
// m_iSizeBytes += strlen(buf);
3378
if (strlen(buf) > 0)
3379
buf[strlen(buf)-1] = 0;
3380
// mprintf("Read1: \"%s\".\n",buf);
3383
eprintf("\nTrajectory file seems to be damaged. Searching for next time step...");
3387
// mprintf("CTimeStep::ReadTimestep(): Unexpected End of File (1).\n");
3391
if (strchr(buf,'.') != NULL)
3395
// mprintf("x: %d - \"%s\"\n",j,buf);
3399
m_iGesAtomCount = atoi(buf);
3400
if (m_iGesAtomCount == 0)
3402
eprintf("\nCTimeStep::ReadXYZ(): Error - atom count = 0. \"%s\"",buf);
3405
if (m_pComment == NULL)
3407
try { m_pComment = new char[128]; } catch(...) { m_pComment = NULL; }
3408
if (m_pComment == NULL) NewException((double)128*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3412
for (z=0;z<m_paLabels.GetSize();z++)
3413
delete[] (char*)m_paLabels[z];
3414
m_paLabels.RemoveAll();
3416
m_paLabels.SetSize(m_iGesAtomCount*g_iDoubleBoxFactor);
3417
else m_paLabels.SetSize(m_iGesAtomCount);
3419
if (v->GetSize() < (long)m_iGesAtomCount)
3420
v->SetSize(m_iGesAtomCount);
3422
if (g_bKeepOriginalCoords)
3424
if (m_vaCoords_Original.GetSize() < (long)m_iGesAtomCount)
3425
m_vaCoords_Original.SetSize(m_iGesAtomCount);
3429
fgets_bin(m_pComment,128,a); // Zeitschritt - egal hier
3430
// if (strlen(m_pComment) > 0)
3431
// m_pComment[strlen(m_pComment)-1] = 0;
3436
if ((*p == 10) || (*p == 13))
3440
// mprintf("Comment: \"%s\".\n",m_pComment);
3441
// m_iSizeBytes += strlen(m_pComment);
3443
if (g_bReadChargesFrom4thXYZ)
3444
m_faCharge.SetSize(m_iGesAtomCount);
3446
for (z=0;z<(long)m_iGesAtomCount;z++) // den ersten Zeitschritt einlesen
3449
fgets_bin(buf,256,a);
3452
eprintf("\nCTimeStep::ReadXYZ(): Unexpected end of file (2). \"%s\"\n",buf);
3456
// m_iSizeBytes += strlen(buf);
3457
buf[strlen(buf)-1] = 0;
3458
// mprintf(" %d: \"%s\".\n",z,buf);
3463
while (strchr(separators,*p) != NULL)
3466
while ((strchr(separators,*q) == NULL) && (*q != 0))
3470
eprintf("\nCTimeStep::ReadXYZ(): %d: Incomplete line (1): \"%s\"\n",z+1,obuf);
3480
eprintf("\nCTimeStep::ReadXYZ(): \"%s\" - Maximum length of atom labels is 7 chars; truncating.\n",p);
3484
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
3485
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3492
while (strchr(separators,*q) != NULL)
3495
while ((strchr(separators,*p) == NULL) && (*p != 0))
3499
eprintf("\nCTimeStep::ReadXYZ(): %d: Incomplete line (2): \"%s\"",z+1,obuf);
3503
(*v)[z][0] = (float)atof(q) * 100.0f;
3505
if (g_bKeepOriginalCoords)
3506
m_vaCoords_Original[z][0] = (double)atof(q) * 100.0;
3509
while (strchr(separators,*q) != NULL)
3512
while ((strchr(separators,*p) == NULL) && (*p != 0))
3516
eprintf("\nCTimeStep::ReadXYZ(): %d: Incomplete line (3) \"%s\"",z+1,obuf);
3520
(*v)[z][1] = (float)atof(q) * 100.0f;
3522
if (g_bKeepOriginalCoords)
3523
m_vaCoords_Original[z][1] = (double)atof(q) * 100.0;
3526
while (strchr(separators,*q) != NULL)
3529
while ((strchr(separators,*p) == NULL) && (*p != 0))
3531
if (g_bReadChargesFrom4thXYZ)
3535
eprintf("\nCTimeStep::ReadXYZ(): %d: Incomplete line (4) \"%s\"",z+1,obuf);
3544
(*v)[z][2] = (float)atof(q) * 100.0f;
3546
if (g_bKeepOriginalCoords)
3547
m_vaCoords_Original[z][2] = (double)atof(q) * 100.0;
3549
if (g_bReadChargesFrom4thXYZ)
3552
while (strchr(separators,*q) != NULL)
3555
while ((strchr(separators,*p) == NULL) && (*p != 0))
3559
m_faCharge[z] = (float)atof(q);
3560
} else if (needinfo && (z==0))
3567
while (strchr(separators,*q) != NULL)
3570
while ((strchr(separators,*p) == NULL) && (*p != 0))
3575
if (!(((*q >= '0') && (*q <= '9')) || (*q == '-') || (*q == '.')))
3577
g_bXYZ4thCol = true;
3582
/* q = strchr(buf,'.');
3586
q = strchr(q+1,'.');
3591
q = strchr(q+1,'.');
3595
eprintf("\nCTimeStep::ReadXYZ(): Error - only %d/3 dots. %d, \"%s\"",i,z+1,buf);
3604
eprintf("\nCTimeStep::ReadXYZ(): Error 1. %d, \"%s\"",z+1,buf);
3607
while (isdigit(*(p-1)) && (p > buf))
3611
eprintf("\nCTimeStep::ReadXYZ(): No Atom label found. %d, \"%s\"",z+1,buf);
3617
r = new char[strlen(q)+1];
3627
eprintf("\nCTimeStep::ReadXYZ(): Error 3. %d, \"%s\"",z+1,q);
3631
(*v)[z][0] = (float)atof(q) * 100.0f;
3638
eprintf("\nCTimeStep::ReadXYZ(): Error 4. %d, \"%s\"",z+1,q);
3642
(*v)[z][1] = (float)atof(q) * 100.0f;
3649
(*v)[z][2] = (float)atof(q) * 100.0f;*/
3653
// mprintf("*** Read Ende.\n");
3659
bool CTimeStep::ReadPDB(FILE *a, bool needinfo, CxVec3Array *v)
3662
static char buf[256], obuf[256], buf2[64];
3667
v->RemoveAll_KeepSize();
3668
for (i=0;i<m_paLabels.GetSize();i++)
3669
delete[] (char*)m_paLabels[i];
3670
m_paLabels.RemoveAll();
3673
fgets_bin(buf,256,a);
3676
if (strlen(buf) == 0)
3678
buf[strlen(buf)-1] = 0;
3682
if (strstr(buf,"CRYST1") != 0) // Boxlaenge
3684
// mprintf(GREY,"\"%s\".\n",buf);
3689
while ((*q != ' ') && (*q != 0))
3693
eprintf("Error 5 reading PDB line: \"%s\".\n",obuf);
3697
g_fBoxX = (float)(atof(p)*100.0);
3703
while ((*q != ' ') && (*q != 0))
3707
eprintf("Error 6 reading PDB line: \"%s\".\n",obuf);
3711
g_fBoxY = (float)(atof(p)*100.0);
3717
while ((*q != ' ') && (*q != 0))
3721
g_fBoxZ = (float)(atof(p)*100.0);
3722
// mprintf(GREY,"--> %f %f %f\n",g_fBoxX,g_fBoxY,g_fBoxZ);
3726
if (strstr(buf,"END") == buf)
3729
if ((strstr(buf,"ATOM")==0) && (strstr(buf,"HETATM")==0))
3733
while (!(isalpha(*p) || (*p == '_')) && (*p != 0))
3737
eprintf("Error 4 reading PDB line: \"%s\".\n",obuf);
3741
while (isalpha(*q) || (*q == '_'))
3748
eprintf("\nCTimeStep::ReadPDB(): \"%s\" - maximum length for atom labels is 7 chars; truncating.\n",p);
3752
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
3753
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3760
while ((*p != '.') && (*p != 0))
3774
if ((*q == ' ') || (*q == '-'))
3779
if ((*q == '-') || (*q == '.') || ((*q >= '0') && (*q <= '9')))
3783
// q = strchr(p,' ');
3786
eprintf("\nCTimeStep::ReadPDB(): Error 1. \"%s\".",obuf);
3791
x = (float)atof(buf2) * 100.0f;
3792
// mprintf("\n \"%s\".",buf2);
3800
if ((*q == ' ') || (*q == '-'))
3805
if ((*q == '-') || (*q == '.') || ((*q >= '0') && (*q <= '9')))
3809
// q = strchr(p,' ');
3812
eprintf("\nCTimeStep::ReadPDB(): Error 2. \"%s\".",obuf);
3817
y = (float)atof(buf2) * 100.0f;
3818
// mprintf("\n \"%s\".",buf2);
3820
z = (float)atof(q) * 100.0f;
3821
// mprintf("\n \"%s\".",q);
3823
// mprintf("\n%f, %f, %f",x,y,z);
3825
m_vaCoords.Add(CxVector3(x,y,z));
3827
m_iGesAtomCount = m_vaCoords.GetSize();
3833
bool CTimeStep::SkipPDB(FILE *a)
3840
fgets_bin(buf,256,a);
3843
if (strlen(buf) == 0)
3845
buf[strlen(buf)-1] = 0;
3846
if (strstr(buf,"END") == buf)
3853
bool CTimeStep::ReadLAMMPS(FILE *a, bool needinfo)
3856
char buf[256], obuf[256], *p, *q, *r;
3859
m_vaCoords.RemoveAll_KeepSize();
3860
for (i=0;i<m_paLabels.GetSize();i++)
3861
delete[] (char*)m_paLabels[i];
3862
m_paLabels.RemoveAll();
3863
m_iGesAtomCount = 0;
3866
fgets_bin(buf,256,a);
3869
if (strlen(buf) == 0)
3871
buf[strlen(buf)-1] = 0;
3875
if (strstr(buf,"ITEM: BOX BOUNDS") != 0) // Boxlaenge
3879
fgets_bin(buf,256,a);
3884
while (strchr(" ",*p) != NULL)
3887
while ((strchr(" ",*q) == NULL) && (*q != 0))
3891
eprintf("\nCTimeStep::ReadLAMMPS(): Incomplete line: \"%s\"\n",obuf);
3898
while (strchr(" ",*p) != NULL)
3905
case 0: g_fBoxX = (y-x)*100.0f; break;
3906
case 1: g_fBoxY = (y-x)*100.0f; break;
3907
case 2: g_fBoxZ = (y-x)*100.0f; break;
3912
if (strstr(buf,"ITEM: NUMBER OF ATOMS") != 0)
3914
fgets_bin(buf,256,a);
3917
buf[strlen(buf)-1] = 0;
3918
m_iGesAtomCount = atoi(buf);
3921
if (strstr(buf,"ITEM: ATOMS") != 0)
3923
if (strstr(buf,"ITEM: ATOMS element xu yu zu") == 0)
3925
eprintf("CTimeStep::ReadLAMMPS(): Wrong LAMMPS dump style: \"%s\".\n",buf);
3926
eprintf("You need to use \"dump custom element xu yu zu\".\n");
3930
if (m_iGesAtomCount == 0)
3932
eprintf("CTimeStep::ReadLAMMPS(): \"ITEM: ATOMS\" before \"ITEM: NUMBER OF ATOMS\".\n");
3939
m_paLabels.SetSize(m_iGesAtomCount*g_iDoubleBoxFactor);
3940
else m_paLabels.SetSize(m_iGesAtomCount);
3943
for (i=0;i<(int)m_iGesAtomCount;i++)
3945
fgets_bin(buf,256,a);
3950
while (strchr(" ",*p) != NULL)
3953
while ((strchr(" ",*q) == NULL) && (*q != 0))
3957
eprintf("\nCTimeStep::ReadLAMMPS(): %d: Incomplete line (1): \"%s\"\n",i+1,obuf);
3967
eprintf("\nCTimeStep::ReadLAMMPS(): \"%s\" - maximum length for atom labels is 7 chars; truncating.\n",p);
3971
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
3972
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3979
while (strchr(" ",*q) != NULL)
3982
while ((strchr(" ",*p) == NULL) && (*p != 0))
3986
eprintf("\nCTimeStep::ReadLAMMPS(): %d: Incomplete line (2): \"%s\"",i+1,obuf);
3990
x = (float)atof(q) * 100.0f;
3992
while (strchr(" ",*q) != NULL)
3995
while ((strchr(" ",*p) == NULL) && (*p != 0))
3999
eprintf("\nCTimeStep::ReadLAMMPS(): %d: Incomplete line (3) \"%s\"",i+1,obuf);
4003
y = (float)atof(q) * 100.0f;
4005
while (strchr(" ",*q) != NULL)
4008
while ((strchr(" ",*p) == NULL) && (*p != 0))
4012
z = (float)atof(q) * 100.0f;
4014
m_vaCoords.Add(CxVector3(x,y,z));
4023
bool CTimeStep::SkipLAMMPS(FILE *a)
4031
fgets_bin(buf,256,a);
4034
if (strlen(buf) == 0)
4036
buf[strlen(buf)-1] = 0;
4037
if (strstr(buf,"ITEM: NUMBER OF ATOMS") != 0)
4039
fgets_bin(buf,256,a);
4042
buf[strlen(buf)-1] = 0;
4046
if (strstr(buf,"ITEM: ATOMS") != 0)
4050
eprintf("CTimeStep::SkipLAMMPS(): \"ITEM: ATOMS\" before \"ITEM: NUMBER OF ATOMS\".\n");
4055
fgets_bin(buf,256,a);
4066
bool CTimeStep::ReadDLPOLY(FILE *a, bool needinfo)
4069
char buf[256], obuf[256], *p, *q, *r;
4072
m_vaCoords.RemoveAll_KeepSize();
4073
for (i=0;i<m_paLabels.GetSize();i++)
4074
delete[] (char*)m_paLabels[i];
4075
m_paLabels.RemoveAll();
4076
m_iGesAtomCount = 0;
4079
fgets_bin(buf,256,a);
4082
if (strlen(buf) == 0)
4084
buf[strlen(buf)-1] = 0;
4087
if (strstr(buf,"timestep") != 0)
4093
while ((*q != ' ') && (*q != 0))
4097
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line A: \"%s\"\n",obuf);
4106
while ((*q != ' ') && (*q != 0))
4110
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line B: \"%s\"\n",obuf);
4119
while ((*q != ' ') && (*q != 0))
4123
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line C: \"%s\"\n",obuf);
4127
m_iGesAtomCount = atoi(p);
4133
fgets_bin(buf,256,a);
4142
while ((*q != ' ') && (*q != 0))
4146
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line D: \"%s\"\n",obuf);
4156
while ((*q != ' ') && (*q != 0))
4160
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line E: \"%s\"\n",obuf);
4170
while ((*q != ' ') && (*q != 0))
4178
if ((y != 0) || (z != 0))
4180
eprintf("\nCTimeStep::ReadDLPOLY(): X: Only orthorhombic cells are supported.\n");
4187
if ((x != 0) || (z != 0))
4189
eprintf("\nCTimeStep::ReadDLPOLY(): Y: Only orthorhombic cells are supported.\n");
4196
if ((x != 0) || (y != 0))
4198
eprintf("\nCTimeStep::ReadDLPOLY(): Z: Only orthorhombic cells are supported.\n");
4208
fgets_bin(buf,256,a);
4209
fgets_bin(buf,256,a);
4210
fgets_bin(buf,256,a);
4213
if (m_iGesAtomCount == 0)
4215
eprintf("CTimeStep::ReadDLPOLY(): Error: Atom count is 0.\n");
4222
m_paLabels.SetSize(m_iGesAtomCount*g_iDoubleBoxFactor);
4223
else m_paLabels.SetSize(m_iGesAtomCount);
4226
for (i=0;i<(int)m_iGesAtomCount;i++)
4229
fgets_bin(buf,256,a);
4238
// Numer at beginning of line: Likely velocities. Skip that line
4239
if ((*p == '-') || (*p == '.') || ((*p >= '0') && (*p <= '9')))
4242
while ((*q != ' ') && (*q != 0))
4246
eprintf("\nCTimeStep::ReadDLPOLY(): %d: Incomplete line F: \"%s\"\n",i+1,obuf);
4255
eprintf("\nCTimeStep::ReadDLPOLY(): \"%s\" - maximum length for atom labels is 7 chars; truncating.\n",p);
4259
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
4260
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4266
fgets_bin(buf,256,a);
4275
while ((*q != ' ') && (*q != 0))
4279
eprintf("\nCTimeStep::ReadDLPOLY(): %d: Incomplete line G: \"%s\"\n",i+1,obuf);
4289
while ((*q != ' ') && (*q != 0))
4293
eprintf("\nCTimeStep::ReadDLPOLY(): %d: Incomplete line H: \"%s\"\n",i+1,obuf);
4303
while ((*q != ' ') && (*q != 0))
4308
m_vaCoords.Add(CxVector3(x,y,z));
4317
bool CTimeStep::SkipDLPOLY(FILE *a)
4320
char buf[256], obuf[256], *p, *q;
4324
fgets_bin(buf,256,a);
4327
if (strlen(buf) == 0)
4329
buf[strlen(buf)-1] = 0;
4332
if (strstr(buf,"timestep") != 0)
4338
while ((*q != ' ') && (*q != 0))
4342
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line A: \"%s\"\n",obuf);
4351
while ((*q != ' ') && (*q != 0))
4355
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line B: \"%s\"\n",obuf);
4364
while ((*q != ' ') && (*q != 0))
4368
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line C: \"%s\"\n",obuf);
4374
fgets_bin(buf,256,a);
4375
fgets_bin(buf,256,a);
4376
fgets_bin(buf,256,a);
4380
eprintf("CTimeStep::ReadDLPOLY(): Error: Atom count is 0.\n");
4386
fgets_bin(buf,256,a);
4387
fgets_bin(buf,256,a);
4398
bool CTimeStep::ReadMol2(FILE *a, bool needinfo)
4401
char buf[256], obuf[256], *p, *q, *r;
4404
fgets_bin(buf,256,a);
4405
fgets_bin(buf,256,a);
4406
fgets_bin(buf,256,a);
4411
while ((*q != ' ') && (*q != 0))
4414
m_iGesAtomCount = atoi(p);
4418
m_vaCoords.RemoveAll_KeepSize();
4419
for (i=0;i<m_paLabels.GetSize();i++)
4420
delete[] (char*)m_paLabels[i];
4421
m_paLabels.RemoveAll();
4422
m_paLabels.SetSize(m_iGesAtomCount);
4423
for (i=0;i<m_paMol2Types.GetSize();i++)
4424
delete[] (char*)m_paMol2Types[i];
4425
m_paMol2Types.RemoveAll();
4426
m_paMol2Types.SetSize(m_iGesAtomCount);
4428
fgets_bin(buf,256,a);
4429
fgets_bin(buf,256,a);
4430
fgets_bin(buf,256,a);
4431
fgets_bin(buf,256,a);
4432
fgets_bin(buf,256,a);
4434
for (i=0;i<(long)m_iGesAtomCount;i++)
4436
fgets_bin(buf,256,a);
4439
buf[strlen(buf)-1] = 0;
4441
// mprintf(" \"%s\"\n",buf);
4445
while ((*p != ' ') && (*p != 0))
4450
while (isalpha(*q) || (*q == '_'))
4457
eprintf("\nCTimeStep::ReadMol2(): \"%s\" - maximum length for atom labels is 7 chars; truncating.\n",p);
4461
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
4462
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4468
while ((*p != ' ') && (*p != 0))
4476
eprintf("\nCTimeStep::ReadMol2(): Error 1. %d. \"%s\".",i+1,obuf);
4480
x = (float)atof(p) * 100.0f;
4488
eprintf("\nCTimeStep::ReadMol2(): Error 2. %d. \"%s\".",i+1,obuf);
4492
y = (float)atof(p) * 100.0f;
4500
eprintf("\nCTimeStep::ReadMol2(): Error 3. %d. \"%s\".",i+1,obuf);
4504
z = (float)atof(p) * 100.0f;
4505
m_vaCoords.Add(CxVector3(x,y,z));
4511
while ((*q != ' ') && (*q != 0))
4517
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
4518
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4521
m_paMol2Types[i] = r;
4523
/* mprintf(" X=%f, Y=%f, Z=%f",x,y,z);
4525
mprintf(", A=%s, B=%s",(char*)m_paLabels[i],(char*)m_paMol2Types[i]);
4528
m_iGesAtomCount = m_vaCoords.GetSize();
4534
bool CTimeStep::SkipMol2(FILE *a)
4539
fgets_bin(buf,256,a);
4540
fgets_bin(buf,256,a);
4541
fgets_bin(buf,256,a);
4542
fgets_bin(buf,256,a);
4543
fgets_bin(buf,256,a);
4544
fgets_bin(buf,256,a);
4545
fgets_bin(buf,256,a);
4546
fgets_bin(buf,256,a);
4548
for (i=0;i<(long)m_iGesAtomCount;i++)
4550
fgets_bin(buf,256,a);
4559
void CTimeStep::CalcMinMax()
4570
for (z=0;z<(long)m_iGesAtomCount;z++)
4572
if (m_vMin[0] > m_vaCoords[z][0])
4573
m_vMin[0] = m_vaCoords[z][0];
4574
if (m_vMin[1] > m_vaCoords[z][1])
4575
m_vMin[1] = m_vaCoords[z][1];
4576
if (m_vMin[2] > m_vaCoords[z][2])
4577
m_vMin[2] = m_vaCoords[z][2];
4578
if (m_vMax[0] < m_vaCoords[z][0])
4579
m_vMax[0] = m_vaCoords[z][0];
4580
if (m_vMax[1] < m_vaCoords[z][1])
4581
m_vMax[1] = m_vaCoords[z][1];
4582
if (m_vMax[2] < m_vaCoords[z][2])
4583
m_vMax[2] = m_vaCoords[z][2];
4588
void CTimeStep::WriteMol2(FILE *a)
4590
int z, z2, z3, z4, ti, c, mc;
4592
CSingleMolecule *sm;
4598
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
4599
bonds += ((CSingleMolecule*)g_oaSingleMolecules[z])->m_oaBonds.GetSize();
4601
try { tpi = new int[g_iGesAtomCount]; } catch(...) { tpi = NULL; }
4602
if (tpi == NULL) NewException((double)g_iGesAtomCount*sizeof(int),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4604
mfprintf(a," @<TRIPOS>MOLECULE\n");
4605
mfprintf(a,"MOL\n");
4606
mfprintf(a," %d %d %d 0 0\n",g_iGesAtomCount,bonds,g_oaSingleMolecules.GetSize());
4607
mfprintf(a," SMALL\n");
4608
mfprintf(a,"resp\n\n\n");
4609
mfprintf(a," @<TRIPOS>ATOM\n");
4612
if (m_faCharge.GetSize() != g_iGesAtomCount)
4614
m_faCharge.SetSize(g_iGesAtomCount);
4615
for (z=0;z<g_iGesAtomCount;z++)
4618
for (z=0;z<g_oaMolecules.GetSize();z++)
4620
m = (CMolecule*)g_oaMolecules[z];
4621
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
4623
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
4625
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
4627
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
4629
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
4631
ti = ((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4);
4632
if (m_paMol2Types.GetSize() != 0)
4633
cc = (char*)m_paMol2Types[ti];
4634
else cc = ((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName;
4636
mfprintf(a," %6d %2s % 11.4f % 11.4f % 11.4f %2s %4d MOL % 8.4f\n",c,((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0,m_vaCoords[ti][1]/100.0,m_vaCoords[ti][2]/100.0,cc,mc,m_faCharge[ti]);
4641
mfprintf(a," @<TRIPOS>BOND\n");
4643
for (z=0;z<g_oaMolecules.GetSize();z++)
4645
m = (CMolecule*)g_oaMolecules[z];
4646
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
4648
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
4649
for (z3=0;z3<sm->m_oaBonds.GetSize();z3++)
4650
mfprintf(a," %6d %6d %6d 1\n",++c,tpi[((CMolBond*)sm->m_oaBonds[z3])->m_iAtomOffset[0]]+1,tpi[((CMolBond*)sm->m_oaBonds[z3])->m_iAtomOffset[1]]+1);
4653
mfprintf(a," @<TRIPOS>SUBSTRUCTURE\n");
4655
for (z=0;z<g_oaMolecules.GetSize();z++)
4657
m = (CMolecule*)g_oaMolecules[z];
4658
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
4660
mfprintf(a," %4d MOL %4d TEMP 0 **** **** 0 ROOT\n",c+1,c+1);
4668
void CTimeStep::ReadCellVector(FILE *a)
4670
char buf[256], obuf[256];
4677
eprintf("\nReadCellVector: End of file.\n");
4678
eprintf("Your cell vector text file is too short.\n");
4681
if (strlen(buf) == 0)
4683
eprintf("\nReadCellVector: Empty line.\n");
4686
buf[strlen(buf)-1] = 0;
4688
// mprintf(GREY,"\nReadCellVector: \"%s\".\n",buf);
4690
while ((!isnumeric(*p)) && (*p != 0))
4694
eprintf("\nReadCellVector: Incomplete line (1) \"%s\".\n",obuf);
4698
while (isnumeric(*q))
4702
eprintf("\nReadCellVector: Incomplete line (2) \"%s\".\n",obuf);
4706
tf = (float)(atof(p)*100.0);
4709
eprintf("\nReadCellVector: Cell vectors need to be > 0 (X) \"%s\".\n",obuf);
4715
while ((!isnumeric(*p)) && (*p != 0))
4719
eprintf("\nReadCellVector: Incomplete line (3) \"%s\".\n",obuf);
4723
while (isnumeric(*q))
4727
eprintf("\nReadCellVector: Incomplete line (4) \"%s\".\n",obuf);
4731
tf = (float)(atof(p)*100.0);
4734
eprintf("\nReadCellVector: Cell vectors need to be > 0 (Y) \"%s\".\n",obuf);
4740
while ((!isnumeric(*p)) && (*p != 0))
4744
eprintf("\nReadCellVector: Incomplete line (5) \"%s\".\n",obuf);
4748
while (isnumeric(*q))
4752
tf = (float)(atof(p)*100.0);
4755
eprintf("\nReadCellVector: Cell vectors need to be > 0 (Z) \"%s\".\n",obuf);
4760
// mprintf(GREY," --> %f %f %f\n",g_fBoxX,g_fBoxY,g_fBoxZ);
4764
void CTimeStep::CenterCOM()
4770
vc = CxVector3(0,0,0);
4772
for (z=0;z<g_iGesAtomCount;z++)
4775
if (g_baAtomIndex[z] == g_iWannierAtomType)
4777
vc += m_vaCoords[z] * ((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_pElement->m_fMass;
4778
m += ((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_pElement->m_fMass;
4781
for (z=0;z<g_iGesAtomCount;z++)
4782
m_vaCoords[z] -= vc;
4786
float CTimeStep::FoldedDistance(int i1, int i2)
4790
t = m_vaCoords[i2]-m_vaCoords[i1];
4794
while (t[0] < -g_fBoxX/2) t[0] += g_fBoxX;
4795
while (t[0] >= g_fBoxX/2) t[0] -= g_fBoxX;
4800
while (t[1] < -g_fBoxY/2) t[1] += g_fBoxY;
4801
while (t[1] >= g_fBoxY/2) t[1] -= g_fBoxY;
4806
while (t[2] < -g_fBoxZ/2) t[2] += g_fBoxZ;
4807
while (t[2] >= g_fBoxZ/2) t[2] -= g_fBoxZ;
4810
return t.GetLength();
4814
void CTimeStep::FoldAtomsPositive()
4822
for (z=0;z<g_iGesVirtAtomCount;z++)
4826
while (m_vaCoords[z][0] < 0) m_vaCoords[z][0] += g_fBoxX;
4827
while (m_vaCoords[z][0] >= g_fBoxX) m_vaCoords[z][0] -= g_fBoxX;
4832
while (m_vaCoords[z][1] < 0) m_vaCoords[z][1] += g_fBoxY;
4833
while (m_vaCoords[z][1] >= g_fBoxY) m_vaCoords[z][1] -= g_fBoxY;
4838
while (m_vaCoords[z][2] < 0) m_vaCoords[z][2] += g_fBoxZ;
4839
while (m_vaCoords[z][2] >= g_fBoxZ) m_vaCoords[z][2] -= g_fBoxZ;
4846
void CTimeStep::WritePOV(const char *s)
4850
CSingleMolecule *sm;
4852
int z, z2, z3, z4, o, o2;
4853
CxVector3 vec1, vec2, vec3, vec1b, vec2b, vec3b, vecA, vecB, vecC, vecD;
4856
// float cr, cg, cb;
4858
b = OpenFileWrite(s,true);
4860
mfprintf(b,"// Written by TRAVIS\n");
4861
mfprintf(b,"// See http://www.travis-analyzer.de\n\n");
4862
mfprintf(b,"#version 3.6;\n");
4865
mfprintf(b,"/**** Atoms ****/\n");
4867
mfprintf(b,"#declare atom_draw = true;\n");
4868
mfprintf(b,"#declare atom_r = 0.65;\n");
4869
mfprintf(b,"#declare atom_specular = 0.7;\n");
4870
mfprintf(b,"#declare atom_reflect = 0;\n");
4871
mfprintf(b,"#declare atom_ambient = 0.2;\n");
4872
mfprintf(b,"#declare atom_diffuse = 0.7;\n");
4873
mfprintf(b,"//#declare atom_color = < 1.0, 1.0, 1.0, 0, 0 >;\n");
4874
mfprintf(b,"//#declare atom_trans = 0.7;\n");
4878
mfprintf(b,"#declare atom_draw_halo1 = true;\n");
4879
mfprintf(b,"#declare atom_r_halo1 = 0.008;\n");
4880
mfprintf(b,"#declare atom_d_halo1 = 0.0125;\n");
4881
mfprintf(b,"#declare atom_color_halo1 = < 0, 0, 0, 0, 0 >;\n");
4882
mfprintf(b,"#declare atom_specular_halo1 = 0;\n");
4883
mfprintf(b,"#declare atom_reflect_halo1 = 0;\n");
4884
mfprintf(b,"#declare atom_ambient_halo1 = 1.0;\n");
4885
mfprintf(b,"#declare atom_diffuse_halo1 = 0;\n");
4889
mfprintf(b,"#declare atom_draw_halo2 = true;\n");
4890
mfprintf(b,"#declare atom_r_halo2 = 0.003;\n");
4891
mfprintf(b,"#declare atom_d_halo2 = 0.01875;\n");
4892
mfprintf(b,"#declare atom_color_halo2 = < 1, 1, 1, 0, 0 >;\n");
4893
mfprintf(b,"#declare atom_specular_halo2 = 0;\n");
4894
mfprintf(b,"#declare atom_reflect_halo2 = 0;\n");
4895
mfprintf(b,"#declare atom_ambient_halo2 = 1.0;\n");
4896
mfprintf(b,"#declare atom_diffuse_halo2 = 0;\n");
4900
mfprintf(b,"#declare atom_draw_halo3 = true;\n");
4901
mfprintf(b,"#declare atom_r_halo3 = 0.003;\n");
4902
mfprintf(b,"#declare atom_d_halo3 = 0.025;\n");
4903
mfprintf(b,"#declare atom_color_halo3 = < 1, 1, 1, 0, 0.5 >;\n");
4904
mfprintf(b,"#declare atom_specular_halo3 = 0;\n");
4905
mfprintf(b,"#declare atom_reflect_halo3 = 0;\n");
4906
mfprintf(b,"#declare atom_ambient_halo3 = 1.0;\n");
4907
mfprintf(b,"#declare atom_diffuse_halo3 = 0;\n");
4911
mfprintf(b,"/**** Bonds ****/\n");
4913
mfprintf(b,"#declare bond_draw = true;\n");
4914
mfprintf(b,"#declare bond_r = 0.015;\n");
4915
mfprintf(b,"#declare bond_specular = 0.7;\n");
4916
mfprintf(b,"#declare bond_reflect = 0;\n");
4917
mfprintf(b,"#declare bond_ambient = 0.2;\n");
4918
mfprintf(b,"#declare bond_diffuse = 0.7;\n");
4922
mfprintf(b,"#declare bond_draw_halo1 = true;\n");
4923
mfprintf(b,"#declare bond_r_halo1 = 0.008;\n");
4924
mfprintf(b,"#declare bond_d_halo1 = 0;\n");
4925
mfprintf(b,"#declare bond_color_halo1 = < 0, 0, 0, 0, 0 >;\n");
4926
mfprintf(b,"#declare bond_specular_halo1 = 0;\n");
4927
mfprintf(b,"#declare bond_reflect_halo1 = 0;\n");
4928
mfprintf(b,"#declare bond_ambient_halo1 = 1.0;\n");
4929
mfprintf(b,"#declare bond_diffuse_halo1 = 0;\n");
4933
mfprintf(b,"#declare bond_draw_halo2 = true;\n");
4934
mfprintf(b,"#declare bond_r_halo2 = 0.003;\n");
4935
mfprintf(b,"#declare bond_d_halo2 = 0.0286;\n");
4936
mfprintf(b,"#declare bond_color_halo2 = < 1, 1, 1, 0, 0 >;\n");
4937
mfprintf(b,"#declare bond_specular_halo2 = 0;\n");
4938
mfprintf(b,"#declare bond_reflect_halo2 = 0;\n");
4939
mfprintf(b,"#declare bond_ambient_halo2 = 1.0;\n");
4940
mfprintf(b,"#declare bond_diffuse_halo2 = 0;\n");
4944
mfprintf(b,"#declare bond_draw_halo3 = true;\n");
4945
mfprintf(b,"#declare bond_r_halo3 = 0.003;\n");
4946
mfprintf(b,"#declare bond_d_halo3 = 0.0333;\n");
4947
mfprintf(b,"#declare bond_color_halo3 = < 1, 1, 1, 0, 0.5 >;\n");
4948
mfprintf(b,"#declare bond_specular_halo3 = 0;\n");
4949
mfprintf(b,"#declare bond_reflect_halo3 = 0;\n");
4950
mfprintf(b,"#declare bond_ambient_halo3 = 1.0;\n");
4951
mfprintf(b,"#declare bond_diffuse_halo3 = 0;\n");
4955
mfprintf(b,"#declare bond_draw_stub = true;\n");
4956
mfprintf(b,"#declare bond_r_stub = 0.004;\n");
4957
mfprintf(b,"#declare bond_l_stub = 0.004;\n");
4958
mfprintf(b,"#declare bond_color_stub = < 0, 0, 0, 0, 0 >;\n");
4959
mfprintf(b,"#declare bond_specular_stub = 0;\n");
4960
mfprintf(b,"#declare bond_reflect_stub = 0;\n");
4961
mfprintf(b,"#declare bond_ambient_stub = 1.0;\n");
4962
mfprintf(b,"#declare bond_diffuse_stub = 0;\n");
4966
mfprintf(b,"/**** Element Colors ****/\n");
4967
for (z=0;z<g_oaAtoms.GetSize();z++)
4969
if (z == g_iVirtAtomType)
4971
el = ((CAtom*)g_oaAtoms[z])->m_pElement;
4972
mfprintf(b,"#declare elem_%s_col = < %f, %f, %f, 0, 0 >;\n",el->m_sLabel,el->m_iColorR/255.0,el->m_iColorG/255.0,el->m_iColorB/255.0);
4975
mfprintf(b,"\n/**** Element Radii ****/\n");
4976
for (z=0;z<g_oaAtoms.GetSize();z++)
4978
if (z == g_iVirtAtomType)
4980
el = ((CAtom*)g_oaAtoms[z])->m_pElement;
4981
mfprintf(b,"#declare elem_%s_r = %f;\n",el->m_sLabel,el->m_fRadius/1000.0);
4989
mfprintf(b,"global_settings {\n");
4990
mfprintf(b," assumed_gamma 1\n");
4991
mfprintf(b,"/* radiosity {\n");
4992
mfprintf(b," pretrace_start 0.08\n");
4993
mfprintf(b," pretrace_end 0.04\n");
4994
mfprintf(b," count 100\n\n");
4995
mfprintf(b," nearest_count 5\n");
4996
mfprintf(b," error_bound 0.4\n");
4997
mfprintf(b," recursion_limit 1\n\n");
4998
mfprintf(b," low_error_factor .5\n");
4999
mfprintf(b," gray_threshold 0.0\n");
5000
mfprintf(b," minimum_reuse 0.015\n");
5001
mfprintf(b," brightness 1\n\n");
5002
mfprintf(b," adc_bailout 0.01/2\n");
5003
mfprintf(b," }*/\n");
5006
mfprintf(b,"\ncamera {\n");
5007
mfprintf(b," location <%f, %f, %f>\n",cam[0],cam[1],cam[2]);
5008
mfprintf(b," sky y\n");
5009
mfprintf(b," right -0.06*x*image_width/image_height\n");
5010
mfprintf(b," up 0.06*y\n");
5011
mfprintf(b," look_at <0, 0, 0>\n");
5015
mfprintf(b,"// Solid background\n");
5016
mfprintf(b,"background { rgb < 0.15, 0.1, 0.3 > }\n");
5019
mfprintf(b,"// Gradient background\n");
5020
mfprintf(b,"sky_sphere {\n");
5021
mfprintf(b," pigment {\n");
5022
mfprintf(b," gradient y\n");
5023
mfprintf(b," color_map {\n");
5024
mfprintf(b," [ 0 color rgb < 0.05, 0.05, 0.05 > ]\n");
5025
mfprintf(b," [ 1 color rgb < 0.20, 0.16, 0.50 > ]\n");
5027
mfprintf(b," scale 0.1\n");
5028
mfprintf(b," translate -0.05\n");
5030
mfprintf(b,"}\n\n");
5032
mfprintf(b,"/**** Invisible, only for Radiosity ****/\n");
5033
mfprintf(b,"sphere {\n");
5034
mfprintf(b," <0, 0, 0>, 1\n");
5035
mfprintf(b," texture {\n");
5036
mfprintf(b," pigment {color rgb < 1.0, 1.0, 1.0 > }\n");
5037
mfprintf(b," finish { diffuse 0 ambient 1 }\n");
5039
mfprintf(b," hollow on\n");
5040
mfprintf(b," no_shadow\n");
5041
mfprintf(b," no_image\n");
5042
mfprintf(b," scale 30000\n");
5043
mfprintf(b,"}\n\n");
5045
mfprintf(b,"light_source { < -8, 20, 20 > color rgb 0.8 }\n");
5046
mfprintf(b,"//light_source { < 25, 12, 20 > color rgb 0.5 }\n\n");
5048
mfprintf(b,"#macro m_atom_color(col)\n");
5049
mfprintf(b," #ifdef(atom_color)\n");
5050
mfprintf(b," atom_color\n");
5051
mfprintf(b," #else #if (defined(atom_trans))\n");
5052
mfprintf(b," col + < 0, 0, 0, 0, atom_trans >\n");
5053
mfprintf(b," #else\n");
5054
mfprintf(b," col\n");
5055
mfprintf(b," #end #end\n");
5056
mfprintf(b,"#end\n");
5058
mfprintf(b,"\nunion {\n");
5060
for (z=0;z<g_oaMolecules.GetSize();z++)
5062
m = (CMolecule*)g_oaMolecules[z];
5064
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
5066
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
5068
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
5070
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
5073
el = ((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_pElement;
5075
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
5077
o = ((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4);
5078
vec1 = m_vaCoords[o];
5081
mfprintf(b,"#if (atom_draw)\n");
5082
mfprintf(b," sphere { <%g, %g, %g>, elem_%s_r*atom_r\n",vec1[0],vec1[1],vec1[2],el->m_sLabel);
5083
mfprintf(b," pigment { rgbft m_atom_color(elem_%s_col) } finish { reflection atom_reflect specular atom_specular ambient atom_ambient diffuse atom_diffuse } }\n",el->m_sLabel);
5084
mfprintf(b,"#end\n");
5091
mfprintf(b,"#if (atom_draw_halo1)\n");
5092
mfprintf(b," disc { < %g - (%g) * atom_d_halo1, %g - (%g) * atom_d_halo1, %g - (%g) * atom_d_halo1 >,\n",vec1[0],vec2[0],vec1[1],vec2[1],vec1[2],vec2[2]);
5093
mfprintf(b," < %g, %g, %g >, (elem_%s_r * atom_r) + atom_r_halo1, elem_%s_r * atom_r\n",vec2[0],vec2[1],vec2[2],el->m_sLabel,el->m_sLabel);
5094
mfprintf(b," pigment { rgbft atom_color_halo1 } finish { reflection atom_reflect_halo1 specular atom_specular_halo1 ambient atom_ambient_halo1 diffuse atom_diffuse_halo1 } no_reflection no_radiosity }\n");
5095
mfprintf(b,"#end\n");
5100
mfprintf(b,"#if (atom_draw_halo2)\n");
5101
mfprintf(b," disc { < %g - (%g) * atom_d_halo2, %g - (%g) * atom_d_halo2, %g - (%g) * atom_d_halo2 >,\n",vec1[0],vec2[0],vec1[1],vec2[1],vec1[2],vec2[2]);
5102
mfprintf(b," < %g, %g, %g >, (elem_%s_r * atom_r) + atom_r_halo1 + atom_r_halo2, elem_%s_r * atom_r\n",vec2[0],vec2[1],vec2[2],el->m_sLabel,el->m_sLabel);
5103
mfprintf(b," pigment { rgbft atom_color_halo2 } finish { reflection atom_reflect_halo2 specular atom_specular_halo2 ambient atom_ambient_halo2 diffuse atom_diffuse_halo2 } no_reflection no_radiosity }\n");
5104
mfprintf(b,"#end\n");
5106
mfprintf(b,"#if (atom_draw_halo3)\n");
5107
mfprintf(b," disc { < %g - (%g) * atom_d_halo3, %g - (%g) * atom_d_halo3, %g - (%g) * atom_d_halo3 >,\n",vec1[0],vec2[0],vec1[1],vec2[1],vec1[2],vec2[2]);
5108
mfprintf(b," < %g, %g, %g >, (elem_%s_r * atom_r) + atom_r_halo1 + atom_r_halo2 + atom_r_halo3, elem_%s_r * atom_r\n",vec2[0],vec2[1],vec2[2],el->m_sLabel,el->m_sLabel);
5109
mfprintf(b," pigment { rgbft atom_color_halo3 } finish { reflection atom_reflect_halo3 specular atom_specular_halo3 ambient atom_ambient_halo3 diffuse atom_diffuse_halo3 } no_reflection no_radiosity }\n");
5110
mfprintf(b,"#end\n");
5115
for (z3=0;z3<sm->m_oaBonds.GetSize();z3++)
5117
mb = (CMolBond*)sm->m_oaBonds[z3];
5118
o = mb->m_iAtomOffset[0];
5119
o2 = mb->m_iAtomOffset[1];
5121
el = ((CAtom*)g_oaAtoms[g_waAtomRealElement[o]])->m_pElement;
5122
el2 = ((CAtom*)g_oaAtoms[g_waAtomRealElement[o2]])->m_pElement;
5124
vec1 = m_vaCoords[o];
5127
vec2 = m_vaCoords[o2];
5130
if ((vec1-vec2).GetLength() > 0.3)
5133
vec3 = (vec1/el->m_fRadius + vec2/el2->m_fRadius) / (1.0/el->m_fRadius+1.0/el2->m_fRadius);
5135
vec3b = vec2 - vec1;
5138
mfprintf(b,"#local vec1c = < %g + (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ),\n",vec1[0],vec3b[0],el->m_sLabel,el->m_sLabel,el->m_sLabel,el->m_sLabel);
5139
mfprintf(b," %g + (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ),\n",vec1[1],vec3b[1],el->m_sLabel,el->m_sLabel,el->m_sLabel,el->m_sLabel);
5140
mfprintf(b," %g + (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ) >;\n",vec1[2],vec3b[2],el->m_sLabel,el->m_sLabel,el->m_sLabel,el->m_sLabel);
5141
mfprintf(b,"#local vec2c = < %g - (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ),\n",vec2[0],vec3b[0],el2->m_sLabel,el2->m_sLabel,el2->m_sLabel,el2->m_sLabel);
5142
mfprintf(b," %g - (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ),\n",vec2[1],vec3b[1],el2->m_sLabel,el2->m_sLabel,el2->m_sLabel,el2->m_sLabel);
5143
mfprintf(b," %g - (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ) >;\n",vec2[2],vec3b[2],el2->m_sLabel,el2->m_sLabel,el2->m_sLabel,el2->m_sLabel);
5145
mfprintf(b,"#if (bond_draw)\n");
5146
mfprintf(b," cylinder { < %g, %g, %g >, vec1c, bond_r open\n",vec3[0],vec3[1],vec3[2]);
5147
mfprintf(b," pigment { rgbft m_atom_color(elem_%s_col) } finish { reflection bond_reflect specular bond_specular ambient bond_ambient diffuse bond_diffuse } }\n",el->m_sLabel);
5148
mfprintf(b," cylinder { < %g, %g, %g >, vec2c, bond_r open\n",vec3[0],vec3[1],vec3[2]);
5149
mfprintf(b," pigment { rgbft m_atom_color(elem_%s_col) } finish { reflection bond_reflect specular bond_specular ambient bond_ambient diffuse bond_diffuse } }\n",el2->m_sLabel);
5150
mfprintf(b,"#end\n");
5152
vec3 = cam - (vec1 + vec2) / 2.0;
5156
vec1b = CrossP(vec3,vec2b);
5159
mfprintf(b,"#local vec3 = < %g, %g, %g >;\n",vec3[0],vec3[1],vec3[2]);
5160
mfprintf(b,"#local vec1b = < %g, %g, %g >;\n",vec1b[0],vec1b[1],vec1b[2]);
5164
mfprintf(b,"#if (bond_draw_halo1)\n");
5165
mfprintf(b," #local vecA = vec1c + vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo1;\n");
5166
mfprintf(b," #local vecB = vec2c + vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo1;\n");
5167
mfprintf(b," #local vecC = vec2c + vec1b * (bond_r) - vec3 * bond_d_halo1;\n");
5168
mfprintf(b," #local vecD = vec1c + vec1b * (bond_r) - vec3 * bond_d_halo1;\n");
5169
mfprintf(b," triangle { vecA, vecB, vecC\n");
5170
mfprintf(b," pigment { rgbft bond_color_halo1 } finish { reflection bond_reflect_halo1 specular bond_specular_halo1 ambient bond_ambient_halo1 diffuse bond_diffuse_halo1 } no_reflection no_radiosity }\n");
5171
mfprintf(b," triangle { vecA, vecD, vecC\n");
5172
mfprintf(b," pigment { rgbft bond_color_halo1 } finish { reflection bond_reflect_halo1 specular bond_specular_halo1 ambient bond_ambient_halo1 diffuse bond_diffuse_halo1 } no_reflection no_radiosity }\n");
5173
mfprintf(b," #local vecA = vec1c - vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo1;\n");
5174
mfprintf(b," #local vecB = vec2c - vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo1;\n");
5175
mfprintf(b," #local vecC = vec2c - vec1b * (bond_r) - vec3 * bond_d_halo1;\n");
5176
mfprintf(b," #local vecD = vec1c - vec1b * (bond_r) - vec3 * bond_d_halo1;\n");
5177
mfprintf(b," triangle { vecA, vecB, vecC\n");
5178
mfprintf(b," pigment { rgbft bond_color_halo1 } finish { reflection bond_reflect_halo1 specular bond_specular_halo1 ambient bond_ambient_halo1 diffuse bond_diffuse_halo1 } no_reflection no_radiosity }\n");
5179
mfprintf(b," triangle { vecA, vecD, vecC\n");
5180
mfprintf(b," pigment { rgbft bond_color_halo1 } finish { reflection bond_reflect_halo1 specular bond_specular_halo1 ambient bond_ambient_halo1 diffuse bond_diffuse_halo1 } no_reflection no_radiosity }\n");
5181
mfprintf(b,"#end\n");
5186
mfprintf(b,"#if (bond_draw_halo2)\n");
5187
mfprintf(b," #local vecA = vec1c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5188
mfprintf(b," #local vecB = vec2c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5189
mfprintf(b," #local vecC = vec2c + vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo2;\n");
5190
mfprintf(b," #local vecD = vec1c + vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo2;\n");
5191
mfprintf(b," triangle { vecA, vecB, vecC\n");
5192
mfprintf(b," pigment { rgbft bond_color_halo2 } finish { reflection bond_reflect_halo2 specular bond_specular_halo2 ambient bond_ambient_halo2 diffuse bond_diffuse_halo2 } no_reflection no_radiosity }\n");
5193
mfprintf(b," triangle { vecA, vecD, vecC\n");
5194
mfprintf(b," pigment { rgbft bond_color_halo2 } finish { reflection bond_reflect_halo2 specular bond_specular_halo2 ambient bond_ambient_halo2 diffuse bond_diffuse_halo2 } no_reflection no_radiosity }\n");
5195
mfprintf(b," #local vecA = vec1c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5196
mfprintf(b," #local vecB = vec2c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5197
mfprintf(b," #local vecC = vec2c - vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo2;\n");
5198
mfprintf(b," #local vecD = vec1c - vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo2;\n");
5199
mfprintf(b," triangle { vecA, vecB, vecC\n");
5200
mfprintf(b," pigment { rgbft bond_color_halo2 } finish { reflection bond_reflect_halo2 specular bond_specular_halo2 ambient bond_ambient_halo2 diffuse bond_diffuse_halo2 } no_reflection no_radiosity }\n");
5201
mfprintf(b," triangle { vecA, vecD, vecC\n");
5202
mfprintf(b," pigment { rgbft bond_color_halo2 } finish { reflection bond_reflect_halo2 specular bond_specular_halo2 ambient bond_ambient_halo2 diffuse bond_diffuse_halo2 } no_reflection no_radiosity }\n");
5203
mfprintf(b,"#end\n");
5205
mfprintf(b,"#if (bond_draw_halo3)\n");
5206
mfprintf(b," #local vecA = vec1c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2 + bond_r_halo3) - vec3 * bond_d_halo2;\n");
5207
mfprintf(b," #local vecB = vec2c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2 + bond_r_halo3) - vec3 * bond_d_halo2;\n");
5208
mfprintf(b," #local vecC = vec2c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5209
mfprintf(b," #local vecD = vec1c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5210
mfprintf(b," triangle { vecA, vecB, vecC\n");
5211
mfprintf(b," pigment { rgbft bond_color_halo3 } finish { reflection bond_reflect_halo3 specular bond_specular_halo3 ambient bond_ambient_halo3 diffuse bond_diffuse_halo3 } no_reflection no_radiosity }\n");
5212
mfprintf(b," triangle { vecA, vecD, vecC\n");
5213
mfprintf(b," pigment { rgbft bond_color_halo3 } finish { reflection bond_reflect_halo3 specular bond_specular_halo3 ambient bond_ambient_halo3 diffuse bond_diffuse_halo3 } no_reflection no_radiosity }\n");
5214
mfprintf(b," #local vecA = vec1c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2 + bond_r_halo3) - vec3 * bond_d_halo2;\n");
5215
mfprintf(b," #local vecB = vec2c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2 + bond_r_halo3) - vec3 * bond_d_halo2;\n");
5216
mfprintf(b," #local vecC = vec2c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5217
mfprintf(b," #local vecD = vec1c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5218
mfprintf(b," triangle { vecA, vecB, vecC\n");
5219
mfprintf(b," pigment { rgbft bond_color_halo3 } finish { reflection bond_reflect_halo3 specular bond_specular_halo3 ambient bond_ambient_halo3 diffuse bond_diffuse_halo3 } no_reflection no_radiosity }\n");
5220
mfprintf(b," triangle { vecA, vecD, vecC\n");
5221
mfprintf(b," pigment { rgbft bond_color_halo3 } finish { reflection bond_reflect_halo3 specular bond_specular_halo3 ambient bond_ambient_halo3 diffuse bond_diffuse_halo3 } no_reflection no_radiosity }\n");
5222
mfprintf(b,"#end\n");
5230
mfprintf(b,"#if (bond_draw_stub)\n");
5231
mfprintf(b," #local vec3 = < %g, %g, %g >;\n",vec3[0],vec3[1],vec3[2]);
5232
mfprintf(b," difference {\n");
5233
mfprintf(b," cylinder { vec1c, vec1c + vec3 * bond_l_stub, bond_r + bond_r_stub }\n");
5234
mfprintf(b," cylinder { vec1c - vec3 * (bond_l_stub+0.001), vec1c + vec3 * (bond_l_stub+0.001), bond_r }\n");
5235
mfprintf(b," pigment { rgbft bond_color_stub } finish { reflection bond_reflect_stub specular bond_specular_stub ambient bond_ambient_stub diffuse bond_diffuse_stub } }\n");
5236
mfprintf(b," difference {\n");
5237
mfprintf(b," cylinder { vec2c, vec2c - vec3 * bond_l_stub, bond_r + bond_r_stub }\n");
5238
mfprintf(b," cylinder { vec2c + vec3 * (bond_l_stub+0.001), vec2c - vec3 * (bond_l_stub+0.001), bond_r }\n");
5239
mfprintf(b," pigment { rgbft bond_color_stub } finish { reflection bond_reflect_stub specular bond_specular_stub ambient bond_ambient_stub diffuse bond_diffuse_stub } }\n");
5240
mfprintf(b,"#end\n");
5246
mfprintf(b,"\n no_shadow\n}\n\n");
5252
void CTimeStep::DumpDipoles()
5254
int z, z2, z3, z4, ti;
5256
CSingleMolecule *sm;
5259
if (!(g_bDipole && g_bDumpDipoleVector))
5262
fprintf(g_fDumpDipole,"%lu",g_iSteps);
5263
for (z=0;z<g_oaMolecules.GetSize();z++)
5265
if (g_oaDumpDipoleVector[z] == NULL)
5267
m = (CMolecule*)g_oaMolecules[z];
5268
for (z2=0;z2<((CxIntArray*)g_oaDumpDipoleVector[z])->GetSize();z2++)
5270
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[((CxIntArray*)g_oaDumpDipoleVector[z])->GetAt(z2)]];
5271
fprintf(g_fDumpDipole,"; %10G; %10G; %10G",sm->m_vDipole[0],sm->m_vDipole[1],sm->m_vDipole[2]);
5272
if (g_bDumpDipoleAbs)
5273
fprintf(g_fDumpDipole,"; %10G",sm->m_vDipole.GetLength());
5276
fprintf(g_fDumpDipole,"\n");
5278
if (g_bDumpDipoleXYZ)
5280
fprintf(g_fDumpDipoleXYZ,"%d\n\n",g_iDumpDipoleXYZAtoms);
5281
for (z=0;z<g_oaMolecules.GetSize();z++)
5283
if (g_oaDumpDipoleVector[z] == NULL)
5285
m = (CMolecule*)g_oaMolecules[z];
5286
for (z2=0;z2<((CxIntArray*)g_oaDumpDipoleVector[z])->GetSize();z2++)
5288
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[((CxIntArray*)g_oaDumpDipoleVector[z])->GetAt(z2)]];
5290
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
5292
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
5294
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
5296
ti = ((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4);
5297
fprintf(g_fDumpDipoleXYZ,"%s %12f %12f %12f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0,m_vaCoords[ti][1]/100.0,m_vaCoords[ti][2]/100.0);
5303
for (z=0;z<g_oaMolecules.GetSize();z++)
5305
if (g_oaDumpDipoleVector[z] == NULL)
5307
m = (CMolecule*)g_oaMolecules[z];
5308
for (z2=0;z2<((CxIntArray*)g_oaDumpDipoleVector[z])->GetSize();z2++)
5310
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[((CxIntArray*)g_oaDumpDipoleVector[z])->GetAt(z2)]];
5311
dc = m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[m->m_iDipoleCenterType])->GetAt(m->m_iDipoleCenterIndex)];
5312
fprintf(g_fDumpDipoleXYZ,"B %12f %12f %12f\n",dc[0]/100.0,dc[1]/100.0,dc[2]/100.0);
5313
fprintf(g_fDumpDipoleXYZ,"B %12f %12f %12f\n",dc[0]/100.0+sm->m_vDipole[0]*g_fDumpDipoleScale,dc[1]/100.0+sm->m_vDipole[1]*g_fDumpDipoleScale,dc[2]/100.0+sm->m_vDipole[2]*g_fDumpDipoleScale);
5320
CTimeStep::CTimeStep()
5324
m_vaCoords.SetName("CTimeStep::m_vaCoords");
5325
m_vaCoords_Unfolded.SetName("CTimeStep::m_vaCoords_Unfolded");
5326
m_vaCoords_Original.SetName("CTimeStep::m_vaCoords_Original");
5327
m_vaVelocities.SetName("CTimeStep::m_vaVelocities");
5328
m_vaForces.SetName("CTimeStep::m_vaForces");
5329
m_paLabels.SetName("CTimeStep::m_paLabels");
5330
m_paMol2Types.SetName("CTimeStep::m_paMol2Types");
5331
m_faCharge.SetName("CTimeStep::m_faCharge");
5335
CTimeStep::~CTimeStep()
5337
/* if (m_pLabels != NULL)
5338
delete[] m_pLabels;*/
5339
if (m_pComment != NULL)
5340
delete[] m_pComment;
1
/*****************************************************************************
2
TRAVIS - Trajectory Analyzer and Visualizer
3
http://www.travis-analyzer.de/
5
Copyright (c) 2009-2014 Martin Brehm
6
2012-2014 Martin Thomas
8
This file written by Martin Brehm.
10
This program is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*****************************************************************************/
28
void CTimeStep::CalcCenters()
39
// mprintf("** CalcCenters **");
41
if (m_vaCoords.GetSize() < g_iGesVirtAtomCount)
42
m_vaCoords.SetSize(g_iGesVirtAtomCount);
44
// mprintf("CalcCenters(): Size is now %d.\n",m_vaCoords.GetSize());
47
if (m_vaVelocities.GetSize() < g_iGesVirtAtomCount)
48
m_vaVelocities.SetSize(g_iGesVirtAtomCount);
51
if (m_vaForces.GetSize() < g_iGesVirtAtomCount)
52
m_vaForces.SetSize(g_iGesVirtAtomCount);
54
for (z=0;z<g_oaVirtualAtoms.GetSize();z++)
56
v = (CVirtualAtom*)g_oaVirtualAtoms[z];
57
m = (CMolecule*)g_oaMolecules[v->m_iMolecule];
58
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
60
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
61
if (v->m_iMode == 0) // Mittel aus Atompositionen
65
for (z3=0;z3<v->m_oCenterAtoms.m_baAtomType.GetSize();z3++)
67
for (z4=0;z4<((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetSize();z4++)
69
// mprintf("{%d:(%G|%G|%G) }\n",((CxIntArray*)sm->m_oaAtomOffset[v->m_oCenterAtoms.m_baAtomType[z3]])->GetAt(((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetAt(z4)),m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_oCenterAtoms.m_baAtomType[z3]])->GetAt(((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetAt(z4))][0],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_oCenterAtoms.m_baAtomType[z3]])->GetAt(((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetAt(z4))][1],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_oCenterAtoms.m_baAtomType[z3]])->GetAt(((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetAt(z4))][2]);
70
tv += m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_oCenterAtoms.m_baAtomType[z3]])->GetAt(((CxIntArray*)v->m_oCenterAtoms.m_oaAtoms[z3])->GetAt(z4))] * v->m_faWeight[c];
74
tv /= v->m_fGesWeight;
75
} else if (v->m_iMode == 1) // Abstand, Winkel, Dihedralwinkel
77
tv = PointFromRAD(m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_iAtomType[0]])->GetAt(v->m_iAtom[0])],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_iAtomType[1]])->GetAt(v->m_iAtom[1])],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[v->m_iAtomType[2]])->GetAt(v->m_iAtom[2])],v->m_fValues[0],v->m_fValues[1],v->m_fValues[2]);
78
} else if (v->m_iMode == 2) // Dipolvektor
82
eprintf("Cannot use dipole vectors.\n");
86
tv = sm->m_vDipole + m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[sm->m_baAtomIndex.GetSize()-1])->GetAt(0)];
87
} else if (v->m_iMode == 3) // Geschwindigkeitsvektor
89
} else if (v->m_iMode == 4) // Kraftvektor
92
// mprintf("%d:(%G|%G|%G), ",((CxIntArray*)sm->m_oaAtomOffset[sm->m_baAtomIndex.GetSize()-1])->GetAt(v->m_iMolVirtAtom),tv[0],tv[1],tv[2]);
93
m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[sm->m_baAtomIndex.GetSize()-1])->GetAt(v->m_iMolVirtAtom)] = tv;
100
bool CTimeStep::BondRange(int i1, int i2, double *f)
107
if (g_iScanMolStep == -1)
110
x = m_vaCoords[i1][0] - m_vaCoords[i2][0];
111
y = m_vaCoords[i1][1] - m_vaCoords[i2][1];
112
z = m_vaCoords[i1][2] - m_vaCoords[i2][2];
118
while (x < -g_fBoxX/2)
120
while (x > g_fBoxX/2)
126
while (y < -g_fBoxY/2)
128
while (y > g_fBoxY/2)
134
while (z < -g_fBoxZ/2)
136
while (z > g_fBoxZ/2)
141
d = (float)sqrt(x*x+y*y+z*z);
146
a = g_baAtomIndex[i1];
147
b = g_baAtomIndex[i2];
149
if ((a >= g_oaAtoms.GetSize()) || (b >= g_oaAtoms.GetSize()))
155
if (((CAtom*)g_oaAtoms[a])->m_pElement->m_fRadius == 0)
161
if (((CAtom*)g_oaAtoms[b])->m_pElement->m_fRadius == 0)
167
if (d < (((CAtom*)g_oaAtoms[a])->m_pElement->m_fRadius+((CAtom*)g_oaAtoms[b])->m_pElement->m_fRadius)*g_fBondFactor)
169
// printf(" \"%s\" br=%f, \"%s\" br=%f Hat Nachbarn %s%d im Abstand von %.3f.\n",m_pLabels[i1],c1,m_pLabels[i2],c2,m_pLabels[i2],i2+1,d);
180
bool CTimeStep::MirrorBond(int i1, int i2)
189
while (m_vaCoords[i1][0]-m_vaCoords[i2][0] > g_fBoxX/2)
191
m_vaCoords[i2][0] += g_fBoxX;
194
while (m_vaCoords[i2][0]-m_vaCoords[i1][0] > g_fBoxX/2)
196
m_vaCoords[i2][0] -= g_fBoxX;
203
while (m_vaCoords[i1][1]-m_vaCoords[i2][1] > g_fBoxY/2)
205
m_vaCoords[i2][1] += g_fBoxY;
208
while (m_vaCoords[i2][1]-m_vaCoords[i1][1] > g_fBoxY/2)
210
m_vaCoords[i2][1] -= g_fBoxY;
217
while (m_vaCoords[i1][2]-m_vaCoords[i2][2] > g_fBoxZ/2)
219
m_vaCoords[i2][2] += g_fBoxZ;
222
while (m_vaCoords[i2][2]-m_vaCoords[i1][2] > g_fBoxZ/2)
224
m_vaCoords[i2][2] -= g_fBoxZ;
239
void CTimeStep::RECURSION_ScanMolecules(int i, CxByteArray *ta, CSingleMolecule *sm, int depth, int *stack, unsigned long bmask, bool w)
247
// mprintf(" Rekursion fuer Atom %d.\n",i+1);
249
// mprintf("Depth=%d, i=%d.\n",depth,i);
253
for (z=1;z<depth;z++)
255
if ((bmask & (int)pow(2.0,z)) != 0)
262
mprintf(WHITE,"|--");
263
else mprintf(WHITE,"`--");
265
mprintf(CYAN,"%s",((CAtom*)g_oaAtoms[g_baAtomIndex[i]])->m_sName);
270
g_laAtomSMIndex[i] = (unsigned long)g_oaSingleMolecules.GetSize()-1;
272
// mprintf(" sm->m_baAtomIndex.GetSize()=%d\n",sm->m_baAtomIndex.GetSize());
273
for (z=0;z<sm->m_baAtomIndex.GetSize();z++)
275
if (sm->m_baAtomIndex[z] == g_baAtomIndex[i])
277
try { ma = new CMolAtom(); } catch(...) { ma = NULL; }
278
if (ma == NULL) NewException((double)sizeof(CMolAtom),__FILE__,__LINE__,__PRETTY_FUNCTION__);
282
sm->m_oaMolAtoms.Add(ma);
287
try { ma = new CMolAtom(); } catch(...) { ma = NULL; }
288
if (ma == NULL) NewException((double)sizeof(CMolAtom),__FILE__,__LINE__,__PRETTY_FUNCTION__);
291
ma->m_iType = sm->m_baAtomIndex.GetSize();
293
sm->m_oaMolAtoms.Add(ma);
295
sm->m_baAtomIndex.Add(g_baAtomIndex[i]);
300
if ((m_iConnectedAtoms % m_iGesAtomModulo)==0)
304
for (z=0;z<(long)m_iGesAtomCount;z++) // Schon mal alle Nachbarn raussuchen
308
if (((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_bExclude)
310
if (BondRange(i,z,&f))
314
if ((depth > 0) && (z != stack[depth-1]))
316
if (sm->m_oaRings.GetSize() < 100)
320
mprintf(GREEN," <-- Ring closure: ");
321
mprintf("%s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[stack[depth]]])->m_sName,stack[depth]+1);
324
try { wa = new CxIntArray("CTimeStep::RECURSION_ScanMolecules():wa"); } catch(...) { wa = NULL; }
325
if (wa == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
327
sm->m_oaRings.Add(wa);
328
wa->Add(stack[depth]);
330
while ((stack[z2] != z) && (z2 >= 0))
334
mprintf(" - %s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[stack[z2]]])->m_sName,stack[z2]+1);
339
mprintf(" - %s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_sName,z+1);
340
} else if (!m_bAbortRing)
343
eprintf("\n### More than 100 rings, aborting ring system scan for molecule %d.",sm->m_iIndex+1);
348
/* for (z2=0;z2<g_waBondBlackList.GetSize();z2+=2)
349
if (((g_waBondBlackList[z2] == i) && (g_waBondBlackList[z2+1] == z)) ||
350
((g_waBondBlackList[z2] == z) && (g_waBondBlackList[z2+1] == i)))
355
for (z2=1;z2<depth+1;z2++)
357
if ((bmask & (int)pow(2,z2)) != 0)
362
mprintf(WHITE,"|--");
364
mprintf("%s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_sName,z+1);
365
mprintf(GREEN," <-- This bond has been broken, skipping.\n");
367
g_iBondBlackListUsed++;
372
if (g_iCloseAtomCounter < 25)
373
eprintf("\n### The atoms %s(%d) and %s(%d) are VERY close to each other. (Distance=%.4f pm)",((CAtom*)g_oaAtoms[g_baAtomIndex[i]])->m_sName,i+1,((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_sName,z+1,f);
374
else if (g_iCloseAtomCounter == 25)
375
eprintf("\n### Suppressing further \"atoms close to each other\" warnings.");
377
g_iCloseAtomCounter++;
381
if (nbs >= MAX_BONDS)
383
eprintf("\n### Atom %s(%d) has more than %d bonds. Ignoring further bonds (defined via MAX_BONDS in config.h).",((CAtom*)g_oaAtoms[g_baAtomIndex[i]])->m_sName,i+1,MAX_BONDS);
391
for (z=0;z<nbs;z++) // Fuer das aktuelle Atom z2 alle Nachbarn durchgehen
393
for (z2=0;z2<g_laBondBlackList.GetSize();z2+=2)
395
if (((g_laBondBlackList[z2] == i) && (g_laBondBlackList[z2+1] == nblist[z])) ||
396
((g_laBondBlackList[z2] == nblist[z]) && (g_laBondBlackList[z2+1] == i)))
401
for (z2=1;z2<depth+1;z2++)
403
if ((bmask & (int)pow(2.0,z2)) != 0)
408
mprintf(WHITE,"|--");
409
else mprintf(WHITE,"`--");
410
mprintf(CYAN,"%s",((CAtom*)g_oaAtoms[g_baAtomIndex[nblist[z]]])->m_sName);
411
mprintf("(%d)",nblist[z]+1);
412
mprintf(GREEN," <-- This bond shall be broken, skipping.\n");
414
g_iBondBlackListUsed++;
419
sm->m_laBonds.Add(i);
420
sm->m_laBonds.Add(nblist[z]);
422
if ((*ta)[nblist[z]] == 0) // Der Nachbar ist noch immer frei
425
bmask -= (int)pow(2.0,depth+1);
426
RECURSION_ScanMolecules(nblist[z],ta,sm,depth+1,stack,bmask,(z+1==nbs)?false:true);
427
} else // Ringschluss
432
for (z2=1;z2<depth+1;z2++)
434
if ((bmask & (int)pow(2.0,z2)) != 0)
439
mprintf(WHITE,"|--");
440
else mprintf(WHITE,"`--");
441
mprintf(CYAN,"%s",((CAtom*)g_oaAtoms[g_baAtomIndex[nblist[z]]])->m_sName);
442
mprintf("(%d)",nblist[z]+1);
443
mprintf(GREEN," <-- Ring closure\n");
452
void CTimeStep::BuildAtomIndex()
459
g_baAtomIndex.SetSize(m_iGesAtomCount);
460
for (z=0;z<(long)m_iGesAtomCount;z++)
462
strcpy(buf,(char*)m_paLabels[z]);
464
for (z2=0;z2<g_oaAtoms.GetSize();z2++)
466
if (mystricmp(buf,((CAtom*)g_oaAtoms[z2])->m_sName)==0)
468
at = (CAtom*)g_oaAtoms[z2];
469
// mprintf("Atom %d: Type %d (%s).\n",z,z2,at->m_sName);
470
while (at->m_pMergedTo != NULL)
472
at = at->m_pMergedTo;
473
// mprintf(" ...was merged to %s.\n",at->m_sName);
475
// mprintf(" Index is %d.\n",at->m_iIndex);
476
g_baAtomIndex[z] = (unsigned char)at->m_iIndex;
480
g_baAtomIndex[z] = 255;
481
eprintf("Error: CTimeStep::BuildAtomIndex(): Atom type \"%s\" not known.\n",buf);
488
bool CTimeStep::ScanMolecules()
491
int z, z2, z3, z4, z5, i, i2, ti, ti2, i1;
493
CSingleMolecule *sm, *sm2;
494
CxIntArray *wa, *waz2, *waz3, *waneu;
496
CMolAtom *ma, *ma2, *ma3;
497
CMolBond *bond, *bond2;
499
CMolAngle *angle, *angle2;
510
try { stack = new int[g_iGesAtomCount]; } catch(...) { stack = NULL; }
511
if (stack == NULL) NewException((double)g_iGesAtomCount*sizeof(int),__FILE__,__LINE__,__PRETTY_FUNCTION__);
514
for (z=0;z<g_oaAtoms.GetSize();z++)
516
if (z == g_iVirtAtomType)
518
at = (CAtom*)g_oaAtoms[z];
519
if (at->m_pMergedTo != NULL)
521
if (at->m_pElement->m_fRadius == 0)
528
at->m_bExclude = AskYesNo(" Atom type \"%s\" has bond radius 0. Exclude it from the system (y/n)? [yes] ",true,at->m_sName);
529
// if (!at->m_bExclude)
530
// at->m_pElement->m_fRadius = AskFloat_ND(" Please enter covalent bond radius for %s (in pm): ",at->m_sName);
534
ta.SetSize(g_iGesAtomCount);
535
g_laAtomSMIndex.SetSize(g_iGesAtomCount);
536
for (z=0;z<g_iGesAtomCount;z++)
539
g_laAtomSMIndex[z] = -1;
541
g_iBondBlackListUsed = 0;
542
g_oaSingleMolecules.RemoveAll();
543
g_oaMolecules.RemoveAll();
544
m_iConnectedAtoms = 0;
545
m_iGesAtomModulo = (m_iGesAtomCount / 60)+1;
546
if (g_iScanMolStep == -1)
548
mprintf(WHITE,"\n Skipping molecule recognition, using atoms as molecules...\n\n");
549
for (z=0;z<(long)m_iGesAtomCount;z++)
551
if (((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_bExclude)
554
try { sm = new CSingleMolecule(); } catch(...) { sm = NULL; }
555
if (sm == NULL) NewException((double)sizeof(CSingleMolecule),__FILE__,__LINE__,__PRETTY_FUNCTION__);
557
sm->m_iIndex = g_oaSingleMolecules.GetSize();
559
g_oaSingleMolecules.Add(sm);
561
g_laAtomSMIndex[z] = (unsigned long)g_oaSingleMolecules.GetSize()-1;
563
try { ma = new CMolAtom(); } catch(...) { ma = NULL; }
564
if (ma == NULL) NewException((double)sizeof(CMolAtom),__FILE__,__LINE__,__PRETTY_FUNCTION__);
567
ma->m_iType = sm->m_baAtomIndex.GetSize();
569
sm->m_oaMolAtoms.Add(ma);
570
sm->m_baAtomIndex.Add(g_baAtomIndex[z]);
572
mprintf(" %d molecules found.\n\n",g_oaSingleMolecules.GetSize());
577
mprintf(WHITE,"\n Molecule recognition...\n\n");
578
mprintf(WHITE,">>> Output of the molecule tree >>>\n");
579
} else mprintf("\n Molecule recognition [");
581
for (z=0;z<(long)m_iGesAtomCount;z++)
583
if (ta[z] != 0) // Dieses Atom wurde bereits in irgendein Molekuel eingebaut
585
// mprintf("> Atom %d: Schon vergeben.\n",z+1);
588
// mprintf("# Atom %d: Starte Rekursion.\n",z+1);
590
if (((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_bExclude)
593
try { sm = new CSingleMolecule(); } catch(...) { sm = NULL; }
594
if (sm == NULL) NewException((double)sizeof(CSingleMolecule),__FILE__,__LINE__,__PRETTY_FUNCTION__);
596
sm->m_iIndex = g_oaSingleMolecules.GetSize();
598
g_oaSingleMolecules.Add(sm);
600
// sm->m_iAtomGes = 0;
601
/* for (z2=0;z2<16;z2++)
602
sm->m_iAtomCount[z2] = 0;
603
sm->m_iElements = 0;*/
605
mprintf(YELLOW,"\nThe next molecule starts with %s(%d):\n",m_paLabels[z],z+1);
607
m_bAbortRing = false;
609
RECURSION_ScanMolecules(z,&ta,sm,0,stack,0xFFFFFFFF,true);
611
// printf("%d Atome in diesem Molekuel.\n",g_pSingleMolecules[g_oaSingleMolecules.GetSize()].AtomGes);
613
// g_oaSingleMolecules.GetSize()++;
617
mprintf(WHITE,"\n<<< Output of the molecule tree <<<\n\n");
618
mprintf("%d molecules found.\n\n",g_oaSingleMolecules.GetSize());
619
} else mprintf("]\n\n %d molecules found.\n\n",g_oaSingleMolecules.GetSize());
622
if (g_iCloseAtomCounter != 0)
624
mprintf(RED,"\n*** Warning: ");
625
mprintf("Some of the atoms were found to be very close to each other (distance < 50 pm).\n");
626
mprintf(" This usually indicates a problem, e.g. an incorrect cell vector.\n\n");
627
if (!AskYesNo(" Continue with molecule recognition anyways (y/n)? [yes] ",true))
632
mprintf(" Sorting atom types...\n");
633
SortSingleMolAtomTypes();
638
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
641
((CSingleMolecule*)g_oaSingleMolecules[z])->Dump();
644
mprintf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");*/
647
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
650
((CSingleMolecule*)g_oaSingleMolecules[z])->Dump();
652
mprintf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");*/
653
if (g_iBondBlackListUsed != 0)
654
mprintf(" %d bonds have been broken.\n",g_iBondBlackListUsed);
656
/* if (g_oaSingleMolecules.GetSize() >= 4096)
658
mprintf("\n>>> Mehr als 4096 Molekuele! Dies wird nicht unterstuetzt. <<<\n\n");
659
// g_oaSingleMolecules.GetSize() = 4096;
662
mprintf(" Setting up bond lists...\n");
663
// Die Bindungen in m_oaMolAtoms aufbauen
664
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
666
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
667
for (z2=0;z2<sm->m_laBonds.GetSize()/2;z2++)
669
i = sm->m_laBonds[z2*2];
670
i2 = sm->m_laBonds[z2*2+1];
672
for (z3=0;z3<sm->m_oaMolAtoms.GetSize();z3++)
674
if (((CMolAtom*)sm->m_oaMolAtoms[z3])->m_iOffset == i)
682
eprintf("CTimeStep::ScanMolecules(): Atom 1 of bond (%d) not found.\n",i);
686
for (z3=0;z3<sm->m_oaMolAtoms.GetSize();z3++)
688
if (((CMolAtom*)sm->m_oaMolAtoms[z3])->m_iOffset == i2)
696
eprintf("CTimeStep::ScanMolecules(): Atom 2 of bond (%d) not found.\n",i2);
699
((CMolAtom*)sm->m_oaMolAtoms[ti])->m_oaBonds.Add((CMolAtom*)sm->m_oaMolAtoms[ti2]);
700
((CMolAtom*)sm->m_oaMolAtoms[ti2])->m_oaBonds.Add((CMolAtom*)sm->m_oaMolAtoms[ti]);
704
// Die AtomCodes berechnen
705
mprintf(" Building atom codes...\n");
706
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
708
// mprintf("Molecule %d: ",z+1);
709
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
711
mprintf(YELLOW,"\n*** Singlemolecule %d ***\n\n",z+1);
712
sm->BuildAtomCodes();
715
mprintf(" Creating topological atom order...\n");
716
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
718
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
719
for (z2=0;z2<sm->m_baAtomIndex.GetSize();z2++)
721
try { wa = new CxIntArray("CTimeStep::ScanMolecules():wa"); } catch(...) { wa = NULL; }
722
if (wa == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
724
sm->m_oaAtomOffset.Add(wa);
725
for (z3=0;z3<sm->m_oaMolAtoms.GetSize();z3++)
727
ma = (CMolAtom*)sm->m_oaMolAtoms[z3];
728
if (ma->m_iType != z2)
730
ma->m_iNumber = wa->GetSize();
731
wa->Add(ma->m_iOffset);
736
mprintf(" Creating bond list...\n");
737
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
739
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
740
// mprintf("%d:\n",z+1);
741
for (z2=0;z2<sm->m_oaMolAtoms.GetSize();z2++)
743
ma = (CMolAtom*)sm->m_oaMolAtoms[z2];
744
for (z3=0;z3<ma->m_oaBonds.GetSize();z3++)
746
ma2 = (CMolAtom*)ma->m_oaBonds[z3];
747
if (ma2->m_iMolAtomNumber < z2 /* == ma->m_iMolAtomNumber*/)
750
// mprintf(" %s%2d <--> %s%2d\n",((CAtom*)g_oaAtoms[sm->m_baAtomIndex[ma->m_iType]])->m_sName,ma->m_iNumber+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[ma2->m_iType]])->m_sName,ma2->m_iNumber+1);
752
try { bond = new CMolBond(); } catch(...) { bond = NULL; }
753
if (bond == NULL) NewException((double)sizeof(CMolBond),__FILE__,__LINE__,__PRETTY_FUNCTION__);
755
bond->m_iAtom[0] = ma->m_iNumber;
756
bond->m_iAtom[1] = ma2->m_iNumber;
757
bond->m_iAtomType[0] = ma->m_iType;
758
bond->m_iAtomType[1] = ma2->m_iType;
759
bond->m_iMolAtom[0] = z2;
760
bond->m_iMolAtom[1] = ma2->m_iMolAtomNumber;
761
bond->m_iAtomOffset[0] = ma->m_iOffset;
762
bond->m_iAtomOffset[1] = ma2->m_iOffset;
763
sm->m_oaBonds.Add(bond);
767
mprintf(" %d Bonds added.\n",oatemp.GetSize());*/
768
for (z2=0;z2<sm->m_oaBonds.GetSize();z2++)
770
bond = (CMolBond*)sm->m_oaBonds[z2];
771
for (z3=0;z3<sm->m_oaBondGroups.GetSize();z3++)
773
bg = (CMolBondGroup*)sm->m_oaBondGroups[z3];
774
for (z4=0;z4<bg->m_oaBonds.GetSize();z4++)
776
bond2 = (CMolBond*)bg->m_oaBonds[z4];
777
if (((((CMolAtom*)sm->m_oaMolAtoms[bond->m_iMolAtom[0]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[bond2->m_iMolAtom[0]])->m_fAtomCode) &&
778
(((CMolAtom*)sm->m_oaMolAtoms[bond->m_iMolAtom[1]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[bond2->m_iMolAtom[1]])->m_fAtomCode)) ||
779
((((CMolAtom*)sm->m_oaMolAtoms[bond->m_iMolAtom[0]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[bond2->m_iMolAtom[1]])->m_fAtomCode) &&
780
(((CMolAtom*)sm->m_oaMolAtoms[bond->m_iMolAtom[1]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[bond2->m_iMolAtom[0]])->m_fAtomCode)))
782
bg->m_oaBonds.Add(bond);
788
try { bg = new CMolBondGroup(); } catch(...) { bg = NULL; }
789
if (bg == NULL) NewException((double)sizeof(CMolBondGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
791
bg->m_oaBonds.Add(bond);
792
sm->m_oaBondGroups.Add(bg);
797
mprintf(" %d Bond groups found:\n",sm->m_oaBondGroups.GetSize());
798
for (z2=0;z2<sm->m_oaBondGroups.GetSize();z2++)
801
bg = (CMolBondGroup*)sm->m_oaBondGroups[z2];
802
for (z3=0;z3<bg->m_oaBonds.GetSize();z3++)
804
bond = (CMolBond*)bg->m_oaBonds[z3];
805
mprintf("%s%2d <--> %s%2d",((CAtom*)g_oaAtoms[sm->m_baAtomIndex[bond->m_iAtomType[0]]])->m_sName,bond->m_iAtom[0]+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[bond->m_iAtomType[1]]])->m_sName,bond->m_iAtom[1]+1);
806
if (z3 < bg->m_oaBonds.GetSize()-1)
814
mprintf(" Creating angle list...\n");
815
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
817
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
818
// mprintf("%d:\n",z+1);
819
for (z2=0;z2<sm->m_oaMolAtoms.GetSize();z2++)
821
ma = (CMolAtom*)sm->m_oaMolAtoms[z2];
822
for (z3=0;z3<ma->m_oaBonds.GetSize();z3++)
824
ma2 = (CMolAtom*)ma->m_oaBonds[z3];
825
for (z4=z3+1;z4<ma->m_oaBonds.GetSize();z4++)
827
ma3 = (CMolAtom*)ma->m_oaBonds[z4];
828
// mprintf(" (%s%2d, %s%2d, %s%2d)\n",((CAtom*)g_oaAtoms[sm->m_baAtomIndex[ma2->m_iType]])->m_sName,ma2->m_iNumber+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[ma->m_iType]])->m_sName,ma->m_iNumber+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[ma3->m_iType]])->m_sName,ma3->m_iNumber+1);
830
try { angle = new CMolAngle(); } catch(...) { angle = NULL; }
831
if (angle == NULL) NewException((double)sizeof(CMolAngle),__FILE__,__LINE__,__PRETTY_FUNCTION__);
833
angle->m_iAtom[0] = ma2->m_iNumber;
834
angle->m_iAtom[1] = ma->m_iNumber;
835
angle->m_iAtom[2] = ma3->m_iNumber;
836
angle->m_iAtomType[0] = ma2->m_iType;
837
angle->m_iAtomType[1] = ma->m_iType;
838
angle->m_iAtomType[2] = ma3->m_iType;
839
angle->m_iMolAtom[0] = ma2->m_iMolAtomNumber;
840
angle->m_iMolAtom[1] = z2;
841
angle->m_iMolAtom[2] = ma3->m_iMolAtomNumber;
842
angle->m_iAtomOffset[0] = ma2->m_iOffset;
843
angle->m_iAtomOffset[1] = ma->m_iOffset;
844
angle->m_iAtomOffset[2] = ma3->m_iOffset;
845
sm->m_oaAngles.Add(angle);
850
mprintf(" %d Angles added.\n",oatemp.GetSize());*/
851
if (sm->m_oaAngles.GetSize() > 1000)
853
tfs = sm->m_oaAngles.GetSize() / 50.0;
854
for (z2=0;z2<sm->m_oaAngles.GetSize();z2++)
856
if (sm->m_oaAngles.GetSize() > 1000)
857
if (fmod(z2,tfs) < 1)
859
angle = (CMolAngle*)sm->m_oaAngles[z2];
860
for (z3=0;z3<sm->m_oaAngleGroups.GetSize();z3++)
862
ag = (CMolAngleGroup*)sm->m_oaAngleGroups[z3];
863
for (z4=0;z4<ag->m_oaAngles.GetSize();z4++)
865
angle2 = (CMolAngle*)ag->m_oaAngles[z4];
866
if (( ((CMolAtom*)sm->m_oaMolAtoms[angle->m_iMolAtom[1]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[angle2->m_iMolAtom[1]])->m_fAtomCode) &&
867
(((( ((CMolAtom*)sm->m_oaMolAtoms[angle->m_iMolAtom[0]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[angle2->m_iMolAtom[0]])->m_fAtomCode) &&
868
( ((CMolAtom*)sm->m_oaMolAtoms[angle->m_iMolAtom[2]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[angle2->m_iMolAtom[2]])->m_fAtomCode))) ||
869
(( ((CMolAtom*)sm->m_oaMolAtoms[angle->m_iMolAtom[0]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[angle2->m_iMolAtom[2]])->m_fAtomCode) &&
870
( ((CMolAtom*)sm->m_oaMolAtoms[angle->m_iMolAtom[2]])->m_fAtomCode == ((CMolAtom*)sm->m_oaMolAtoms[angle2->m_iMolAtom[0]])->m_fAtomCode))))
872
ag->m_oaAngles.Add(angle);
878
try { ag = new CMolAngleGroup(); } catch(...) { ag = NULL; }
879
if (ag == NULL) NewException((double)sizeof(CMolAngleGroup),__FILE__,__LINE__,__PRETTY_FUNCTION__);
881
ag->m_oaAngles.Add(angle);
882
sm->m_oaAngleGroups.Add(ag);
885
if (sm->m_oaAngles.GetSize() > 1000)
886
mprintf(WHITE,"]\n");
889
mprintf(" %d Angle groups found:\n",sm->m_oaAngleGroups.GetSize());
890
for (z2=0;z2<sm->m_oaAngleGroups.GetSize();z2++)
893
ag = (CMolAngleGroup*)sm->m_oaAngleGroups[z2];
894
for (z3=0;z3<ag->m_oaAngles.GetSize();z3++)
896
angle = (CMolAngle*)ag->m_oaAngles[z3];
897
mprintf(" (%s%2d, %s%2d, %s%2d)",((CAtom*)g_oaAtoms[sm->m_baAtomIndex[angle->m_iAtomType[0]]])->m_sName,angle->m_iAtom[0]+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[angle->m_iAtomType[1]]])->m_sName,angle->m_iAtom[1]+1,((CAtom*)g_oaAtoms[sm->m_baAtomIndex[angle->m_iAtomType[2]]])->m_sName,angle->m_iAtom[2]+1);
898
if (z3 < ag->m_oaAngles.GetSize()-1)
906
mprintf(" Grouping together equivalent molecules...\n");
907
for (z=0;z<g_oaSingleMolecules.GetSize();z++) // Alle Molekuelvertreter durchgehen
909
// mprintf("Pruefe SM %d...\n",z+1);
910
sm = (CSingleMolecule*)g_oaSingleMolecules[z];
911
for (z2=0;z2<g_oaMolecules.GetSize();z2++) // Alle schon vorhandenen Molekueltemplates durchgehen
913
m = (CMolecule*)g_oaMolecules[z2];
914
sm2 = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[0]];
915
/* if (m->m_baAtomIndex.GetSize() != sm->m_baAtomIndex.GetSize())
916
goto _cont; // Nich die Gleiche Anzahl verschiedener Elemente -> Keine Uebereinstimmung
917
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
919
if (m->m_baAtomIndex[z3] != sm->m_baAtomIndex[z3])
920
goto _cont; // Elemente an Position z3 unterscheiden sich -> keine Uebereinstimmung
921
if (m->m_waAtomCount[z3] != ((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize())
922
goto _cont; // Anzahl an Atomen dieser Elementsorte unterscheidet sich -> Keine Uebereinstimmung*/
923
// mprintf(" Stimmt mit M%d ueberein.\n",z2);
924
// ((CMolecule*)g_oaMolecules[z2])->Count++;
925
// g_pSingleMolecules[z].m_iMoleculeOffset = z2;
927
if (sm->m_oaMolAtoms.GetSize() != sm2->m_oaMolAtoms.GetSize())
929
for (z3=0;z3<sm->m_oaMolAtoms.GetSize();z3++)
930
if (((CMolAtom*)sm->m_oaMolAtoms[z3])->m_fAtomCode != ((CMolAtom*)sm2->m_oaMolAtoms[z3])->m_fAtomCode)
932
sm->m_iMolSMIndex = m->m_laSingleMolIndex.GetSize();
933
m->m_laSingleMolIndex.Add(z);
934
// sm->m_iMolType = z2;
939
try { m = new CMolecule(); } catch(...) { m = NULL; }
940
if (m == NULL) NewException((double)sizeof(CMolecule),__FILE__,__LINE__,__PRETTY_FUNCTION__);
942
g_oaMolecules.Add(m);
943
// m->Count = 1; // Neues Molekueltemplate hinzufuegen
944
// m->Elements = ((CSingleMolecule*)g_oaSingleMolecules[z])->m_iElements;
947
for (z2=0;z2<sm->m_oaAtomOffset.GetSize();z2++)
949
m->m_iAtomGes += ((CxIntArray*)sm->m_oaAtomOffset[z2])->GetSize();
950
f += ((CAtom*)g_oaAtoms[sm->m_baAtomIndex[z2]])->m_pElement->m_fMass * ((CxIntArray*)sm->m_oaAtomOffset[z2])->GetSize();
952
m->m_iAtomGesNoVirt = m->m_iAtomGes;
954
((CSingleMolecule*)g_oaSingleMolecules[z])->m_iMolType = g_oaMolecules.GetSize()-1;
955
for (z2=0;z2<((CSingleMolecule*)g_oaSingleMolecules[z])->m_baAtomIndex.GetSize();z2++)
957
m->m_baAtomIndex.Add(((CSingleMolecule*)g_oaSingleMolecules[z])->m_baAtomIndex[z2]);
958
m->m_waAtomCount.Add(((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[z])->m_oaAtomOffset[z2])->GetSize());
959
// m->AtomCount[z2] = ((CSingleMolecule*)g_oaSingleMolecules[z])->m_iAtomCount[z2];
961
sm->m_iMolSMIndex = m->m_laSingleMolIndex.GetSize();
962
m->m_laSingleMolIndex.Add(z);
963
// g_pSingleMolecules[z].m_iMoleculeOffset = g_oaMolecules.GetSize();
966
// Standardmaessig geom. Zentrum als Dipolzentrum
967
m->m_iDipoleCenterType = m->m_baAtomIndex.GetSize();
968
m->m_iDipoleCenterIndex = 0;
970
// mprintf("### Erzeuge neues Molekuel %d \"%s\".\n",g_oaMolecules.GetSize(),m->Name);
971
// g_oaMolecules.GetSize()++;
974
mprintf(" Found %d unique molecule types.\n",g_oaMolecules.GetSize());
976
// Sort by molecular mass
977
mprintf(" Sorting molecule types by molecular mass...\n");
978
for (z=0;z<g_oaMolecules.GetSize();z++)
980
// mprintf("@ z=%d\n",z);
983
for (z2=z;z2<g_oaMolecules.GetSize();z2++)
985
// mprintf("@ z2=%d\n",z2);
986
if (((CMolecule*)g_oaMolecules[z2])->m_fMass > f)
988
// mprintf("@ %f > %f --> z3 = %d\n",((CMolecule*)g_oaMolecules[z2])->m_fMass,f,z2);
989
f = ((CMolecule*)g_oaMolecules[z2])->m_fMass;
997
// mprintf("@ Swapping %d with %d.\n",z,z3);
998
m = (CMolecule*)g_oaMolecules[z3];
999
g_oaMolecules[z3] = g_oaMolecules[z];
1000
g_oaMolecules[z] = m;
1004
for (z=0;z<g_oaMolecules.GetSize();z++)
1006
((CMolecule*)g_oaMolecules[z])->m_iIndex = z;
1007
for (z2=0;z2<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z2++)
1008
((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[z2]])->m_iMolType = z;
1012
/* for (z=0;z<g_oaMolecules.GetSize();z++)
1014
m = (CMolecule*)g_oaMolecules[z];
1015
sm = (CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[0]];
1016
mprintf("Molecule %d Ring systems:\n",z+1);
1017
for (z2=0;z2<sm->m_oaRings.GetSize();z2++)
1019
wa = (CxIntArray*)sm->m_oaRings[z2];
1020
mprintf(" - Ring %d: ",z2+1);
1021
for (z3=0;z3<wa->GetSize();z3++)
1023
mprintf("%d",(*wa)[z3]);
1024
if (z3+1 < wa->GetSize())
1033
for (z=0;z<g_oaMolecules.GetSize();z++)
1035
sm = (CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[0]];
1036
ti += sm->m_oaRings.GetSize();
1039
mprintf(" Found %d rings.\n",ti);
1042
mprintf(" Refining ring systems...\n");
1044
try { wa = new CxIntArray("CTimeStep::ScanMolecules():wa"); } catch(...) { wa = NULL; }
1045
if (wa == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1047
// Process ring systems
1048
for (z=0;z<g_oaMolecules.GetSize();z++)
1050
m = (CMolecule*)g_oaMolecules[z];
1051
sm = (CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[0]];
1052
if (sm->m_oaRings.GetSize() > 100)
1054
eprintf(" More than 100 rings in molecule %d, skipping refinement. Ring system may be improper.\n",z+1);
1062
eprintf(" Too many iterations in molecule %d, aborting refinement. Ring system may be improper.\n",z+1);
1065
// mprintf("### again\n");
1066
for (z2=0;z2<sm->m_oaRings.GetSize();z2++)
1068
waz2 = (CxIntArray*)sm->m_oaRings[z2];
1069
for (z3=z2+1;z3<sm->m_oaRings.GetSize();z3++)
1071
waz3 = (CxIntArray*)sm->m_oaRings[z3];
1073
// mprintf("*A* Checking if %d(%d) contains %d(%d)...\n",z2+1,waz2->GetSize(),z3+1,waz3->GetSize());
1074
// Check if waz2 contains waz3
1075
wa->SetSize(waz2->GetSize());
1076
for (z4=0;z4<waz2->GetSize();z4++)
1078
for (z4=0;z4<waz3->GetSize();z4++)
1080
for (z5=0;z5<waz2->GetSize();z5++)
1082
if ((*waz3)[z4] == (*waz2)[z5])
1091
// mprintf(" Yes!\n");
1093
try { waneu = new CxIntArray("CTimeStep::ScanMolecules():waneu"); } catch(...) { waneu = NULL; }
1094
if (waneu == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1096
for (z4=0;z4<waz2->GetSize();z4++)
1100
if (((*wa)[z4] == 0) || ((*wa)[z4+1] == 0) || ((*wa)[waz2->GetSize()-1] == 0))
1101
waneu->Add((*waz2)[z4]);
1102
} else if (z4 == waz2->GetSize()-1)
1104
if (((*wa)[z4] == 0) || ((*wa)[z4-1] == 0) || ((*wa)[0] == 0))
1105
waneu->Add((*waz2)[z4]);
1108
if (((*wa)[z4] == 0) || ((*wa)[z4+1] == 0) || ((*wa)[z4-1] == 0))
1109
waneu->Add((*waz2)[z4]);
1112
// mprintf(" Took %d from %d atoms from waz2.\n",waneu->GetSize(),waz2->GetSize());
1113
i1 = waz2->GetSize();
1115
sm->m_oaRings[z2] = waneu;
1116
if (waneu->GetSize() != i1)
1120
// mprintf("*B* Checking if %d contains %d...\n",z3+1,z2+1);
1121
// Check if waz3 contains waz2
1122
wa->SetSize(waz3->GetSize());
1123
for (z4=0;z4<waz3->GetSize();z4++)
1125
for (z4=0;z4<waz2->GetSize();z4++)
1127
for (z5=0;z5<waz3->GetSize();z5++)
1129
if ((*waz2)[z4] == (*waz3)[z5])
1138
// mprintf(" Yes!\n");
1140
try { waneu = new CxIntArray("CTimeStep::ScanMolecules():waneu"); } catch(...) { waneu = NULL; }
1141
if (waneu == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1143
for (z4=0;z4<waz3->GetSize();z4++)
1147
if (((*wa)[z4] == 0) || ((*wa)[z4+1] == 0) || ((*wa)[waz3->GetSize()-1] == 0))
1148
waneu->Add((*waz3)[z4]);
1149
} else if (z4 == waz3->GetSize()-1)
1151
if (((*wa)[z4] == 0) || ((*wa)[z4-1] == 0) || ((*wa)[0] == 0))
1152
waneu->Add((*waz3)[z4]);
1155
if (((*wa)[z4] == 0) || ((*wa)[z4+1] == 0) || ((*wa)[z4-1] == 0))
1156
waneu->Add((*waz3)[z4]);
1159
// mprintf(" Took %d from %d atoms from waz3.\n",waneu->GetSize(),waz3->GetSize());
1160
i1 = waz3->GetSize();
1162
sm->m_oaRings[z3] = waneu;
1163
if (waneu->GetSize() != i1)
1171
mprintf(" Assigning ring systems to molecule types...\n");
1172
for (z=0;z<g_oaMolecules.GetSize();z++)
1174
m = (CMolecule*)g_oaMolecules[z];
1175
sm = (CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[0]];
1176
for (z2=0;z2<sm->m_oaRings.GetSize();z2++)
1178
wa = (CxIntArray*)sm->m_oaRings[z2];
1180
try { waz2 = new CxIntArray("CTimeStep::ScanMolecules():waz2"); } catch(...) { waz2 = NULL; }
1181
if (waz2 == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1183
try { waz3 = new CxIntArray("CTimeStep::ScanMolecules():waz3"); } catch(...) { waz3 = NULL; }
1184
if (waz3 == NULL) NewException((double)sizeof(CxIntArray),__FILE__,__LINE__,__PRETTY_FUNCTION__);
1186
m->m_oaRingAtomTypes.Add(waz2);
1187
m->m_oaRingAtoms.Add(waz3);
1188
for (z3=0;z3<wa->GetSize();z3++)
1190
for (z4=0;z4<sm->m_baAtomIndex.GetSize();z4++)
1192
for (z5=0;z5<((CxIntArray*)sm->m_oaAtomOffset[z4])->GetSize();z5++)
1194
if (((CxIntArray*)sm->m_oaAtomOffset[z4])->GetAt(z5) == wa->GetAt(z3))
1207
mprintf(" Sorting rings by size...\n");
1208
for (z=0;z<g_oaMolecules.GetSize();z++)
1210
m = (CMolecule*)g_oaMolecules[z];
1212
for (z2=0;z2<m->m_oaRingAtoms.GetSize();z2++)
1216
for (z3=z2;z3<m->m_oaRingAtoms.GetSize();z3++)
1218
if (((CxIntArray*)m->m_oaRingAtoms[z3])->GetSize() > i1)
1220
i1 = ((CxIntArray*)m->m_oaRingAtoms[z3])->GetSize();
1224
if ((ti != -1) && (ti != z2))
1226
wa = (CxIntArray*)m->m_oaRingAtoms[z2];
1227
m->m_oaRingAtoms[z2] = m->m_oaRingAtoms[ti];
1228
m->m_oaRingAtoms[ti] = wa;
1229
wa = (CxIntArray*)m->m_oaRingAtomTypes[z2];
1230
m->m_oaRingAtomTypes[z2] = m->m_oaRingAtomTypes[ti];
1231
m->m_oaRingAtomTypes[ti] = wa;
1237
/* for (z=0;z<g_oaMolecules.GetSize();z++)
1239
m = (CMolecule*)g_oaMolecules[z];
1240
sm = (CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex[0]];
1241
mprintf("Molecule %d Ring systems:\n",z+1);
1242
for (z2=0;z2<sm->m_oaRings.GetSize();z2++)
1244
wa = (CxIntArray*)sm->m_oaRings[z2];
1245
mprintf(" - Ring %d: ",z2+1);
1246
for (z3=0;z3<wa->GetSize();z3++)
1248
mprintf("%d",(*wa)[z3]);
1249
if (z3+1 < wa->GetSize())
1257
/* mprintf("\n%d Molekuelsorten gefunden.\n",g_oaMolecules.GetSize());
1258
for (z=0;z<g_oaMolecules.GetSize();z++)
1259
mprintf("Molekuel \"%s\": %d Atome gesamt, %d mal in der Simulation.\n",g_pMolecules[z].Name,g_pMolecules[z].AtomGes,g_pMolecules[z].Count);
1262
for (z=0;z<g_oaMolecules.GetSize();z++)
1265
((CMolecule*)g_oaMolecules[z])->Dump();
1267
mprintf(" Molecule recognition finished.\n");
1273
void CTimeStep::RECURSION_MegaTree(int i, char *ta, int depth, unsigned long bmask, bool w, int *stack)
1277
int nblist[20], nbs;
1281
for (z=1;z<depth;z++)
1283
if ((bmask & (int)pow(2.0,z)) != 0)
1284
mprintf(WHITE,"| ");
1290
mprintf(WHITE,"|--");
1291
else mprintf(WHITE,"`--");
1293
mprintf("%s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[i]])->m_sName,i+1);
1295
for (z=0;z<(long)m_iGesAtomCount;z++) // Schon mal alle Nachbarn raussuchen
1299
if (BondRange(i,z,NULL))
1303
if ((depth > 0) && (z != stack[depth-1]))
1305
mprintf(GREEN," <-- Ring closure: ");
1306
mprintf("%s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[stack[depth]]])->m_sName,stack[depth]+1);
1308
while ((stack[z2] != z) && (z2 >= 0))
1310
mprintf(" - %s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[stack[z2]]])->m_sName,stack[z2]+1);
1313
mprintf(" - %s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_sName,z+1);
1314
// mprintf("Ringschluss! [d-1=%d,d=%d,i=%d] %s(%d)\n",stack[depth-1]+1,stack[depth]+1,i+1,((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_sName,z+1);
1323
for (z=0;z<nbs;z++) // Fuer das aktuelle Atom z2 alle Nachbarn finden
1325
if (ta[nblist[z]] != 0) // Der Nachbar wurde uns weggeschnappt -> Ringschluss
1327
for (z2=1;z2<depth+1;z2++)
1329
if ((bmask & (int)pow(2.0,z2)) != 0)
1330
mprintf(WHITE,"| ");
1334
mprintf(WHITE,"|--");
1335
else mprintf("`--");
1336
mprintf("%s(%d)",((CAtom*)g_oaAtoms[g_baAtomIndex[nblist[z]]])->m_sName,nblist[z]+1);
1337
mprintf(GREEN," <-- Ring closure\n");
1341
bmask -= (int)pow(2.0,depth+1);
1342
RECURSION_MegaTree(nblist[z],ta,/*sm,*/depth+1,bmask,(z+1==nbs)?false:true,stack);
1349
void CTimeStep::PrintMegaTree()
1356
for (z=0;z<16384;z++)
1358
for (z=0;z<(long)m_iGesAtomCount;z++)
1360
if (ta[z] != 0) // Dieses Atom wurde bereits in irgendein Molekuel eingebaut
1362
mprintf(YELLOW,"\nThe next molecule starts with %s(%d):\n",m_paLabels[z],z+1);
1363
RECURSION_MegaTree(z,ta,0,0xFFFFFFFF,true,stack);
1370
void CTimeStep::PrintMatrix(bool onlyfirst, bool onlybind)
1373
int z, z2, z3, z4, z5, z6, z7, z8, ti, ti2;
1376
CxVector3 vec1, vec2;
1377
CSingleMolecule *sm;
1380
CxIntArray *wa, *wat;
1382
for (z=0;z<g_oaMolecules.GetSize();z++)
1384
m = (CMolecule*)g_oaMolecules[z];
1385
for (z6=0;z6<(onlyfirst?1:m->m_laSingleMolIndex.GetSize());z6++)
1387
mprintf(YELLOW,"\n*** Molecule %d: %s; Representant %d; Distances in pm ***\n",z+1,m->m_sName,z6+1);
1388
if ((m->m_baAtomIndex.GetSize() == 1) && (m->m_waAtomCount[0] == 1))
1390
mprintf("[only 1 Atom]\n");
1393
if (m->m_iAtomGes > 200)
1395
mprintf(WHITE,"\n This molecule has > 200 atoms. Output would flood the screen. Skipping.\n");
1400
if (m->m_oaRingAtoms.GetSize() != 0)
1401
mprintf(GREEN," (ring bonds are shown in green)\n");
1404
for (z2=0;z2<m->m_baAtomIndex.GetSize();z2++)
1406
if (noh) // Skip H atoms
1407
if (mystricmp(((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,"H") == 0)
1409
for (z3=0;z3<m->m_waAtomCount[z2];z3++)
1411
if (((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName[1] == 0)
1413
mprintf(WHITE,"%s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,z3+1);
1419
for (z2=0;z2<m->m_baAtomIndex.GetSize();z2++)
1421
if (noh) // Skip H atoms
1422
if (mystricmp(((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,"H") == 0)
1424
for (z3=0;z3<m->m_waAtomCount[z2];z3++)
1426
mprintf(WHITE,"%s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,z3+1);
1427
if (((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName[1] == 0)
1431
for (z4=0;z4<m->m_baAtomIndex.GetSize();z4++)
1433
if (noh) // Skip H atoms
1434
if (mystricmp(((CAtom*)g_oaAtoms[m->m_baAtomIndex[z4]])->m_sName,"H") == 0)
1436
for (z5=0;z5<m->m_waAtomCount[z4];z5++)
1438
if ((z2 == z4) && (z3 == z5))
1440
mprintf(BLUE,"*** ");
1443
ti = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z6]])->m_oaAtomOffset[z2])->GetAt(z3);
1444
vec1 = g_TimeStep.m_vaCoords[ti];
1445
ti2 = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z6]])->m_oaAtomOffset[z4])->GetAt(z5);
1446
vec2 = g_TimeStep.m_vaCoords[ti2];
1448
tf = vec1.GetLength();
1449
if ((g_TimeStep.BondRange(ti,ti2,NULL)) || (!onlybind))
1451
for (z8=0;z8<m->m_oaRingAtomTypes.GetSize();z8++)
1453
wat = (CxIntArray*)m->m_oaRingAtomTypes[z8];
1454
wa = (CxIntArray*)m->m_oaRingAtoms[z8];
1455
for (z7=0;z7<wa->GetSize();z7++)
1457
if (((*wat)[z7] == z2) && ((*wa)[z7] == z3))
1461
if (((*wat)[z7+1] == z4) && ((*wa)[z7+1] == z5))
1463
if (((*wat)[wa->GetSize()-1] == z4) && ((*wa)[wa->GetSize()-1] == z5))
1465
} else if (z7 == wa->GetSize()-1)
1467
if (((*wat)[0] == z4) && ((*wa)[0] == z5))
1469
if (((*wat)[z7-1] == z4) && ((*wa)[z7-1] == z5))
1473
if (((*wat)[z7+1] == z4) && ((*wa)[z7+1] == z5))
1475
if (((*wat)[z7-1] == z4) && ((*wa)[z7-1] == z5))
1481
mprintf("%3.0f ",tf);
1484
mprintf(GREEN,"%3.0f ",tf);
1485
} else mprintf(" - ");
1491
if ((!noh) && (m->m_iAtomGes > 30))
1493
mprintf(WHITE,"\n This was a very large molecule.\n Printing the matrix again without H atoms.\n");
1497
// if (((!onlyfirst) && ((z2 < ((CMolecule*)g_oaMolecules[z])->Elements-1) || (g_oaMolecules.GetSize()-1))) || (z < g_oaMolecules.GetSize()-1))
1501
if (m->m_oaRingAtoms.GetSize() != 0)
1504
for (z2=0;z2<m->m_oaRingAtoms.GetSize();z2++)
1506
mprintf(" %d-ring: ",((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize());
1507
if (((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize() > 20)
1509
for (z3=0;z3<5;z3++)
1511
mprintf("%s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[((CxIntArray*)m->m_oaRingAtomTypes[z2])->GetAt(z3)]])->m_sName,((CxIntArray*)m->m_oaRingAtoms[z2])->GetAt(z3)+1);
1512
if (z3+1 < ((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize())
1517
for (z3=((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize()-5;z3<((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize();z3++)
1519
mprintf("%s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[((CxIntArray*)m->m_oaRingAtomTypes[z2])->GetAt(z3)]])->m_sName,((CxIntArray*)m->m_oaRingAtoms[z2])->GetAt(z3)+1);
1520
if (z3+1 < ((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize())
1525
for (z3=0;z3<((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize();z3++)
1527
mprintf("%s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[((CxIntArray*)m->m_oaRingAtomTypes[z2])->GetAt(z3)]])->m_sName,((CxIntArray*)m->m_oaRingAtoms[z2])->GetAt(z3)+1);
1528
if (z3+1 < ((CxIntArray*)m->m_oaRingAtoms[z2])->GetSize())
1535
mprintf(RED,"\n Only showing the first 100 rings.\n");
1542
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[0]];
1543
for (z2=0;z2<m->m_baAtomIndex.GetSize();z2++)
1547
for (z3=0;z3<sm->m_oaMolAtoms.GetSize();z3++)
1549
if (((CMolAtom*)sm->m_oaMolAtoms[z3])->m_iType != z2)
1552
ma = (CMolAtom*)sm->m_oaMolAtoms[z3];
1555
z4 = ma0->m_iNumber;
1556
if (ma->m_fAtomCode == ma0->m_fAtomCode)
1560
mprintf(", %s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,ma->m_iNumber+1);
1568
mprintf(" Atoms %s%d, %s%d",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,z4+1,((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_sName,ma->m_iNumber+1);
1573
mprintf(" are equivalent.\n");
1578
mprintf(" are equivalent.\n");
1585
void CTimeStep::Transform(const CxMatrix3 &mat)
1591
for (z=0;z<g_iGesVirtAtomCount;z++)
1593
// if (z < g_iGesAtomCount)
1594
// mprintf("@ %2d: ( %g | %g | %g ) --> ",z,m_vaCoords[z][0],m_vaCoords[z][1],m_vaCoords[z][2]);
1595
m_vaCoords[z] = mat * m_vaCoords[z];
1596
// if (z < g_iGesAtomCount)
1597
// mprintf("( %g | %g | %g )\n",m_vaCoords[z][0],m_vaCoords[z][1],m_vaCoords[z][2]);
1600
if (g_bUseVelocities)
1601
for (z=0;z<g_iGesVirtAtomCount;z++)
1602
m_vaVelocities[z] = mat * m_vaVelocities[z];
1605
for (z=0;z<g_iGesVirtAtomCount;z++)
1606
m_vaForces[z] = mat * m_vaForces[z];
1611
void CTimeStep::Transform(const CxDMatrix3 &mat)
1616
for (z=0;z<g_iGesVirtAtomCount;z++)
1617
m_vaCoords[z] = mat * m_vaCoords[z];
1619
if (g_bUseVelocities)
1620
for (z=0;z<g_iGesVirtAtomCount;z++)
1621
m_vaVelocities[z] = mat * m_vaVelocities[z];
1624
for (z=0;z<g_iGesVirtAtomCount;z++)
1625
m_vaForces[z] = mat * m_vaForces[z];
1630
void CTimeStep::Transform(const CxQuaternion &q)
1635
for (z=0;z<g_iGesVirtAtomCount;z++)
1636
m_vaCoords[z] = q.Transform(m_vaCoords[z]);
1638
if (g_bUseVelocities)
1639
for (z=0;z<g_iGesVirtAtomCount;z++)
1640
m_vaVelocities[z] = q.Transform(m_vaVelocities[z]);
1643
for (z=0;z<g_iGesVirtAtomCount;z++)
1644
m_vaForces[z] = q.Transform(m_vaForces[z]);
1649
void CTimeStep::SubVelocities(const CxVector3 &vec)
1654
for (z=0;z<g_iGesVirtAtomCount;z++)
1655
m_vaVelocities[z] -= vec;
1660
void CTimeStep::FoldMolecules()
1666
CSingleMolecule *sm;
1671
// mprintf("*** Fold ***\n");
1673
for (z=0;z<g_oaMolecules.GetSize();z++)
1675
m = (CMolecule*)g_oaMolecules[z];
1678
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
1680
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
1682
// mprintf("\n%d, %d",m->m_baAtomIndex.GetSize(),((CxIntArray*)sm->m_oaAtomOffset[m->m_baAtomIndex.GetSize()-1])->GetAt(1));
1685
v = m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[m->m_baAtomIndex.GetSize()-1])->GetAt(1)];
1687
/* mprintf(" .Mol ");
1691
*/ vc = CxVector3(0,0,0);
1695
while (v[0] < -g_fBoxX/2) { v[0] += g_fBoxX; vc[0] += g_fBoxX; }
1696
while (v[0] >= g_fBoxX/2) { v[0] -= g_fBoxX; vc[0] -= g_fBoxX; }
1700
while (v[1] < -g_fBoxY/2) { v[1] += g_fBoxY; vc[1] += g_fBoxY; }
1701
while (v[1] >= g_fBoxY/2) { v[1] -= g_fBoxY; vc[1] -= g_fBoxY; }
1705
while (v[2] < -g_fBoxZ/2) { v[2] += g_fBoxZ; vc[2] += g_fBoxZ; }
1706
while (v[2] >= g_fBoxZ/2) { v[2] -= g_fBoxZ; vc[2] -= g_fBoxZ; }
1709
if ((vc[0] == 0) && (vc[1] == 0) && (vc[2] == 0))
1712
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
1713
for (z4=0;z4<m->m_waAtomCount[z3];z4++)
1714
m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)] += vc;
1717
for (z3=0;z3<sm->m_laWannier.GetSize();z3++)
1718
m_vaCoords[sm->m_laWannier[z3]] += vc;
1721
// mprintf(" Fold Done\n");
1726
void CTimeStep::FoldAtoms()
1734
for (z=0;z<g_iGesVirtAtomCount;z++)
1738
while (m_vaCoords[z][0] < -g_fBoxX/2) m_vaCoords[z][0] += g_fBoxX;
1739
while (m_vaCoords[z][0] >= g_fBoxX/2) m_vaCoords[z][0] -= g_fBoxX;
1744
while (m_vaCoords[z][1] < -g_fBoxY/2) m_vaCoords[z][1] += g_fBoxY;
1745
while (m_vaCoords[z][1] >= g_fBoxY/2) m_vaCoords[z][1] -= g_fBoxY;
1750
while (m_vaCoords[z][2] < -g_fBoxZ/2) m_vaCoords[z][2] += g_fBoxZ;
1751
while (m_vaCoords[z][2] >= g_fBoxZ/2) m_vaCoords[z][2] -= g_fBoxZ;
1758
void CTimeStep::CenterPos(const CxVector3 &vec)
1761
int z/*, z2, z3, z4*/;
1763
/* for (z=0;z<g_oaMolecules.GetSize();z++)
1764
for (z2=0;z2<((CMolecule*)g_oaMolecules[z])->Count;z2++)
1765
for (z3=0;z3<((CMolecule*)g_oaMolecules[z])->Elements;z3++)
1766
for (z4=0;z4<((CMolecule*)g_oaMolecules[z])->AtomCount[z3];z4++)
1767
m_vaCoords[((CSingleMolecule*)g_oaSingleMolecules[((CMolecule*)g_oaMolecules[z])->SingleMolIndex[z2]])->m_iAtomOffset[z3][z4]] -= vec;*/
1769
for (z=0;z<g_iGesVirtAtomCount;z++)
1770
m_vaCoords[z] -= vec;
1775
void CTimeStep::AddAtoms()
1780
// bool labeledatoms;
1782
// labeledatoms = false;
1783
for (z=0;z<(long)m_iGesAtomCount;z++)
1785
q = (char*)m_paLabels[z];
1787
/* while ((*q >= '0') && (*q <= '9'))
1791
mprintf(">>>\n>>> The atoms in the input file are numbered.\n>>> Ignoring this, using own numbers ;-)\n>>>\n");
1792
labeledatoms = true;
1797
// printf("AddAtoms: \"%s\"\n",q);
1798
xAddAtom((char*)m_paLabels[z]);
1804
void CTimeStep::WriteTimestep(FILE *a)
1807
int z, z2, z3, z4, z0;
1809
CSingleMolecule *sm;
1811
if (g_bSaveVirtAtoms)
1812
mfprintf(a," %d\n",g_iGesVirtAtomCount);
1813
else mfprintf(a," %d\n",g_iGesAtomCount);
1814
if (m_pComment != NULL)
1815
mfprintf(a,"%s\n",m_pComment);
1816
else mfprintf(a,"\n");
1818
if (g_bWriteAtomwise)
1820
for (z0=0;z0<g_oaAtoms.GetSize();z0++)
1822
for (z=0;z<g_oaMolecules.GetSize();z++)
1824
m = (CMolecule*)g_oaMolecules[z];
1827
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
1829
if (m->m_baAtomIndex[z3] != z0)
1831
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
1833
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
1835
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
1836
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
1837
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
1844
for (z=0;z<g_oaMolecules.GetSize();z++)
1846
m = (CMolecule*)g_oaMolecules[z];
1849
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
1851
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
1852
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
1854
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
1856
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
1857
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
1867
void CTimeStep::WriteTimestepNb(FILE *a, CNbSet *nbs, int singlemol)
1870
int z, z2, z3, z4, z0, n, ti;
1872
CSingleMolecule *sm;
1873
CConditionGroup *cg;
1874
CConditionSubGroup *cs;
1879
for (z=0;z<g_oaMolecules.GetSize();z++)
1881
if (nbs->m_oaConditionGroups[z] == NULL)
1883
m = (CMolecule*)g_oaMolecules[z];
1884
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
1886
if (((CConditionGroup*)nbs->m_oaConditionGroups[z])->Contains(z2))
1889
if (!g_bSaveVirtAtoms)
1890
n -= m->m_laVirtualAtoms.GetSize();
1895
mfprintf(a," %d\n",n);
1897
mfprintf(a,"# Step %d",((int)g_iSteps));
1901
sm = (CSingleMolecule*)g_oaSingleMolecules[singlemol];
1902
m = (CMolecule*)g_oaMolecules[sm->m_iMolType];
1903
if (!g_bSaveVirtAtoms)
1905
if (g_bWriteAtomwise)
1906
mfprintf(a,", RM=%s[%d]",m->m_sName,sm->m_iMolSMIndex+1);
1907
else mfprintf(a,", RM=%s[%d] (%d atoms)",m->m_sName,sm->m_iMolSMIndex+1,m->m_iAtomGes-m->m_laVirtualAtoms.GetSize());
1910
if (g_bWriteAtomwise)
1911
mfprintf(a,", RM=%s[%d]",m->m_sName,sm->m_iMolSMIndex+1);
1912
else mfprintf(a,", RM=%s[%d] (%d atoms)",m->m_sName,sm->m_iMolSMIndex+1,m->m_iAtomGes);
1916
if (g_bEnvWriteDetailedInfo)
1918
for (z=0;z<g_oaMolecules.GetSize();z++)
1920
if (nbs->m_oaConditionGroups[z] == NULL)
1922
m = (CMolecule*)g_oaMolecules[z];
1924
cg = (CConditionGroup*)nbs->m_oaConditionGroups[z];
1929
if (cg->m_oaConditionSubGroups.GetSize() == 1)
1931
cs = (CConditionSubGroup*)cg->m_oaConditionSubGroups[0];
1932
if (cs->m_oaConditions.GetSize() == 1)
1933
nb = (CNbSearch*)cs->m_oaConditions[0];
1938
if (nb->m_iNbCountMin <= -1)
1941
for (z2=nb->m_iNbCountMin;z2<=nb->m_iNbCountMax;z2++)
1943
ti = nb->m_pNbSort[z2].m_iOM;
1944
if (!g_bSaveVirtAtoms)
1946
if (m->m_laSingleMolIndex[ti] != singlemol)
1948
if (g_bWriteAtomwise)
1949
mfprintf(a,", %s[%d] d=%.3fpm",m->m_sName,z2+1,nb->m_pNbSort[z2].m_fMinDist);
1950
else mfprintf(a,", %s[%d] d=%.3fpm (%d atoms)",m->m_sName,ti+1,nb->m_pNbSort[z2].m_fMinDist,m->m_iAtomGes-m->m_laVirtualAtoms.GetSize());
1954
if (m->m_laSingleMolIndex[ti] != singlemol)
1956
if (g_bWriteAtomwise)
1957
mfprintf(a,", %s[%d] d=%.3fpm",m->m_sName,z2+1,nb->m_pNbSort[z2].m_fMinDist);
1958
else mfprintf(a,", %s[%d] d=%.3fpm (%d atoms)",m->m_sName,ti+1,nb->m_pNbSort[z2].m_fMinDist,m->m_iAtomGes);
1965
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
1967
if (cg->Contains(z2))
1969
if (!g_bSaveVirtAtoms)
1971
if (m->m_laSingleMolIndex[z2] != singlemol)
1973
if (g_bWriteAtomwise)
1974
mfprintf(a,", %s[%d]",m->m_sName,z2+1);
1975
else mfprintf(a,", %s[%d] (%d atoms)",m->m_sName,z2+1,m->m_iAtomGes-m->m_laVirtualAtoms.GetSize());
1979
if (m->m_laSingleMolIndex[z2] != singlemol)
1981
if (g_bWriteAtomwise)
1982
mfprintf(a,", %s[%d]",m->m_sName,z2+1);
1983
else mfprintf(a,", %s[%d] (%d atoms)",m->m_sName,z2+1,m->m_iAtomGes);
1994
if (g_bWriteAtomwise)
1996
for (z0=0;z0<g_oaAtoms.GetSize();z0++)
1998
for (z=0;z<g_oaMolecules.GetSize();z++)
2000
if (nbs->m_oaConditionGroups[z] == NULL)
2002
m = (CMolecule*)g_oaMolecules[z];
2003
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2005
if (m->m_baAtomIndex[z3] != z0)
2007
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
2009
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
2011
if (((CConditionGroup*)nbs->m_oaConditionGroups[z])->Contains(z2))
2013
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
2014
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
2015
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
2025
sm = (CSingleMolecule*)g_oaSingleMolecules[singlemol];
2026
m = (CMolecule*)g_oaMolecules[sm->m_iMolType];
2027
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2029
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
2031
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
2032
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
2036
for (z=0;z<g_oaMolecules.GetSize();z++)
2038
if (nbs->m_oaConditionGroups[z] == NULL)
2040
m = (CMolecule*)g_oaMolecules[z];
2041
cg = (CConditionGroup*)nbs->m_oaConditionGroups[z];
2046
if (cg->m_oaConditionSubGroups.GetSize() == 1)
2048
cs = (CConditionSubGroup*)cg->m_oaConditionSubGroups[0];
2049
if (cs->m_oaConditions.GetSize() == 1)
2050
nb = (CNbSearch*)cs->m_oaConditions[0];
2055
if (nb->m_iNbCountMin <= -1)
2058
for (z2=nb->m_iNbCountMin;z2<=nb->m_iNbCountMax;z2++)
2060
ti = nb->m_pNbSort[z2].m_iOM;
2062
if (m->m_laSingleMolIndex[ti] == singlemol)
2065
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[ti]];
2066
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2068
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
2070
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
2071
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
2077
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
2079
if (((CConditionGroup*)nbs->m_oaConditionGroups[z])->Contains(z2))
2081
if (m->m_laSingleMolIndex[z2] == singlemol)
2083
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
2084
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2086
if ((!g_bSaveVirtAtoms) && (m->m_baAtomIndex[z3] == g_iVirtAtomType))
2088
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
2089
mfprintf(a," %s %8.5f %8.5f %8.5f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1]/100.0f,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]/100.0f);
2101
/*void CTimeStep::WriteTimestepNb(int refmol, FILE *a)
2104
int z, c, z2, z3, z4, z0;
2108
m = (CMolecule*)g_oaMolecules[g_iFixMol];
2113
for (z=0;z<g_oaMolecules.GetSize();z++)
2114
c += g_pNbAll->m_waScanNeighborCount[z]*((CMolecule*)g_oaMolecules[z])->m_iAtomGes;
2115
if (g_bSaveRefWithEnv)
2119
for (z=0;z<g_oaMolecules.GetSize();z++)
2120
c += g_pNbAll->m_waScanNeighborCount[z]*(((CMolecule*)g_oaMolecules[z])->m_iAtomGes-((CMolecule*)g_oaMolecules[z])->m_waVirtualAtoms.GetSize());
2121
if (g_bSaveRefWithEnv)
2122
c += m->m_iAtomGes - m->m_waVirtualAtoms.GetSize();
2125
mfprintf(a," %d\n\n",c);
2127
if (g_bRefEnvAtomwise)
2129
for (z0=0;z0<g_oaAtoms.GetSize();z0++)
2131
if (g_bSaveRefWithEnv)
2133
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2135
if (m->m_baAtomIndex[z3] != z0)
2138
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
2140
for (z4=0;z4<m->m_waAtomCount[z3];z4++)
2142
ti = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[refmol]])->m_oaAtomOffset[z3])->GetAt(z4);
2143
mfprintf(a," %s %f %f %f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0f,m_vaCoords[ti][1]/100.0f,m_vaCoords[ti][2]/100.0f);
2147
for (z=0;z<g_oaMolecules.GetSize();z++)
2149
m2 = (CMolecule*)g_oaMolecules[z];
2150
for (z2=0;z2<g_pNbAll->m_waScanNeighborCount[z];z2++)
2152
for (z3=0;z3<m2->m_baAtomIndex.GetSize();z3++)
2154
if (m2->m_baAtomIndex[z3] != z0)
2157
if (m2->m_baAtomIndex[z3] == g_iVirtAtomType)
2159
for (z4=0;z4<m2->m_waAtomCount[z3];z4++)
2161
ti = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m2->m_laSingleMolIndex[((CxIntArray*)g_pNbAll->m_oaScanNeighbors[z])->GetAt(z2)]])->m_oaAtomOffset[z3])->GetAt(z4);
2162
mfprintf(a," %s %f %f %f\n",((CAtom*)g_oaAtoms[m2->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0f,m_vaCoords[ti][1]/100.0f,m_vaCoords[ti][2]/100.0f);
2170
if (g_bSaveRefWithEnv)
2172
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
2175
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
2177
for (z4=0;z4<m->m_waAtomCount[z3];z4++)
2179
ti = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[refmol]])->m_oaAtomOffset[z3])->GetAt(z4);
2180
mfprintf(a," %s %f %f %f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0,m_vaCoords[ti][1]/100.0,m_vaCoords[ti][2]/100.0);
2184
for (z=0;z<g_oaMolecules.GetSize();z++)
2186
m2 = (CMolecule*)g_oaMolecules[z];
2187
for (z2=0;z2<g_pNbAll->m_waScanNeighborCount[z];z2++)
2189
for (z3=0;z3<m2->m_baAtomIndex.GetSize();z3++)
2192
if (m2->m_baAtomIndex[z3] == g_iVirtAtomType)
2194
for (z4=0;z4<m2->m_waAtomCount[z3];z4++)
2196
ti = ((CxIntArray*)((CSingleMolecule*)g_oaSingleMolecules[m2->m_laSingleMolIndex[((CxIntArray*)g_pNbAll->m_oaScanNeighbors[z])->GetAt(z2)]])->m_oaAtomOffset[z3])->GetAt(z4);
2197
mfprintf(a," %s %f %f %f\n",((CAtom*)g_oaAtoms[m2->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0,m_vaCoords[ti][1]/100.0,m_vaCoords[ti][2]/100.0);
2207
/*float CTimeStep::MolDist(CSingleMolecule *ref, CSingleMolecule *sm2, CNbSearch *nb)
2215
for (z3=0;z3<nb->m_waRefElements.GetSize();z3++)
2216
for (z4=0;z4<((CxIntArray*)nb->m_oaNbElements[sm2->m_iMolType])->GetSize();z4++)
2218
vec = m_vaCoords[((CxIntArray*)ref->m_oaAtomOffset[nb->m_waRefElements[z3]])->GetAt(nb->m_waRefAtoms[z3])] - m_vaCoords[((CxIntArray*)sm2->m_oaAtomOffset[((CxIntArray*)nb->m_oaNbElements[sm2->m_iMolType])->GetAt(z4)])->GetAt(((CxIntArray*)nb->m_oaNbAtoms[sm2->m_iMolType])->GetAt(z4))];
2221
while (vec[0] >= g_fBoxX/2) vec[0] -= g_fBoxX;
2222
while (vec[0] < -g_fBoxX/2) vec[0] += g_fBoxX;
2223
while (vec[1] >= g_fBoxY/2) vec[1] -= g_fBoxY;
2224
while (vec[1] < -g_fBoxY/2) vec[1] += g_fBoxY;
2225
while (vec[2] >= g_fBoxZ/2) vec[2] -= g_fBoxZ;
2226
while (vec[2] < -g_fBoxZ/2) vec[2] += g_fBoxZ;
2228
if (vec.GetLength() < d)
2229
d = vec.GetLength();
2238
/*void CTimeStep::ScanNeighborhood(int fixmol, int refmol, CNbSearch *nb, CNbSearch *prev)
2245
CSingleMolecule *sm, *sm2;
2248
m = (CMolecule*)g_oaMolecules[fixmol];
2249
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[refmol]];
2250
del = new float[g_oaSingleMolecules.GetSize()];
2251
best = new int[g_oaSingleMolecules.GetSize()];
2253
// printf("Suche Nachbarschaft von Molekuel %d...\n",refmol+1);
2255
for (z=0;z<g_oaMolecules.GetSize();z++)
2257
if (((!nb->m_bDistMode) && (nb->m_waMolCount[z] == 0)) || (nb->m_bDistMode && (nb->m_faMolDist[z] == 0)))
2259
nb->m_waScanNeighborCount[z] = 0;
2262
m2 = (CMolecule*)g_oaMolecules[z];
2263
// printf("*** Molekuel %d: %s\n",z+1,m2->Name);
2264
for (z2=0;z2<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z2++)
2267
if ((z == fixmol) && (z2 == refmol))
2270
if (!prev->Contains(z,z2))
2272
// printf(" - Vertreter %d\n",z2+1);
2273
sm2 = (CSingleMolecule*)g_oaSingleMolecules[m2->m_laSingleMolIndex[z2]];
2274
del[z2] = MolDist(sm,sm2,nb);
2275
// printf(" - Finaler Abstand: %f\n",del[z2]);
2277
if (nb->m_bDistMode)
2279
// printf("**DistMode**\n");
2280
// mprintf("Die Nachbarn: ");
2282
for (z3=0;z3<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z3++)
2283
if ((del[z3] <= nb->m_faMolDist[z]) && (del[z3] >= nb->m_faMolMinDist[z]))
2285
// mprintf("%d (%f), ",z3+1,del[z3]);
2290
// printf(" # Die naechsten Nachbarn: ");
2291
for (z2=0;z2<c;z2++)
2293
// printf("%d, ",best[z2]+1);
2294
nb->m_iNeighbourCount++;
2295
for (z3=0;z3<nb->m_waScanNeighborCount[z];z3++)
2296
if (((CxIntArray*)nb->m_oaScanNeighbors[z])->GetAt(z3) == best[z2])
2298
((CxIntArray*)nb->m_oaScanNeighborHits[z])->GetAt(z3)++;
2301
((CxIntArray*)nb->m_oaScanNeighbors[z])->Add(best[z2]);
2302
((CxIntArray*)nb->m_oaScanNeighborHits[z])->Add(1);
2303
nb->m_waScanNeighborCount[z]++;
2309
// printf("**CountMode**\n");
2310
for (z2=0;z2<nb->m_waMolCount[z];z2++)
2314
for (z3=0;z3<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z3++)
2323
del[b] = 1000000.0f;
2325
// printf(" # Die naechsten Nachbarn: ");
2326
for (z2=nb->m_waMolCountMin[z]-1;z2<nb->m_waMolCount[z];z2++)
2328
// printf("%d, ",best[z2]);
2329
nb->m_iNeighbourCount++;
2330
for (z3=0;z3<nb->m_waScanNeighborCount[z];z3++)
2331
if (((CxIntArray*)nb->m_oaScanNeighbors[z])->GetAt(z3) == best[z2])
2333
((CxIntArray*)nb->m_oaScanNeighborHits[z])->GetAt(z3)++;
2336
((CxIntArray*)nb->m_oaScanNeighbors[z])->Add(best[z2]);
2337
((CxIntArray*)nb->m_oaScanNeighborHits[z])->Add(1);
2338
nb->m_waScanNeighborCount[z]++;
2350
/*void CTimeStep::ScanAngle(int fixmol, int refmol, CCondition *co, CNbSearch *prev)
2356
CSingleMolecule *sm, *sm2;
2357
CxVector3 vec0, vec1, vec2, vec3, vec4, vec5;
2361
// mprintf("*** ScanAngle ***\n");
2362
// mprintf(" FixMol = %d, RefMol = %d\n",fixmol,refmol);
2363
m = (CMolecule*)g_oaMolecules[fixmol];
2364
// mprintf(" m->m_laSingleMolIndex[refmol] = %d\n",m->m_laSingleMolIndex[refmol]);
2366
nb = co->m_pTempNbS;
2367
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[refmol]];
2369
// printf("Suche Nachbarschaft von Molekuel %d...\n",refmol+1);
2371
// mprintf(" SecondMol = %d\n",co->m_iSecondMol);
2372
m2 = (CMolecule*)g_oaMolecules[co->m_iSecondMol];
2374
// printf("*** Molekuel %d: %s\n",z+1,m2->Name);
2375
for (z2=0;z2<m2->m_laSingleMolIndex.GetSize();z2++)
2377
if ((co->m_iSecondMol == fixmol) && (z2 == refmol))
2380
if (!prev->Contains(co->m_iSecondMol,z2))
2382
// printf(" - Vertreter %d\n",z2+1);
2383
sm2 = (CSingleMolecule*)g_oaSingleMolecules[m2->m_laSingleMolIndex[z2]];
2385
co->m_pADF->BuildAtomList(sm,sm2,NULL,&tempwa);
2387
for (z4=0;z4<tempwa.GetSize();z4+=6)
2389
if (co->m_pADF->m_bOrtho[0])
2391
vec0 = m_vaCoords[tempwa[z4]];
2392
vec2 = m_vaCoords[tempwa[z4+1]];
2393
vec3 = m_vaCoords[tempwa[z4+2]];
2394
vec1 = CrossP(vec2-vec0,vec3-vec0);
2397
vec0 = m_vaCoords[tempwa[z4]];
2398
vec2 = m_vaCoords[tempwa[z4+1]];
2401
if (co->m_pADF->m_bOrtho[1])
2403
vec4 = m_vaCoords[tempwa[z4+3]];
2404
vec3 = m_vaCoords[tempwa[z4+4]];
2405
vec5 = m_vaCoords[tempwa[z4+5]];
2406
vec2 = CrossP(vec3-vec4,vec5-vec4);
2409
vec4 = m_vaCoords[tempwa[z4+3]];
2410
vec3 = m_vaCoords[tempwa[z4+4]];
2414
tf = Angle_Deg(vec1,vec2);
2416
if ((tf >= co->m_pADF->m_fMinAngle) && (tf <= co->m_pADF->m_fMaxAngle))
2418
nb->m_iNeighbourCount++;
2419
for (z3=0;z3<nb->m_waScanNeighborCount[co->m_iSecondMol];z3++)
2420
if (((CxIntArray*)nb->m_oaScanNeighbors[co->m_iSecondMol])->GetAt(z3) == z2)
2422
((CxIntArray*)nb->m_oaScanNeighborHits[co->m_iSecondMol])->GetAt(z3)++;
2425
((CxIntArray*)nb->m_oaScanNeighbors[co->m_iSecondMol])->Add(z2);
2426
((CxIntArray*)nb->m_oaScanNeighborHits[co->m_iSecondMol])->Add(1);
2427
nb->m_waScanNeighborCount[co->m_iSecondMol]++;
2435
/*void CTimeStep::GatherNbDiagram(int refmol, CNbSearch *nb)
2441
int z, z2, z3, z4, c, z0;
2443
CSingleMolecule *sm, *sm2;
2447
m = (CMolecule*)g_oaMolecules[g_iFixMol];
2448
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[refmol]];
2449
del = new float[g_oaSingleMolecules.GetSize()];
2450
best = new int[g_oaSingleMolecules.GetSize()];
2451
done = new bool[g_oaSingleMolecules.GetSize()];
2453
// printf("Suche Nachbarschaft von Molekuel %d...\n",refmol+1);
2455
for (z=0;z<g_oaMolecules.GetSize();z++)
2457
if (nb->m_bDistMode && (nb->m_faMolDist[z] == 0))
2459
nb->m_waScanNeighborCount[z] = 0;
2462
m2 = (CMolecule*)g_oaMolecules[z];
2463
// printf("*** Molekuel %d: %s\n",z+1,m2->Name);
2464
// for (z2=0;z2<=((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z2++)
2465
// del[z2] = 99999.0f;
2466
for (z2=0;z2<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z2++)
2469
if ((z == g_iFixMol) && (z2 == refmol))
2471
// printf(" - Vertreter %d\n",z2+1);
2472
sm2 = (CSingleMolecule*)g_oaSingleMolecules[m2->m_laSingleMolIndex[z2]];
2473
for (z3=0;z3<nb->m_waRefElements.GetSize();z3++)
2474
for (z4=0;z4<((CxIntArray*)nb->m_oaNbElements[z])->GetSize();z4++)
2476
vec = m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[nb->m_waRefElements[z3]])->GetAt(nb->m_waRefAtoms[z3])] - m_vaCoords[((CxIntArray*)sm2->m_oaAtomOffset[((CxIntArray*)nb->m_oaNbElements[z])->GetAt(z4)])->GetAt(((CxIntArray*)nb->m_oaNbAtoms[z])->GetAt(z4))];
2479
while (vec[0] >= g_fBoxX/2) vec[0] -= g_fBoxX;
2480
while (vec[0] < -g_fBoxX/2) vec[0] += g_fBoxX;
2481
while (vec[1] >= g_fBoxY/2) vec[1] -= g_fBoxY;
2482
while (vec[1] < -g_fBoxY/2) vec[1] += g_fBoxY;
2483
while (vec[2] >= g_fBoxZ/2) vec[2] -= g_fBoxZ;
2484
while (vec[2] < -g_fBoxZ/2) vec[2] += g_fBoxZ;
2486
d = vec.GetLength();
2487
// printf(" = m1 %d (%d|%d); m2 %d (%d|%d); Dist = %f\n",z3+1,m->m_waNbElements[z3]+1,m->m_waNbAtoms[z3]+1,z4+1,m2->m_waNbElements[z4]+1,m2->m_waNbAtoms[z4]+1,d);
2491
// printf(" - Finaler Abstand: %f\n",del[z2]);
2494
for (z0=0;z0<nb->m_pAF->m_iResolution;z0++)
2497
for (z2=0;z2<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z2++)
2503
for (z3=0;z3<((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize();z3++)
2513
if (d > nb->m_pAF->m_fMaxVal*z0/nb->m_pAF->m_iResolution)
2518
// if (c >= ((CMolecule*)g_oaMolecules[z])->m_laSingleMolIndex.GetSize())
2521
nb->m_pAF->AddToBin(nb->m_pAF->m_fMaxVal*z0/nb->m_pAF->m_iResolution,(float)c);
2522
// if (g_iSteps == 1)
2523
// mfprintf(a,"%f;%f\n",nb->m_pAF->m_fMaxVal*z0/nb->m_pAF->m_iResolution,(float)c);
2525
// if (g_iSteps == 1)
2534
int CTimeStep::REC_UniteMolecules(CSingleMolecule *sm, int i0, int depth)
2540
m = (CMolAtom*)sm->m_oaMolAtoms[i0];
2545
for (z2=0;z2<depth;z2++)
2547
mprintf(">>> REC_UniteMolecules MolAtom=%d, Offset=%d.\n",i0,m->m_iOffset);
2550
g_pUniteTemp[m->m_iOffset] = true;
2552
for (z=0;z<m->m_oaBonds.GetSize();z++)
2554
if (!g_pUniteTemp[((CMolAtom*)m->m_oaBonds[z])->m_iOffset])
2556
if (MirrorBond(m->m_iOffset,((CMolAtom*)m->m_oaBonds[z])->m_iOffset))
2561
for (z2=0;z2<depth;z2++)
2563
mprintf(" Bond %s(%d) <--> %s(%d) unwrapped.\n",((CAtom*)g_oaAtoms[g_baAtomIndex[m->m_iOffset]])->m_sName,m->m_iOffset+1,((CAtom*)g_oaAtoms[g_baAtomIndex[((CMolAtom*)m->m_oaBonds[z])->m_iOffset]])->m_sName,((CMolAtom*)m->m_oaBonds[z])->m_iOffset+1);
2567
n += REC_UniteMolecules(sm,((CMolAtom*)m->m_oaBonds[z])->m_iMolAtomNumber,depth+1);
2573
for (z2=0;z2<depth;z2++)
2575
mprintf("<<< REC_UniteMolecules MolAtom=%d, Offset=%d.\n",i0,m->m_iOffset);
2581
void CTimeStep::UniteMolecules(bool verbose)
2586
CSingleMolecule *sm;
2588
for (z=0;z<g_iGesAtomCount;z++)
2589
g_pUniteTemp[z] = false;
2590
for (z=0;z<g_oaMolecules.GetSize();z++)
2592
m = (CMolecule*)g_oaMolecules[z];
2595
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
2597
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
2600
// mprintf(" # UniteMolecules molecule %s (%d)\n",m->m_sName,z2+1);
2602
n = REC_UniteMolecules(sm,0,0);
2604
if ((n != 0) && verbose)
2605
mprintf(" - Molecule %s[%d] united, %d bonds unwrapped.\n",m->m_sName,z2+1,n);
2607
if ((n != 0) && (!verbose) && g_bVerbose)
2608
mprintf("\n # UniteMolecules: Molecule %s[%d] united, %d bonds unwrapped.",m->m_sName,z2+1,n);
2616
bool CTimeStep::ReadTimestep(FILE *a, bool needinfo)
2619
switch(g_iTrajFormat)
2622
if (!ReadXYZ(a,needinfo,&m_vaCoords))
2627
if (!ReadPDB(a,needinfo,&m_vaCoords))
2632
if (!ReadMol2(a,needinfo))
2637
if (!ReadLAMMPS(a,needinfo))
2642
if (!ReadDLPOLY(a,needinfo))
2653
bool CTimeStep::SkipTimestep(FILE *a)
2656
switch(g_iTrajFormat)
2688
bool CTimeStep::ReadTimestepVel(FILE *a)
2691
char buf[256], *p, *q;
2701
if (strlen(buf) > 0)
2702
buf[strlen(buf)-1] = 0;
2709
m_vaVelocities.SetSize(tc);
2711
fgets(buf,256,a); // Zeitschritt - egal hier
2712
if (strlen(buf) > 0)
2713
buf[strlen(buf)-1] = 0;
2714
for (z=0;z<tc;z++) // den ersten Zeitschritt einlesen
2723
if (strlen(buf) > 0)
2724
buf[strlen(buf)-1] = 0;
2731
eprintf("CTimeStep::ReadTimestepVel(): Error 1. %d, \"%s\"\n",z+1,buf);
2734
while (isdigit(*(p-1)) && (p > buf))
2738
eprintf("CTimeStep::ReadTimestepVel(): No Atom laben found. %d, \"%s\"\n",z+1,buf);
2746
eprintf("CTimeStep::ReadTimestepVel(): Error 2. %d, \"%s\"\n",z+1,p);
2754
eprintf("CTimeStep::ReadTimestepVel(): Error 3. %d, \"%s\"\n",z+1,q);
2758
m_vaVelocities[z][0] = (float)atof(q);
2765
eprintf("CTimeStep::ReadTimestepVel(): Error 4. %d, \"%s\"\n",z+1,q);
2769
m_vaVelocities[z][1] = (float)atof(q);
2776
m_vaVelocities[z][2] = (float)atof(q);
2779
DoubleBoxVelocity();
2785
bool CTimeStep::ReadTimestepForce(FILE *a)
2788
char buf[256], *p, *q;
2798
if (strlen(buf) > 0)
2799
buf[strlen(buf)-1] = 0;
2806
m_vaForces.SetSize(tc);
2808
fgets(buf,256,a); // Zeitschritt - egal hier
2809
if (strlen(buf) > 0)
2810
buf[strlen(buf)-1] = 0;
2811
for (z=0;z<tc;z++) // den ersten Zeitschritt einlesen
2820
if (strlen(buf) > 0)
2821
buf[strlen(buf)-1] = 0;
2828
eprintf("CTimeStep::ReadTimestepForce(): Error 1. %d, \"%s\"\n",z+1,buf);
2831
while (isdigit(*(p-1)) && (p > buf))
2835
eprintf("CTimeStep::ReadTimestepForce(): No Atom laben found. %d, \"%s\"\n",z+1,buf);
2843
eprintf("CTimeStep::ReadTimestepForce(): Error 2. %d, \"%s\"\n",z+1,p);
2851
eprintf("CTimeStep::ReadTimestepForce(): Error 3. %d, \"%s\"\n",z+1,q);
2855
m_vaForces[z][0] = (float)atof(q);
2862
eprintf("CTimeStep::ReadTimestepForce(): Error 4. %d, \"%s\"\n",z+1,q);
2866
m_vaForces[z][1] = (float)atof(q);
2873
m_vaForces[z][2] = (float)atof(q);
2882
bool CTimeStep::SkipXYZ(FILE *a)
2888
// mprintf("*** Skip Anfang ***\n");
2890
fgets_bin(buf,256,a);
2901
buf[strlen(buf)-1] = 0;
2903
// mprintf("SkipA: \"%s\".\n",buf);
2910
fgets_bin(buf,256,a); // Zeitschritt - egal hier
2911
// mprintf("SkipB: \"%s\".\n",buf);
2912
for (z=0;z<tc;z++) // den ersten Zeitschritt einlesen
2915
fgets_bin(buf,256,a);
2916
// mprintf("SkipC%d: \"%s\".\n",z,buf);
2923
// mprintf("*** Skip Ende ***\n");
2929
void CTimeStep::CopyFrom(CTimeStep *t)
2936
m_iGesAtomCount = t->m_iGesAtomCount;
2937
m_vaCoords.CopyFrom(&t->m_vaCoords);
2938
if (g_bKeepUnfoldedCoords)
2939
m_vaCoords_Unfolded.CopyFrom(&t->m_vaCoords_Unfolded);
2940
m_vaForces.CopyFrom(&t->m_vaForces);
2941
m_vaVelocities.CopyFrom(&t->m_vaVelocities);
2942
if (t->m_paLabels.GetSize() != 0)
2944
for (z=0;z<m_paLabels.GetSize();z++)
2945
delete[] (char*)m_paLabels[z];
2946
m_paLabels.RemoveAll();
2947
for (z=0;z<t->m_paLabels.GetSize();z++)
2949
try { p = new char[strlen((char*)t->m_paLabels[z])+1]; } catch(...) { p = NULL; }
2950
if (p == NULL) NewException((double)(strlen((char*)t->m_paLabels[z])+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2952
strcpy(p,(char*)t->m_paLabels[z]);
2956
if (t->m_pComment != NULL)
2958
if (m_pComment == NULL)
2960
try { m_pComment = new char[256]; } catch(...) { m_pComment = NULL; }
2961
if (m_pComment == NULL) NewException((double)256*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
2963
strcpy(m_pComment,t->m_pComment);
2969
long CTimeStep::ExtractNumber(int i)
2972
char *p, *q, buf[20];
2976
if (m_pComment == NULL)
2981
while ((!isdigit(*p)) && (*p != 0))
2989
while ((isdigit(*q)) && (*q != 0))
2998
while ((!isdigit(*p)) && (*p != 0))
3006
while ((isdigit(*q)) && (*q != 0))
3021
int CTimeStep::GetCommentNumberCount()
3027
if (m_pComment == NULL)
3033
while ((!isdigit(*p)) && (*p != 0))
3037
// mprintf("GetCommentNumberCount 1: %d (p=\"%s\", q=\"%s\")\n",z,p,q);
3042
while ((isdigit(*q)) && (*q != 0))
3046
// mprintf("GetCommentNumberCount 2: %d (p=\"%s\", q=\"%s\")\n",z,p,q);
3053
// mprintf("GetCommentNumberCount 3: %d (p=\"%s\", q=\"%s\")\n",z,p,q);
3059
return 0; // Never happens
3063
bool CTimeStep::ScanWannier(bool verbose)
3067
float td, d, dx, dy, dz;
3072
mprintf(WHITE,"\n*** ScanWannier ***\n\n");
3076
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
3077
((CSingleMolecule*)g_oaSingleMolecules[z])->m_laWannier.RemoveAll_KeepSize();
3079
for (z=0;z<g_iGesAtomCount;z++)
3081
if (g_baAtomIndex[z] != g_iWannierAtomType)
3085
for (z2=0;z2<g_iGesAtomCount;z2++)
3087
if (g_baAtomIndex[z2] == g_iWannierAtomType)
3089
dx = m_vaCoords[z][0]-m_vaCoords[z2][0];
3090
dy = m_vaCoords[z][1]-m_vaCoords[z2][1];
3091
dz = m_vaCoords[z][2]-m_vaCoords[z2][2];
3094
while (dx > g_fBoxX/2.0f) dx -= g_fBoxX;
3095
while (dx < -g_fBoxX/2.0f) dx += g_fBoxX;
3099
while (dy > g_fBoxY/2.0f) dy -= g_fBoxY;
3100
while (dy < -g_fBoxY/2.0f) dy += g_fBoxY;
3104
while (dz > g_fBoxZ/2.0f) dz -= g_fBoxZ;
3105
while (dz < -g_fBoxZ/2.0f) dz += g_fBoxZ;
3107
td = (float)sqrt(dx*dx+dy*dy+dz*dz);
3118
while (m_vaCoords[z][0]-m_vaCoords[z3][0] > g_fBoxX/2.0f) m_vaCoords[z][0] -= g_fBoxX;
3119
while (m_vaCoords[z][0]-m_vaCoords[z3][0] < -g_fBoxX/2.0f) m_vaCoords[z][0] += g_fBoxX;
3123
while (m_vaCoords[z][1]-m_vaCoords[z3][1] > g_fBoxY/2.0f) m_vaCoords[z][1] -= g_fBoxY;
3124
while (m_vaCoords[z][1]-m_vaCoords[z3][1] < -g_fBoxY/2.0f) m_vaCoords[z][1] += g_fBoxY;
3128
while (m_vaCoords[z][2]-m_vaCoords[z3][2] > g_fBoxZ/2.0f) m_vaCoords[z][2] -= g_fBoxZ;
3129
while (m_vaCoords[z][2]-m_vaCoords[z3][2] < -g_fBoxZ/2.0f) m_vaCoords[z][2] += g_fBoxZ;
3131
z2 = g_laAtomSMIndex[z3];
3134
eprintf("Step %d: Wannier center at offset %d too far away from any atom (closest atom is %s[%d] %s%d, %.0f pm).\n",g_iSteps,z+1,((CMolecule*)g_oaMolecules[((CSingleMolecule*)g_oaSingleMolecules[z2])->m_iMolType])->m_sName,((CSingleMolecule*)g_oaSingleMolecules[z2])->m_iMolSMIndex+1,((CAtom*)g_oaAtoms[g_waAtomRealElement[z3]])->m_sName,g_waAtomMolNumber[z3]+1,d);
3136
mprintf(" - Wannier center %d belongs to %s[%d] %s%d (%.0f pm).\n",z+1,((CMolecule*)g_oaMolecules[((CSingleMolecule*)g_oaSingleMolecules[z2])->m_iMolType])->m_sName,((CSingleMolecule*)g_oaSingleMolecules[z2])->m_iMolSMIndex+1,((CAtom*)g_oaAtoms[g_waAtomRealElement[z3]])->m_sName,g_waAtomMolNumber[z3]+1,d);
3139
eprintf("Wannier center %d: Atom %d does not belong to any molecule.\n",z+1,z3+1);
3142
// mprintf("Wannier Center %d hat Abstand %.2f zu Atom %d in SM %d.\n",z+1,d,z3+1,z2+1);
3143
((CSingleMolecule*)g_oaSingleMolecules[z2])->m_laWannier.Add(z);
3147
for (z=0;z<g_oaMolecules.GetSize();z++)
3149
m = (CMolecule*)g_oaMolecules[z];
3150
if (m->m_iWannierCount == 0)
3152
m->m_iWannierCount = ((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[0]])->m_laWannier.GetSize();
3154
for (z2=0;z2<m->m_baAtomIndex.GetSize();z2++)
3156
if (m->m_baAtomIndex[z2] == g_iWannierAtomType)
3158
if (m->m_baAtomIndex[z2] == g_iVirtAtomType)
3160
td += ((CAtom*)g_oaAtoms[m->m_baAtomIndex[z2]])->m_fCharge * m->m_waAtomCount[z2];
3162
m->m_fCharge = td-m->m_iWannierCount*g_fWannierCharge;
3163
mprintf(" - Molecule %s contains %d wannier centers. Total charge is %.2f - %.2f = %.2f\n",m->m_sName,m->m_iWannierCount,td,m->m_iWannierCount*g_fWannierCharge,m->m_fCharge);
3164
if (m->m_fCharge > 5.0)
3166
eprintf("\n This molecular charge seems to be too high.\n\n");
3167
if (!AskYesNo(" Do you want to continue (y/n)? [yes] ",true))
3171
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
3173
if (m->m_iWannierCount != ((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]])->m_laWannier.GetSize())
3174
eprintf("Step %d: Molecule %s[%d] contains %d instead of %d wannier centers.\n",g_iSteps,m->m_sName,z2+1,((CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]])->m_laWannier.GetSize(),m->m_iWannierCount);
3182
void CTimeStep::CalcDipoles()
3187
CSingleMolecule *sm;
3191
// mprintf("\n*** CalcDipoles ***");
3193
for (z=0;z<g_oaMolecules.GetSize();z++)
3195
m = (CMolecule*)g_oaMolecules[z];
3196
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
3199
mprintf("\nCalcDipoles %s (%d):\n",m->m_sName,z2+1);
3201
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
3203
sm->m_vDipole = CxVector3(0,0,0);
3205
if ((!g_bWannier) && (!m->m_bChargesAssigned))
3208
if (g_bDipoleRefFixed)
3209
dc = CxVector3(0,0,0);
3210
else dc = m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[m->m_iDipoleCenterType])->GetAt(m->m_iDipoleCenterIndex)];
3213
mprintf(" Ref. point is ( %f | %f | %f )\n",dc[0],dc[1],dc[2]);
3215
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
3217
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
3221
if (m->m_baAtomIndex[z3] == g_iWannierAtomType)
3224
a = (CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]];
3225
for (z4=0;z4<m->m_waAtomCount[z3];z4++)
3227
// mprintf(" %s%d %.2f x ",a->m_sName,z4+1,a->m_fCharge);
3228
// (m_vaCoords[sm->m_iAtomOffset[z3][z4]]-m_vaCoords[sm->m_iAtomOffset[m->Elements-1][0]]).Dump();
3230
// mprintf(" %s%d %.2f (%d)\n",a->m_sName,z4+1,a->m_fCharge,((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4));
3234
sm->m_vDipole += a->m_fCharge * (m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)] - dc);
3237
mprintf(" %.2f: ( %f | %f | %f )\n",a->m_fCharge,m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]);
3240
if (g_bReadChargesFrom4thXYZ)
3242
// mprintf("Moep. z3=%d, z4=%d, c=%f.\n",z3,z4,m_faCharge[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)]);
3243
sm->m_vDipole += m_faCharge[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)] * (m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)] - dc);
3245
mprintf(" %.2f: ( %f | %f | %f )\n",m_faCharge[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]);
3248
sm->m_vDipole += ((CxFloatArray*)m->m_oaCharges[z3])->GetAt(z4) * (m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)] - dc);
3250
mprintf(" %.2f: ( %f | %f | %f )\n",((CxFloatArray*)m->m_oaCharges[z3])->GetAt(z4),m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][0],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][1],m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4)][2]);
3255
for (z3=0;z3<sm->m_laWannier.GetSize();z3++)
3257
// mprintf(" - %.2f x ",g_fWannierCharge);
3258
// (m_vaCoords[sm->m_waWannier[z3]] - m_vaCoords[sm->m_iAtomOffset[m->Elements-1][0]]).Dump();
3260
sm->m_vDipole -= g_fWannierCharge * (m_vaCoords[sm->m_laWannier[z3]] - dc);
3263
mprintf(" %.2f: ( %f | %f | %f )\n",-g_fWannierCharge,m_vaCoords[sm->m_laWannier[z3]][0],m_vaCoords[sm->m_laWannier[z3]][1],m_vaCoords[sm->m_laWannier[z3]][2]);
3266
// sm->m_vDipole.Dump();
3268
sm->m_vDipole *= 0.048008f; // Conversion e*pm --> Debye
3271
mprintf(" Result: %f.\n",sm->m_vDipole.GetLength());
3273
// mprintf("Molecule %s - Dipole %.3f\n",m->Name,sm->m_vDipole.GetLength());
3280
void CTimeStep::DoubleBox()
3285
if (m_vaCoords.GetSize() < g_iGesAtomCount)
3286
m_vaCoords.SetSize(g_iGesAtomCount);
3288
if (m_paLabels.GetSize() != 0)
3289
m_paLabels.SetSize(g_iGesAtomCount);
3291
for (pz=0;pz<g_iDoubleBoxZ;pz++)
3293
for (py=0;py<g_iDoubleBoxY;py++)
3295
for (px=0;px<g_iDoubleBoxX;px++)
3297
if ((px == 0) && (py == 0) && (pz == 0))
3299
for (z=0;z<g_iGesAtomCount/g_iDoubleBoxFactor;z++)
3301
m_vaCoords[(pz*g_iDoubleBoxX*g_iDoubleBoxY+py*g_iDoubleBoxX+px)*g_iGesAtomCount/g_iDoubleBoxFactor+z] = m_vaCoords[z] + CxVector3(px*g_fBoxX/g_iDoubleBoxX,py*g_fBoxY/g_iDoubleBoxY,pz*g_fBoxZ/g_iDoubleBoxZ);
3302
if (m_paLabels.GetSize() != 0)
3304
try { p = new char[strlen((char*)m_paLabels[z])+1]; } catch(...) { p = NULL; }
3305
if (p == NULL) NewException((double)(strlen((char*)m_paLabels[z])+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3307
strcpy(p,(char*)m_paLabels[z]);
3308
m_paLabels[(pz*g_iDoubleBoxX*g_iDoubleBoxY+py*g_iDoubleBoxX+px)*g_iGesAtomCount/g_iDoubleBoxFactor+z] = p;
3314
m_iGesAtomCount = g_iGesAtomCount;
3318
void CTimeStep::DoubleBoxVelocity()
3322
if (m_vaVelocities.GetSize() < g_iGesAtomCount)
3323
m_vaVelocities.SetSize(g_iGesAtomCount);
3325
for (pz=0;pz<g_iDoubleBoxZ;pz++)
3327
for (py=0;py<g_iDoubleBoxY;py++)
3329
for (px=0;px<g_iDoubleBoxX;px++)
3331
if ((px == 0) && (py == 0) && (pz == 0))
3333
for (z=0;z<g_iGesAtomCount/g_iDoubleBoxFactor;z++)
3334
m_vaVelocities[(pz*g_iDoubleBoxX*g_iDoubleBoxY+py*g_iDoubleBoxX+px)*g_iGesAtomCount/g_iDoubleBoxFactor+z] = m_vaVelocities[z];
3341
void CTimeStep::DoubleBoxForce()
3345
if (m_vaForces.GetSize() < g_iGesAtomCount)
3346
m_vaForces.SetSize(g_iGesAtomCount);
3348
for (pz=0;pz<g_iDoubleBoxZ;pz++)
3350
for (py=0;py<g_iDoubleBoxY;py++)
3352
for (px=0;px<g_iDoubleBoxX;px++)
3354
if ((px == 0) && (py == 0) && (pz == 0))
3356
for (z=0;z<g_iGesAtomCount/g_iDoubleBoxFactor;z++)
3357
m_vaForces[(pz*g_iDoubleBoxX*g_iDoubleBoxY+py*g_iDoubleBoxX+px)*g_iGesAtomCount/g_iDoubleBoxFactor+z] = m_vaForces[z];
3364
bool CTimeStep::ReadXYZ(FILE *a, bool needinfo, CxVec3Array *v)
3367
char buf[256], obuf[256], *p, *q, *r;
3369
const char *separators = " ,;\"'\t";
3371
// mprintf("*** Read Anfang.\n");
3373
// m_iSizeBytes = 0;
3376
fgets_bin(buf,256,a);
3377
// m_iSizeBytes += strlen(buf);
3378
if (strlen(buf) > 0)
3379
buf[strlen(buf)-1] = 0;
3380
// mprintf("Read1: \"%s\".\n",buf);
3383
eprintf("\nTrajectory file seems to be damaged. Searching for next time step...");
3387
// mprintf("CTimeStep::ReadTimestep(): Unexpected End of File (1).\n");
3391
if (strchr(buf,'.') != NULL)
3395
// mprintf("x: %d - \"%s\"\n",j,buf);
3399
m_iGesAtomCount = atoi(buf);
3400
if (m_iGesAtomCount == 0)
3402
eprintf("\nCTimeStep::ReadXYZ(): Error - atom count = 0. \"%s\"",buf);
3405
if (m_pComment == NULL)
3407
try { m_pComment = new char[128]; } catch(...) { m_pComment = NULL; }
3408
if (m_pComment == NULL) NewException((double)128*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3412
for (z=0;z<m_paLabels.GetSize();z++)
3413
delete[] (char*)m_paLabels[z];
3414
m_paLabels.RemoveAll();
3416
m_paLabels.SetSize(m_iGesAtomCount*g_iDoubleBoxFactor);
3417
else m_paLabels.SetSize(m_iGesAtomCount);
3419
if (v->GetSize() < (long)m_iGesAtomCount)
3420
v->SetSize(m_iGesAtomCount);
3422
if (g_bKeepOriginalCoords)
3424
if (m_vaCoords_Original.GetSize() < (long)m_iGesAtomCount)
3425
m_vaCoords_Original.SetSize(m_iGesAtomCount);
3429
fgets_bin(m_pComment,128,a); // Zeitschritt - egal hier
3430
// if (strlen(m_pComment) > 0)
3431
// m_pComment[strlen(m_pComment)-1] = 0;
3436
if ((*p == 10) || (*p == 13))
3440
// mprintf("Comment: \"%s\".\n",m_pComment);
3441
// m_iSizeBytes += strlen(m_pComment);
3443
if (g_bReadChargesFrom4thXYZ)
3444
m_faCharge.SetSize(m_iGesAtomCount);
3446
for (z=0;z<(long)m_iGesAtomCount;z++) // den ersten Zeitschritt einlesen
3449
fgets_bin(buf,256,a);
3452
eprintf("\nCTimeStep::ReadXYZ(): Unexpected end of file (2). \"%s\"\n",buf);
3456
// m_iSizeBytes += strlen(buf);
3457
buf[strlen(buf)-1] = 0;
3458
// mprintf(" %d: \"%s\".\n",z,buf);
3463
while (strchr(separators,*p) != NULL)
3466
while ((strchr(separators,*q) == NULL) && (*q != 0))
3470
eprintf("\nCTimeStep::ReadXYZ(): %d: Incomplete line (1): \"%s\"\n",z+1,obuf);
3480
eprintf("\nCTimeStep::ReadXYZ(): \"%s\" - Maximum length of atom labels is 7 chars; truncating.\n",p);
3484
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
3485
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3492
while (strchr(separators,*q) != NULL)
3495
while ((strchr(separators,*p) == NULL) && (*p != 0))
3499
eprintf("\nCTimeStep::ReadXYZ(): %d: Incomplete line (2): \"%s\"",z+1,obuf);
3503
(*v)[z][0] = (float)atof(q) * 100.0f;
3505
if (g_bKeepOriginalCoords)
3506
m_vaCoords_Original[z][0] = (double)atof(q) * 100.0;
3509
while (strchr(separators,*q) != NULL)
3512
while ((strchr(separators,*p) == NULL) && (*p != 0))
3516
eprintf("\nCTimeStep::ReadXYZ(): %d: Incomplete line (3) \"%s\"",z+1,obuf);
3520
(*v)[z][1] = (float)atof(q) * 100.0f;
3522
if (g_bKeepOriginalCoords)
3523
m_vaCoords_Original[z][1] = (double)atof(q) * 100.0;
3526
while (strchr(separators,*q) != NULL)
3529
while ((strchr(separators,*p) == NULL) && (*p != 0))
3531
if (g_bReadChargesFrom4thXYZ)
3535
eprintf("\nCTimeStep::ReadXYZ(): %d: Incomplete line (4) \"%s\"",z+1,obuf);
3544
(*v)[z][2] = (float)atof(q) * 100.0f;
3546
if (g_bKeepOriginalCoords)
3547
m_vaCoords_Original[z][2] = (double)atof(q) * 100.0;
3549
if (g_bReadChargesFrom4thXYZ)
3552
while (strchr(separators,*q) != NULL)
3555
while ((strchr(separators,*p) == NULL) && (*p != 0))
3559
m_faCharge[z] = (float)atof(q);
3560
} else if (needinfo && (z==0))
3567
while (strchr(separators,*q) != NULL)
3570
while ((strchr(separators,*p) == NULL) && (*p != 0))
3575
if (!(((*q >= '0') && (*q <= '9')) || (*q == '-') || (*q == '.')))
3577
g_bXYZ4thCol = true;
3582
/* q = strchr(buf,'.');
3586
q = strchr(q+1,'.');
3591
q = strchr(q+1,'.');
3595
eprintf("\nCTimeStep::ReadXYZ(): Error - only %d/3 dots. %d, \"%s\"",i,z+1,buf);
3604
eprintf("\nCTimeStep::ReadXYZ(): Error 1. %d, \"%s\"",z+1,buf);
3607
while (isdigit(*(p-1)) && (p > buf))
3611
eprintf("\nCTimeStep::ReadXYZ(): No Atom label found. %d, \"%s\"",z+1,buf);
3617
r = new char[strlen(q)+1];
3627
eprintf("\nCTimeStep::ReadXYZ(): Error 3. %d, \"%s\"",z+1,q);
3631
(*v)[z][0] = (float)atof(q) * 100.0f;
3638
eprintf("\nCTimeStep::ReadXYZ(): Error 4. %d, \"%s\"",z+1,q);
3642
(*v)[z][1] = (float)atof(q) * 100.0f;
3649
(*v)[z][2] = (float)atof(q) * 100.0f;*/
3653
// mprintf("*** Read Ende.\n");
3659
bool CTimeStep::ReadPDB(FILE *a, bool needinfo, CxVec3Array *v)
3662
static char buf[256], obuf[256], buf2[64];
3667
v->RemoveAll_KeepSize();
3668
for (i=0;i<m_paLabels.GetSize();i++)
3669
delete[] (char*)m_paLabels[i];
3670
m_paLabels.RemoveAll();
3673
fgets_bin(buf,256,a);
3676
if (strlen(buf) == 0)
3678
buf[strlen(buf)-1] = 0;
3682
if (strstr(buf,"CRYST1") != 0) // Boxlaenge
3684
// mprintf(GREY,"\"%s\".\n",buf);
3689
while ((*q != ' ') && (*q != 0))
3693
eprintf("Error 5 reading PDB line: \"%s\".\n",obuf);
3697
g_fBoxX = (float)(atof(p)*100.0);
3703
while ((*q != ' ') && (*q != 0))
3707
eprintf("Error 6 reading PDB line: \"%s\".\n",obuf);
3711
g_fBoxY = (float)(atof(p)*100.0);
3717
while ((*q != ' ') && (*q != 0))
3721
g_fBoxZ = (float)(atof(p)*100.0);
3722
// mprintf(GREY,"--> %f %f %f\n",g_fBoxX,g_fBoxY,g_fBoxZ);
3726
if (strstr(buf,"END") == buf)
3729
if ((strstr(buf,"ATOM")==0) && (strstr(buf,"HETATM")==0))
3733
while (!(isalpha(*p) || (*p == '_')) && (*p != 0))
3737
eprintf("Error 4 reading PDB line: \"%s\".\n",obuf);
3741
while (isalpha(*q) || (*q == '_'))
3748
eprintf("\nCTimeStep::ReadPDB(): \"%s\" - maximum length for atom labels is 7 chars; truncating.\n",p);
3752
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
3753
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3760
while ((*p != '.') && (*p != 0))
3774
if ((*q == ' ') || (*q == '-'))
3779
if ((*q == '-') || (*q == '.') || ((*q >= '0') && (*q <= '9')))
3783
// q = strchr(p,' ');
3786
eprintf("\nCTimeStep::ReadPDB(): Error 1. \"%s\".",obuf);
3791
x = (float)atof(buf2) * 100.0f;
3792
// mprintf("\n \"%s\".",buf2);
3800
if ((*q == ' ') || (*q == '-'))
3805
if ((*q == '-') || (*q == '.') || ((*q >= '0') && (*q <= '9')))
3809
// q = strchr(p,' ');
3812
eprintf("\nCTimeStep::ReadPDB(): Error 2. \"%s\".",obuf);
3817
y = (float)atof(buf2) * 100.0f;
3818
// mprintf("\n \"%s\".",buf2);
3820
z = (float)atof(q) * 100.0f;
3821
// mprintf("\n \"%s\".",q);
3823
// mprintf("\n%f, %f, %f",x,y,z);
3825
m_vaCoords.Add(CxVector3(x,y,z));
3827
m_iGesAtomCount = m_vaCoords.GetSize();
3833
bool CTimeStep::SkipPDB(FILE *a)
3840
fgets_bin(buf,256,a);
3843
if (strlen(buf) == 0)
3845
buf[strlen(buf)-1] = 0;
3846
if (strstr(buf,"END") == buf)
3853
bool CTimeStep::ReadLAMMPS(FILE *a, bool needinfo)
3856
char buf[256], obuf[256], *p, *q, *r;
3859
m_vaCoords.RemoveAll_KeepSize();
3860
for (i=0;i<m_paLabels.GetSize();i++)
3861
delete[] (char*)m_paLabels[i];
3862
m_paLabels.RemoveAll();
3863
m_iGesAtomCount = 0;
3866
fgets_bin(buf,256,a);
3869
if (strlen(buf) == 0)
3871
buf[strlen(buf)-1] = 0;
3875
if (strstr(buf,"ITEM: BOX BOUNDS") != 0) // Boxlaenge
3879
fgets_bin(buf,256,a);
3884
while (strchr(" ",*p) != NULL)
3887
while ((strchr(" ",*q) == NULL) && (*q != 0))
3891
eprintf("\nCTimeStep::ReadLAMMPS(): Incomplete line: \"%s\"\n",obuf);
3898
while (strchr(" ",*p) != NULL)
3905
case 0: g_fBoxX = (y-x)*100.0f; break;
3906
case 1: g_fBoxY = (y-x)*100.0f; break;
3907
case 2: g_fBoxZ = (y-x)*100.0f; break;
3912
if (strstr(buf,"ITEM: NUMBER OF ATOMS") != 0)
3914
fgets_bin(buf,256,a);
3917
buf[strlen(buf)-1] = 0;
3918
m_iGesAtomCount = atoi(buf);
3921
if (strstr(buf,"ITEM: ATOMS") != 0)
3923
if (strstr(buf,"ITEM: ATOMS element xu yu zu") == 0)
3925
eprintf("CTimeStep::ReadLAMMPS(): Wrong LAMMPS dump style: \"%s\".\n",buf);
3926
eprintf("You need to use \"dump custom element xu yu zu\".\n");
3930
if (m_iGesAtomCount == 0)
3932
eprintf("CTimeStep::ReadLAMMPS(): \"ITEM: ATOMS\" before \"ITEM: NUMBER OF ATOMS\".\n");
3939
m_paLabels.SetSize(m_iGesAtomCount*g_iDoubleBoxFactor);
3940
else m_paLabels.SetSize(m_iGesAtomCount);
3943
for (i=0;i<(int)m_iGesAtomCount;i++)
3945
fgets_bin(buf,256,a);
3950
while (strchr(" ",*p) != NULL)
3953
while ((strchr(" ",*q) == NULL) && (*q != 0))
3957
eprintf("\nCTimeStep::ReadLAMMPS(): %d: Incomplete line (1): \"%s\"\n",i+1,obuf);
3967
eprintf("\nCTimeStep::ReadLAMMPS(): \"%s\" - maximum length for atom labels is 7 chars; truncating.\n",p);
3971
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
3972
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
3979
while (strchr(" ",*q) != NULL)
3982
while ((strchr(" ",*p) == NULL) && (*p != 0))
3986
eprintf("\nCTimeStep::ReadLAMMPS(): %d: Incomplete line (2): \"%s\"",i+1,obuf);
3990
x = (float)atof(q) * 100.0f;
3992
while (strchr(" ",*q) != NULL)
3995
while ((strchr(" ",*p) == NULL) && (*p != 0))
3999
eprintf("\nCTimeStep::ReadLAMMPS(): %d: Incomplete line (3) \"%s\"",i+1,obuf);
4003
y = (float)atof(q) * 100.0f;
4005
while (strchr(" ",*q) != NULL)
4008
while ((strchr(" ",*p) == NULL) && (*p != 0))
4012
z = (float)atof(q) * 100.0f;
4014
m_vaCoords.Add(CxVector3(x,y,z));
4023
bool CTimeStep::SkipLAMMPS(FILE *a)
4031
fgets_bin(buf,256,a);
4034
if (strlen(buf) == 0)
4036
buf[strlen(buf)-1] = 0;
4037
if (strstr(buf,"ITEM: NUMBER OF ATOMS") != 0)
4039
fgets_bin(buf,256,a);
4042
buf[strlen(buf)-1] = 0;
4046
if (strstr(buf,"ITEM: ATOMS") != 0)
4050
eprintf("CTimeStep::SkipLAMMPS(): \"ITEM: ATOMS\" before \"ITEM: NUMBER OF ATOMS\".\n");
4055
fgets_bin(buf,256,a);
4066
bool CTimeStep::ReadDLPOLY(FILE *a, bool needinfo)
4069
char buf[256], obuf[256], *p, *q, *r;
4072
m_vaCoords.RemoveAll_KeepSize();
4073
for (i=0;i<m_paLabels.GetSize();i++)
4074
delete[] (char*)m_paLabels[i];
4075
m_paLabels.RemoveAll();
4076
m_iGesAtomCount = 0;
4079
fgets_bin(buf,256,a);
4082
if (strlen(buf) == 0)
4084
buf[strlen(buf)-1] = 0;
4087
if (strstr(buf,"timestep") != 0)
4093
while ((*q != ' ') && (*q != 0))
4097
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line A: \"%s\"\n",obuf);
4106
while ((*q != ' ') && (*q != 0))
4110
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line B: \"%s\"\n",obuf);
4119
while ((*q != ' ') && (*q != 0))
4123
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line C: \"%s\"\n",obuf);
4127
m_iGesAtomCount = atoi(p);
4133
fgets_bin(buf,256,a);
4142
while ((*q != ' ') && (*q != 0))
4146
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line D: \"%s\"\n",obuf);
4156
while ((*q != ' ') && (*q != 0))
4160
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line E: \"%s\"\n",obuf);
4170
while ((*q != ' ') && (*q != 0))
4178
if ((y != 0) || (z != 0))
4180
eprintf("\nCTimeStep::ReadDLPOLY(): X: Only orthorhombic cells are supported.\n");
4187
if ((x != 0) || (z != 0))
4189
eprintf("\nCTimeStep::ReadDLPOLY(): Y: Only orthorhombic cells are supported.\n");
4196
if ((x != 0) || (y != 0))
4198
eprintf("\nCTimeStep::ReadDLPOLY(): Z: Only orthorhombic cells are supported.\n");
4208
fgets_bin(buf,256,a);
4209
fgets_bin(buf,256,a);
4210
fgets_bin(buf,256,a);
4213
if (m_iGesAtomCount == 0)
4215
eprintf("CTimeStep::ReadDLPOLY(): Error: Atom count is 0.\n");
4222
m_paLabels.SetSize(m_iGesAtomCount*g_iDoubleBoxFactor);
4223
else m_paLabels.SetSize(m_iGesAtomCount);
4226
for (i=0;i<(int)m_iGesAtomCount;i++)
4229
fgets_bin(buf,256,a);
4238
// Numer at beginning of line: Likely velocities. Skip that line
4239
if ((*p == '-') || (*p == '.') || ((*p >= '0') && (*p <= '9')))
4242
while ((*q != ' ') && (*q != 0))
4246
eprintf("\nCTimeStep::ReadDLPOLY(): %d: Incomplete line F: \"%s\"\n",i+1,obuf);
4255
eprintf("\nCTimeStep::ReadDLPOLY(): \"%s\" - maximum length for atom labels is 7 chars; truncating.\n",p);
4259
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
4260
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4266
fgets_bin(buf,256,a);
4275
while ((*q != ' ') && (*q != 0))
4279
eprintf("\nCTimeStep::ReadDLPOLY(): %d: Incomplete line G: \"%s\"\n",i+1,obuf);
4289
while ((*q != ' ') && (*q != 0))
4293
eprintf("\nCTimeStep::ReadDLPOLY(): %d: Incomplete line H: \"%s\"\n",i+1,obuf);
4303
while ((*q != ' ') && (*q != 0))
4308
m_vaCoords.Add(CxVector3(x,y,z));
4317
bool CTimeStep::SkipDLPOLY(FILE *a)
4320
char buf[256], obuf[256], *p, *q;
4324
fgets_bin(buf,256,a);
4327
if (strlen(buf) == 0)
4329
buf[strlen(buf)-1] = 0;
4332
if (strstr(buf,"timestep") != 0)
4338
while ((*q != ' ') && (*q != 0))
4342
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line A: \"%s\"\n",obuf);
4351
while ((*q != ' ') && (*q != 0))
4355
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line B: \"%s\"\n",obuf);
4364
while ((*q != ' ') && (*q != 0))
4368
eprintf("\nCTimeStep::ReadDLPOLY(): Incomplete line C: \"%s\"\n",obuf);
4374
fgets_bin(buf,256,a);
4375
fgets_bin(buf,256,a);
4376
fgets_bin(buf,256,a);
4380
eprintf("CTimeStep::ReadDLPOLY(): Error: Atom count is 0.\n");
4386
fgets_bin(buf,256,a);
4387
fgets_bin(buf,256,a);
4398
bool CTimeStep::ReadMol2(FILE *a, bool needinfo)
4401
char buf[256], obuf[256], *p, *q, *r;
4404
fgets_bin(buf,256,a);
4405
fgets_bin(buf,256,a);
4406
fgets_bin(buf,256,a);
4411
while ((*q != ' ') && (*q != 0))
4414
m_iGesAtomCount = atoi(p);
4418
m_vaCoords.RemoveAll_KeepSize();
4419
for (i=0;i<m_paLabels.GetSize();i++)
4420
delete[] (char*)m_paLabels[i];
4421
m_paLabels.RemoveAll();
4422
m_paLabels.SetSize(m_iGesAtomCount);
4423
for (i=0;i<m_paMol2Types.GetSize();i++)
4424
delete[] (char*)m_paMol2Types[i];
4425
m_paMol2Types.RemoveAll();
4426
m_paMol2Types.SetSize(m_iGesAtomCount);
4428
fgets_bin(buf,256,a);
4429
fgets_bin(buf,256,a);
4430
fgets_bin(buf,256,a);
4431
fgets_bin(buf,256,a);
4432
fgets_bin(buf,256,a);
4434
for (i=0;i<(long)m_iGesAtomCount;i++)
4436
fgets_bin(buf,256,a);
4439
buf[strlen(buf)-1] = 0;
4441
// mprintf(" \"%s\"\n",buf);
4445
while ((*p != ' ') && (*p != 0))
4450
while (isalpha(*q) || (*q == '_'))
4457
eprintf("\nCTimeStep::ReadMol2(): \"%s\" - maximum length for atom labels is 7 chars; truncating.\n",p);
4461
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
4462
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4468
while ((*p != ' ') && (*p != 0))
4476
eprintf("\nCTimeStep::ReadMol2(): Error 1. %d. \"%s\".",i+1,obuf);
4480
x = (float)atof(p) * 100.0f;
4488
eprintf("\nCTimeStep::ReadMol2(): Error 2. %d. \"%s\".",i+1,obuf);
4492
y = (float)atof(p) * 100.0f;
4500
eprintf("\nCTimeStep::ReadMol2(): Error 3. %d. \"%s\".",i+1,obuf);
4504
z = (float)atof(p) * 100.0f;
4505
m_vaCoords.Add(CxVector3(x,y,z));
4511
while ((*q != ' ') && (*q != 0))
4517
try { r = new char[strlen(p)+1]; } catch(...) { r = NULL; }
4518
if (r == NULL) NewException((double)(strlen(p)+1)*sizeof(char),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4521
m_paMol2Types[i] = r;
4523
/* mprintf(" X=%f, Y=%f, Z=%f",x,y,z);
4525
mprintf(", A=%s, B=%s",(char*)m_paLabels[i],(char*)m_paMol2Types[i]);
4528
m_iGesAtomCount = m_vaCoords.GetSize();
4534
bool CTimeStep::SkipMol2(FILE *a)
4539
fgets_bin(buf,256,a);
4540
fgets_bin(buf,256,a);
4541
fgets_bin(buf,256,a);
4542
fgets_bin(buf,256,a);
4543
fgets_bin(buf,256,a);
4544
fgets_bin(buf,256,a);
4545
fgets_bin(buf,256,a);
4546
fgets_bin(buf,256,a);
4548
for (i=0;i<(long)m_iGesAtomCount;i++)
4550
fgets_bin(buf,256,a);
4559
void CTimeStep::CalcMinMax()
4570
for (z=0;z<(long)m_iGesAtomCount;z++)
4572
if (m_vMin[0] > m_vaCoords[z][0])
4573
m_vMin[0] = m_vaCoords[z][0];
4574
if (m_vMin[1] > m_vaCoords[z][1])
4575
m_vMin[1] = m_vaCoords[z][1];
4576
if (m_vMin[2] > m_vaCoords[z][2])
4577
m_vMin[2] = m_vaCoords[z][2];
4578
if (m_vMax[0] < m_vaCoords[z][0])
4579
m_vMax[0] = m_vaCoords[z][0];
4580
if (m_vMax[1] < m_vaCoords[z][1])
4581
m_vMax[1] = m_vaCoords[z][1];
4582
if (m_vMax[2] < m_vaCoords[z][2])
4583
m_vMax[2] = m_vaCoords[z][2];
4588
void CTimeStep::WriteMol2(FILE *a)
4590
int z, z2, z3, z4, ti, c, mc;
4592
CSingleMolecule *sm;
4598
for (z=0;z<g_oaSingleMolecules.GetSize();z++)
4599
bonds += ((CSingleMolecule*)g_oaSingleMolecules[z])->m_oaBonds.GetSize();
4601
try { tpi = new int[g_iGesAtomCount]; } catch(...) { tpi = NULL; }
4602
if (tpi == NULL) NewException((double)g_iGesAtomCount*sizeof(int),__FILE__,__LINE__,__PRETTY_FUNCTION__);
4604
mfprintf(a," @<TRIPOS>MOLECULE\n");
4605
mfprintf(a,"MOL\n");
4606
mfprintf(a," %d %d %d 0 0\n",g_iGesAtomCount,bonds,g_oaSingleMolecules.GetSize());
4607
mfprintf(a," SMALL\n");
4608
mfprintf(a,"resp\n\n\n");
4609
mfprintf(a," @<TRIPOS>ATOM\n");
4612
if (m_faCharge.GetSize() != g_iGesAtomCount)
4614
m_faCharge.SetSize(g_iGesAtomCount);
4615
for (z=0;z<g_iGesAtomCount;z++)
4618
for (z=0;z<g_oaMolecules.GetSize();z++)
4620
m = (CMolecule*)g_oaMolecules[z];
4621
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
4623
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
4625
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
4627
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
4629
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
4631
ti = ((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4);
4632
if (m_paMol2Types.GetSize() != 0)
4633
cc = (char*)m_paMol2Types[ti];
4634
else cc = ((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName;
4636
mfprintf(a," %6d %2s % 11.4f % 11.4f % 11.4f %2s %4d MOL % 8.4f\n",c,((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0,m_vaCoords[ti][1]/100.0,m_vaCoords[ti][2]/100.0,cc,mc,m_faCharge[ti]);
4641
mfprintf(a," @<TRIPOS>BOND\n");
4643
for (z=0;z<g_oaMolecules.GetSize();z++)
4645
m = (CMolecule*)g_oaMolecules[z];
4646
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
4648
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
4649
for (z3=0;z3<sm->m_oaBonds.GetSize();z3++)
4650
mfprintf(a," %6d %6d %6d 1\n",++c,tpi[((CMolBond*)sm->m_oaBonds[z3])->m_iAtomOffset[0]]+1,tpi[((CMolBond*)sm->m_oaBonds[z3])->m_iAtomOffset[1]]+1);
4653
mfprintf(a," @<TRIPOS>SUBSTRUCTURE\n");
4655
for (z=0;z<g_oaMolecules.GetSize();z++)
4657
m = (CMolecule*)g_oaMolecules[z];
4658
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
4660
mfprintf(a," %4d MOL %4d TEMP 0 **** **** 0 ROOT\n",c+1,c+1);
4668
void CTimeStep::ReadCellVector(FILE *a)
4670
char buf[256], obuf[256];
4677
eprintf("\nReadCellVector: End of file.\n");
4678
eprintf("Your cell vector text file is too short.\n");
4681
if (strlen(buf) == 0)
4683
eprintf("\nReadCellVector: Empty line.\n");
4686
buf[strlen(buf)-1] = 0;
4688
// mprintf(GREY,"\nReadCellVector: \"%s\".\n",buf);
4690
while ((!isnumeric(*p)) && (*p != 0))
4694
eprintf("\nReadCellVector: Incomplete line (1) \"%s\".\n",obuf);
4698
while (isnumeric(*q))
4702
eprintf("\nReadCellVector: Incomplete line (2) \"%s\".\n",obuf);
4706
tf = (float)(atof(p)*100.0);
4709
eprintf("\nReadCellVector: Cell vectors need to be > 0 (X) \"%s\".\n",obuf);
4715
while ((!isnumeric(*p)) && (*p != 0))
4719
eprintf("\nReadCellVector: Incomplete line (3) \"%s\".\n",obuf);
4723
while (isnumeric(*q))
4727
eprintf("\nReadCellVector: Incomplete line (4) \"%s\".\n",obuf);
4731
tf = (float)(atof(p)*100.0);
4734
eprintf("\nReadCellVector: Cell vectors need to be > 0 (Y) \"%s\".\n",obuf);
4740
while ((!isnumeric(*p)) && (*p != 0))
4744
eprintf("\nReadCellVector: Incomplete line (5) \"%s\".\n",obuf);
4748
while (isnumeric(*q))
4752
tf = (float)(atof(p)*100.0);
4755
eprintf("\nReadCellVector: Cell vectors need to be > 0 (Z) \"%s\".\n",obuf);
4760
// mprintf(GREY," --> %f %f %f\n",g_fBoxX,g_fBoxY,g_fBoxZ);
4764
void CTimeStep::CenterCOM()
4770
vc = CxVector3(0,0,0);
4772
for (z=0;z<g_iGesAtomCount;z++)
4775
if (g_baAtomIndex[z] == g_iWannierAtomType)
4777
vc += m_vaCoords[z] * ((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_pElement->m_fMass;
4778
m += ((CAtom*)g_oaAtoms[g_baAtomIndex[z]])->m_pElement->m_fMass;
4781
for (z=0;z<g_iGesAtomCount;z++)
4782
m_vaCoords[z] -= vc;
4786
float CTimeStep::FoldedDistance(int i1, int i2)
4790
t = m_vaCoords[i2]-m_vaCoords[i1];
4794
while (t[0] < -g_fBoxX/2) t[0] += g_fBoxX;
4795
while (t[0] >= g_fBoxX/2) t[0] -= g_fBoxX;
4800
while (t[1] < -g_fBoxY/2) t[1] += g_fBoxY;
4801
while (t[1] >= g_fBoxY/2) t[1] -= g_fBoxY;
4806
while (t[2] < -g_fBoxZ/2) t[2] += g_fBoxZ;
4807
while (t[2] >= g_fBoxZ/2) t[2] -= g_fBoxZ;
4810
return t.GetLength();
4814
void CTimeStep::FoldAtomsPositive()
4822
for (z=0;z<g_iGesVirtAtomCount;z++)
4826
while (m_vaCoords[z][0] < 0) m_vaCoords[z][0] += g_fBoxX;
4827
while (m_vaCoords[z][0] >= g_fBoxX) m_vaCoords[z][0] -= g_fBoxX;
4832
while (m_vaCoords[z][1] < 0) m_vaCoords[z][1] += g_fBoxY;
4833
while (m_vaCoords[z][1] >= g_fBoxY) m_vaCoords[z][1] -= g_fBoxY;
4838
while (m_vaCoords[z][2] < 0) m_vaCoords[z][2] += g_fBoxZ;
4839
while (m_vaCoords[z][2] >= g_fBoxZ) m_vaCoords[z][2] -= g_fBoxZ;
4846
void CTimeStep::WritePOV(const char *s)
4850
CSingleMolecule *sm;
4852
int z, z2, z3, z4, o, o2;
4853
CxVector3 vec1, vec2, vec3, vec1b, vec2b, vec3b, vecA, vecB, vecC, vecD;
4856
// float cr, cg, cb;
4858
b = OpenFileWrite(s,true);
4860
mfprintf(b,"// Written by TRAVIS\n");
4861
mfprintf(b,"// See http://www.travis-analyzer.de\n\n");
4862
mfprintf(b,"#version 3.6;\n");
4865
mfprintf(b,"/**** Atoms ****/\n");
4867
mfprintf(b,"#declare atom_draw = true;\n");
4868
mfprintf(b,"#declare atom_r = 0.65;\n");
4869
mfprintf(b,"#declare atom_specular = 0.7;\n");
4870
mfprintf(b,"#declare atom_reflect = 0;\n");
4871
mfprintf(b,"#declare atom_ambient = 0.2;\n");
4872
mfprintf(b,"#declare atom_diffuse = 0.7;\n");
4873
mfprintf(b,"//#declare atom_color = < 1.0, 1.0, 1.0, 0, 0 >;\n");
4874
mfprintf(b,"//#declare atom_trans = 0.7;\n");
4878
mfprintf(b,"#declare atom_draw_halo1 = true;\n");
4879
mfprintf(b,"#declare atom_r_halo1 = 0.008;\n");
4880
mfprintf(b,"#declare atom_d_halo1 = 0.0125;\n");
4881
mfprintf(b,"#declare atom_color_halo1 = < 0, 0, 0, 0, 0 >;\n");
4882
mfprintf(b,"#declare atom_specular_halo1 = 0;\n");
4883
mfprintf(b,"#declare atom_reflect_halo1 = 0;\n");
4884
mfprintf(b,"#declare atom_ambient_halo1 = 1.0;\n");
4885
mfprintf(b,"#declare atom_diffuse_halo1 = 0;\n");
4889
mfprintf(b,"#declare atom_draw_halo2 = true;\n");
4890
mfprintf(b,"#declare atom_r_halo2 = 0.003;\n");
4891
mfprintf(b,"#declare atom_d_halo2 = 0.01875;\n");
4892
mfprintf(b,"#declare atom_color_halo2 = < 1, 1, 1, 0, 0 >;\n");
4893
mfprintf(b,"#declare atom_specular_halo2 = 0;\n");
4894
mfprintf(b,"#declare atom_reflect_halo2 = 0;\n");
4895
mfprintf(b,"#declare atom_ambient_halo2 = 1.0;\n");
4896
mfprintf(b,"#declare atom_diffuse_halo2 = 0;\n");
4900
mfprintf(b,"#declare atom_draw_halo3 = true;\n");
4901
mfprintf(b,"#declare atom_r_halo3 = 0.003;\n");
4902
mfprintf(b,"#declare atom_d_halo3 = 0.025;\n");
4903
mfprintf(b,"#declare atom_color_halo3 = < 1, 1, 1, 0, 0.5 >;\n");
4904
mfprintf(b,"#declare atom_specular_halo3 = 0;\n");
4905
mfprintf(b,"#declare atom_reflect_halo3 = 0;\n");
4906
mfprintf(b,"#declare atom_ambient_halo3 = 1.0;\n");
4907
mfprintf(b,"#declare atom_diffuse_halo3 = 0;\n");
4911
mfprintf(b,"/**** Bonds ****/\n");
4913
mfprintf(b,"#declare bond_draw = true;\n");
4914
mfprintf(b,"#declare bond_r = 0.015;\n");
4915
mfprintf(b,"#declare bond_specular = 0.7;\n");
4916
mfprintf(b,"#declare bond_reflect = 0;\n");
4917
mfprintf(b,"#declare bond_ambient = 0.2;\n");
4918
mfprintf(b,"#declare bond_diffuse = 0.7;\n");
4922
mfprintf(b,"#declare bond_draw_halo1 = true;\n");
4923
mfprintf(b,"#declare bond_r_halo1 = 0.008;\n");
4924
mfprintf(b,"#declare bond_d_halo1 = 0;\n");
4925
mfprintf(b,"#declare bond_color_halo1 = < 0, 0, 0, 0, 0 >;\n");
4926
mfprintf(b,"#declare bond_specular_halo1 = 0;\n");
4927
mfprintf(b,"#declare bond_reflect_halo1 = 0;\n");
4928
mfprintf(b,"#declare bond_ambient_halo1 = 1.0;\n");
4929
mfprintf(b,"#declare bond_diffuse_halo1 = 0;\n");
4933
mfprintf(b,"#declare bond_draw_halo2 = true;\n");
4934
mfprintf(b,"#declare bond_r_halo2 = 0.003;\n");
4935
mfprintf(b,"#declare bond_d_halo2 = 0.0286;\n");
4936
mfprintf(b,"#declare bond_color_halo2 = < 1, 1, 1, 0, 0 >;\n");
4937
mfprintf(b,"#declare bond_specular_halo2 = 0;\n");
4938
mfprintf(b,"#declare bond_reflect_halo2 = 0;\n");
4939
mfprintf(b,"#declare bond_ambient_halo2 = 1.0;\n");
4940
mfprintf(b,"#declare bond_diffuse_halo2 = 0;\n");
4944
mfprintf(b,"#declare bond_draw_halo3 = true;\n");
4945
mfprintf(b,"#declare bond_r_halo3 = 0.003;\n");
4946
mfprintf(b,"#declare bond_d_halo3 = 0.0333;\n");
4947
mfprintf(b,"#declare bond_color_halo3 = < 1, 1, 1, 0, 0.5 >;\n");
4948
mfprintf(b,"#declare bond_specular_halo3 = 0;\n");
4949
mfprintf(b,"#declare bond_reflect_halo3 = 0;\n");
4950
mfprintf(b,"#declare bond_ambient_halo3 = 1.0;\n");
4951
mfprintf(b,"#declare bond_diffuse_halo3 = 0;\n");
4955
mfprintf(b,"#declare bond_draw_stub = true;\n");
4956
mfprintf(b,"#declare bond_r_stub = 0.004;\n");
4957
mfprintf(b,"#declare bond_l_stub = 0.004;\n");
4958
mfprintf(b,"#declare bond_color_stub = < 0, 0, 0, 0, 0 >;\n");
4959
mfprintf(b,"#declare bond_specular_stub = 0;\n");
4960
mfprintf(b,"#declare bond_reflect_stub = 0;\n");
4961
mfprintf(b,"#declare bond_ambient_stub = 1.0;\n");
4962
mfprintf(b,"#declare bond_diffuse_stub = 0;\n");
4966
mfprintf(b,"/**** Element Colors ****/\n");
4967
for (z=0;z<g_oaAtoms.GetSize();z++)
4969
if (z == g_iVirtAtomType)
4971
el = ((CAtom*)g_oaAtoms[z])->m_pElement;
4972
mfprintf(b,"#declare elem_%s_col = < %f, %f, %f, 0, 0 >;\n",el->m_sLabel,el->m_iColorR/255.0,el->m_iColorG/255.0,el->m_iColorB/255.0);
4975
mfprintf(b,"\n/**** Element Radii ****/\n");
4976
for (z=0;z<g_oaAtoms.GetSize();z++)
4978
if (z == g_iVirtAtomType)
4980
el = ((CAtom*)g_oaAtoms[z])->m_pElement;
4981
mfprintf(b,"#declare elem_%s_r = %f;\n",el->m_sLabel,el->m_fRadius/1000.0);
4989
mfprintf(b,"global_settings {\n");
4990
mfprintf(b," assumed_gamma 1\n");
4991
mfprintf(b,"/* radiosity {\n");
4992
mfprintf(b," pretrace_start 0.08\n");
4993
mfprintf(b," pretrace_end 0.04\n");
4994
mfprintf(b," count 100\n\n");
4995
mfprintf(b," nearest_count 5\n");
4996
mfprintf(b," error_bound 0.4\n");
4997
mfprintf(b," recursion_limit 1\n\n");
4998
mfprintf(b," low_error_factor .5\n");
4999
mfprintf(b," gray_threshold 0.0\n");
5000
mfprintf(b," minimum_reuse 0.015\n");
5001
mfprintf(b," brightness 1\n\n");
5002
mfprintf(b," adc_bailout 0.01/2\n");
5003
mfprintf(b," }*/\n");
5006
mfprintf(b,"\ncamera {\n");
5007
mfprintf(b," location <%f, %f, %f>\n",cam[0],cam[1],cam[2]);
5008
mfprintf(b," sky y\n");
5009
mfprintf(b," right -0.06*x*image_width/image_height\n");
5010
mfprintf(b," up 0.06*y\n");
5011
mfprintf(b," look_at <0, 0, 0>\n");
5015
mfprintf(b,"// Solid background\n");
5016
mfprintf(b,"background { rgb < 0.15, 0.1, 0.3 > }\n");
5019
mfprintf(b,"// Gradient background\n");
5020
mfprintf(b,"sky_sphere {\n");
5021
mfprintf(b," pigment {\n");
5022
mfprintf(b," gradient y\n");
5023
mfprintf(b," color_map {\n");
5024
mfprintf(b," [ 0 color rgb < 0.05, 0.05, 0.05 > ]\n");
5025
mfprintf(b," [ 1 color rgb < 0.20, 0.16, 0.50 > ]\n");
5027
mfprintf(b," scale 0.1\n");
5028
mfprintf(b," translate -0.05\n");
5030
mfprintf(b,"}\n\n");
5032
mfprintf(b,"/**** Invisible, only for Radiosity ****/\n");
5033
mfprintf(b,"sphere {\n");
5034
mfprintf(b," <0, 0, 0>, 1\n");
5035
mfprintf(b," texture {\n");
5036
mfprintf(b," pigment {color rgb < 1.0, 1.0, 1.0 > }\n");
5037
mfprintf(b," finish { diffuse 0 ambient 1 }\n");
5039
mfprintf(b," hollow on\n");
5040
mfprintf(b," no_shadow\n");
5041
mfprintf(b," no_image\n");
5042
mfprintf(b," scale 30000\n");
5043
mfprintf(b,"}\n\n");
5045
mfprintf(b,"light_source { < -8, 20, 20 > color rgb 0.8 }\n");
5046
mfprintf(b,"//light_source { < 25, 12, 20 > color rgb 0.5 }\n\n");
5048
mfprintf(b,"#macro m_atom_color(col)\n");
5049
mfprintf(b," #ifdef(atom_color)\n");
5050
mfprintf(b," atom_color\n");
5051
mfprintf(b," #else #if (defined(atom_trans))\n");
5052
mfprintf(b," col + < 0, 0, 0, 0, atom_trans >\n");
5053
mfprintf(b," #else\n");
5054
mfprintf(b," col\n");
5055
mfprintf(b," #end #end\n");
5056
mfprintf(b,"#end\n");
5058
mfprintf(b,"\nunion {\n");
5060
for (z=0;z<g_oaMolecules.GetSize();z++)
5062
m = (CMolecule*)g_oaMolecules[z];
5064
for (z2=0;z2<m->m_laSingleMolIndex.GetSize();z2++)
5066
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[z2]];
5068
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
5070
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
5073
el = ((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_pElement;
5075
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
5077
o = ((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4);
5078
vec1 = m_vaCoords[o];
5081
mfprintf(b,"#if (atom_draw)\n");
5082
mfprintf(b," sphere { <%g, %g, %g>, elem_%s_r*atom_r\n",vec1[0],vec1[1],vec1[2],el->m_sLabel);
5083
mfprintf(b," pigment { rgbft m_atom_color(elem_%s_col) } finish { reflection atom_reflect specular atom_specular ambient atom_ambient diffuse atom_diffuse } }\n",el->m_sLabel);
5084
mfprintf(b,"#end\n");
5091
mfprintf(b,"#if (atom_draw_halo1)\n");
5092
mfprintf(b," disc { < %g - (%g) * atom_d_halo1, %g - (%g) * atom_d_halo1, %g - (%g) * atom_d_halo1 >,\n",vec1[0],vec2[0],vec1[1],vec2[1],vec1[2],vec2[2]);
5093
mfprintf(b," < %g, %g, %g >, (elem_%s_r * atom_r) + atom_r_halo1, elem_%s_r * atom_r\n",vec2[0],vec2[1],vec2[2],el->m_sLabel,el->m_sLabel);
5094
mfprintf(b," pigment { rgbft atom_color_halo1 } finish { reflection atom_reflect_halo1 specular atom_specular_halo1 ambient atom_ambient_halo1 diffuse atom_diffuse_halo1 } no_reflection no_radiosity }\n");
5095
mfprintf(b,"#end\n");
5100
mfprintf(b,"#if (atom_draw_halo2)\n");
5101
mfprintf(b," disc { < %g - (%g) * atom_d_halo2, %g - (%g) * atom_d_halo2, %g - (%g) * atom_d_halo2 >,\n",vec1[0],vec2[0],vec1[1],vec2[1],vec1[2],vec2[2]);
5102
mfprintf(b," < %g, %g, %g >, (elem_%s_r * atom_r) + atom_r_halo1 + atom_r_halo2, elem_%s_r * atom_r\n",vec2[0],vec2[1],vec2[2],el->m_sLabel,el->m_sLabel);
5103
mfprintf(b," pigment { rgbft atom_color_halo2 } finish { reflection atom_reflect_halo2 specular atom_specular_halo2 ambient atom_ambient_halo2 diffuse atom_diffuse_halo2 } no_reflection no_radiosity }\n");
5104
mfprintf(b,"#end\n");
5106
mfprintf(b,"#if (atom_draw_halo3)\n");
5107
mfprintf(b," disc { < %g - (%g) * atom_d_halo3, %g - (%g) * atom_d_halo3, %g - (%g) * atom_d_halo3 >,\n",vec1[0],vec2[0],vec1[1],vec2[1],vec1[2],vec2[2]);
5108
mfprintf(b," < %g, %g, %g >, (elem_%s_r * atom_r) + atom_r_halo1 + atom_r_halo2 + atom_r_halo3, elem_%s_r * atom_r\n",vec2[0],vec2[1],vec2[2],el->m_sLabel,el->m_sLabel);
5109
mfprintf(b," pigment { rgbft atom_color_halo3 } finish { reflection atom_reflect_halo3 specular atom_specular_halo3 ambient atom_ambient_halo3 diffuse atom_diffuse_halo3 } no_reflection no_radiosity }\n");
5110
mfprintf(b,"#end\n");
5115
for (z3=0;z3<sm->m_oaBonds.GetSize();z3++)
5117
mb = (CMolBond*)sm->m_oaBonds[z3];
5118
o = mb->m_iAtomOffset[0];
5119
o2 = mb->m_iAtomOffset[1];
5121
el = ((CAtom*)g_oaAtoms[g_waAtomRealElement[o]])->m_pElement;
5122
el2 = ((CAtom*)g_oaAtoms[g_waAtomRealElement[o2]])->m_pElement;
5124
vec1 = m_vaCoords[o];
5127
vec2 = m_vaCoords[o2];
5130
if ((vec1-vec2).GetLength() > 0.3)
5133
vec3 = (vec1/el->m_fRadius + vec2/el2->m_fRadius) / (1.0/el->m_fRadius+1.0/el2->m_fRadius);
5135
vec3b = vec2 - vec1;
5138
mfprintf(b,"#local vec1c = < %g + (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ),\n",vec1[0],vec3b[0],el->m_sLabel,el->m_sLabel,el->m_sLabel,el->m_sLabel);
5139
mfprintf(b," %g + (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ),\n",vec1[1],vec3b[1],el->m_sLabel,el->m_sLabel,el->m_sLabel,el->m_sLabel);
5140
mfprintf(b," %g + (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ) >;\n",vec1[2],vec3b[2],el->m_sLabel,el->m_sLabel,el->m_sLabel,el->m_sLabel);
5141
mfprintf(b,"#local vec2c = < %g - (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ),\n",vec2[0],vec3b[0],el2->m_sLabel,el2->m_sLabel,el2->m_sLabel,el2->m_sLabel);
5142
mfprintf(b," %g - (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ),\n",vec2[1],vec3b[1],el2->m_sLabel,el2->m_sLabel,el2->m_sLabel,el2->m_sLabel);
5143
mfprintf(b," %g - (%g) * ( elem_%s_r*atom_r - ( elem_%s_r*atom_r - 0.5*sqrt(4*elem_%s_r*elem_%s_r*atom_r*atom_r - 4*bond_r*bond_r ) ) ) >;\n",vec2[2],vec3b[2],el2->m_sLabel,el2->m_sLabel,el2->m_sLabel,el2->m_sLabel);
5145
mfprintf(b,"#if (bond_draw)\n");
5146
mfprintf(b," cylinder { < %g, %g, %g >, vec1c, bond_r open\n",vec3[0],vec3[1],vec3[2]);
5147
mfprintf(b," pigment { rgbft m_atom_color(elem_%s_col) } finish { reflection bond_reflect specular bond_specular ambient bond_ambient diffuse bond_diffuse } }\n",el->m_sLabel);
5148
mfprintf(b," cylinder { < %g, %g, %g >, vec2c, bond_r open\n",vec3[0],vec3[1],vec3[2]);
5149
mfprintf(b," pigment { rgbft m_atom_color(elem_%s_col) } finish { reflection bond_reflect specular bond_specular ambient bond_ambient diffuse bond_diffuse } }\n",el2->m_sLabel);
5150
mfprintf(b,"#end\n");
5152
vec3 = cam - (vec1 + vec2) / 2.0;
5156
vec1b = CrossP(vec3,vec2b);
5159
mfprintf(b,"#local vec3 = < %g, %g, %g >;\n",vec3[0],vec3[1],vec3[2]);
5160
mfprintf(b,"#local vec1b = < %g, %g, %g >;\n",vec1b[0],vec1b[1],vec1b[2]);
5164
mfprintf(b,"#if (bond_draw_halo1)\n");
5165
mfprintf(b," #local vecA = vec1c + vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo1;\n");
5166
mfprintf(b," #local vecB = vec2c + vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo1;\n");
5167
mfprintf(b," #local vecC = vec2c + vec1b * (bond_r) - vec3 * bond_d_halo1;\n");
5168
mfprintf(b," #local vecD = vec1c + vec1b * (bond_r) - vec3 * bond_d_halo1;\n");
5169
mfprintf(b," triangle { vecA, vecB, vecC\n");
5170
mfprintf(b," pigment { rgbft bond_color_halo1 } finish { reflection bond_reflect_halo1 specular bond_specular_halo1 ambient bond_ambient_halo1 diffuse bond_diffuse_halo1 } no_reflection no_radiosity }\n");
5171
mfprintf(b," triangle { vecA, vecD, vecC\n");
5172
mfprintf(b," pigment { rgbft bond_color_halo1 } finish { reflection bond_reflect_halo1 specular bond_specular_halo1 ambient bond_ambient_halo1 diffuse bond_diffuse_halo1 } no_reflection no_radiosity }\n");
5173
mfprintf(b," #local vecA = vec1c - vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo1;\n");
5174
mfprintf(b," #local vecB = vec2c - vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo1;\n");
5175
mfprintf(b," #local vecC = vec2c - vec1b * (bond_r) - vec3 * bond_d_halo1;\n");
5176
mfprintf(b," #local vecD = vec1c - vec1b * (bond_r) - vec3 * bond_d_halo1;\n");
5177
mfprintf(b," triangle { vecA, vecB, vecC\n");
5178
mfprintf(b," pigment { rgbft bond_color_halo1 } finish { reflection bond_reflect_halo1 specular bond_specular_halo1 ambient bond_ambient_halo1 diffuse bond_diffuse_halo1 } no_reflection no_radiosity }\n");
5179
mfprintf(b," triangle { vecA, vecD, vecC\n");
5180
mfprintf(b," pigment { rgbft bond_color_halo1 } finish { reflection bond_reflect_halo1 specular bond_specular_halo1 ambient bond_ambient_halo1 diffuse bond_diffuse_halo1 } no_reflection no_radiosity }\n");
5181
mfprintf(b,"#end\n");
5186
mfprintf(b,"#if (bond_draw_halo2)\n");
5187
mfprintf(b," #local vecA = vec1c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5188
mfprintf(b," #local vecB = vec2c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5189
mfprintf(b," #local vecC = vec2c + vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo2;\n");
5190
mfprintf(b," #local vecD = vec1c + vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo2;\n");
5191
mfprintf(b," triangle { vecA, vecB, vecC\n");
5192
mfprintf(b," pigment { rgbft bond_color_halo2 } finish { reflection bond_reflect_halo2 specular bond_specular_halo2 ambient bond_ambient_halo2 diffuse bond_diffuse_halo2 } no_reflection no_radiosity }\n");
5193
mfprintf(b," triangle { vecA, vecD, vecC\n");
5194
mfprintf(b," pigment { rgbft bond_color_halo2 } finish { reflection bond_reflect_halo2 specular bond_specular_halo2 ambient bond_ambient_halo2 diffuse bond_diffuse_halo2 } no_reflection no_radiosity }\n");
5195
mfprintf(b," #local vecA = vec1c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5196
mfprintf(b," #local vecB = vec2c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5197
mfprintf(b," #local vecC = vec2c - vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo2;\n");
5198
mfprintf(b," #local vecD = vec1c - vec1b * (bond_r + bond_r_halo1) - vec3 * bond_d_halo2;\n");
5199
mfprintf(b," triangle { vecA, vecB, vecC\n");
5200
mfprintf(b," pigment { rgbft bond_color_halo2 } finish { reflection bond_reflect_halo2 specular bond_specular_halo2 ambient bond_ambient_halo2 diffuse bond_diffuse_halo2 } no_reflection no_radiosity }\n");
5201
mfprintf(b," triangle { vecA, vecD, vecC\n");
5202
mfprintf(b," pigment { rgbft bond_color_halo2 } finish { reflection bond_reflect_halo2 specular bond_specular_halo2 ambient bond_ambient_halo2 diffuse bond_diffuse_halo2 } no_reflection no_radiosity }\n");
5203
mfprintf(b,"#end\n");
5205
mfprintf(b,"#if (bond_draw_halo3)\n");
5206
mfprintf(b," #local vecA = vec1c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2 + bond_r_halo3) - vec3 * bond_d_halo2;\n");
5207
mfprintf(b," #local vecB = vec2c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2 + bond_r_halo3) - vec3 * bond_d_halo2;\n");
5208
mfprintf(b," #local vecC = vec2c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5209
mfprintf(b," #local vecD = vec1c + vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5210
mfprintf(b," triangle { vecA, vecB, vecC\n");
5211
mfprintf(b," pigment { rgbft bond_color_halo3 } finish { reflection bond_reflect_halo3 specular bond_specular_halo3 ambient bond_ambient_halo3 diffuse bond_diffuse_halo3 } no_reflection no_radiosity }\n");
5212
mfprintf(b," triangle { vecA, vecD, vecC\n");
5213
mfprintf(b," pigment { rgbft bond_color_halo3 } finish { reflection bond_reflect_halo3 specular bond_specular_halo3 ambient bond_ambient_halo3 diffuse bond_diffuse_halo3 } no_reflection no_radiosity }\n");
5214
mfprintf(b," #local vecA = vec1c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2 + bond_r_halo3) - vec3 * bond_d_halo2;\n");
5215
mfprintf(b," #local vecB = vec2c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2 + bond_r_halo3) - vec3 * bond_d_halo2;\n");
5216
mfprintf(b," #local vecC = vec2c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5217
mfprintf(b," #local vecD = vec1c - vec1b * (bond_r + bond_r_halo1 + bond_r_halo2) - vec3 * bond_d_halo2;\n");
5218
mfprintf(b," triangle { vecA, vecB, vecC\n");
5219
mfprintf(b," pigment { rgbft bond_color_halo3 } finish { reflection bond_reflect_halo3 specular bond_specular_halo3 ambient bond_ambient_halo3 diffuse bond_diffuse_halo3 } no_reflection no_radiosity }\n");
5220
mfprintf(b," triangle { vecA, vecD, vecC\n");
5221
mfprintf(b," pigment { rgbft bond_color_halo3 } finish { reflection bond_reflect_halo3 specular bond_specular_halo3 ambient bond_ambient_halo3 diffuse bond_diffuse_halo3 } no_reflection no_radiosity }\n");
5222
mfprintf(b,"#end\n");
5230
mfprintf(b,"#if (bond_draw_stub)\n");
5231
mfprintf(b," #local vec3 = < %g, %g, %g >;\n",vec3[0],vec3[1],vec3[2]);
5232
mfprintf(b," difference {\n");
5233
mfprintf(b," cylinder { vec1c, vec1c + vec3 * bond_l_stub, bond_r + bond_r_stub }\n");
5234
mfprintf(b," cylinder { vec1c - vec3 * (bond_l_stub+0.001), vec1c + vec3 * (bond_l_stub+0.001), bond_r }\n");
5235
mfprintf(b," pigment { rgbft bond_color_stub } finish { reflection bond_reflect_stub specular bond_specular_stub ambient bond_ambient_stub diffuse bond_diffuse_stub } }\n");
5236
mfprintf(b," difference {\n");
5237
mfprintf(b," cylinder { vec2c, vec2c - vec3 * bond_l_stub, bond_r + bond_r_stub }\n");
5238
mfprintf(b," cylinder { vec2c + vec3 * (bond_l_stub+0.001), vec2c - vec3 * (bond_l_stub+0.001), bond_r }\n");
5239
mfprintf(b," pigment { rgbft bond_color_stub } finish { reflection bond_reflect_stub specular bond_specular_stub ambient bond_ambient_stub diffuse bond_diffuse_stub } }\n");
5240
mfprintf(b,"#end\n");
5246
mfprintf(b,"\n no_shadow\n}\n\n");
5252
void CTimeStep::DumpDipoles()
5254
int z, z2, z3, z4, ti;
5256
CSingleMolecule *sm;
5259
if (!(g_bDipole && g_bDumpDipoleVector))
5262
fprintf(g_fDumpDipole,"%lu",g_iSteps);
5263
for (z=0;z<g_oaMolecules.GetSize();z++)
5265
if (g_oaDumpDipoleVector[z] == NULL)
5267
m = (CMolecule*)g_oaMolecules[z];
5268
for (z2=0;z2<((CxIntArray*)g_oaDumpDipoleVector[z])->GetSize();z2++)
5270
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[((CxIntArray*)g_oaDumpDipoleVector[z])->GetAt(z2)]];
5271
fprintf(g_fDumpDipole,"; %10G; %10G; %10G",sm->m_vDipole[0],sm->m_vDipole[1],sm->m_vDipole[2]);
5272
if (g_bDumpDipoleAbs)
5273
fprintf(g_fDumpDipole,"; %10G",sm->m_vDipole.GetLength());
5276
fprintf(g_fDumpDipole,"\n");
5278
if (g_bDumpDipoleXYZ)
5280
fprintf(g_fDumpDipoleXYZ,"%d\n\n",g_iDumpDipoleXYZAtoms);
5281
for (z=0;z<g_oaMolecules.GetSize();z++)
5283
if (g_oaDumpDipoleVector[z] == NULL)
5285
m = (CMolecule*)g_oaMolecules[z];
5286
for (z2=0;z2<((CxIntArray*)g_oaDumpDipoleVector[z])->GetSize();z2++)
5288
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[((CxIntArray*)g_oaDumpDipoleVector[z])->GetAt(z2)]];
5290
for (z3=0;z3<m->m_baAtomIndex.GetSize();z3++)
5292
if (m->m_baAtomIndex[z3] == g_iVirtAtomType)
5294
for (z4=0;z4<((CxIntArray*)sm->m_oaAtomOffset[z3])->GetSize();z4++)
5296
ti = ((CxIntArray*)sm->m_oaAtomOffset[z3])->GetAt(z4);
5297
fprintf(g_fDumpDipoleXYZ,"%s %12f %12f %12f\n",((CAtom*)g_oaAtoms[m->m_baAtomIndex[z3]])->m_sName,m_vaCoords[ti][0]/100.0,m_vaCoords[ti][1]/100.0,m_vaCoords[ti][2]/100.0);
5303
for (z=0;z<g_oaMolecules.GetSize();z++)
5305
if (g_oaDumpDipoleVector[z] == NULL)
5307
m = (CMolecule*)g_oaMolecules[z];
5308
for (z2=0;z2<((CxIntArray*)g_oaDumpDipoleVector[z])->GetSize();z2++)
5310
sm = (CSingleMolecule*)g_oaSingleMolecules[m->m_laSingleMolIndex[((CxIntArray*)g_oaDumpDipoleVector[z])->GetAt(z2)]];
5311
dc = m_vaCoords[((CxIntArray*)sm->m_oaAtomOffset[m->m_iDipoleCenterType])->GetAt(m->m_iDipoleCenterIndex)];
5312
fprintf(g_fDumpDipoleXYZ,"B %12f %12f %12f\n",dc[0]/100.0,dc[1]/100.0,dc[2]/100.0);
5313
fprintf(g_fDumpDipoleXYZ,"B %12f %12f %12f\n",dc[0]/100.0+sm->m_vDipole[0]*g_fDumpDipoleScale,dc[1]/100.0+sm->m_vDipole[1]*g_fDumpDipoleScale,dc[2]/100.0+sm->m_vDipole[2]*g_fDumpDipoleScale);
5320
CTimeStep::CTimeStep()
5324
m_vaCoords.SetName("CTimeStep::m_vaCoords");
5325
m_vaCoords_Unfolded.SetName("CTimeStep::m_vaCoords_Unfolded");
5326
m_vaCoords_Original.SetName("CTimeStep::m_vaCoords_Original");
5327
m_vaVelocities.SetName("CTimeStep::m_vaVelocities");
5328
m_vaForces.SetName("CTimeStep::m_vaForces");
5329
m_paLabels.SetName("CTimeStep::m_paLabels");
5330
m_paMol2Types.SetName("CTimeStep::m_paMol2Types");
5331
m_faCharge.SetName("CTimeStep::m_faCharge");
5335
CTimeStep::~CTimeStep()
5337
/* if (m_pLabels != NULL)
5338
delete[] m_pLabels;*/
5339
if (m_pComment != NULL)
5340
delete[] m_pComment;