scieee AI-readable full text Open interactive document viewer

GAFit : a computational tool kit for parameterizations of potential energy surfaces

Rodríguez Fernández, Roberto

Abstract

The potential energy surface of a molecular system governs many of its chemical properties, and particularly, the dynamics, that is, the spatial evolution of nuclei with time. Most of the chemical dynamics simulations performed nowadays involve integration of the classical equations of motion, calculating the forces on atoms at each step either directly by electronic structure calculations (i.e., “on-the-fly” or direct dynamics) or from analytical PES (Potential Energy Surfaces). In principle, the direct dynamics approach may be the preferred option for simulations of reactive systems that include a small number of atoms, because one avoids the construction of the analytical surface. The use of analytical PES, however, has a clear advantage in terms of CPU-time costs, being mandatory in molecular dynamics simulations of systems composed by thousands of atoms. Even for small-size systems, the use of an analytical surface may be a convenient choice. If it is developed with care, it may be almost as accurate as the exact surface corresponding to the electronic structure method used as a reference for its construction. The development of analytical PES may be facilitated by using optimization methods, and many research groups have been using them for their particular purposes. However, to our knowledge, there is not a general code that allows users to parametrize analytical surfaces in a relatively easy way. The aim of the present work was to write a suite of programs to assist users in developing analytical surfaces. This suite of programs is called GAFit. GAFit is a package of programs initially developed to facilitate fittings of intermolecular potentials and reparametrizations of semiempirical Hamiltonians. However, it can be easily adjusted for other purposes in which fittings of a series of parameters are needed. The core of the package is the genetic algorithm developed by Marques and co-workers (Marques, J M C; Prudente, F V; Pereira F B; Almeida M M; Maniero A M and Fellows C E. “A new genetic algorithm to be used in the direct fit of potential energy curves to ab initio and spectroscopic data”. In: Journal of Physics B: Atomic, Molecular and Optical Physics 41.8 (2008), p. 085103.). The functionality of the package was extended separating the core itself from the fitting targets. Now, users can choose, upon their programming skills, from introducing their custom potentials directly into code, use an easy pre-coded potential template to do so, or for those with no programming knowledge at all, use an analytical expression or the most used potentials coded just ready to use. A complete set of tools were added to the package to facilitate the creation and configuration of input files. In addition, an external interface was developed to interact with external programs. Using this interface the tools needed to use GAFit to parametrize the MOPAC program were developed. A further MOPAC enhanced interface permits running parallel copies of MOPAC to speed up calculations and face up some problems encountered during the first stage development.

Full text

UNIVERSIDADE DE SANTIAGO DE COMPOSTELA FACULTADE DE QUÍMICA PhD Thesis GAFit: A computational tool kit for parameterizations of potential energy surfaces Roberto Rodríguez-Fernández Santiago de Compostela, June 2014 UNIVERSIDADE DE SANTIAGO DE COMPOSTELA FACULTADE DE QUÍMICA DEPARTAMENTO DE QUÍMICA FÍSICA PhD Thesis GAFit: A computational tool kit for parameterizations of potential energy surfaces Roberto Rodríguez-Fernández Santiago de Compostela, June 2014 Dr. Emilio Martínez-Núñez e Dr. Saulo A. Vázquez-Rodríguez, Profesores titulares do Departamento de Química Física da Universidade de Santiago de Compostela, autorizan a presentación da tesis doctoral titulada “GAFit: A computational tool kit for parametrizations of potential energy surfaces” realizada por D. Roberto Rodríguez-Fernández, Licenciado en Química pola Universidade de Santiago de Compostela, para optar ao grao de Doctor en Química. E para que así conste, asinamos o presente documento. En Santiago de Compostela a 13 de xuño do 2014. Dr. Emilio Martínez-Núñez Dr. Saulo A. Vázquez-Rodríguez Aos meus: meus pais, Gloria e Primo, miña irmá, Susana, miña dona, Marysol, meus fillos, Lois e Victoria Uxía, e aos amigos... o GAFit: A computational tool kit for parametrizations of potential energy surfaces RESUMO A superficie de enerxía potencial (PES) de un sistema goberna moitas das súas propiedades químicas, e particularmente, a dinámica, isto é, a evolución espacial dos núcleos co tempo. Hoxe en día, moitas das simulacións feitas integran as ecuacións clásicas do movemento, calculando as forzas sobre os átomos a cada paso directamente por cálculos de estruturas moleculares –dinámica directa– ou por PES analíticas. Incluso, en sistemas pequenos, o uso dunha superficie analítica pode ser unha elección axeitada. Sen embargo, ata o que coñecemos, non hai un código xenérico que permita aos usuarios parametrizar superficies analíticas de unha forma fácil. O motivo final deste traballo é escribir un conxunto de programas que axuden aos usuarios no desenvolvemento de superficies analíticas. GAFit foi inicialmente desenvolvido para facilitar o axuste de potenciais intermoleculares e a reparametrización de hamiltonianos semiempíricos usando un alogritmo xenético. Sen embargo, pode ser facilmente configurado para outros propósitos nos que se necesiten axustar series de parámetros. A funcionalidade do paquete foi estendido separando o núcleo dos obxetivos a axustar. Os usuarios poden escoller, dependendo dos seus coñecementos de programación, dende introducir os seus propios potenciais directamente no código, usar un esquema fácil de encher co potencial requerido, ou para eses sen coñecementos, empregar unha expresión analítica ou os potenciais máis comúns xa listos para usar. Para facilitar a creación e configuración dos arquivos de entrada engadíronse un conxunto de ferramentas especializadas ao paquete. A maiores, desenvolveuse unha interface externa para interactuar con programas externos. Usando esta interface creáronse as ferramentas necesarias para parametrizar o MOPAC. Co gallo de solucionar certos problemas atopados perante o primeiro estadio de desenvolvemento, creouse unha interface mellorada que incluso permite lanzar procesos MOPAC concorrentes acelerando os cálculos. PALABRAS CHAVE algoritmo xenético superficie enerxía potencial [\ SUMMARY The potential energy surface (PES) of a molecular system governs many of its chemical properties, and particularly, the dynamics, that is, the spatial evolution of nuclei with time. xiv CONTENTS 14.2 Running and examining results .............. 153 15 External Interface example 155 15.1 Input files ......................... 155 15.2 Running the example and examining results ....... 159 16 MOPAC Interface example 169 16.1 Prerequisites ........................ 169 16.2 Input and executable files ................. 169 16.3 Running the example and examining results ....... 175 17 Enhanced MOPAC Interface example 181 17.1 Input and executable files ................. 181 17.2 Running the example ................... 182 IV Applications 185 18 Collision-induced dissociation mechanisms of [Li(uracil)]+187 18.1 Abstract .......................... 187 18.2 Introduction ........................ 188 18.3 Computational details ................... 190 18.3.1 Potential energy surface .............. 190 18.3.2 Chemical dynamics simulations .......... 191 18.4 Results and Discussion .................. 194 18.4.1 Trajectory types .................. 194 18.4.2 Aditional fragmentation channels of [Li(uracil)]+198 18.4.3 Comparison with experiment ........... 203 18.4.4 Energy transfer .................. 204 18.5 Conclusions ........................ 206 18.6 Acknowledgements ..................... 208 18.7 Electronic Supplementary Information .......... 208 18.7.1 Intramolecular [Li(uracil)]+Potential Energy Surface ......................... 208 18.7.2 LJ parameters for [Li(uracil)]+.......... 209 18.7.3 Tables ....................... 209 CONTENTS xv 19 Ab initio and RRKM study of the HCN/HNC elimination channels from vinyl cyanide 217 19.1 Introduction ........................ 218 19.2 Computational details ................... 220 19.3 Results and Discussion .................. 222 19.4 Conclusions ........................ 229 19.5 Acknowledgement ..................... 230 19.6 Supporting Information .................. 235 19.6.1 Frequencies of all stationary points found in this study ........................ 235 19.6.2 Cartesian Coordinates (in Å) of all stationary points found in this study ................ 235 V Conclusions 239 20 Conclusions 241 Appendices 247 A Source code 247 A.1 Source files ......................... 247 A.2 Analytical job ....................... 248 A.3 Potential base routines .................. 249 A.4 Fpu routines ........................ 249 A.5 GAFit ........................... 250 A.6 Genetic Algorithm Core .................. 250 A.6.1 Crossover ...................... 250 A.6.2 Mutation ...................... 250 A.6.3 Selection ...................... 250 A.6.4 Stats ........................ 250 A.6.5 Utils ........................ 250 A.7 External job ........................ 251 A.7.1 Flyctl ........................ 251 A.7.2 Mopac ....................... 251 xvi CONTENTS A.8 Miscellaneous ....................... 251 A.8.1 Arguments ..................... 251 A.8.2 Autoweights .................... 252 A.8.3 Bounds ....................... 252 A.8.4 Cnames ...................... 252 A.8.5 InputLine ..................... 252 A.8.6 Integer ....................... 252 A.8.7 Literals ....................... 253 A.8.8 Parameters ..................... 253 A.8.9 Rand ........................ 253 A.8.10 Rstrings ...................... 253 A.9 Tools ............................ 253 A.9.1 Bedit ........................ 253 A.9.2 Fitview ....................... 254 A.9.3 JobTreeEditor ................... 254 A.9.4 Needle ....................... 254 A.9.5 Ufpu ........................ 255 B Resumo 257 References 267 Other interesting references to the reader 275 Index 279 List of tables 285 List of figures 287 List of files 293 Acknowledgements First and foremost, I have to thank my thesis directors, Emilio Martínez Núñez and Saulo A. Vázquez Rodríguez, for their support and understanding over these past years. I would also like to thank Francisco Baptista Pereira and Jorge M. C. Marques. Without their help this thesis would not have been possible. Last, but not least, I would like to thank my family and friends for their support. xvii Conventions Symbols −→ tabs ␣blank spaces . . . or [...] more output not shown 'wrapped line &wrapped line continuation Acronyms 3C three-centered ...................................... 218 4C four-centered ....................................... 219 AM1 Austin Model 1.....................................187 AM1-SRP AM1 Specific Reaction Parameters..................198 BLX-αBlend Alpha Crossover...............................31 BSSE Basis Set Superposition Error.......................191 CESGA "Centro de Supercomputación de Galicia" .......... 208 CID Collision-Induced Dissociation ...................... 187 CPU Central Processing Unit...............................5 1 2 CONTENTS DNA deoxyribonucleic acid ................................ 18 DPC Double Point Crossover (or TPX, Two Point Crossover) 21 ESI Electronic Supplementary Information .............. 190 TR-FTIRES time-resolved Fourier transform infrared emission spectroscopy........................................218 FPU Floating Point Unit..................................73 GA Genetic Algorithm .................................... 6 GUI Graphical User Interface............................123 IDE integrated development environment ................ 266 ITPs Inner Turning Points ............................... 193 IVR Intramolecular Vibrational Energy Redistribution...189 KMC Kinetic Monte Carlo................................193 LJ Lennard-Jones......................................194 MEP minimum energy path .............................. 220 MOPAC Molecular Orbital PACkage..........................36 MPX Multiple Point Crossover.............................21 NFS Network File System................................100 PBS Portable Batch System ............................. 262 PDF portable document format .......................... 263 PES Potential Energy Surface..............................5 PNG portable network graphics .......................... 263 QCT Quasiclassical Trajectory ........................... 191 RNA ribonucleic acid.....................................189 RRKM Rice–Ramsperger–Kassel–Marcus ................... 189 SBX Simulated Binary Crossover..........................30 SPC Single Point Crossover (or SPX) ..................... 21 SRP Specific Reaction Parameters ....................... 208 VC vinyl cyanide ....................................... 169 CONTENTS 3 ZPE zero-point vibrational energies ...................... 220 Input, output and files •A command line interactive shell session: tar -xvzf gafit-VERSION.tar.gz cd gafit-VERSION ./configure make make install •A program output to interactive terminal or redirected to a file: Build: 2122 Settings for job ----------------------------- Geometries:[coord.molden] Energies:[energies] Atom2type:[atom2type.txt] Bounds:[bounds.txt] Charges:[charges.txt] Potential read: 2 All coefficients: no, Read and repeat subset Fitting: absolute [...] •An input or output file: File 1: Input file example. [ job ] runs : ␣␣␣␣␣␣␣␣␣1 evaluations : ␣␣5000000 Geometries : ␣␣␣moldeni . dat Energies : ␣␣␣␣␣ energies . dat Atom2type : ␣␣␣␣atom2types . txt Bounds : ␣␣␣␣␣␣␣bounds . txt Charges : ␣␣␣␣␣␣charges . txt Potential : ␣␣␣␣1 All ␣ c o e f f i c i e n t s : ␣0 •Source code file: File 2: C source code 34 35 int 4 CONTENTS 36 build (void ) 37 { 38 char ∗build = "$Rev : ␣3521␣$" ; 39 return atoi ( index ( build , ’ : ’ ) + 1) ; 40 } •Command line tool syntax: command [-a][-b c] [-d [e]] [-f {g|h|i}] mandatory-argument [optional-argument] options or flags consist of ’-’ characters and single letters or digits, such as ’-a’ or ’-1’ which enable a feature. Some of them have an option argument too, like the ’-b c’, where ’c’ is the argument for option ’-b’. Here ’c’ is used to ’tune’ the ’feature’ enabled with ’-b’. Arguments or option-arguments enclosed in the ’[’ and ’]’ notation are optional and can be omitted like the ’[optional-argument]’ or ’[e]’ or ’[-d [e]]’. The ones not enclosed like ’mandatoryargument’ must be set. If the ’-b’ feature is enabled ’c’ must be set, but if the ’-d’ feature is enabled, ’e’ is optional. ’{’ and ’}’ notation represents a set of options to select. Arguments separated by the ’|’ bar notation are mutually-exclusive, and only one of them must be chosen from the set enclosed with ’{’ and ’}’. •Menu selection sequence: Edit Tree Internal job Analytical •keystrokes: –A+O: A key plus O key at the same time. –A,O: A key, then O key. 1 Introduction and objectives To invent, you need a good imagination and a pile of junk. Thomas A. Edison One of the key concepts in chemistry is that of Potential Energy Surface (PES)[1]. It comes from the Born-Oppenheimer approximation, which facilitates the solution of the time-independent Schrödinger equation for molecular systems. Fortunately, the errors associated with this approximation are negligible for many of the systems and conditions of interest to chemists. The potential energy surface of a molecular system governs many of its chemical properties, and particularly, the dynamics, that is, the spatial evolution of nuclei with time. Most of the chemical dynamics simulations performed nowadays involve integration of the classical equations of motion, calculating the forces on atoms at each step either directly by electronic structure calculations (i.e., “onthe-fly” or direct dynamics) or from analytical PESs. In principle, the direct dynamics approach may be the preferred option for simulations of reactive systems that include a small number of atoms, because one avoids the construction of the analytical surface. The use of analytical PESs, however, has a clear advantage in terms of Central Processing Unit (CPU)-time costs, being mandatory in molecular dynamics simulations of systems composed of thousands of atoms1. Even for small-size 1In molecular mechanics and molecular dynamics, the analytical potential energy surface of a system is generally known as the force field. 5 12 2. OPTIMIZATION METHODS In behalf of clarity, a simpler and practical classification can be used as in Boyd and Vandenberghe [7] taking into account convexity and linearity. 2.2 Linear programming A linear programming problem is a problem of minimizing a linear function –(2.1.3)– with linear constraints of the inequality and/or the equality type[8]: Maximize Z =c1x1+c2x2+. . . +cnxn subject to a11x1+a12x2+. . . +a1nxn≤b1 . . . +. . . +. . . +. . . . . . am1x1+am2x2+. . . +amnxn≤bm x1≥0x2≥0. . . xn≥0 Zis the objective function to be minimized, c1, c2, ..., cnare the cost coefficients and x1, x2, ..., xnare the decision variables. Finally, aij are the technological coefficients forming the constraint matrix. There are effective methods for solving linear programming problems as the simplex method or the interior-point methods. 2.3 Convex optimization Aconvex optimization problem is one in which the objective and constraint functions are convex, which means they satisfy the inequality (2.1.2). Linear programming and least-squares problems are special cases of convex problems. Convex programming problems have a well developed theory, and can be solved numerically very reliably and efficiently, using interior-point methods or other special methods for convex optimization[7]. Convex optimization has also found wide application in global optimization, where it is used to find an optimal value as approximate solutions. 2.4. NONLINEAR OPTIMIZATION 13 2.4 Nonlinear optimization Nonlinear optimization is the term used to describe an optimization problem when the objective or constraint functions are not linear, but not known to be convex[7]. There are no effective methods for solving the general nonlinear programming problem. The simple ones with a dozen of variables are difficult to solve, and those with one hundred variables may become an impossible task. 2.4.1 Local optimization In local optimization we search for a good feasible point, x∗, that is the best compared with nearby feasible points in the same region: ∀x∃δ > 0(kx−x∗k< δ f(x∗)≤f(x)e.g., if x∗is a minimum (2.4.1) But it may not coincide with the globally optimal solution. There are some facts about local optimization methods: •For most local optimization methods differentiability of the objective and constraint functions, with respect to the variables or parameters, is the only requirement. •You have to experiment with the choice of algorithm to find a suitable one to the problem at hand. •They are often sensitive to algorithm parameters and must be adjusted depending on the problem to be solved. •In many cases, an initial guess –seed– is needed. This has a huge influence on the solution. In figure 2.2 we can see an example of a surface with local minima (green), and an absolute minimum (in red). Using our initial guess, and the gradient to move over the surface, we can find one of the minima, but it may not be the global one. 14 2. OPTIMIZATION METHODS 2.4.2 Global optimization Global optimization is the task of finding the absolute minimum (or best solution). It is considered “the hardest part of a subject called nonlinear programming[9]”. In the worst case, complexity grows exponentially with the sizes of parameters and constraints, so it can take a long time to solve. If the number of variables is big –hundreds–, the cost in computation time can make the problem intractable[7]. An intractable problem in complexity theory is a a problem in which no algorithm can exist computing all instances of it in polynomial time[10]: When the execution time of a computation, m(n), is no more than a polynomial function of the problem size, n. More formally m(n) = O(nk)where kis a constant[11]. Global optimization algorithms can be classified according to the method of operation into two different types[12]: deterministic and probabilistic. Deterministic At least one way to proceed exists in each execution step. If there is not any way, the algorithm ends. Deterministic algorithms are often used if there is a clear relation to the fitness of the possible solutions. If so, the search space could be efficiently explored to find good solutions. Probabilistic If the relation is not obvious, if it is difficult or if the search space has a high dimensionality, then probabilistic algorithms are used. In general, to obtain an optimal solution, you must spend time exploring the search space. Examples of deterministic are State Space Search,Branch and Bound and Algebraic Geometry. Examples of probabilistic are Hill Climbing,Random Optimization, Simulated Annealing,Genetic Algorithms etc.. 2.4. NONLINEAR OPTIMIZATION 15 Global Figure 2.2: Global search. 3 Evolutionary Algorithms I am turned into a sort of machine for observing facts and grinding out conclusions. Charles Darwin Evolutionary algorithms are a good tool in Global Optimization because they make no assumptions about the problem, and therefore, they usually perform very well in all types of problems[12]. These algorithms employ techniques inspired in biology such as reproduction, mutation, recombination and selection applied to a set of candidates used as a population to find optimal ones. Evolutionary algorithms proceed according to the scheme shown in Figure 3.1. A population is initialized; then, each member is evaluated according to some objective function. And finally, some of the members initialize population evaluation selection reproduction Figure 3.1: Evolutionary algorithms. 17 18 3. EVOLUTIONARY ALGORITHMS B C D E F v= eB -Br +C rD+r E F A A Figure 3.2: Genes and chromosome example: 4th potential from Table 6.2. are selected to create a new population using reproduction techniques. The process continues until a population member turns out to be a good solution, or a maximum number of populations are reached. There are many evolutionary algorithm types with distinctive features depending on how the populations are used, how the individuals are represented, how the individuals are selected to reproduction, how the offspring are included in the population of the next generation, etc. The population of the next generation can be formed from: •a combination of the current population and its offspring, •some or all of the offspring, and none of the current generation individuals, •none or some of the best individuals –known as elitist algorithm– are propagated to the next generation. We describe here two types of evolutionary algorithms of our interest: Genetic Algorithms and Genetic Programming. 3.1 Genetic Algorithms The individuals are described by an array of elementary types –the genes: any suitable representation, including bits and bytes– similar to a deoxyribonucleic acid (DNA) string, and are also called a chromosome. Each gen can describe a characteristic, e.g. a double precision polynomial coefficient value like the example in Fig. 3.2 where is represented the 4th potential from Table 6.2. 3.1. GENETIC ALGORITHMS 19 Figure 3.3: Single gene mutation. Figure 3.4: Multiple gene mutation. Chromosomes could be fixed or variable length strings. The type, number, characteristics, etc of genes and how they are related in the chromosoma is a problem type dependent matter. There are some genetic operators which can be applied over a chromosome string: Mutation,permutation and crossover. 3.1.1 Mutation Mutation randomly changes one or more genes. If the chromosomes are of fixed length, we may have a single gene mutation (Fig. 3.3) or a multiple gene mutation (Fig. 3.4), and if the chromosomes are of variable length, there can be an insertion (Fig. 3.5) or a deletion (Fig. 3.6). 3.1.2 Permutation Permutation exchanges a pair of genes. Fig. 3.7. 20 3. EVOLUTIONARY ALGORITHMS Figure 3.5: Variable lenght insertion. Figure 3.6: Variable lenght deletion. Figure 3.7: Permutation. 3.2. GENETIC PROGRAMMING 21 Figure 3.8: Single point crossover. Figure 3.9: Variable lenght single point crossover. 3.1.3 Crossover Crossover recombines two chromosomes to obtain a new one. Some crossover types are described in the literature as Single Point Crossover (SPC), Double Point Crossover (DPC), and Multiple Point Crossover (MPX). As above, the chromosomes can be of fixed or variable length. See Fig. 3.8,3.9,3.10 and 3.11. 3.2 Genetic Programming We do not use in this Thesis Genetic Programming, but we do not disregard its use in the future as it provides a new means to implement new capabilities in the program. One of those capabilities that would be of great interest to us is the optimization of the functional form of the potentials we employ to fit a set of ab initio energies for two interacting species. Genetic Programming includes all evolutionary algorithms that cre- 28 4. THE GENETIC ALGORITHM 179 while ( current_evaluations < evaluations ) ; The system is configured reading an input file –Section 6–. Once configured, the GA main loop routine starts and continues till a maximum number of evaluations is reached as shown in Figure 4.1. The GA only comunicates with the external world –internal or external routines or programs– through the evaluation phase and when some subroutines print outputs. Table 4.1: GA subroutines subroutine source comments ga ga.c main loop tournament_selection selection.c tournament algorithm apply_elitism selection.c elitism algorithm apply_crossover crossover.c crossover apply_mutation mutation.c mutation evaluate_pop evaluation.c this subroutine works as an interface switching the evaluation to the desired type of application get_best selection.c 4.1 Tournament Selection A subset of Kindividuals are selected randomly from the old population. The best of the set is selected and introduced in the new population. This operation is repeated till the new population is completed. Kis the tournament controlling parameter: Tournament size. 4.2 Genetic operations 4.2.1 Crossover For all the population, each two consecutive individuals, a random number between 0and 1is obtained and if it is greater than the crossover rate a crossover is performed obtaining two new offspring replacing their parents. The type of crossover selects the operator to apply: •Single point crossover. A random point is selected and the offspring are obtained from the parents by exchanging the tail segments. 4.2. GENETIC OPERATIONS 29 Confirgure system Create first population Evaluate first population Tournament selection Genetic operations Evaluation Elitism Save all time best Current evaluations < evaluations End 4.000000000000 0.000000000000 -5.000000000000 0.000000000000 1.000000000000 Fitness: 0.000000000000 best.txt YES NO GA interface Figure 4.1: GA main loop 30 4. THE GENETIC ALGORITHM •Double point crossover. Two random points are selected and the offspring are obtained from the parents by exchanging the center segments. •Simulated Binary Crossover (SBX)[13].SBX simulates a SPC operator on binary strings obtaining two offspring having some interesting properties to self-adaptation[14]: –high probability to mantain the extend between them like the parents –high probability to be near the parents values SBX works as follows: –A random value between 0and 1is selected: µ∈[0,1]1. –Using a uniform distribution we calculate βso the area under probability curve from 0to βis equal to µ: β= (2µ)1 η+1 if µ ≤0.5 β= ( 1 2(1−µ))1 η+1 if µ > 0.5 –Now, we obtain the two children, C1and C2, from the parents, P1and P2: C1=1 2[(1 + β)P1−(1 −β)P2] C2=1 2[(1 −β)P1+ (1 + β)P2] The controlling parameter is η–eta_sbx, Table 6.1– which is a real non negative number. Larger values increase probability of children close to their parents while small ones increase probability of distant children[2]. 1Really, here the coded implementation is µ∈[0,0.99] to avoid a divide by zero problem in the calculation of β 4.2. GENETIC OPERATIONS 31 •Blend Alpha Crossover (BLX-α)[15].BLX-αcrossover creates new offspring choosing a random value for each gene in the range: [Gmin −∆α, Gmax + ∆α] Here Gmin and Gmax are the smallest and largest of the two parents gene values. ∆is Gmax −Gmin. The value obtained is checked and limited to the acceptable values for the gene, called the bounds. BLX-αcrossover has the first interesting self-adaption property of SBX: high probability to mantain the extend between them like the parents[14]. The controlling parameter is α–blx_alpha, Table 6.1– which determines the degree of variability. It was reported that a value α= 0.52performs better than other values for many test problems[14]. SBX and BLX-αare calculated crossovers. In both cases, if an integer gene type is used, they revert to a Single Point crossover. 4.2.2 Mutation The application is slighty different from the crossover operators. Here mutation rate operates over genes while crossover rate operates over individuals: •For all individuals in the population, a call to mutation subroutines is performed obtaining a new offspring replacing the parent. •For each individual’s gene, a random number between 0and 1is obtained, and if it is greater than the mutation rate the corresponding mutation is performed in the gene3. There are four types of mutation to apply upon coefficient nature and user choice: •Real coefficients: Random and sigma. 2Known as BLX-0.5 crossover 3As the mutation rate drops to zero, the probability that the parent replaces itself increases. 32 4. THE GENETIC ALGORITHM –Random mutation. The parent gene is replaced by a random number obtained from the acceptable set of values for the gen –bounds–. –Sigma mutation. The child gene, Gchild, is replaced by a new value calculated from parent Gparent as: Gchild =Gparent +σ(Gmax −Gmin)N(0,1) Gmax and Gmin are bounds, N(0,1) is a random value sampled from a standard normal distribution and σ–sigma, Table 6.1– is the control parameter. The value is checked against the bounds, and if in five tries a suitable value between bounds is not found, a random mutation is performed. •Integer coefficients: Random and adjacent. –Random mutation. The parent gene is replaced by a random integer number between bounds. –Adjacent mutation. Adjacent changes the parent gene by a unit amount as follows: Gchild =       Gmin + 1 if Gparent =Gmin Gmax −1if Gparent =Gmax otherwise randomly: Gparent + 1 Gparent −1 4.3 Elitism Finally, elitism is applied: A random individual of the new generation is replaced with the best from parent generation ensuring that the quality of the best does not decrease along the time. Part II Program Details 33 5 GAFit DNA is like a computer program but far, far more advanced than any software ever created. Bill Gates 5.1 Introduction GAFit is a package of programs initially developed to facilitate fittings of intermolecular potentials and reparametrizations of semiempirical Hamiltonians. However, it can be easily adjusted for other purposes in which fittings of a series of parameters are needed. The core of the package is the genetic algorithm developed by Marques [2] and co-workers. The functionality of the package was extended separating the core itself from the fitting targets –See Figure 4.1–. Now, users can choose, upon their programming skills, from introducing their custom potentials directly into code, use an easy pre-coded potential template to do so, or for those with no programming knowledge at all, use an analytical expression or the most used potentials coded just ready to use. A complete set of tools were added to the package to facilitate the creation and configuration of input files. In addition, a external interface was developed to interact with external programs. Using this interface were developed the tools needed to 35 36 5. GAFIT use GAFit to parametrize the Molecular Orbital PACkage (MOPAC). A further MOPAC enhanced interface permits running parallel copies of MOPAC to speed up calculations and face up some problems encountered during the first stage development. 5.2 Installation The configuration, compilation and installation phases are done by the GNU autotools utilities. tar -xvzf gafit-VERSION.tar.gz cd gafit-VERSION ./configure make make install The binaries go into $HOME/bin and other files into $HOME/share. To install into /usr/local (note that you need superuser permissions.), use: ./configure --prefix=/usr/local make sudo make install To force a fortran compiler (e.g. ifort) use: ./configure FC=ifort To force a C compiler (e.g. icc) use: ./configure CC=icc Or any combination above: ./configure --prefix=/usr/local FC=ifort CC=icc To compile with debug options: ./configure --enable-debug In addition, the usual targets of Autotools apply (i.e. make distcheck, make clean etc). 5.3. USAGE 37 5.3 Usage 5.3.1 Overview Internal job Internal job means here a job where an internal intermolecular potential energy function is parametrized to fit a set of interaction energies between two fragments. You must have the files: geometries,energies and charges if needed. See 6.3. To edit and/or build the atom2type file, you can use the needle tool with the geometries file as input. See 12.1. It is compulsory to check the atom2type file if you employed the needle tool. Once you know how many different interactions you have in your system you can write the bounds file, page 48. Write the job.txt, see 6.3. Run the GAFit executable in the folder where all the files are located. If you want to run more than one GAFit process from the same folder –with the same configuration–, you can use a command line argument to distinguish the output files: $ gafit alpha Build: 2427 TAG:alpha OUTPUT_FILE: stats.alpha.txt OUTPUT_BEST: best.alpha.txt Settings for job ----------------------------- [...] and change their names accordingly to prevent overwriting. See 7.2. External job The files needed for an external job depend on the type of job to be done. In this case, an external program or tool evaluates the coefficients 44 6. INPUT FILES Section Parameter Type Valid set Default command string ./external external input string external.input external fit string external.fit coefficients integer 0 print geometries bool {yes, no} yes runs bool {yes, no} yes ga settings bool {yes, no} no analytical bool {yes, no} yes auto weights bool {yes, no} yes An external job implies that the user only employs the genetic algorithm to fit the parameters and evaluate them by an external program. 6.2 Section [parameters] The section [parameters] contains the genetic algorithm settings. population Population size elitism Elistism strategy. Section 4.3. •no •yes tournament size Tournament selection size. Section 4.1. crossover rate Crossover rate. Section 3.1.3. blx_alpha BLX-αcrossover coefficient eta_sbx SBX crossover coefficient crossover Crossover type. •spc: Single Point Crossover •dpc: Double Point Crossover •blax: Blend Alpha Crossover •sbx: Simulated Binary Crossover mutation rate Mutation rate. Section 4.2.2. mutation Mutation type 6.3. SECTION [JOB] 45 •random = Random mutation •sigma = Sigma mutation sigma Sigma mutation coefficient integer mutation Mutation operator for integer variables. Section 4.2.2. •random •adjacent direction Search direction •min: Minimization •max: Maximization 6.3 Section [job] This section defines the run parameters for the present job. It also indicates the names of the different files for the calculation. The job parameters from the job section are: Type type of job: external or internal. In case of external could be: external Each gene is passed to the external program, one per run. external bulk All the genes of the same generation are passed to the external program, an entire generation per run, reducing the overall load, speeding up calculations. external auto GAFit is configured by the external command. See 9.1. Test If it is not equal to zero, the integer is used as random seed, breaking the system randomness. This is useful for testing purposes. For as standard job you should use a random number: set to zero this value or do not put anything. The used seed in a job is printed in the output as shown below to recover it when needed . 46 6. INPUT FILES [...] #seed#1348550422#seed# [...] Runs Number of runs. Remember to change this setting if you are using auto weights, page 52. Evaluations Number of generations Geometries Continuous set of molden format Cartesian geometries without any empty lines between them. File 6.3: Geometries file. Molden xyz coordinates ␣␣␣␣␣␣␣␣␣␣116 ␣␣␣␣␣␣␣␣␣␣␣␣X␣␣␣␣␣␣␣␣␣␣␣Y␣␣␣␣␣␣␣␣␣␣␣Z ␣N␣␣␣ −13.694289␣␣␣␣ −0.182672␣␣␣␣␣0.000000 ␣H␣␣␣ −13.299638␣␣␣␣␣ 0.824476␣␣␣␣␣0.000000 ␣C␣␣␣ −12.403476␣␣␣␣ −0.960776␣␣␣␣␣0.000000 ␣H␣␣␣ −14.263389␣␣␣␣ −0.348152␣␣␣␣ −0.831048 ␣H␣␣␣ −14.263389␣␣␣␣ −0.348152␣␣␣␣␣0.831048 ␣C␣␣␣ −11.316612␣␣␣␣␣0.153002 ␣␣␣␣␣0.000000 ␣H␣␣␣ −12.348018␣␣␣␣ −1.588139␣␣␣␣ −0.892698 ␣H␣␣␣ −12.348018␣␣␣␣ −1.588139␣␣␣␣␣0.892698 ␣O␣␣␣ −11.719020␣␣␣␣␣1.326881␣␣␣␣␣0.000000 ␣ . . . ␣␣␣␣␣␣␣␣␣␣116 ␣␣␣␣␣␣␣␣␣␣␣␣X␣␣␣␣␣␣␣␣␣␣␣Y␣␣␣␣␣␣␣␣␣␣␣Z ␣N␣␣␣␣ −9.694289␣␣␣␣ −0.182672␣␣␣␣␣0.000000 ␣H␣␣␣␣ −9.299638␣␣␣␣␣0.824476␣␣␣␣␣0.000000 ␣C␣␣␣␣ −8.403476␣␣␣␣ −0.960776␣␣␣␣␣0.000000 ␣H␣␣␣ −10.263389␣␣␣␣ −0.348152␣␣␣␣ −0.831048 ␣H␣␣␣ −10.263389␣␣␣␣ −0.348152␣␣␣␣␣0.831048 ␣C␣␣␣␣ −7.316612␣␣␣␣␣ 0.153002␣␣␣␣␣0.000000 ␣H␣␣␣␣ −8.348018␣␣␣␣ −1.588139␣␣␣␣ −0.892698 ␣H␣␣␣␣ −8.348018␣␣␣␣ −1.588139␣␣␣␣␣0.892698 ␣O␣␣␣␣ −7.719020␣␣␣␣␣1.326881 ␣␣␣␣␣0.000000 ␣ . . . ␣␣␣␣␣␣␣␣␣␣116 ␣␣␣␣␣␣␣␣␣␣␣␣X␣␣␣␣␣␣␣␣␣␣␣Y␣␣␣␣␣␣␣␣␣␣␣Z ␣N␣␣␣␣ −6.694289␣␣␣␣ −0.182672␣␣␣␣␣0.000000 ␣H␣␣␣␣ −6.299638␣␣␣␣␣0.824476␣␣␣␣␣0.000000 ␣C␣␣␣␣ −5.403476␣␣␣␣ −0.960776␣␣␣␣␣0.000000 ␣H␣␣␣␣ −7.263389␣␣␣␣ −0.348152␣␣␣␣ −0.831048 ␣H␣␣␣␣ −7.263389␣␣␣␣ −0.348152␣␣␣␣␣0.831048 ␣C␣␣␣␣ −4.316612␣␣␣␣␣ 0.153002␣␣␣␣␣0.000000 ␣H␣␣␣␣ −5.348018␣␣␣␣ −1.588139␣␣␣␣ −0.892698 ␣H␣␣␣␣ −5.348018␣␣␣␣ −1.588139␣␣␣␣␣0.892698 ␣O␣␣␣␣ −4.719020␣␣␣␣␣1.326881 ␣␣␣␣␣0.000000 6.3. SECTION [JOB] 47 ␣ . . . Energies File with energies and weights for each geometry listed at geometries file. It must be in sync with the geometries file. Weights are taken into account when the potential is calculated. File 6.4: Energies file. Energies and weights −0.016881788␣␣1 −0.024242894␣␣1 −0.033981373␣␣1 ␣ . . . File 6.5: Energies file. Structure energie_of_first_geometry␣␣ first_weight energie_of_second_geometry␣␣second_weight energie_of_third_geometry␣␣third_weight ␣ . . . If the option auto weights in the [job] section is used, each contain the type,tolerance and delta columns needed for the desired automatic weights calculations. See 6.3. File 6.6: Energies file. Energies with auto weights −0.006436␣1␣1␣ .5 ␣ 0.5 −0.012603␣1␣1␣␣ .5 ␣ 0.5 −0.024660␣1␣1␣␣ .5 ␣ 0.5 . . . File 6.7: Energies file. Structure of Energies file with auto weights energie_first_geometry␣␣ first_weight ␣auto␣ tolerance ␣ delta energie_second_geometry␣␣second_weight␣auto␣ tolerance ␣ delta energie_third_geometry␣␣third_weight␣auto␣ tolerance ␣ delta ␣ . . . Atom2type File to map atom numbers to type numbers. The first line has the required parameters as integer numbers: •Number of atoms in Fragment A. In this example, 18 (File 6.8). •Total number of atoms. The rest of the lines, three columns, specify: 48 6. INPUT FILES •Atom number. Atom numbering must follow the order given in the coordinate file. •Atom symbol (two character max). •Atom type number. A positive integer used as a type index. From these parameters, all the different interactions are calculated. The total number of interactions is obtained from the number of atoms in Fragment A times the number of atoms in Fragment B. The coefficients of some interactions are repeated: those that correspond to interactions between atoms of the same type. So, the number of different interactions is just the different atom types in Fragment A multiplied by the number of different atom types in Fragment B. See 5.3.2 for an example. File 6.8: Atom2type. Atom to atom types mapping ␣18␣116 ␣␣␣␣1␣␣␣␣N␣␣␣␣␣␣1 ␣␣␣␣2␣␣␣␣H␣␣␣␣␣␣2 ␣␣␣␣3␣␣␣␣C␣␣␣␣␣␣3 ␣␣␣␣4␣␣␣␣H␣␣␣␣␣␣2 ␣␣␣␣5␣␣␣␣H␣␣␣␣␣␣2 ␣␣␣␣6␣␣␣␣C␣␣␣␣␣␣4 ␣␣␣␣7␣␣␣␣H␣␣␣␣␣␣5 ␣␣␣␣8␣␣␣␣H␣␣␣␣␣␣5 ␣␣␣␣9␣␣␣␣O␣␣␣␣␣␣6 ␣ . . . File 6.9: Atom2type. Structure ␣AtmFrA␣␣AtmTotal ␣␣␣␣AtomNumber1␣␣␣␣AtomSymbol1␣␣␣␣␣␣AtomTypeNumber1 ␣␣␣␣AtomNumber2␣␣␣␣AtomSymbol2␣␣␣␣␣␣AtomTypeNumber2 ␣␣␣␣AtomNumber3␣␣␣␣AtomSymbol3␣␣␣␣␣␣AtomTypeNumber3 ␣␣␣␣AtomNumber4␣␣␣␣AtomSymbol4␣␣␣␣␣␣AtomTypeNumber2 ␣␣␣␣AtomNumber5␣␣␣␣AtomSymbol5␣␣␣␣␣␣AtomTypeNumber2 ␣␣␣␣AtomNumber6␣␣␣␣AtomSymbol6␣␣␣␣␣␣AtomTypeNumber4 ␣␣␣␣AtomNumber7␣␣␣␣AtomSymbol7␣␣␣␣␣␣AtomTypeNumber5 ␣␣␣␣AtomNumber8␣␣␣␣AtomSymbol8␣␣␣␣␣␣AtomTypeNumber5 ␣␣␣␣AtomNumber9␣␣␣␣AtomSymbol9␣␣␣␣␣␣AtomTypeNumber6 ␣ . . . This file can be created with the needle tool. See 12.1, page 115. Bounds The variation range of the coefficients is specified here. The third column specifies if the coefficient will be treated as a real 6.3. SECTION [JOB] 49 (0) or integer (1) number. The number of lines depends on All coefficients parameter –[job] section– and the chosen potential in job file. It could be edited by the bedit tool. See 12.2, page 115. File 6.10: Bounds. Variation range of the coefficients TEXT␣OR␣EMPTY −−−−−−−→−100−−−→100.−−−→0 −−−−−−−→0.−−−−−→␣100.0−→0 −−−−−−−→−1500.−→5000.0−→0 −−−−−−−→3.5−−−−→5.5−−−−→0 File 6.11: Bounds. All Coefficients=0. Structure TEXT␣OR␣EMPTY␣LINE 1stMinimum−−−−−→1stMaximum−−−−−→1stType 2ndMinimum−−−−−→2ndMaximum−−−−−→2ndType 3rdMinimum−−−−−→3rdMaximum−−−−−→3rdType 4thMinimum−−−−−→4thMaximum−−−−−→4thType . . . nthMinimum−−−−−→nthMaximum−−−−−→nthType File 6.12: Bounds. All Coefficients<>0. Structure TEXT␣OR␣EMPTY␣LINE␣−␣ i nteracti on ␣1␣ c o e f f i c i e n t s ␣ set 1stMinimum−−−−−→1stMaximum−−−−−→1stType 2ndMinimum−−−−−→2ndMaximum−−−−−→2ndType 3rdMinimum−−−−−→3rdMaximum−−−−−→3rdType 4thMinimum−−−−−→4thMaximum−−−−−→4thType . . . nthMinimum−−−−−→nthMaximum−−−−−→nthType TEXT␣OR␣EMPTY␣LINE␣␣−␣ interaction ␣2␣ c o e f f i c i e n t s ␣ set 1stMinimum−−−−−→1stMaximum−−−−−→1stType 2ndMinimum−−−−−→2ndMaximum−−−−−→2ndType 3rdMinimum−−−−−→3rdMaximum−−−−−→3rdType 4thMinimum−−−−−→4thMaximum−−−−−→4thType . . . nthMinimum−−−−−→nthMaximum−−−−−→nthType . . . . TEXT␣OR␣EMPTY␣LINE␣␣−␣ interaction ␣N␣ c o e f f i c i e n t s ␣ set 1stMinimum−−−−−→1stMaximum−−−−−→1stType 2ndMinimum−−−−−→2ndMaximum−−−−−→2ndType 3rdMinimum−−−−−→3rdMaximum−−−−−→3rdType 4thMinimum−−−−−→4thMaximum−−−−−→4thType . . . nthMinimum−−−−−→nthMaximum−−−−−→nthType The text line between each interaction is skipped when reading bounds. Using the bedit tool, labels can be written automatically as in File 6.13. 50 6. INPUT FILES Note that BLX-αand SBX revert to SPC crossover for integer coefficients. File 6.13: Bounds file written with the bedit tool TYPE␣ 1: ␣C(1)−Xe(14) ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+0.00000␣␣␣+1000000.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+0.00000␣␣␣␣␣␣␣␣+10.00000␣␣␣1 ␣␣␣␣␣␣␣␣␣␣␣␣−1500.00000␣␣␣␣␣␣␣␣␣+0.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+4.00000␣␣␣␣␣␣␣␣␣+8.00000␣␣␣0 TYPE␣ 2: ␣N(2)−Xe(14) ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+0.00000␣␣␣+1000000.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+0.00000␣␣␣␣␣␣␣␣+10.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣−1500.00000␣␣␣␣␣␣␣␣␣+0.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+4.00000␣␣␣␣␣␣␣␣␣+8.00000␣␣␣0 TYPE␣ 3: ␣C(3)−Xe(14) ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+0.00000␣␣␣+1000000.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+0.00000␣␣␣␣␣␣␣␣+10.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣−1500.00000␣␣␣␣␣␣␣␣␣+0.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+4.00000␣␣␣␣␣␣␣␣␣+8.00000␣␣␣0 TYPE␣ 4: ␣N(4)−Xe(14) ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+0.00000␣␣␣+1000000.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+0.00000␣␣␣␣␣␣␣␣+10.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣−1500.00000␣␣␣␣␣␣␣␣␣+0.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+4.00000␣␣␣␣␣␣␣␣␣+8.00000␣␣␣0 TYPE␣ 5: ␣C(5)−Xe(14) ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+0.00000␣␣␣+1000000.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+0.00000␣␣␣␣␣␣␣␣+10.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣−1500.00000␣␣␣␣␣␣␣␣␣+0.00000␣␣␣0 ␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣+4.00000␣␣␣␣␣␣␣␣␣+8.00000␣␣␣0 Charges This file must include partial charges (in a.u.) for all atoms when potential 4 is selected (see Table 6.2). Partial charges may be specified for atom types (File 6.14 and 6.15). The types must be the same as those from Atom2type file. See 6.8. It depends on the chosen potential. Note that the type number can be any one, as long as they are different between them. The file can be edited by the bedit tool, and generated from needle. See 12.1 and 12.2. File 6.14: Charges. Type to charges mapping ␣␣␣␣1␣␣␣0.027 ␣␣␣␣2␣␣␣0.113 ␣␣␣␣3␣␣−0.057 ␣␣␣␣4␣␣−0.01 ␣␣␣␣5␣␣␣0.001 ␣ . . . 6.3. SECTION [JOB] 51 File 6.15: Charges. Structure ␣␣␣␣AtomType1␣␣␣Charge1 ␣␣␣␣AtomType2␣␣␣Charge2 ␣␣␣␣AtomType3␣␣␣Charge3 ␣␣␣␣AtomType4␣␣␣Charge4 ␣␣␣␣AtomType5␣␣␣Charge5 ␣ . . . Potential An integer, that specifies the chosen potential as defined in potentials.f source fortran file. Table 6.2: Potential values from potentials.f code file Value Coefficients Potential -1 any any user defined potential 0 any any analytical expression as potential 1 4 V=Ae−Br +C rD 2 6 V=Ae−Br +C rD+E rF 3 8 V=Ae−Br +C rD+E rF+G rH 4 3 plus charges V=AhB r12 −B r6i+ 332.0532qiqj r Table 6.2 shows the available potentials where: ris the distance between the two atoms whose interaction is calculated 332.0532 A conversion factor A, B, C, D, E, F, G The coefficients to be fitted qi,qjCharges All coefficients Drives the reading mode of Bounds file. If this variable is not set, it reads a sequence of coefficients for only one interaction, and then, the program assumes all the interactions have the same bounds. If it is set, it reads the bounds for all the coefficients. See Files 6.10,6.11 and 6.12 52 6. INPUT FILES Fitting Can be absolute or relative (see below). absolute Xh(vi−Pot(i))2Weight(i)i relative X"(vi−Pot(i))2 v2 i Weight(i)# user this option redirects to a user defined fitting function in the userpotential.f file. See 8.1.4 section. Auto weights Boolean parameter. Activate automatic weights: At the end of every run, the potential for each geometry is calculated and compared with the reference value. If the difference is larger than tolerance, the weight is increased by delta as detailed below. In this case, each energies file line must contain: energy The energy of the geometry weight The initial weight type The type of check performed. 0None, a 0 must be typed. 1Relative. Weight is incremented by delta if tolerance is less than the relative value between calculated energy and the energy. [Energy−Calculated]2 Energy2 2Absolute. Weight is incremented by delta if tolerance is less than the absolute value between calculated energy and the energy. |Energy −Calculated| tolerance The tolerance. A real number. delta The value to increment weight. A real number. See page 47 for energies file details. Note in file example 6.16 the runs and evaluations parameters. In this case, 10 times (10 runs) the checks are performed at the end of each run. 6.3. SECTION [JOB] 53 File 6.16: Job settings with auto weights [ job ] runs :−−→−−−−−−−→␣100 evaluations :−−−→␣50000 auto␣weights : ␣yes Command External job, the command to be run. File 6.17: External job settings [ job ] runs : ␣␣␣␣␣␣␣␣␣␣␣1 evaluations : ␣␣␣␣500000 type : ␣␣␣␣␣␣␣␣␣␣␣ external ␣bulk command: ␣␣␣␣␣␣␣␣ external . sh c o e f f i c i e n t s : ␣␣␣5 external ␣input : ␣ external . input external ␣ f i t : ␣␣␣ external . f i t bounds : ␣␣␣␣␣␣␣␣␣bounds . txt External input External job, the input for the external command, File 6.18. Here GAFit writes a coefficient vector to be evaluated by the external command. If the option external bulk is chosen, all the coefficients for a complete generation are passed, separating each one by a blank line, File 6.19. File 6.18: External input 4.894146 0.013449 −6.092118 −0.003859 1.216052 File 6.19: External bulk input 4.894146 0.013449 −6.092118 −0.003859 1.216052 4.894410 0.013449 −6.091149 −0.003859 1.215979 4.894332 0.013449 60 7. OUTPUT FILES analytical yes Analytical expression ----------------------------- expression name: "potential 5" potential: pot distance: dist coefficients: aaa, bbb, c1, c2, d1, d2, e1, e2 Expression found: v1 = aaa * exp ( -bbb * dist ) ; v2 = c1 / pow ( dist , c2 ) ; v3 = d1 / dist ** d2 ; v4 = e1 / dist ^ e2 ; pot = v1 + v2 + v3 + v4@ Variables found in expression: v1 aaa bbb dist v2 c1 c2 v3 d1 d2 v4 e1 e2 pot Expression code OK pot index 13 dist index 3 8 coefficients found ...now reading data 14 C 0.0000000 0.0000000 0.0000000 N 0.0000000 0.0000000 1.3545491 C 1.1521430 0.0000000 2.1275020 [...] Creating a 104 bounds vector... 104 BOUNDS VECTOR ====================== INTERACTION TYPE 1 ---------------------- C(1)-Xe(14) Coefficients: 1 aaa +0.00000 - +1000000.00000 (real) 2 bbb +0.00000 - +10.00000 (integer) 3 c1 -1500.00000 - +0.00000 (real) 4 c2 +4.00000 - +8.00000 (integer) 5 d1 +0.00000 - +1000000.00000 (real) 6 d2 +0.00000 - +10.00000 (integer) 7 e1 -1500.00000 - +0.00000 (real) 8 e2 +4.00000 - +8.00000 (integer) INTERACTION TYPE 2 ---------------------- N(2)-Xe(14) Coefficients: 9 aaa +0.00000 - +1000000.00000 (real) 10 bbb +0.00000 - +10.00000 (integer) 11 c1 -1500.00000 - +0.00000 (real) 12 c2 +4.00000 - +8.00000 (integer) 13 d1 +0.00000 - +1000000.00000 (real) 14 d2 +0.00000 - +10.00000 (integer) 15 e1 -1500.00000 - +0.00000 (real) 16 e2 +4.00000 - +8.00000 (integer) [...] run 1 50 1 62550614237885.890625000000 1.415158910538e+10 200 4 1319338879864.184570312500 2.876907390518e+08 7.1. OTHER OUTPUT FILES 61 [...] # #Results # INTERACTION TYPE 1 ---------------------- C(1)-Xe(14) Coefficients: 1 aaa +105671.4794050544 2 bbb +4.0000000000 3 c1 -1085.2285321549 4 c2 +6.0000000000 5 d1 +974559.2805542682 6 d2 +9.0000000000 7 e1 -990.8034563390 8 e2 +6.0000000000 INTERACTION TYPE 2 ---------------------- N(2)-Xe(14) Coefficients: 9 aaa +680324.6698314144 10 bbb +3.0000000000 11 c1 -204.2193705419 12 c2 +4.0000000000 13 d1 +0.0000000000 14 d2 +7.0000000000 15 e1 -1178.8818235065 16 e2 +4.0000000000 [...] best.txt This file contains the best set of coefficients. It is updated every time GAFit finds a better set, and it can be used by fitview -see 12.3-to obtain the coefficient values. NOTE: This file is NOT loaded at the beginning of any run, so it can be overwritten when a new run begins if you do not save it beforehand. 7.1 Other output files Other intermediate output files are: •stats.txt 7.2 Using TAGS You can also use a command line tag to run multiple GAFit processes changing the output names, as stated in Section 5.3. 62 7. OUTPUT FILES $ gafit TAG The file names are changed inserting the tag before the .txt suffix: •best.TAG.txt •stats.TAG.txt You cannot use TAGS with external potentials. 8 Specifiying a new interaction potential Simplicity is the ultimate sophistication. Apple II pc slogan, 1977 Besides the interaction potentials implemented in this code –See Table 6.2–, the user can specify a new potential to fit the interaction energies of the system. The new potential can be introduced by: •adding it in the file potentials.f •modifying the file userpotential.f using it as a template •writing an analytical expression. 8.1 Modifiying potentials.f and userpotential.f 8.1.1 VGLOBALES module You can use the variables exported by the VGLOBALES module in addition to your own variables from the USERDATA module to customize your potential or your fitting function. These are shown in Table 8.1. 8.1.2 Interface subroutines and functions For an easy customization, some functions and subroutines are provided in addition to the module VGLOBALES. 63 64 8. SPECIFIYING A NEW INTERACTION POTENTIAL Table 8.1: Module VGLOBALES variables variable type dimension comments r double precision (geometries, nprox, nsam) Calculated interatomic distances for each interaction v double precision geometries Potential energy for each geometry. Read from energies file w double precision geometries Weights. Read from energies file wdelta double precision geometries Delta for each weight. Read from energies file wtol double precision geometries Tolerance. Read from energies file wtype integer geometries Type of weight. Read from energies file q double precision natom Charges. Read from charges file. geometries integer - Number of geometries nprox integer - Number of atoms in fragment A nsam integer - Number of atoms in fragment B natom integer . Number total of atoms ptypes integer - Different types of atoms in fragment A stypes integer - Different types of atoms in fragment B potential integer - Type of potential interactions integer - Number of different interactions coefficients integer - Number of coefficients charges logical - If charges file is needed autoweights logical - If autoweights is active atom character*2 natom Two character atom labels ix function The function ix(i,j,k) organizes the different coefficients into the coefficient vector. kis the index of a given coefficient, i.e.: k=1 means A, k=2 means B, etc. kranges from 1 to the number of coefficients i, j are the atoms that define a given interaction for which the coefficients are defined. Atom ibelongs to fragment A and jbelongs to fragment B. The atoms of Fragment A range from 1 to nprox, and those of fragment B range from nprox+1 to natom. See also the needle tool output, page 116. 8.1. MODIFIYING POTENTIALS.F AND USERPOTENTIAL.F 65 coordinates subroutine The coordinates(geo,atom,x,y,z) subroutine can access the Cartesian coordinates. geo is the geometry index, ranging from 1 to geometries atom the atom index in the geometry, ranging from 1 to natom x, y, z the coordinates returned by subroutine. 8.1.3 Adding a new potential to potentials.f Introducing a new potential in the program implies to implement it into potentials.f –File 8.1–, to modify setcoefs (line 3), getcharges (line 28), potRouter (line 51) and curRouter (line 74) functions, and to write the corresponding potential functions. Finally, the program has to be recompiled. File 8.1: potentials.f 1c POTENTIALS 2c sets the number of coefs required by potential 3c 4integer function set co ef s ( potential ) 5implicit none 6integer potential 7integer angetncoefs 8integer usetcoefs 9external angetncoefs 10 i f ( potential . eq .−1) then 11 set co ef s=usetcoefs () 12 else i f ( potential . eq . 0) then 13 set co ef s=angetncoefs () 14 else i f ( potential . eq . 1) then 15 set co ef s=4 16 else i f ( potential . eq . 2) then 17 set co ef s=6 18 else i f ( potential . eq . 3) then 19 set co ef s=8 20 else i f ( po tential . eq .4) then 21 set co ef s=2 22 else 23 stop ’ s et co ef s : ␣not␣implemented ’ 24 endif 25 end 26 27 c i f a charge f i l e is needed 28 c 66 8. SPECIFIYING A NEW INTERACTION POTENTIAL 29 logical function getcharges ( potential ) 30 implicit none 31 integer potential 32 logical ugetcharges 33 i f ( potential . eq .−1) then 34 getcharges=ugetcharges () 35 else i f ( potential . eq . 0) then 36 getcharges =. false . 37 else i f ( potential . eq . 1) then 38 getcharges =. false . 39 else i f ( potential . eq . 2) then 40 getcharges =. false . 41 else i f ( potential . eq . 3) then 42 getcharges =. false . 43 else i f ( potentia l . eq .4) then 44 getcharges =.true . 45 else 46 stop ’ getcharges : ␣not␣implemented ’ 47 endif 48 end 49 50 c Potential Router , route cal culat ions to the desired potential 51 c 52 subroutine potRouter ( geo , x , nmax, vpot ) 53 use vglobales 54 integer nmax, geo 55 double precision vpot , x(nmax) 56 i f ( potential . eq .−1) then 57 call userpot ( geo , x ,nmax, vpot ) 58 else i f ( potential . eq . 0) then 59 call pot0 ( geo , x , nmax, vpot ) 60 else i f ( potential . eq . 1) then 61 call pot1 ( geo , x , nmax, vpot ) 62 else i f ( potential . eq . 2)then 63 call pot2 ( geo , x , nmax, vpot ) 64 else i f ( potential . eq . 3) then 65 call pot3 ( geo , x , nmax, vpot ) 66 else i f ( potentia l . eq .4) then 67 call pot4 ( geo , x , nmax, vpot ) 68 else 69 stop ’ not␣implemented␣ potential ’ 70 endif 71 end 72 73 c Curve Router , route calcu lati ons to the desired potential 74 c 75 subroutine curRouter (d , atom1 , atom2 , x ,nmax, vpot ) 76 use vglobales 77 integer nmax, atom1 , atom2 , index 78 double precision vpot , x(nmax) ,d 79 double precision analytical , userv , v1 , v2 , v3 , v4 80 integer ix 81 i f ( potential . eq .−1) then 8.1. MODIFIYING POTENTIALS.F AND USERPOTENTIAL.F 67 82 vpot=userv (d , atom1 , atom2 , x , nmax) 83 else i f ( potential . eq . 0) then 84 index=ix (atom1 , atom2 ,1) 85 vpot=analytical (d , index , x) 86 else i f ( potential . eq . 1) then 87 vpot=V1(d , atom1 , atom2 , x ,nmax) 88 else i f ( potential . eq . 2)then 89 vpot=V2(d , atom1 , atom2 , x ,nmax) 90 else i f ( potential . eq . 3) then 91 vpot=V3(d , atom1 , atom2 , x ,nmax) 92 else i f ( po tential . eq .4) then 93 vpot=V4(d , atom1 , atom2 , x ,nmax, q(atom1) ,q(atom2) ) 94 else 95 stop ’ not␣implemented␣ potential ’ 96 endif 97 end 98 99 c Now, each potential calculation down from here . 100 101 c 0−−−−−−−analytical−−−−−−−−−−−−−− 102 subroutine pot0 ( geo , x , nmax, vpot ) 103 use vglobales 104 integer nmax, geo , i , j , k , index 105 double precision d , vpot , analyti cal 106 external analytical 107 double precision X(nmax) 108 integer ix 109 vpot=0.0d0 110 do i =1,nprox 111 do j =1,nsam 112 k=j+nprox 113 d=r ( geo , i , j ) 114 index=ix ( i , k , 1) 115 vpot=vpot+a nalytical (d , index , x) 116 enddo 117 enddo 118 return 119 end 120 121 c 1−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 122 subroutine pot1 ( geo , x , nmax, vpot ) 123 use vglobales 124 integer nmax, geo , i , j , k 125 double precision d , vpot ,V1 126 double precision X(nmax) 127 vpot=0.0d0 128 do i =1,nprox 129 do j =1,nsam 130 k=j+nprox 131 d=r ( geo , i , j ) 132 vpot=vpot+V1(d , i , k , x ,nmax) 133 enddo 134 enddo 68 8. SPECIFIYING A NEW INTERACTION POTENTIAL 135 return 136 end 137 138 FUNCTION V1( r , i , j , x ,m) 139 implicit none 140 integer i , j ,m, ix 141 dimension x(m) 142 double precision x , r , a , b , c , d , v1 143 A=x( ix ( i , j ,1) ) 144 B=x( ix ( i , j ,2) ) 145 C=x( ix ( i , j ,3) ) 146 D=x( ix ( i , j ,4) ) 147 V1=A∗EXP(−B∗R)+C/R∗∗D 148 RETURN 149 END 150 151 c 2−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 152 subroutine pot2 ( geo , x , nmax, vpot ) 153 use vglobales 154 integer nmax, geo , i , j , k 155 double precision d , vpot ,V2 156 double precision X(nmax) 157 vpot=0.0d0 158 do i =1,nprox 159 do j =1,nsam 160 k=j+nprox 161 d=r ( geo , i , j ) 162 vpot=vpot+V2(d , i , k , x ,nmax) 163 enddo 164 enddo 165 return 166 end 167 168 FUNCTION V2( r , i , j , x ,m) 169 implicit none 170 integer i , j ,m, ix 171 dimension x(m) 172 double precision x , r , a , b , c , d , e , f , v2 173 A=x( ix ( i , j ,1) ) 174 B=x( ix ( i , j ,2) ) 175 C=x( ix ( i , j ,3) ) 176 D=x( ix ( i , j ,4) ) 177 E=x( ix ( i , j ,5) ) 178 F=x( ix ( i , j ,6) ) 179 V2=A∗EXP(−B∗R)+C/R∗∗D+E/R∗∗F 180 RETURN 181 END 182 183 184 c 3−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 185 subroutine pot3 ( geo , x , nmax, vpot ) 186 use vglobales 187 integer nmax, geo , i , j , k 8.1. MODIFIYING POTENTIALS.F AND USERPOTENTIAL.F 69 188 double precision d , vpot ,V3 189 double precision X(nmax) 190 vpot=0.0d0 191 do i =1,nprox 192 do j =1,nsam 193 k=j+nprox 194 d=r ( geo , i , j ) 195 vpot=vpot+V3(d , i , k , x ,nmax) 196 enddo 197 enddo 198 return 199 end 200 201 FUNCTION V3( r , i , j , x ,m) 202 implicit none 203 integer i , j ,m, ix 204 dimension x(m) 205 double precision x , r , a , b , c , d , e , f , g , h , v3 206 A=x( ix ( i , j ,1) ) 207 B=x( ix ( i , j ,2) ) 208 C=x( ix ( i , j ,3) ) 209 D=x( ix ( i , j ,4) ) 210 E=x( ix ( i , j ,5) ) 211 F=x( ix ( i , j ,6) ) 212 G=x( ix ( i , j ,7) ) 213 H=x( ix ( i , j ,8) ) 214 V3=A∗EXP(−B∗R)+C/R∗∗D+E/R∗∗F+G/R∗∗H 215 RETURN 216 END 217 218 c 4−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 219 subroutine pot4 ( geo , x , nmax, vpot ) 220 use vglobales 221 integer nmax, geo , i , j , k 222 double precision d , vpot ,V4 223 double precision X(nmax) 224 vpot=0.0d0 225 do i =1,nprox 226 do j =1,nsam 227 k=j+nprox 228 d=r ( geo , i , j ) 229 vpot=vpot+V4(d , i , k , x ,nmax, q( i ) ,q( j ) ) 230 enddo 231 enddo 232 return 233 end 234 235 FUNCTION V4( r , i , j , x ,m, qi , qj ) 236 implicit none 237 integer i , j ,m, ix 238 dimension x(m) 239 double precision x , r , a , b 240 double precision v4 , qi , qj 76 8. SPECIFIYING A NEW INTERACTION POTENTIAL Table 8.3: Operators and functions supported in expressions Operators Precedence Example = assignment 0 a=b + addition 1 a+b - subtraction 1 a-b *multiplication 2 a*b /division 2 a/b unary + unary plus 3 +a unary - unary minus 3 -a ** a raised by power b, ab4 a**b ^a raised by power b, ab4 a^b Puntuaction ( ) change precedence (a+b)*c , comma, separate arguments in functions pow(a,b) ; semicolon, separate individual expressions a=b+c; d=e+f Functions exp number e raised by power a, eaexp(a) pow a raised by power b, abpow(a,b) 9 MOPAC interface To err is human, but to really screw things up you need a computer. Bill Vaughn An additional feature of GAFit is the possibility of parametrizing a semiempirical Hamiltonian. The current version of GAFit supports MOPAC –2009 and 2012– as the external program to compute the PES of our system. In the example given in Section 16 the MOPAC interface is used to parametrize the intramolecular PES of vinyl cyanide. The details of how GAFit works with an external interface –or external potential– are explained in the following. 9.1 External potential The external potential works as follows: •GAFit generates a whole generation, where each individual is a coefficient vector. •for each individual, –the coefficients are written in the file named in the external input option of the [job] section. –the external program specified in the option command is run. 77 78 9. MOPAC INTERFACE ∗The external program must read the external input file, ∗doing its calculations, ∗and writing the file named in the external fit option of the [job]. – GAFit reads the external fit file. •GAFit using the fit, given by the external program, applies the genetic operators to create a new generation. If the bulk option is chosen, an entire generation is written to the external input file, and the external command must write into the external fit file all the individuals fitting values. This option speeds up calculations. In all cases, the command is executed passing one argument in the command line: the number of the individuals that were written to the external input file. For example, if the command is mopac2009.sh, and the job is an external bulk passing an entire generation of 100 coefficient vectors, the command line executed by the shell is: $ mopac2009.sh 100 external input examples are given in Files 6.18 and 6.19.external fit examples are the Files 6.20 and 6.21 GAFit only evaluates if there is a command processor available –i.e. sh– and the coefficients value. No other checks are performed. Note that you cannot use TAGS with external potentials. 9.1.1 Autoconfigure If the option external auto is chosen, the external command can configure GAFit. At the beginning, GAFit executes the external command passing an argument of "0". If the external command is mopac2009.sh, the command line executed by the shell is: $ mopac2009.sh 0 The external command must answer with a file named "response" with the options requested. This file follows the job.txt format. An example from the MOPAC interface is shown below. 9.1. EXTERNAL POTENTIAL 79 File 9.1: response [ job ] type : ␣ external ␣bulk c o e f f i c i e n t s : ␣16 external ␣input : ␣mopac2009 . input external ␣ f i t : ␣mopac2009 . f i t bounds : ␣bounds . txt [ c o e f f i c i e n t ␣names ] BETAS␣H ZS␣H ALP␣H GSS␣H USS␣C UPP␣C BETAS␣C BETAP␣C ZS␣C ZP␣C ALP␣C GSS␣C GSP␣C GPP␣C GP2␣C HSP␣C Note that GAFit does not check if there is a response file before the call. All is ok if it finds one, independently of whether it has been created by the system call or not. 9.1.2 Stopping an external job You can stop a running job writing a stop file in the folder where it is running. The stop file’s name is __STOP__, and the text it contains is whatever you want. $ echo ‘‘stop job’’> __STOP__ A first approach to the general problem of launching an external program is shown as a guideline for development to complement section 9.1 with a useful case: MOPAC 2009. Later, a better solution –shepherd–, specifically designed to solve some problems found while testing these scripts, is developed and discussed in Section 10. 80 9. MOPAC INTERFACE 9.2 Interfacing with MOPAC 2009 Interfacing with MOPAC 2009 is achieved using three new tools: injector Written in C, is responsible for: •answering the GAFit external auto configuration option. •creating the MOPAC’s external file parameters. •creating the MOPAC’s input file. extractor Written in perl and using perl’s special characteristics to extract text, it is in charge of: •extracting and digesting data from the MOPAC output to a intermediate file with a format for easy retrieve by the next tool. •dealing with MOPAC’s calculation failures. fitter Written in fortran, •calculates the fitting. •writes the file with the fits to be read by GAFit. Two templates are used to create the files needed by MOPAC 2009. coefficients template (COEFS_TEMPLATE) is used to extract the coefficients values and replace them with the ones obtained by GAFit and to count and assign names to GAFit coefficients too. MOPAC calculation template (MOPAC_TEMPLATE), contains one or more calculations. For example: one for the reactants, one for the TS and a third one for the products (calculations 1, 2 and 3 respectively). It is used to generate a continuous and unique file with all calculations, which is employed as input of MOPAC 2009. There are places, marked with an @, where the symbol is replaced by the file name of the coefficients template, containing the coefficients obtained by GAFit. 9.2. INTERFACING WITH MOPAC 2009 81 Figure 9.1: MOPAC 2009 interface: normal operation GAFit external-mopac2009.sh N injector N EXTERNAL_INPUT bounds.txt COEFS_TEMPLATE MOPAC_TEMPLATE MOPAC_MOP MOPAC2009 (or shepherd) MOPAC_MOP.out extractor N EXTRACTED_DATA fitter N [extracted-data [external-fit]] conditions.txt EXTERNAL_FIT A B C D... 82 9. MOPAC INTERFACE Figure 9.2: MOPAC 2009 interface: autoconfigure GAFit external-mopac2009.sh 0 injector 0 response COEFS_TEMPLATE If there are two calculations in the MOPAC calculation template and GAFit exports 100 sets of coefficients per generation, then the unique file generated contains 200 calculations, and also, there are 100 independent files generated from the coefficients template, each one with a complete set of coefficients replaced. These files are named A ...Z, AA ...AZ ...and so on. Figures 9.1 and 9.2 show the relations between programs and files: •Dashed blue lines indicate that a tool uses the file as input. •A red line indicates that a tool creates the file. •Black lines indicate calls to execute a tool. •Files fill in yellow indicate that they must be created or given by the user. There are environmental variables, shown in Table 9.1, which can be set to control the file names. Notice that for the fitter point of view, EXTERNAL_FIT and E XTRACTED_DATA are command line arguments. 9.3. EXTERNAL COMMAND 83 Table 9.1: Environmental variables Variable Default value Tools COEFS_TEMPLATE template.coefs injector MOPAC_TEMPLATE template.mop injector MOPAC_MOP mopac_input.mop injector, MOPAC 2009, extractor, shepherd EXTERNAL_INPUT mopac2009.input GAFit, injector EXTERNAL_FIT mopac2009.fit GAFit EXTRACTED_DATA extracted.data extractor BOUNDS_FILE bounds.txt GAFit, injector 9.3 External command GAFit only calls an external shell script: external-mopac2009.sh, or the name given in job.txt. There is a complete example in the folder mopac-example which can be examined in the File 9.2. A minimal implementation due to the defaults could be the one in File 9.4. File 9.2: external-mopac2009.sh 1#!/ bin/sh 2export MOPAC_LICENSE=$HOME/mopac2009 3 4export COEFS_TEMPLATE="template . coefs " 5export MOPAC_TEMPLATE="template .mop" 6export MOPAC_MOP="mopac_input .mop" 7export EXTERNAL_INPUT="mopac2009 . input" 8export EXTERNAL_FIT="mopac2009 . f i t " 9export EXTRACTED_DATA=" extracted . data" 10 export BOUNDS_FILE="bounds . txt " 11 12 inje ct or $1 13 i f [ "$1" −ne "0" ] 14 then 15 $MOPAC_LICENSE/MOPAC2009. exe $MOPAC_MOP 16 extractor $1 17 f i t t e r $1 $EXTRACTED_DATA $EXTERNAL_FIT 18 f i 9.4 injector injector is a program written in C. The syntax is injector number-of-vectors [bulk] 84 9. MOPAC INTERFACE where number-of-vectors and bulk are parameters explained below. 9.4.1 Configuration If the external auto option is used, GAFit calls the external command passing a “0” as first parameter, so the injector creates the file response and GAFit uses this information to configure itself. This file is deleted the first time injector runs in the normal operation. File 9.3: job.txt in mopac-example [ parameters ] population :−−−−→␣100 crossover ␣ rate :−→␣ 0.75 blx_alpha :−−−−−→␣ 0.5 mutation␣ rate : −→␣ 0.1 elitism:−−−−−−−→␣yes tournament␣ si ze : ␣5 crossover : ␣␣␣␣␣␣␣sbx mutation : ␣␣␣␣␣␣␣␣sigma sigma :−→−−−−−−−→␣ 0.1 direction : −−−−−→␣min [ job ] runs :−−→−−−−−−−→1 evaluations :−−−→5000 type : ␣␣␣␣␣␣␣␣␣␣␣ external ␣auto command : ␣␣␣␣␣␣␣␣ external −mopac2009 . sh [ print ] print ␣runs : ␣ yes The data needed to create the response file is obtained from environmental variables and from the COEFS_TEMPLATE file1. If it is not set, there are default values for them (see Table 9.1). A minimal external script is shown in File 9.4. In this case, the external auto option defaults to external. To override defaults use bulk option to change to external bulk. 1Number and name of the coefficients. 9.4. INJECTOR 85 File 9.4: Minimal external-mopac2009.sh 1#!/ bin/sh 2export MOPAC_LICENSE=$HOME/mopac2009 3 4export MOPAC_MOP="mopac_input .mop" 5 6inje ct or $1 7i f [ "$1" −ne "0" ] 8then 9$MOPAC_LICENSE/MOPAC2009. exe $MOPAC_MOP 10 extractor $1 11 f i t t e r $1 12 f i 9.4.2 Normal operation If the parameter is not “0”, it must be the number of coefficient vectors, which are written in the file EXTERNAL_INPUT. The injector reads EXTERNAL_INPUT and using COEFS_T EMPLATE and MOPAC_TEMPLATE it creates the MOPAC_MOP file and its relative external coefficients files, which are named according to the default option for the coefficients names. See 6.5. File 9.5: COEFS_TEMPLATE file: template.coefs BETAS␣H␣␣␣␣␣␣␣ −6.173787 ZS␣␣␣H␣␣␣␣␣␣␣␣␣1.188078 ALP␣␣H␣␣␣␣␣␣␣␣␣2.882324 GSS␣␣H␣␣␣␣␣␣␣␣ 12.848 USS␣␣C␣␣␣␣␣␣␣−52.028658 UPP␣␣C␣␣␣␣␣␣␣ −39.614239 BETAS␣C␣␣␣␣␣␣ −15.715783 BETAP␣C␣␣␣␣␣␣␣ −7.719283 ZS␣␣␣C␣␣␣␣␣␣␣␣␣1.808665 ZP␣␣␣C␣␣␣␣␣␣␣␣␣1.685116 ALP␣␣C␣␣␣␣␣␣␣␣␣2.648274 GSS␣␣C␣␣␣␣␣␣␣␣ 12.23 GSP␣␣C␣␣␣␣␣␣␣␣11.47 GPP␣␣C␣␣␣␣␣␣␣␣ 11.08 GP2␣␣C␣␣␣␣␣␣␣␣␣9.84 HSP␣␣C␣␣␣␣␣␣␣␣␣ 2.43 At the configuration stage, the file COEFS_TEMPLATE is analyzed; this file provides the number of coefficients and their names. In a normal operation, the file is replicated to generate the files needed to complement the jobs in MOPAC_TEMPLATE. 92 9. MOPAC INTERFACE File 9.10: fitter calculations example ␣DELTA␣␣␣␣␣␣␣␣␣␣␣ calc=␣␣␣317.14201000000003␣␣␣␣␣␣␣ r ef=␣␣␣100.59999999999999␣␣␣␣' &␣␣␣we=␣␣0.10000000000000001␣␣␣␣␣␣␣cont=␣␣0.46332780745783869 ␣FREQUENCY␣␣␣␣␣␣␣ calc=␣␣␣1894.7900000000000␣␣␣␣␣␣␣ ref=␣␣␣3271.0000000000000␣␣␣␣' &␣␣␣we=␣␣1.00000000000000005E−004␣␣cont=␣␣1.77014291129788933E−005 ␣DISTANCE␣␣␣␣␣␣␣␣ calc=␣␣␣2.8164272438676630␣␣␣␣␣␣␣ re f=␣␣␣3.7003090959999998␣␣␣␣' &␣␣␣we=␣␣␣100.00000000000000␣␣␣␣␣␣␣cont=␣␣␣5.7057459091163221 ␣␣ individual ␣␣␣␣␣␣␣␣␣␣␣97␣␣ f i t=␣␣␣6.1690914180032737 ␣DELTA␣␣␣␣␣␣␣␣␣␣␣ calc=␣␣␣3347.9733500000002␣␣␣␣␣␣␣ r ef=␣␣␣100.59999999999999␣␣␣␣' &␣␣␣we=␣␣0.10000000000000001␣␣␣␣␣␣␣cont=␣␣␣104.20018333626695 ␣FREQUENCY␣␣␣␣␣␣␣ calc=␣␣␣4569.0900000000001␣␣␣␣␣␣␣ ref=␣␣␣3271.0000000000000␣␣␣␣' &␣␣␣we=␣␣1.00000000000000005E−004␣␣cont=␣␣1.57488381692090322E−005 ␣DISTANCE␣␣␣␣␣␣␣␣ calc=␣␣␣2.2933691656599904␣␣␣␣␣␣␣ re f=␣␣␣3.7003090959999998␣␣␣␣' &␣␣␣we=␣␣␣100.00000000000000␣␣␣␣␣␣␣cont=␣␣␣14.456897586931765 ␣␣ individual ␣␣␣␣␣␣␣␣␣␣␣98␣␣ f i t=␣␣␣118.65709667203687 ␣DELTA␣␣␣␣␣␣␣␣␣␣␣ calc=␣␣ −8.4001199999999994␣␣␣␣␣␣␣ re f=␣␣␣100.59999999999999␣␣␣␣' &␣␣␣we=␣␣0.10000000000000001␣␣␣␣␣␣␣cont=␣␣0.11739726808151489 ␣FREQUENCY␣␣␣␣␣␣␣ calc=␣␣␣1086.3800000000001␣␣␣␣␣␣␣ ref=␣␣␣3271.0000000000000␣␣␣␣' &␣␣␣we=␣␣1.00000000000000005E−004␣␣cont=␣␣4.46057372941259230E−005 ␣DISTANCE␣␣␣␣␣␣␣␣ calc=␣␣␣3.8158625315909900␣␣␣␣␣␣␣ re f=␣␣␣3.7003090959999998␣␣␣␣' &␣␣␣we=␣␣␣100.00000000000000␣␣␣␣␣␣␣cont=␣␣9.75191075166021992E−002 ␣␣ individual ␣␣␣␣␣␣␣␣␣␣␣99␣␣ f i t=␣␣0.21496098133541122 ␣DELTA␣␣␣␣␣␣␣␣␣␣␣ calc=␣␣␣2421.2273100000002␣␣␣␣␣␣␣ r ef=␣␣␣100.59999999999999␣␣␣␣' &␣␣␣we=␣␣0.10000000000000001␣␣␣␣␣␣␣cont=␣␣␣53.212643739134158 ␣FREQUENCY␣␣␣␣␣␣␣ calc=␣␣␣1331.9000000000001␣␣␣␣␣␣␣ ref=␣␣␣3271.0000000000000␣␣␣␣' &␣␣␣we=␣␣1.00000000000000005E−004␣␣cont=␣␣3.51430398092760188E−005 ␣DISTANCE␣␣␣␣␣␣␣␣ calc=␣␣␣5.1161291627557643␣␣␣␣␣␣␣ re f=␣␣␣3.7003090959999998␣␣␣␣' &␣␣␣we=␣␣␣100.00000000000000␣␣␣␣␣␣␣cont=␣␣␣14.639967757020900 ␣␣ individual ␣␣␣␣␣␣␣␣␣␣100␣␣ f i t=␣␣␣67.852646639194873 9.7 Caveats Some problems may arise when using a long MOPAC input file if the initial parameters are far from the optimized ones: •If MOPAC crashes, it can freeze the entire job and you have to kill the MOPAC process manually. Alternatively, you may use shepherd to control this. See 10. 9.8. MOPAC 2012 93 •It can be worse: a failed MOPAC calculation can spoil all the previous calculations in the input file. These failed calculations are the ones which the fitter assigns a penalty. See 9.6. You must use the injector default option to calculate one vector at once, or use shepherd to deal with it. 9.8 MOPAC 2012 MOPAC 2012 output differs a little from that of MOPAC 2009. From our point of view, the most important change is that some cartesian coordinates printout are missing, so internal coordinates must be used and converted to Cartesian. This job must be done by extractor using quaternion maths to calculate 3D rotations. The Karney [16] article is a good reference about this subject. 10 shepherd Computers are good at following instructions, but not at reading your mind. Donald Knuth shepherd launches and controls the running MOPAC processes. It is written in C. Also, it can deal with the problems shown in section 9.7. It can: •Detect and kill a MOPAC frozen/crashed process. •Split the job sent by GAFit from one individual once at a time to a bunch of them. The default behavior is to send a sole calculation – a MOPAC_TEMPLATE clone– per MOPAC process. You can change defaults modifying the source code and compiling it again: Details in section 10.2. •Run, control and maintain a suitable number –equal or near to the number of resources available: CPUs, cores or hyperthreads, etc– of parallel MOPAC processes. shepherd calculates a good value to this number. It dynamically changes depending on the node load. Syntax: 95 96 10. SHEPHERD shepherd The external command to be used is slightly different with shepherd as shown in File 10.1: •To use the special characteristics of shepherd the line 12 is changed to pass an entire parameters vector (bulk) . •Also line 15 is changed, where shepherd replaces the entire "$MOPAC_LICENSE/ MOPAC2009.exe $MOPAC_MOP" line. shepherd calls itself the MOPAC executable as needed. File 10.1: external-mopac2009.sh with shepherd 1#!/ bin/sh 2export MOPAC_LICENSE=$HOME/mopac2009 3 4export COEFS_TEMPLATE="template . coefs " 5export MOPAC_TEMPLATE="template .mop" 6export MOPAC_MOP="mopac_input .mop" 7export EXTERNAL_INPUT="mopac2009 . input" 8export EXTERNAL_FIT="mopac2009 . f i t " 9export EXTRACTED_DATA=" extracted . data" 10 export BOUNDS_FILE="bounds . txt " 11 12 inje ct or $1 bulk 13 i f [ "$1" −ne "0" ] 14 then 15 shepherd 16 extractor $1 17 f i t t e r $1 $EXTRACTED_DATA $EXTERNAL_FIT 18 f i A shorter version of File 10.1 is 10.2 using the default values. shepherd is totally configured by the environmental variables. File 10.2: Shorter external-mopac2009.sh with shepherd 1#!/ bin/sh 2export MOPAC_LICENSE=$HOME/mopac2009 3 4inje ct or $1 bulk 5i f [ "$1" −ne "0" ] 6then 7shepherd 8extractor $1 9f i t t e r $1 10 f i 10.1. CONTROLING FREEZES 97 10.1 Controling freezes IfaMOPAC 2009 process crashes, it freezes and blocks all the entire job (see 9.7). In these cases, glibc will produce output on the process controlling terminal, so the environment variable LIBC_FATAL_STDERR_=1 must be set to send fatal errors to stderr in order to check it. shepherd forks itself and execs the MOPAC process in an environment with the LIBC_FATAL_STDERR_ variable set, and establishing apipe with the child process to read MOPAC’s stderr. If a fatal error is noticed, shepherd kills the child process avoiding the freeze and creates a fake MOPAC output file suitable for the extractor. [...] shepherd #flocks:4 shepherd errno 2 forrtl: severe (174): SIGSEGV, segmentation fault occurred Image PC Routine Line Source libc.so.6 B760BEEA Unknown Unknown Unknown libc.so.6 B7610050 Unknown Unknown Unknown MOPAC2009.exe 08267594 Unknown Unknown Unknown MOPAC2009.exe 08089053 Unknown Unknown Unknown MOPAC2009.exe 0822AA58 Unknown Unknown Unknown MOPAC2009.exe 081E835E Unknown Unknown Unknown MOPAC2009.exe 0818392E Unknown Unknown Unknown MOPAC2009.exe 0804A141 Unknown Unknown Unknown libc.so.6 B75B1DB6 Unknown Unknown Unknown MOPAC2009.exe 0804A051 Unknown Unknown Unknown in file BE-BE.out lost sheep:56 shepherd elapsed time:17.611128 [...] In the above example, shepherd notices a runtime error, so it kills the MOPAC 2009 process, creates the fake BE-BE.out file and continues processing. In the case of MOPAC 2012, the output is the same but with less detail. 10.2 Operating modes shepherd takes the file MOPAC_MOP as input to build a MOPAC_MOP.out file, suitable for the extractor. It calculates the number of individuals –how many MOPAC_TEMPLATEs are in the file–, and it can split the input in slices1from one individual2 1Flocks in shepherd parlance 2Sheep 98 10. SHEPHERD to many, running a MOPAC 2009 process on each slice. The temporary files for the slices are in the form FIRST-LAST.ext, where FIRST and LAST are the first and last individuals in the file using the same naming convention as the coefficient names default option –see 6.5–, and ext is the extension corresponding to the type of file. For example: •BE-BE.mop is the MOPAC 2009 input file corresponding from 56th to 56th individuals. •A-E.out is the MOPAC 2009 output file corresponding from 1st to 5th individuals as a result of calculations on A-E.mop input file. The default is to launch a MOPAC 2009 process with an individual –i.e.: A-A.mop–, an individual per slice3. The other mode –burst– is disabled but it can be enabled recompiling the source code changing the line 613 in the main function setting burst to a value different from zero, File 10.3.burst mode is discouraged. See 9.7. File 10.3: Shepherd, main function. 603 604 int 605 main ( int argc , char ∗∗argv) 606 { 607 int burst = 0; In this mode, the slice can contain more than one individual and it will be calculated by one MOPAC 2009 process. 10.3 Parallel processes Tracking the minimum time elapsed, processing an entire population and running a fixed number of concurrent MOPAC 2009 processes, yields the blue line shown in figure 10.1. There is an optimum number from which a further increase in the number of parallel processes provides little gain in performance, or no gain at all. shepherd maintains the number of parallel processes around this number. 3A sheep per flock 10.3. PARALLEL PROCESSES 99 Optimal NA NA+ 1 NA−1 NB NB+ 1 NB−1 Running processes in parallel Time Minimun time moment A moment B Figure 10.1: Shepherd algorithm: minimum time Using the taskset utility, some experiments were performed. Figure 10.2 shows the results in a real four core CPU running repeatedly the same GAFit task –same seed– selecting from one to four cores. The same experiment was performed in an eight virtual cpu system. The host really had only a four core CPU. The results are shown in figure 10.3. Notice that the algorithm behaves as if there were only four core CPU. In figure 10.1, the red and green lines represent two different moments in the calculations. In both cases, shepherd steps down to find the first minimum. The minimum found is considered the optimum for this run –noted as NAand NB–. shepherd processes entire populations cycling between N,N+1 and N−1as the number of concurrent processes and it counts the real time spent. The time recorded changes dynamically, changing Nin turn. The number of times a number of parallel processes are chosen by 100 10. SHEPHERD 12345678910 0 5 10 15 20 25 30 35 40 45 1 2 34 Running processes in parallel Time 1 Core 2 Cores 3 Cores 4 Cores Figure 10.2: Real four core CPU: minimun time vs maximum concurrent parallel processes per run shepherd are shown in figures 10.4 and 10.5. This information can be summarized taking into account the average N in both cases, as shown in figure 10.6. The algorithm presents a weakness: if shepherd writes to a local storage, the algorithm works well. However, if it writes to a share, it fails. Figure 10.7 compares the same job –using the same seed, executed in a one CPU node– writing to a local storage and to a Network File System (NFS) share4. As shown, writing to a local storage stabilizes the minimum time from one running process –it is a one core CPU–. But writing to a NFS share, minimum times stabilize over 12 running processes, as if there were 12 core CPUs. 4A typical configuration where the user’s HOME is shared with all cluster nodes. 10.3. PARALLEL PROCESSES 101 12345678910 0 20 40 60 80 100 120 140 160 180 Running processes in parallel Time 1 vcpu 2 vcpu 3 vcpu 4 vcpu 5 vcpu 6 vcpu 7 vcpu 8 vcpu Figure 10.3: Virtual eight core CPU: minimum time vs maximum concurrent parallel processes per run There are a utility, lstimes, to show the current number of parallel processes, the time spend, the number of times the algorithm choose a particular number of processes and the maximum and minimun time. 108 11. FPU Figure 11.2: Fpu load the machine code and process the variables to obtain V value. Table 11.1: Fpu source code Folder Comments fpu implements the Fpu function compiler implements the bytecode compiler pack bytecode packaging (as file or in memory) bytecodes bytecode instructions helper functions nullist implements stacks using null terminated lists of strings memory pool an array referencing each allocated double, always growing up. There is no mechanism to resize down allocated memory, except resetting or deleting the Fpu from memory. It is like a real CPU stack. program counter memory address pointing to the instruction to be processed, like a real CPU program counter. status flags register which is set on error like a real CPU flags. program A continuous memory block containing the loaded program opcodes. The data and the program code does not share the same "memory", so conceptually this is a virtual machine with a Harvard architecture1. The supported instruction set is shown in table 11.2. 1The opposite is the von Neumann’s architecture where data and program code are loaded in the same memory. This is the most widely used if not the unique. 11.2. MODE OF OPERATION 109 Figure 11.3: Fpu overview Address#0 Address#1 Address#2 Address#3 Address#4 Address#5 Address Stack Double Double Double Double Double Double Double Double Double Double Main Memory N0 Address N1 Address N2 Address N3 Address N4 Address N5 Address N6 Address N7 Address N8 Address N9 Address Memory Pool Program Counter Flags 00 0 Program bytecode . . . apush 0apush 1neg mult . . . 11.2 Mode of operation A program example is shown in File 11.2, which is generated using the job.txt file configuration 11.1. Semicolons are interpreted as comments. File 11.1: Job.txt to generate the File 11.2 [ analytic al ] expression : ␣ potential ␣1 distance : ␣r potential : ␣v c o e f f i c i e n t s : ␣a , ␣b , ␣c , ␣d [ potential ␣ 1] V=A∗EXP(−B∗R)+C/R∗∗D; 110 11. FPU Table 11.2: Fpu instruction set Instruction Parameters Comments NOP No operation APUSH N pushes address of memory pool N onto stack PUSH A allocates memory for value A incrementing memory pool, and pushes its address onto stack POP pops from stack MOVE N copies top of stack value to Nth memory pool reference and leaves stack unchanged STORE moves value of top of stack to allocation referenced by top of stack - 1. Pops both addresses from stack CLRF clears status flags ADD adds two top most referenced values of stack, pops both from stack, and allocates memory for result pushing its address onto it SUB same as add but substracting MULT same as add but multiplicating DIV same as add but dividing NEG pops out top of stack reference, allocating memory for its negated value and pushing onto it POW raises power of the two top most values of stack popping them, allocates memory for result and pushes onto it EXP allocates memory for the result of etopmoststack, pops the top most stack references, and pushes onto it the result reference File 11.2: Bytecode source example ␣ ; ␣v:0 ␣ ; ␣a :1 ␣ ; ␣b:2 ␣ ; ␣r :3 ␣ ; ␣c :4 ␣ ; ␣d:5 ␣apush␣0 ␣apush␣1 ␣apush␣2 ␣neg ␣apush␣3 ␣mult ␣exp ␣mult ␣apush␣4 ␣apush␣3 ␣apush␣5 ␣pow ␣div ␣add ␣ store 11.2. MODE OF OPERATION 111 As shown in File 11.2, a memory block must be passed to Fpu containing the variables v,a,b,r,c,din the correct order, as it could be seen in the first lines of the file –comments which are generated by the compiler as a remark–. At this time, the Address Stack is empty, so v, aand bare pushed. empty v apush 0 a v apush 1 b a v apush 2 -b a v neg r -b a v apush 3 -b*r a v mult Next, the value of the top of the stack is negated (−b). ris pushed and multiplied by −b, so on top of the stack we have −b∗r. The e−br is calculated and multiplied by aleaving it in the top of stack again. Figure 11.4: Initial status empty Address Stack address of d address of c address of r address of b address of a address of v Memory Pool d c r b a v Main Memory Memory Block passed as parameter From the memory management point of view, the first six operations from File 11.2 are shown in figures 11.4 to 11.8. A memory block with the program variables is passed to Fpu. New intermediate results generate new allocations of memory, all of them are taken into account by the Memory Pool array, which always grows. At the end, all of them are freed except the initial memory block with the initial variables returned to the caller. 112 11. FPU Figure 11.5: apush 0, apush 1, apush 2 address of b address of a address of v Address Stack address of d address of c address of r address of b address of a address of v Memory Pool d c r b a v Main Memory Figure 11.6: neg address of -b address of a address of v Address Stack address of -b address of d address of c address of r address of b address of a address of v Memory Pool d c r b a v -b Main Memory Allocated 11.2. MODE OF OPERATION 113 Figure 11.7: apush 3 address of r address of -b address of a address of v Address Stack address of r address of -b address of d address of c address of r address of b address of a address of v Memory Pool d c r b a v -b Main Memory Figure 11.8: mult address of −b∗r address of a address of v Address Stack address of −b∗r address of r address of -b address of d address of c address of r address of b address of a address of v Memory Pool d c r b a v −b∗r -b Main Memory Allocated 12 Tools Contrary to popular belief, Unix is user friendly. It just happens to be very selective about who it decides to make friends with. Anonymous 12.1 needle needle is a perl script used to distinguish different types of atoms, which are needed to calculate the different types of interactions between Fragment A and Fragment B. $ needle -h needle v0.4 (c) Roberto Rodriguez-Fernandez - 2010-2013 collects sets of equivalent atoms input: any geometries input file -d debug -p N fragment A atoms -o creates needed files The atoms considered are: F, H, Si, O, N, S, C and Au. If any atom is different from those, it must be previously coded. $ needle -p 18 moldeni.dat needle v0.2 (c) Roberto Rodriguez-Fernandez - 2010-2013 collects sets of equivalent atoms input: any geometries input file 115 116 12. TOOLS Number(Atom) 1. 1(N) 2. 2(H) 4(H) 5(H) 3. 3(C) 4. 6(C) 5. 7(H) 8(H) 6. 9(O) 7. 10(N) 8. 11(H) 9. 12(C) 10. 13(C) 11. 14(H) 15(H) 12. 16(O) 13. 17(O) 14. 18(H) 15. 19(C) 22(C) 33(C) ... 16. 20(C) 21(C) 34(C) ... 17. 23(F) 24(F) 29(F) ... 18. 25(F) 26(F) 27(F) ... Results: 1 245 3 6 7 8 9 10 11 12 13 14 15 16 17 18 19 22 33 ... 20 21 34 ... 23 24 29 ... 25 26 27 ... Fragment A atoms:18 There are 18 different atom types. Fragment A:14, Fragment B:4, Common types:0 Total diff interactions: a vector of 56 coefs, X(k) Vector Atom2Type: Atom2Type(i)={1 2 3 2 2 4 ... 17 17 17 17 } Options: -d Debug output. -p N Indicates the number of atoms into fragment A, required if -o is used. -o Creates output files: atom2type.txt and charges.txt as a template to be modified as desired. Note that charges.txt assigns a dummy value of 0to each type of atom, therefore the file must be manually edited or edited using bedit tool. See 6.3. 12.2. BEDIT 117 Notice that needle only reads the first molden geometry in the file, so its input can be the geometries file used for the job. The algorithm used in needle is not bulletproof, so pay special attention to the atom2type.txt file. 12.2 bedit bedit is an interactive editor to: •edit atom types and charges •edit bounds •copy and clone bounds across the bounds vector All options are self explained in the example below. The first option changes atom2type and charges files. Bedit v0.2 Interactive editing (c) Roberto Rodriguez Fernandez 2010 ==== actual interaction: [1] ==== a Interactive modify atom types b Interactive modify bounds c Interactive copy bounds z Quit ==== Option: Option:a Type Atoms ------ -------- 1.- N(1) 2.- H(2) H(4) H(5) 3.- C(3) 4.- C(6) 5.- H(7) H(8) 6.- O(9) 7.- N(10) 8.- H(11) 9.- C(12) 10.- C(13) 11.- H(14) H(15) 12.- O(16) 13.- O(17) 14.- H(18) 15.- C(19) C(22) C(33) ... 16.- C(20) C(21) C(34) ... 17.- F(23) F(24) F(29) ... 18.- F(25) F(26) F(27) ... use ’c3=766’ to change atom 3 to type 766 124 12. TOOLS From up to down, left to right: •Set default : Sets the selected key to its default value. •Cut defaults : Deletes the key/value pairs from tree if the value is the default one. If the key is not present, GAFit takes its default value. •Move up : Moves up a key/value pair or a whole section. •Delete : Deletes key/value pair or a whole section. The key or the whole section keys take their default values. •Move down : Moves down a key/value pair or a whole section. •Default file : Clears all the tree and load a default one: an internal job with potential type 1 and all default values. After loading defaults, check the remaining tree inmediatly when you apply the Edit Cut Defaults option menu or Cut defaults button. •New section Add : Adds a new empty section. •New text section Add : Adds a new text section with the required text. Useful to introduce an analytical expression as potential. •New key:value pair Add : Adds a new key/value pair to the selected section. Also, there is a menu, see Figure 12.3: •File Open file or alt +O: To open a file. •File Save or alt +S: To save the current file. •File Save as or alt +A: To save the current file changing its name. •Edit Tree Clear all, empty file : To clear the whole tree. •Edit Tree Internal job Internal default : Same as Default file button. •Edit Tree Internal job Analytical : Defaults to use an analytical expression as potential. You must introduce the analytical expression by hand using the new text section Add button. Section 6.6,8.2 and 14. 12.5. JOBTREEEDITOR 125 Figure 12.3: Job Tree Editor menu. •Edit Tree Internal job User defined : Defaults to use an user defined potential. You must introduce your potential changing the code: Check Section 8.1.4. Note that you can use a new potential adding your own one giving it a number different from those in Table 6.2 as shown in Section 8.1.3. In this case, also change the key potential to the newly defined potential. •Edit Tree External job External ,Edit Tree External job External bulk and Edit Tree External job External auto : External jobs configurations. Check Sections 9.1,9,10,15,16 and 17. •Edit Cut Defaults : Same as Cut defaults button. •Edit Add known key/value pair : Shows up a menu to pick up one of 126 12. TOOLS the not present keys with their default values to just edit and add to the selected section. See Figure 12.4. Figure 12.4: Job Tree Editor editing a key-value pair with a context menu. Part III Step by step examples 127 13 Xe + [Li(Uracil)]+example As a rule, software systems do not work well until they have been used, and have failed repeatedly, in real applications. Dave Parnas H12 C1C6 H11 C5O8Li9+Xe14 N4 H10 C3 O7 N2 H13 We shall use the Xe + [Li(Uracil)]+system as an example taken from Section 18. In this example, we fit one of the potentials shown in Table 6.2 to the interaction energies between Xe and the [Li(Uracil)]+complex, computed by ab initio calculations. These files are included in the uracil-example folder. You can run it typing: $ make test Once this command is employed, some files are extracted and GAFit is run. 129 130 13. XE + [LI(URACIL)]+EXAMPLE 13.1 Preparing input files The input file coord.molden contains the set of geometries employed in the ab initio calculations. The geometries can be viewed using molden (see Fig. 13.1): $ molden coord.molden Figure 13.1: Viewing the points with Molden. The very first lines of this file are shown in File 13.1. File 13.1: coord.molden geometries file first lines. 14 C 0.000000 0.000000 0.000000 N 0.000000 0.000000 1.354549 C 1.152143 0.000000 2.127502 N 2.311655 0.000000 1.343162 C 2.393034 0.000000 −0.016579 C 1.152592 0.000000 −0.718330 O 1.169220 0.0000 00 3 .330930 O 3.523582 0.0000 00 −0.559509 Li 4.96 8935 0.000000 −1.513449 H 3.175968 0.000000 1.870824 H 1.142155 0.000000 −1.793856 H−0.971622 0.000000 −0.471648 H−0.866367 0.000000 1.87 4333 Xe 17. 488048 0.000000 −9.776123 14 C 0.000000 0.000000 0.000000 N 0.000000 0.000000 1.354549 C 1.152143 0.000000 2.127502 N 2.311655 0.000000 1.343162 C 2.393034 0.000000 −0.016579 [ . . . ] 13.1. PREPARING INPUT FILES 131 Also, we need the interaction energies corresponding to each geometry in coord.molden. These energies are used to fit our model potential and they are listed in the file energies.txt (see File 13.2). This file follows the specifications described in 6.3. File 13.2: energies.txt file. −0.006436 1 −0.012603 1 −0.024660 1 −0.053662 1 −0.151027 1 −0.208324 1 −0.298249 1 −0.443987 1 −0.576097 1 −0.762092 1 −1.031527 1 −1.431174 1 −2.022694 1 −2.554913 1 −3.208230 1 −3.966854 1 −4.767595 1 −5.448579 1 −5.645469 1 −5.658691 1 −5.387761 1 −4.692701 1 −3.377588 1 −1.167944 1 2.322455 1 7.633202 1 15.516838 1 27.007602 1 66.979582 1 146.056144 1 297.072019 1 There are two columns, the first one is the interaction energies and the second one is the weight of each geometry. The order must be the same of the geometries file. Taking into account that some of the atoms in the [Li(Uracil)]+complex (Fragment A below) can be equivalent, we have to determine the different atom types. To achieve this, we shall use the needle tool–see 12.1–. $ needle -p 13 -o coord.molden [...] Fragment A atoms:13 There are 14 different atom types. Fragment A:13, Fragment B:1, Common types:0 Total diff interactions: a vector of 13 coefs, X(k) Vector Atom2Type: Atom2Type(i)={1 2 3 4 5 6 7 8 9 10 11 12 13 14 } two files created: atom2type.txt and charges.txt 132 13. XE + [LI(URACIL)]+EXAMPLE When we run needle using the -p and -o switches, we have to provide the number of atoms present in fragment A. Additionally, with these options needle creates the atom2type.txt –File 13.3– and charges.txt– File 13.4– files (see section 6.3). As seen above, the output informs that, in this case, there are no equivalent atoms. In our example, there are 14 different atom types, and 13 different interactions between fragment Aand fragment B (Xe) File 13.3: atom2type.txt file. 13 14 1 C 1 2 N 2 3 C 3 4 N 4 5 C 5 6 C 6 7 O 7 8 O 8 9 LI 9 10 H 10 11 H 11 12 H 12 13 H 13 14 XE 14 The number of different types of atoms determines the charges.txt file with a line per atom type. The generated charges.txt file is a dummy file to be used as a template and you need to edit it, if you use a potential with charges. File 13.4: charges.txt file. 1 0.000000 2 0.000000 3 0.000000 4 0.000000 5 0.000000 6 0.000000 7 0.000000 8 0.000000 9 0.000000 10 0.00000 0 11 0.00000 0 12 0.00000 0 13 0.00000 0 14 0.00000 0 We shall use the implemented potential number 1 with four coefficients –from Table 6.2–. V=Ae−Br +C rD So we need a file with the lower and upper limits of the coefficients –the bounds–. Here we can specify the same limits for all interactions or different limits per each interaction. We choose the former option, as shown in File 13.5. 13.1. PREPARING INPUT FILES 133 File 13.5: bounds.txt file. TEXT TEXT TEXT TEXT 0 . 1 00 00 00. 0 0 . 1 0. 0 1 −1500. 0 . 0 4. 0 8.0 1 To edit the atom2type and the bounds file we can use the bedit tool –12.2– using option a. Option bis employed to edit the bounds.txt file, and option cis needed when we want to specify different bounds for the parameters corresponding to the different interaction types. $ bedit Bedit v0.2 Interactive editing (c) Roberto Rodriguez Fernandez 2010 Job type: internal ==== actual interaction: [1] ==== a Interactive modify atom types b Interactive modify bounds c Interactive copy bounds z Quit ==== Option:a Type Atoms ------ -------- 1.- C(1) 2.- N(2) 3.- C(3) 4.- N(4) 5.- C(5) 6.- C(6) 7.- O(7) 8.- O(8) 9.- Li(9) 10.- H(10) 11.- H(11) 12.- H(12) 13.- H(13) 14.- Xe(14) use ’c3=766’ to change atom 3 to type 766 ’c4=100 c5=1000’ to change atom 3 to type 100 and atom 5 to type 1000 ’q3=-0.33’ to set type 3 charge to -0.33 ’w’ to save types to file ’z’ to quit Input:z ==== actual interaction: [1] ==== a Interactive modify atom types b Interactive modify bounds c Interactive copy bounds z Quit ==== Option:b INTERACTION TYPE 1 236 19. AB INITIO AND RRKM STUDY OF THE HCN/HNC ELIMINATION CHANNELS FROM VINYL CYANIDE Table 19.5: HCN.xyz N 0.000000 0.000000 0.652578 C 0.000000 0.000000 -0.500525 H 0.000000 0.000000 -1.564896 Table 19.6: Int1-III.xyz H 1.728243 1.892979 0.000000 C 1.320636 0.894959 0.000000 C 0.000000 0.725214 0.000000 H -0.701092 1.544974 0.000000 C -1.137810 -1.574041 0.000000 N -0.588772 -0.538465 0.000000 H 1.997293 0.054512 0.000000 Table 19.7: Int1-IV.xyz C -0.979481 -0.651941 -0.000072 H 1.999891 0.786895 0.000095 H -1.587159 -1.539544 0.000111 C -0.962037 0.681350 -0.000129 H -1.546591 1.584752 0.000154 C 0.303023 -0.015183 0.000299 N 1.566404 -0.131066 -0.000135 Table 19.8: Int1-V.xyz C 0.088169 1.909407 0.000000 H -0.798096 2.531221 0.000000 H 1.047627 2.411050 0.000000 C 0.000000 0.593153 0.000000 H 0.681248 -2.437335 0.000000 C -0.019514 -0.684988 0.000000 N -0.191816 -1.915767 0.000000 Table 19.9: Int2-IV.xyz C 0.752231 0.512909 0.010709 H -2.363819 -0.456989 0.594247 H 0.979149 1.574844 0.056239 C 1.592936 -0.610264 -0.006023 H 2.632464 -0.247184 0.036993 C -0.566987 0.155356 0.006348 N -1.702410 -0.174096 -0.107669 Table 19.10: Int2-V.xyz H 0.941823 -3.205479 0.000000 C 0.002627 -2.663768 0.000000 H -0.936309 -3.205959 0.000000 C 0.002093 -1.366377 0.000000 C -0.003832 2.924519 0.000000 N -0.001548 1.756679 0.000000 H 0.000000 0.748448 0.000000 19.6. SUPPORTING INFORMATION 237 Table 19.11: TS1-III.xyz C 1.425012 -0.263427 0.079283 C 0.354129 0.498225 -0.121163 C -1.129426 0.188334 0.593364 N -1.145832 -0.412558 -0.440426 H 2.404215 0.125561 -0.158428 H 0.372692 1.481893 -0.554674 H 1.345628 -1.258340 0.487184 Table 19.12: TS1-II.xyz C -1.123017 1.530547 0.000000 C -1.251470 0.297002 0.000000 C 0.965619 -0.541190 0.000000 N 1.618519 -1.510187 0.000000 H -1.450019 2.546888 0.000000 H -1.426411 -0.756012 0.000000 H 0.000000 1.062279 0.000000 Table 19.13: TS1-IV.xyz C 0.098171 -1.392816 0.000000 H -1.270267 -0.014155 0.000000 H 0.644486 -2.342959 0.000000 C 0.951278 -0.306501 0.000000 H 2.022457 -0.173053 0.000000 C 0.000000 0.737394 0.000000 N -1.099053 1.185958 0.000000 Table 19.14: TS1-I.xyz C -0.044176 -1.730040 0.000000 H -1.094048 -1.490714 0.000000 H 0.256536 -2.772055 0.000000 C 0.957042 -0.884377 0.000000 H 1.162350 0.306873 0.000000 C 0.000000 1.073269 0.000000 N -0.828862 1.886112 0.000000 Table 19.15: TS1-VI.xyz C 1.293549 1.121106 0.000000 C 0.000000 1.074190 0.000000 N -1.165554 -0.833953 0.000000 C -0.364829 -1.706840 0.000000 H 1.720937 2.119168 0.000000 H -1.073535 0.530804 0.000000 H 1.939154 0.256966 0.000000 Table 19.16: TS1-V.xyz C 1.791655 0.127867 0.000020 H 1.992513 1.193394 0.000108 H 2.647592 -0.532279 0.000039 C 0.555741 -0.367625 -0.000073 H -0.970507 -1.029273 0.000255 C -0.716863 0.187548 -0.000026 N -1.921829 0.097346 0.000011 238 19. AB INITIO AND RRKM STUDY OF THE HCN/HNC ELIMINATION CHANNELS FROM VINYL CYANIDE Table 19.17: TS2-III.xyz H -1.916255 1.816458 0.000000 C -1.185312 1.030689 0.000000 C -1.149921 -0.223557 0.000000 H -1.076098 -1.289589 0.000000 C 1.394753 0.124243 0.000000 N 1.233604 -1.039622 0.000000 H 0.000000 1.162233 0.000000 Table 19.18: TS2-IV.xyz C 0.819819 0.591947 -0.009475 H -2.180138 -0.827002 0.384548 H 1.153138 1.611530 0.158940 C 1.368336 -0.662794 -0.042733 H 2.443028 -0.710931 0.161078 C -0.493515 0.170351 0.001644 N -1.654838 -0.095803 -0.057311 Table 19.19: TSiso.xyz C 0.078325 0.519890 0.000000 C 0.078325 -0.732774 0.000000 H -1.041882 -0.311646 0.000000 H 0.101977 1.588950 0.000000 Table 19.20: TS2-V.xyz H 1.786035 -1.336957 0.000000 C 0.835235 -1.839086 0.000000 H 0.801039 -2.926625 0.000000 C -0.371884 -1.319233 0.000000 C 0.000000 1.028607 0.000000 N -0.599762 2.028314 0.000000 H -1.168847 2.843656 0.000000 Table 19.21: TS3-IV.xyz C -1.008648 -0.552746 -0.000053 H 2.489365 0.123182 0.000350 H -1.393511 -1.550668 -0.000283 C -1.447043 0.635924 0.000000 H -1.114538 1.652427 0.000339 C 0.698849 -0.543933 0.000218 N 1.508534 0.362797 -0.000201 Table 19.22: VC.xyz C -0.583152 -0.536271 0.000000 N -1.068238 -1.586302 0.000000 C 0.000000 0.785121 0.000000 H -0.694962 1.611652 0.000000 C 1.321786 0.978464 0.000000 H 2.013999 0.149805 0.000000 H 1.726828 1.978777 0.000000 Part V Conclusions 239 20 Conclusions There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult. Sir Charles Antony Richard Hoare The main conclusions of this Thesis are enumerated as follows: 1Core GA routines were isolated and GA was modified to deal with integer parameters in the functions employed to fit intermolecular interactions. 2A flexible interface was designed with a well known logic to help adding new features sharing code between distinct package utilities to maintain the oneness of the whole. In deep coding was done to increase portability between different systems. 3Robust routines to read input files were coded. Over these reading routines, a configuration system was created. This system supports configuration sections featuring key/value pairs ready to expand new capabilities with no effort. 241 242 20. CONCLUSIONS 4Specifying a new intermolecular potential energy function can be done modifying clear and explained source code or using a file template to fill up with user code. 5To use an analytical expression, a complete virtual FPU was developed with its own machine instruction set, a compiler to translate the expression to binary executable code or to its assembler representation. Also a new utility was developed to test analytical expressions compiling and running the resulting executable. 6To interface with external programs a communication protocol was developed, so with a minimum effort, the external programs can configure GAFit behavior. This characteristic was used to build the two MOPAC interfaces but it is general to deal with any external program. 7A first MOPAC interface was built coding a set of tools and gluing them all together in a shell script, the external-mopac2009.sh: The injector, in C, to configure GAFit and create MOPAC input files, the MOPAC binary executable to run each job, the extractor, in Perl, to process the output files and write results to a file, extracted.data, with a well known file format, and the fitter, in Fortran, to evaluate the results upon the user requirements. If the variables to control and fit are the same as in MOPAC, it only must be changed the injector and extractor tools to use a new external program. In the case of MOPAC 2012, where some output in Cartesian coordinates are missing, the extractor utility also translates internal coordinates to Cartesian coordinates using quaternion maths to calculate 3D rotations. 8An enhanced MOPAC interface was coded replacing the MOPAC executable with a new tool: shepherd, which can launch and control running MOPAC jobs maintaining an optimal number of parallel MOPAC processes, depending on available resources, to speed up calculations. 243 9A perl tool, needle, was developed to identify types of atoms, which are needed to calculate the different types of interactions between two fragments and automatically build the atom2type file from Cartesian coordinates. 10 The bedit tool, source code in C and Fortran, was designed to help modifying atom types, charges and bounds in the corresponding input files. 11 AGUI program, JobTreeEditor, was developed in Java using the swing widget toolkit to create and modify the job configuration file job.txt. 12 fitview, written in C and Fortran, an utility to write and plot data from results generating gnuplot files was developed. 13 A complete set of case examples is included with code and explained. 14 The package was automated with the GNU build system1. It can be deployed, compiled, installed and run in many systems, including MacOSX. 1Also known as the autotools:http://www.gnu.org/software/automake/manual/html_node/ Autotools-Introduction.html Appendices 245 252 A. SOURCE CODE A.8.2 Autoweights Code to implement the auto-weights feature. C language. •autoweights.h •autoweights.c A.8.3 Bounds Custom routines to read bounds files. C language. •bounds.h •bounds.c A.8.4 Cnames Coefficient names stuff. C language. •cnames.h •cnames.c A.8.5 InputLine Custom routines to read lines and text from configuration and data files. C language. •line.h •line.c A.8.6 Integer Code to support integer coefficients. C language. •integer.h •integer.c A.9. TOOLS 253 A.8.7 Literals Routines to support automatic coefficient names. C language. •literals.h •literals.c A.8.8 Parameters Code to deal with program parameters. C language. •parameters.h •paramenters.c A.8.9 Rand Random stuff. C language. •rand.h •rand.c A.8.10 Rstrings C strings custom routines. C language. •rstrings.h •rstrings.c A.9 Tools C, Java and Perl languages. A.9.1 Bedit Terminal utiltiy to edit atom2type,bounds and charges files. •bedit.c 254 A. SOURCE CODE A.9.2 Fitview Tool to create some gnuplot plots. •fitview.c A.9.3 JobTreeEditor Java graphical interface to create and edit the configuration file job.txt. •DoubleString.java •EditorComboBox.java •EditorRoot.java •EditorSectionTextField.java •EditorTextArea.java •EditorTextField.java •FilterTxt.java •FIve.java •IniData.java •IniEditor.java •IniModel.java •IniRenderer.java •JobTreeEditor.java •JobTxtConf.java •KnownValues.java •RoFileFilters.java A.9.4 Needle Perl tool to create the atom2type file from a geometry file. •needle A.9. TOOLS 255 A.9.5 Ufpu Utility to test analytical expressions as potentials. •ufpu.c B Resumo Un dos conceptos chaves na química é o da superficie de enerxía potencial, –Potential Energy Surface (PES), en inglés– a cal vén da aproximación de Born-Oppenheimer que facilita a solución da ecuación de Schrödinger independente do tempo para sistemas moleculares, e afortunadamente, os erros asociados con esta aproximación son depreciábeis para a maioría dos sistemas e condicións de interese para os químicos. APES dun sistema molecular goberna a maioría das súas propiedades químicas, e particularmente a dinámica, é dicir, a evolución espacial dos núcleos co tempo. Moitas das simulacións dinámicas realizadas hoxe en día envolven a integración das ecuacións clásicas do movemento, calculando as forzas sobre os átomos en cada paso, directamente mediante cálculos da estrutura electrónica –dinámica directa, cálculos “ao voo”– ou por PES analíticas. Nun principio, o enfoque da dinámica directa pode ser a opción preferida para a simulación de sistemas reactivos que inclúen un pequeno número de átomos, porque se evita a construción da superficie analítica. Sen embargo, o uso das PES analíticas ten unha clara vantaxe en termos de custos en tempos de CPU –Central Processing Unit (CPU), unidade de proceso central, sinónimo do microprocesador ou procesador dos modernos computadores–, sendo obrigada en simulacións dinámicas de sistemas compostos por miles de átomos. Incluso para sistemas de pequeno tamaño, o uso dunha superficie analítica —tamén xeralmente chamada campo de forzas en mecánica molecular edinámica molecular– 257 258 B. RESUMO pode ser unha boa elección. Se se fai con coidado, pode ser, como mínimo, tan boa como a superficie exacta correspondente ao método cálculo da estrutura electrónica usado como referencia para a súa construción. O desenvolvemento das PES analíticas ou campos de forza pódese facilitar usando métodos de optimización, e varios grupos de investigación xa as usaron para diversos obxectivos do seu interese. Sen embargo, ata o que sabemos, non hai un programa xeral que permita aos usuarios parametrizar superficies analíticas ou campos de forza dunha forma relativamente fácil. O motivo do presente traballo é escribir unha suite de ferramentas que axuden aos usuarios a desenvolver superficies analíticas. Esta suite de programas chámase GAFit. Usamos este nome porque neste kit de ferramentas un GA –Algoritmo xenético, Genetic Algorithm (GA)– conduce o axuste —fit—- ou parametrización da superficie de enerxía potencial desexada. O algoritmo xenético non foi desenvolvido neste traballo, senón que foi recollido da literatura: [F V; Pereira F B; Almeida M M; Maniero A M; Fellows C E Marques J M C; Prudente. “A new genetic algorithm to be used in the direct fit of potential energy curves to ab initio and spectroscopic data”. In: Journal of Physics B: Atomic, Molecular and Optical Physics 41.8 (2008), p. 085103. url:http://stacks.iop.org/0953-4075/41/i=8/a=085103] e [Marcos M Almeida et al. “Direct fit of spectroscopic data of diatomic molecules by using genetic algorithms: II. The ground state of RbCs”. In: Journal of Physics B: Atomic, Molecular and Optical Physics 44.22 (2011), p. 225102]. Para os nosos obxectivos, a vantaxe dun algoritmo xenético fronte a outro tipo de método de optimización é dado polo tipo de problema a resolver. Por unha banda, é necesario un algoritmo que realice unha optimización global atopando unha posible resposta dentro dun tempo razoable. Por outra banda, outra característica desexable é non ter que adaptar o algoritmo ao tipo de problema. Neste caso, os algoritmos xenéticos posúen as dúas: exploran todo o posible espazo de solucións co engadido de que non fan ningún tipo de asuncións a priori sobre a tarefa a realizar, e polo tanto traballan ben con calquera tipo de problema. Pódese comparar, en contraposición, cun algoritmo tipo, dos usados normalmente para as optimizacións, o cal necesitaría de informa- 259 ción inicial: a semente ou o punto de comezo, a partires do cal empeza a optimización. Dependendo da semente, é obvio que posiblemente atopará un mínimo próximo, que non ten por que ser o mínimo global. E polo tanto, é necesario ter un coñecemento a priori do sistema a axustar. Neste traballo, o programa GAFit aplícase ao desenvolvemento de un potencial intermolecular para a interacción entre o Xe e o complexo [Li(Uracil)]+, e para a reparametrización de un Hamiltoniano semiempírico. Os Hamiltonianos semiempíricos modificados con parámetros de reacción específicos –Specific Reaction Parameters (SRP)– foron propostos por primeira vez por [Angels Gonzalez-Lafont, Thanh N Truong, and Donald G Truhlar. “Direct dynamics calculations with NDDO (neglect of diatomic differential overlap) molecular orbital theory with specific reaction parameters”. In: The Journal of Physical Chemistry 95.12 (1991), pp. 4618–4627] como un método práctico de cálculo de dinámicas directas. O programa, sen embargo, pode ser facilmente adaptado para conducir calquera tipo de axuste ou parametrización de superficies analíticas ou campos de forza, así como tamén, para outros problemas de optimización na química. No GAFit a funcionalidade do núcleo do GA foi estendida en varias direccións: illando o núcleo do resto do código, modificando o mesmo para permitir o uso de valores enteiros nos coeficientes a parametrizar das funcións de axuste para as interaccións intermoleculares, engadindo utilidade e usabilidade coas novas características e úteis de axuda, e por último, unha codificación coidadosa para permitir a portabilidade entre distintos sistemas operativos. No caso do illamento do core, isto facilitou o deseño dunha interface flexible e ben estruturada que permite o engadido de características novas de forma sinxela compartindo código entre as distintas partes, incluíndo os programas illados de utilidade co fin de que as distintas partes se interrelacionan facendo o todo unha única unidade fácil de manter. As características engadidas permiten agora aos usuarios escoller, dependendo das súas habilidades de programación, desde codificar directamente os seus potenciais no propio código fonte do GAFit ata, para eses usuarios que non teñen ningún coñecemento, poder usar os potenciais máis comúns na literatura xa codificados no propio programa. Outra 260 B. RESUMO opción para os que non teñen coñecementos de programación é o uso de expresións analíticas que son compiladas ao código máquina dunha FPU virtual que o interpreta como o potencial a parametrizar. Para usuarios intermedios que queiran codificar un potencial axustado ás súas necesidades, pero que teñan medo de modificar o código fonte do GAFit, inclúese un modelo en Fortran a cubrir polo usuario co seu potencial e a súa función de axuste. En ámbolos dous casos, o código fonte do propio GAFit ou o modelo, están claramente codificados e comentados para ir conducindo ao usuario na dirección axeitada. Ademais, engádese, como complemento para facilitar o traballo, unha completa colección de ferramentas para a creación e configuración dos arquivos de entrada e examinar os resultados: needle,bedit,JobTreeEditor,fitview eufpu. Para o uso de expresións analíticas como potenciais, desenvolveuse unha Floating Point Unit (FPU) virtual co seu propio conxunto de instrucións máquina, un compilador para traducir as expresións analíticas a un binario executable pola propia FPU –ou a súa representación na linguaxe ensambladora da FPU para facilitar a detección de erros–. Co fin de testar as expresións analíticas, a compilación e execución das mesmas, construíuse unha nova utilidade: ufpu, que usa directamente o arquivo de configuración do traballo de cálculo para realizar os tests. Codificáronse rutinas robustas para a lectura de arquivos de entrada. Sobre estas rutinas creouse un sistema de configuración que soporta a división lóxica das distintas partes a configurar en seccións, podendo introducir os parámetros individuais de cada sección mediante un método sinxelo de pares chave/valor. Este sistema de división lóxica e o feito de usar pares chave/valor facilitan o engadido de novas características sen moito traballo. Estas facilidades permitirían ao propio usuario parametrizar os seus propios módulos usando o mesmo arquivo de configuración xenérico do programa ou outro calquera ao seu gusto. Usando a nova interface co core, deseñouse como nova característica unha interface de segundo nivel para interactuar con programas externos e usar os seus resultados como axuste dos parámetros obtidos polo algoritmo xenético. O protocolo establecido permite que calquera utilidade externa configure o comportamento do propio GAFit de forma 261 automática. Usando este interface, desenvolvéronse as ferramentas necesarias para parametrizar algún dos Hamiltonianos semiempíricos implementados no programa de cálculo de estrutura electrónica MOPAC co GAFit facendo dúas interfaces. A primeira sería o exemplo a seguir polo usuario para interactuar cun programa externo diferente ao MOPAC. Sen embargo, atopáronse certas deficiencias inherentes ao MOPAC, co cal fíxose de seguido unha interface máis sofisticada para solventar estas eivas. A primeira foi feita codificando un conxunto de ferramentas e xuntándoas nun shell script, o external-mopac2009.sh: O injector, escrito en C, para configurar o GAFit e crear traballos MOPAC, o executable binario do MOPAC para correr cada traballo, o extractor, feito en Perl, para procesar os arquivos de saída, e o fitter, en Fortran, para avaliar os resultados dependendo dos requirimentos do usuario. Se se usa un novo programa externo que use as mesmas variables co MOPAC so é necesario reescribir o injector e o extractor para adaptar o sistema ao novo programa. Oinjector usando os conxuntos de coeficientes pasados polo GA- Fit crea os arquivos necesarios para que sirvan de entrada de datos ao MOPAC. Tamén é responsable de configurar ao GAFit se se usa a configuración automática –autoconfigure–. Oextractor le os arquivos de saída e recolle toda a información interesante gravándoa nun arquivo intermedio cunha estrutura ben coñecida. Ofitter usa este arquivo para coller a información necesaria tendo en conta o especificado polo usuario nun arquivo de texto no que especifica que variables hai que ter en conta para o axuste e que peso van ter. No caso do MOPAC 2012, onde parte dos resultados en coordenadas cartesianas xa non se escriben no arquivo de saída, o extractor traduce as coordenadas internas a cartesianas usando operacións con quaternions para calcular as rotacións 3D necesarias para esta tarefa. Ofitter recolle os requirimentos do usuario para os axustes e usa os datos recopilados polo extractor para calcular o resultado do axuste. Entre as distintas variables que se poden usar están as calores de formación ou a súa diferenza entre distintos cálculos –entre un produto e un estado de transición, por exemplo–, distancias entre átomos, ángu- 268 REFERENCES [9] Arnold Neumaier. Introduction to Global Optimization. Accessed 1 April 2014. Self-Published, May 2013. url:http://www.mat.univie.ac.at/~neum/glopt/intro. html. [10] Paul M. Sant. "intractable". in Dictionary of Algorithms and Data Structures [online], Vreda Pieterse and Paul E. Black eds. accessed 1 April 2014 (Modified December 17 2004). Dec. 2004. url:http://www.nist.gov/dads/HTML/intractable. html. [11] Paul M. Sant. "big-O notation". in Dictionary of Algorithms and Data Structures [online], Vreda Pieterse and Paul E. Black eds. accessed 1 April 2014 (Modified August 31 2012). Aug. 2012. url:http : / / www . nist . gov / dads / HTML / bigOnotation.html. [12] Thomas Weise. Global Optimization Algorithms - Theory and Application. en. Second. Online available at http://www.it-weise.de/ Accessed 1 April 2014. Self- Published, June 2009. url:http://www.it-weise.de/. [13] Kalyanmoy Deb and Ram Bhushan Agrawal. “Simulated binary crossover for continuous search space”. In: Complex Systems 9 (1994), pp. 1–34. [14] Kalyanmoy Deb and Hans-georg Beyer. “Self-Adaptive Genetic Algorithms with Simulated Binary Crossover”. In: Evol. Comput. 9 (2 June 2001), pp. 197– 221. issn: 1063-6560. doi:http://dx.doi.org/10.1162/106365601750190406. [15] Larry J. Eshelman and J. David Schaffer. “Real-Coded Genetic Algorithms and Interval-Schemata”. In: FOGA. Ed. by L. Darrell Whitley. Morgan Kaufmann, 1992, pp. 187–202. isbn: 1-55860-263-1. [16] Charles FF Karney. “Quaternions in molecular modeling”. In: Journal of Molecular Graphics and Modelling 25.5 (2007), pp. 595–604. [17] M.T. Rodgers and P.B. Armentrout. In: J. Am. Chem. Soc. 122 (2000), pp. 8548– 8558. [18] P.B. Armentrout. In: Top. Curr. Chem. 225 (2003), p. 233. [19] P.B. Armentrout. In: J. Am. Soc. Mass Spectrom. 13 (2002), p. 419. [20] P.B. Armentrout, D.A. Hales, and L. Lian. Advances in Metal and Semiconductor Clusters. Greenwich, CT: JAI, 1994. [21] P.B. Armentrout, H. Koizumi, and M. MacKenna. In: J. Phys. Chem. A 109 (2005), p. 11365. [22] W. Buchmann et al. In: J. Mass Spectrom. 42 (2007), p. 517. [23] D.R. Carl, R.M. Moision, and P.B. Armentrout. In: Int. J. Mass Spectrom. 256 (2007), p. 308. [24] R. Chawla, A. Shukla, and J. Futrell. “Collision-induced dissociation of nitrobenzene molecular cations at low energies by crossed-beam tandem mass spectrometry”. In: J. Phys. Chem. A 105.2 (2001), p. 349. [25] R. G. Cooks. Collision Spectroscopy. New York: Plenum, 1978. REFERENCES 269 [26] E.R. Fisher, B.L. Kickel, and P.B. Armentrout. In: J. Phys. Chem. 97 (1993), p. 10204. [27] Y.J. Fu, J. Laskin, and L.S. Wang. In: Int. J. Mass Spectrom. 255 (2006), p. 102. [28] N. Hallowita et al. In: J. Phys. Chem. A 112 (2008), p. 7996. [29] A.L. Heaton and P.B. Armentrout. In: J. Phys. Chem. A 112 (2008), p. 10156. [30] J. Laskin, E. Denisov, and J. H. Futrell. “Fragmentation energetics of small peptides from multiple-collision activation and surface-induced dissociation in FTICR MS”. In: Int. J. Mass. Spectr. 219.1 (2002), p. 189. [31] J. Laskin and J. H. Futrell. “Collisional activation of peptide ions in FT-ICR mass spectrometry”. In: Mass Spectrometry Reviews 22.3 (2003), pp. 158–181. [32] J. Laskin and J. H. Futrell. “On the efficiency of energy transfer in collisional activation of small peptides”. In: J. Chem. Phys. 116.10 (2002), pp. 4302–4310. [33] F Muntean and P.B. Armentrout. In: J. Chem. Phys. 115 (2001), pp. 1213– 1228. [34] C.-Y. Ng. In: J. Phys. Chem. A 106 (2002), p. 5953. [35] M.T. Rodgers and P.B. Armentrout. In: Mass. Spectrom. Rev. 19 (2000), p. 215. [36] J.-Y. Salpin and J. Tortajada. In: J. Mass Spectrom. 37 (2002), p. 379. [37] A. K. Shukla and J. H. Futrell. “Tandem mass spectrometry: Dissociation of ions by collisional activation”. In: Journal of Mass Spectrometry 35.9 (2000), p. 1069. [38] A. K. Shukla and J. H. Futrell. “Collisional activation and dissociation of polyatomic ions”. In: Mass Spectrometry Reviews 12.4 (1993), p. 211. [39] R. E. Tosh, A. K. Shukla, and J. H. Futrell. “Energy transfer, scattering and dissociation in ion atom collisions: CO2 +/Ar”. In: J. Chem. Phys. 114.7 (2001), p. 2986. [40] D.J. Douglas. In: J. Phys. Chem. 86 (1982), p. 185. [41] V.H. Wysocki, H.I. Kenttämaa, and R. G. Cooks. In: Int. J. Mass Spectrom. Ion Processes 75 (1987), pp. 181–208. [42] H. Yamaoka. In: J. Phys. Chem. 86 (1982), p. 185. [43] P. DeSainteClaire, G. H. Peslherbe, and W. L. Hase. “Energy transfer dynamics in the collision-induced dissociation of Al6 and Al13 clusters”. In: J. Phys. Chem. 99.20 (1995), pp. 8147–8161. [44] Y. Jeanvoine et al. In: Int. J. Mass Spectrom. 308 (2011), pp. 289–298. [45] E. Martínez-Núñez et al. “Quasiclassical dynamics simulation of the collisioninduced dissociation of Cr (CO)6 + with Xe”. In: J. Chem. Phys. 123 (2005), p. 154311. 270 REFERENCES [46] O. Meroueh and W. L. Hase. “Energy transfer pathways in the collisional activation of peptides”. In: Int. J. Mass. Spectr. 201.1-3 (2000), pp. 233–244. [47] R. Spezia et al. In: Phys. Chem. Chem. Phys. 14 (2012), pp. 11724–11736. [48] R. Spezia et al. In: J. Phys. Chem. A 113 (2009), pp. 13853–13862. [49] T. Raz and R. D. Levine. In: J. Chem. Phys. 105 (1996), p. 8097. [50] D.G. Schultz and L. Hanley. In: J. Chem. Phys. 109 (1998), p. 10976. [51] T Baer and W. L. Hase. Unimolecular Reaction Dynamics. Oxford, 1996. [52] E. Martinez-Nunez et al. “Quasiclassical trajectory study of the collisioninduced dissociation dynamics of Ar+CH3SH+ using an ab initio interpolated potential energy surface”. In: J. Phys. Chem. A 110.4 (2006). 010MF Times Cited:1 Cited References Count:22, pp. 1225–1231. issn: 1089-5639. doi:Doi10.1021/ Jp052325d. [53] E. Martinez-Nunez, S. A. Vazquez, and J. M. C. Marques. “Quasiclassical trajectory study of the collision-induced dissociation of CH3SH++Ar”. In: J. Chem. Phys. 121.6 (2004). 840JX Times Cited:3 Cited References Count:32, pp. 2571– 2577. issn: 0021-9606. doi:Doi10.1063/1.1769364. [54] Y.-J. Chen et al. In: J. Phys. Chem. A 106 (2002), p. 9729. [55] P.T. Fenn et al. In: J. Phys. Chem. A 101 (1997), p. 6513. [56] J. Liu et al. “Direct dynamics study of energy transfer and collision-induced dissociation: Effects of impact energy, geometry, and reactant vibrational mode in H2CO+ - Ne collisions”. In: J. Chem. Phys. 119.6 (2003), p. 3040. [57] U. Lourderaj and W. L. Hase. “Theoretical and Computational Studies of Non- RRKM Unimolecular Dynamics”. In: J. Phys. Chem. A 113.11 (2009). Lourderaj, Upakarasamy Hase, William L., pp. 2236–2253. issn: 1089-5639. doi:10.1021/ jp806659f. [58] S. O. Meroueh, Y. Wang, and W. L. Hase. “Direct dynamics simulations of collision- and surface-induced dissociation of n-protonated glycine. Shattering fragmentation”. In: J. Phys. Chem. A 106.42 (2002), p. 9983. [59] B. Coupier et al. In: Eur. J. Phys. J. D 20 (2002), p. 459. [60] M. Imhoff, Z. Deng, and M. Huels. In: Int. J. Mass Spectrom. 154 (2007), p. 262. [61] M. Imhoff, Z. Deng, and M. Huels. In: Int. J. Mass Spectrom. 245 (2005), p. 68. [62] A. Le Padellec et al. In: J. Phys.:Conf. Ser. 101 (2008), p. 012007. [63] T. Schlatholter et al. In: ChemPhysChem 7 (2006), p. 2339. [64] T. Schlatholter, F. Alvarado, and R. Hoekstra. In: Nucl. Instrum. Methods Phys. Res. Sect. B 233 (2005), p. 62. [65] J. Tabet et al. In: Int. J. Mass Spectrom. 292 (2010), p. 53. REFERENCES 271 [66] J. Tabet et al. In: Phys. Rev. A 82 (2010), p. 022703. [67] J. Tabet et al. In: Phys. Rev. A 81 (2010), p. 012711. [68] J. de Vries et al. In: Eur. Phys. J. D 24 (2003), p. 161. [69] H. Budzikiewicz, J.I. Brauman, and C. Djerass. In: Tetrahedron 21 (1965), p. 1855. [70] R.C. Dougherty. In: J. Am. Chem. Soc. 90 (1968), p. 5780. [71] M Monge-Palacios, J. J. Nogueira, and E Martinez-Nunez. In: J. Phys. Chem. C116 (2012), pp. 25454–25464. [72] J. J. Nogueira et al. In: J. Phys. Chem. C 115 (2011), pp. 23817–23830. [73] M.J.S. Dewar, E.G. Zoebisch, and E.F. Healey. In: J. Am. Chem. Soc. 107 (1985), pp. 3902–3909. [74] F. Weigend, F. Furche, and R. Ahlrichs. In: J. Chem. Phys. 119 (2003), pp. 12753–12762. [75] TURBOMOLE v6.4 2012, a development of University of Karlsruhe and Forschungszentrum Karlsruhe GmbH, 1989-2007, TURBOMOLE GmbH. Computer Program. url:http://www.turbomole.com. [76] S. F. Boys and F. Bernardi. In: Mol. Phys. 19 (1970), pp. 553–566. [77] W. L. Hase et al. In: QCPE 16 (1996), p. 671. [78] A.B. Bortz, M. H. Kalos, and J.L. Lebowitz. In: J. Comput. Phys. 17 (1975), pp. 10–18. [79] D.T. Gillespie. In: J. Comput. Phys. 22 (1976), pp. 403–434. [80] X. Hu and W. L. Hase. In: J. Chem. Phys. 95 (1991), p. 8073. [81] R.N. Porter and L.M. Raff. Dynamics of Molecular Collisions. Vol. B. New York: Plenum Press, 1976. [82] A. Linhananta and K.F. Lim. In: Phys. Chem. Chem. Phys. 4 (2002), pp. 577– 585. [83] J. M. C. Marques et al. “Trajectory dynamics study of the Ar+CH4 dissociation reaction at high temperatures: the importance of zero-point-energy effects”. In: J. Phys. Chem. A 109.24 (2005). 936PC Times Cited:11 Cited References Count:64, pp. 5415–5423. issn: 1089-5639. doi:Doi10.1021/Jp044707+. [84] K.F. Lim. In: Quantum Chem. Program Exchange Bull. 14.1 (1994), p. 3. [85] J. Hippler, J. Troe, and H.J. Wendelken. In: J. Chem. Phys. 78 (1983), p. 6709. [86] F.M. Mourits and F.H.A. Rummens. In: Can. J. Chem. 55 (1977), p. 3007. [87] A.J. Stone. The Theory of Intermolecular Forces. Oxford: Oxford University Press, 1996. [88] L. Sadr Arani et al. In: Phys. Chem. Chem. Phys. 14 (2012), pp. 9855–9870. 272 REFERENCES [89] K. Fukui. In: Acc. Chem. Res. 14 (1981), p. 363. [90] D.H. Ess et al. In: Angew. Chem. Int. Ed. 47 (2008), p. 7592. [91] J. Rehbein and B.K. Carpenter. In: Phys. Chem. Chem. Phys. 13 (2011), p. 20906. [92] E. J. Bylaska et al. NW Chem, A Computational Chemistry Package for Parallel Computers, Version 5.1. Computer Program. 2007. [93] R. A. Kendall et al. In: Comput. Phys. Chem. 128 (2000), p. 260. [94] U. Lourderaj et al. “Direct dynamics simulations using Hessian-based predictorcorrector integration algorithms”. In: J. Chem. Phys. 126.4 (2007), p. 044105. [95] W. L. Hase et al. “Translational and vibrational energy dependence of the cross section for H + C2H4 → C2H5”. In: J. Phys. Chem. 85.8 (1981), p. 958. [96] C.S. Sloane and W. L. Hase. In: J. Chem. Phys. 66 (1977), p. 1523. [97] B.K. Carpenter. In: J. Phys. Org. Chem. 16 (2003), p. 858. [98] D. Gerlich. In: Adv. Chem. Phys. 82 (1992), p. 1. [99] J. Liu, B. van Devener, and S.L. Anderson. In: J. Chem. Phys. 116 (2002), p. 5530. [100] K. Song, O. Meroueh, and W. L. Hase. “Dynamics of Cr(CO)6 + collisions with hydrogenated surfaces”. In: J. Chem. Phys. 118.6 (2003), pp. 2893–2902. [101] J. Wang et al. “Efficiency of energy transfer in protonated diglycine and dialanine SID: Effects of collision angle, peptide ion size, and intramolecular potential”. In: Int. J. Mass. Spectr. 230.1 (2003), pp. 57–63. [102] L. Yang et al. In: J. Phys. Chem. C 112 (2008). Yang, Li Mazyar, Oleg A. Lourderaj, U. Wang, Jiangping Rodgers, M. T. Martinez-Nunez, Emilio Addepalli, Srirangam V. Hase, William L., pp. 9377–9386. issn: 1932-7447. doi:10.1021/ jp712069b. [103] J. Troe. In: J. Chem. Phys. 66 (1977), p. 4758. [104] A. Derecskei-Kovacs and S.W. North. In: J. Chem. Phys. 110 (1999), p. 2862. [105] M. J. Wilhelm et al. In: J. Chem. Phys. 130 (2009), p. 044307. [106] S. A. Abrash et al. In: J. Phys. Chem. 99 (1995), p. 2959. [107] M. Bahou and Y. P. Lee. “Photodissociation dynamics of vinyl chloride investigated with a pulsed slit-jet and time-resolved Fourier-transform spectroscopy”. In: Aust. J. Chem. 57.12 (2004), pp. 1161–1164. issn: 0004-9425. doi:Doi10.1071/ Ch04117. [108] M. Barbatti, A.J.A. Aquino, and H. Lischka. In: J. Phys. Chem. A 109 (2005), p. 5168. [109] D. A. Blank et al. In: J. Chem. Phys. 108 (1998), p. 5414. [110] T.R. Fletcher and S.R. Leone. In: J. Chem. Phys. 88 (1988), p. 4720. REFERENCES 273 [111] J. Gonzalez-Vazquez et al. “Dissociation of difluoroethylenes. I. Global potential energy surface, RRKM, and VTST calculations”. In: J. Phys. Chem. A 107.9 (2003), pp. 1389–1397. issn: 1089-5639. doi:Doi10.1021/Jp021901s. [112] J. Gonzalez-Vazquez et al. “Dissociation of difluoroethylenes. II. Direct Classical Trajectory Study of the HF elimination from 1,2-difluoroethylene”. In: J. Phys. Chem. A 107.9 (2003), pp. 1398–1404. issn: 1089-5639. doi:Doi10.1021/ Jp021902k. [113] G. He et al. In: J. Chem. Phys. 103 (1995), p. 5488. [114] Y. Huang et al. In: J. Chem. Phys. 103 (1995), p. 5476. [115] W. A. Jalenak and N. S. Nogar. In: J. Chem. Phys. 79 (1983), p. 816. [116] S. Kato and K. Morokuma. In: J. Chem. Phys. 74 (1981), p. 6285. [117] H.S. Ko et al. In: J. Chem. Phys. 117 (2002), p. 6038. [118] Y.R. Lee et al. In: J. Chem. Phys. 113 (2000), p. 5331. [119] S. R. Lin et al. “I. Three-center versus four-center HCl-elimination in photolysis of vinyl chloride at 193 nm: Bimodal rotational distribution of HCl (v <= 7) detected with time-resolved Fourier-transform spectroscopy”. In: J. Chem. Phys. 114.1 (2001), pp. 160–168. issn: 0021-9606. [120] S. R. Lin et al. “Three-center versus four-center elimination in photolysis of vinyl fluoride and vinyl bromide at 193 nm: Bimodal rotational distribution of HF and HBr (v <= 5) detected with time-resolved Fourier transform spectroscopy”. In: J. Chem. Phys. 114.17 (2001), pp. 7396–7406. issn: 0021-9606. [121] E. Martínez-Núñez et al. “Product energy distributions for the four-center HF elimination from 1,1-difluoroethylene. a direct dynamics study”. In: Chem. Phys. Lett. 348.1-2 (2001), p. 81. [122] E. Martínez-Núñez and S. Vázquez. “Rotational distributions of HBr in the photodissociation of vinyl bromide at 193 nm: An investigation by direct quasiclassical trajectory calculations”. In: Chem. Phys. Lett. 425.1-3 (2006), p. 22. [123] E. Martínez-Núñez and S. Vázquez. “Quasiclassical trajectory calculations on the photodissociation of C F2 CHCl at 193 nm: Product energy distributions for the HF and HCl eliminations”. In: J. Chem. Phys. 122.10 (2005), p. 1. [124] E. Martínez-Núñez and S. Vázquez. “Rovibrational distributions of HF in the photodissociation of vinyl fluoride at 193 nm: A direct MP2 quasiclassical trajectory study”. In: J. Chem. Phys. 121.11 (2004), p. 5179. [125] E. Martínez-Núñez and S. A. Vázquez. “Three-center vs. four-center HF elimination from vinyl fluoride: A direct dynamics study”. In: Chem. Phys. Lett. 332.5- 6 (2000), p. 583. [126] E. Martínez-Núñez et al. “Further investigation of the HCl elimination in the photodissociation of vinyl chloride at 193 nm: A direct MP2/6-31G(d,p) trajectory study”. In: Chem. Phys. Lett. 386.4-6 (2004), p. 225. 274 REFERENCES [127] J.-F. Riehl and K. Morokuma. In: J. Chem. Phys. 100 (1994), p. 8976. [128] T. Takayanagi and A. Yokoyama. In: Bull. Chem. Soc. Japan 68 (1995), p. 245. [129] T. Tarrazo-Antelo, E. Martinez-Nunez, and S. A. Vazquez. “Ab initio and RRKM study of the elimination of HF and HCl from chlorofluoroethylene”. In: Chem. Phys. Lett. 435.4-6 (2007). 140AR Times Cited:0 Cited References Count:35, pp. 176–181. issn: 0009-2614. doi:DOI10.1016/j.cplett.2006.12.075. [130] M. Umemoto et al. In: J. Chem. Phys. 83 (1985), p. 1657. [131] C.A. Bird and D.J. Donaldson. In: Chem. Phys. Lett. 249 (1996), p. 40. [132] D. A. Blank et al. In: J. Chem. Phys. 108 (1998), p. 5784. [133] A. Fahr and A.H. Laufer. In: J. Phys. Chem. 96 (1992), p. 4217. [134] L. Letendre and H.-L. Dai. In: J. Phys. Chem. A 106 (2002), p. 12035. [135] S. W. North and G. E. Hall. In: Chem. Phys. Lett. 263 (1996), p. 143. [136] C Gonzalez and H. B. Schlegel. In: J. Phys. Chem. 94 (1990), p. 5523. [137] M. J.; Frisch et al. et. al. Gaussian 09. Computer Program. 2009. [138] W. H. Miller. In: J. Am. Chem. Soc. 101 (1979), p. 6810. [139] K.M. Ervin, J. Ho, and W.C. Lineberger. In: J. Chem. Phys. 91 (1989), p. 5974. [140] J.B. Moffat. In: J. Phys. Chem. 81 (1977), p. 82. Other interesting references to the reader Erling D. Andersen. Linear optimization: Theory, methods, and extensions. Accessed 1 April 2014. Self-Published, 1998. url:http://plato.asu.edu/ftp/linopt.pdf. M.S. Bazaraa, H.D. Sherali, and C.M. Shetty. Nonlinear Programming: Theory and Algorithms. Wiley, 2006. isbn: 9780471787761. Kent Beck. Una explicación de la programación extrema. Pearson Educación, 2002, 189 pages. isbn: 8478290559. John Calcote. Autotools: A Practioner’s Guide to GNU Autoconf, Automake, and Libtool. 1st. San Francisco, CA, USA: No Starch Press, 2010. isbn: 1593272065, 9781593272067. Bruce Eckel. Piensa en Java. Pearson Educación, 2002, 906 pages. isbn: 9788420531922. Brian Foy, Tom Phoenix, and Randal Schwartz. Learning Perl. "O’Reilly Media, Inc.", 2011, 363 pages. isbn: 9781449303587. Daniel Gilly and O’Reilly & Associates. UNIX in a nutshell. O’Reilly & Associates, 1992. isbn: 9781565920019. H. J. Greenberg. Myths and Counterexamples in Mathematical Programming. (ongoing, first posted October 2008, Accessed 1 April 2014.) http://glossary.computing. society.informs.org: INFORMS Computing Society, Feb. 2010. David Gunter and Jack Tackett. Utilizando Linux. Prentice Hall, 1996, 846 pages. isbn: 9788489660557. Francisco Herrera, Manuel Lozano, and Jose L. Verdegay. “Tackling real-coded genetic algorithms: Operators and tools for behavioural analysis”. In: Artificial intelligence review 12.4 (1998), pp. 265–319. Jarkko Hietaniemi, John Macdonald, and Jon Orwant. Mastering Algorithms with Perl. O’Reilly Media, Inc., 1999, 684 pages. isbn: 9781565923980. 275 276 OTHER INTERESTING REFERENCES TO THE READER C. T. Kelley. Iterative Methods for Linear and Nonlinear Equations. Frontiers in Applied Mathematics 16. Accessed 1 April 2014. SIAM, 1995. url:http://www. siam.org/books/textbooks/fr16_book.pdf. C. T. Kelley. Iterative Methods for Optimization. Vol. 19. Accessed 1 April 2014. SIAM Frontiers in Applied Mathematics, 1999. url:http://www.siam.org/ books/textbooks/fr18_book.pdf. Olaf Kirch. Linux. O’Reilly Media, 1995, 335 pages. isbn: 9781565920873. Donald Ervin Knuth. The art of computer programming. Vol. 1,2,3,4A. Pearson Education, 1968-2011. Jesse Liberty. C++ para principiantes. Pearson Educación, 2000, 422 pages. isbn: 9789701704165. H. A. Luther, James O. Wilkes, and Brice Carnahan. Cálculo numérico. Rueda, 1979, 639 pages. isbn: 8472070131. Félix García Merayo. Programación en FORTRAN 77. Paraninfo, 1991, 399 pages. isbn: 9788428318181. James Newkirk et al. La programación extrema en la práctica. Pearson Educación, 2002, 200 pages. isbn: 8478290575. Francisco José Baptista Pereira. “Estudo das interacções entre evolução e aprendizagem em ambientes de computação evolucionária”. PhD thesis. 2002. url: http://hdl.handle.net/10316/1744. Riccardo Poli, William B. Langdon, and Nicholas Freitag McPhee. A field guide to genetic programming. (With contributions by J. R. Koza. Accessed 1 April 2014.) Published via http://lulu.com and freely available at http://www.gp-field- guide.org.uk, 2008. url:http://www.gp-field-guide.org.uk. William H. Press et al. Numerical Recipes 3rd Edition: The Art of Scientific Computing. Cambridge University Press, 2007. isbn: 0521880688. Eric S. Raymond. The Art of UNIX Programming. Pearson Education, 2003. isbn: 0131429019. Herbert Schildt. C. Osborne MacGraw-Hill, 1989, 358 pages. isbn: 9788476153819. Fco. Javier Ceballos Sierra and Francisco Javier Ceballos Sierra. C/C++. RA-MA S.A. Editorial y Publicaciones, 2001, 704 pages. isbn: 9788478974801. Kathy Sierra and Bert Bates. Head First Java, 2nd Edition. O’Reilly Media, 2005. isbn: 0596009208. Nick Sofroniou, Apostolos Syropoulos, and Antonis Tsolomitis. Digital Typography Using LaTeX. Springer, 2003, 510 pages. isbn: 9780387952178. James C. Spall. Introduction to Stochastic Search and Optimization. Wiley-Interscience, 2003, 595 pages. isbn: 9780471330523. S. Srinivasan. Advanced Perl programming. A Nutshell handbook. O’Reilly, 1997. isbn: 9781565922204. OTHER INTERESTING REFERENCES TO THE READER 277 Johan Vromans. Perl 5 pocket reference. O’Reilly Media, 2000, 90 pages. isbn: 9780596000325. Kurt Wall. Programación en Linux con ejemplos. Prentice-Hall, 2000, 541 pages. isbn: 9789879460092. L. Wall, T. Christiansen, and J. Orwant. Programming Perl. O’Reilly Series. O’Reilly, 2000. isbn: 9780596000271. L. Darrell Whitley, ed. Proceedings of the Second Workshop on Foundations of Genetic Algorithms. Vail, Colorado, USA, July 26-29 1992. Morgan Kaufmann, 1993. isbn: 1-55860-263-1. Stephen Wright and Jorge Nocedal. Numerical Optimization. Springer Verlag, 2006, 664 pages. isbn: 9780387303031. 284 INDEX curRouter, 65 potRouter, 65 userpot, 73 userread, 73 tags, 37,61,78,121 taskset, 99 template, 80 tournament, 28 size, 28,44 transition state, 173 transition states, 38 uCompiler, 107 ufpu, 75,107,121,149 unimolecular decomposition channels, 38 uracil example, 134 user defined potential, 125 userpotential.f example, 38 utility lsexdata, 89 lstimes, 101 vibrational frequencies, 173 vibrational frequency, 174 von Neumann architecture, 108 weights, 47,90 auto, 52 auto weights, 47 auto, print, 54 vglobales, 64 whitespace, 43 List of Tables 4.1 GA subroutines ..................... 28 6.1 Job file default value parameters ............ 43 6.2 Potential values from potentials.f code file ....... 51 8.1 Module VGLOBALES variables ............ 64 8.2 Analyltical potential parameters ............ 74 8.3 Operators and functions supported in expressions . . . 76 9.1 Environmental variables ................. 83 9.2 Extracted data ...................... 89 9.3 Fitter conditions ..................... 90 11.1 Fpu source code ..................... 108 11.2 Fpu instruction set .................... 110 15.1 Example values to fit. .................. 156 15.2 nth set of coefficients fit. ................. 161 15.3 Some results running the example with 6 coefficients. . 166 16.1 Files in the mopac-example folder after run make test.170 17.1 Files in the shepherd-example folder after run make test.182 285 286 LIST OF TABLES 18.1 Computational details of the quasi-classical trajectory simulations carried out in this work to calculate the cross sections and energy transfer. ........... 192 18.2 Simulation results for the trajectories starting from the TSI1-b and TSb-b transition states. .......... 201 18.3 Parameters of the energy transfer model (eqn 18.4.1) fitted to our simulation data. .............. 205 18.4 Molecular properties selected for the reparametrization of the AM1 Hamiltonian. ................ 210 18.5 AM1-SRP optimized parameters. ............ 211 18.6 Computed relative energies (in kcal/mol) of the main stationary points of the [Li(uracil)]+system. ...... 211 18.7 Parameters for the two-body intermolecular potentials. 212 19.1 Final relative populations of HCN and HNC obtained in channels I-VII. .................... 228 19.2 Frequencies of all stationary points found in this study 235 19.3 :CCH2.xyz ........................ 235 19.4 HCCH.xyz ........................ 235 19.5 HCN.xyz ......................... 236 19.6 Int1-III.xyz ........................ 236 19.7 Int1-IV.xyz ........................ 236 19.8 Int1-V.xyz ........................ 236 19.9 Int2-IV.xyz ........................ 236 19.10 Int2-V.xyz ........................ 236 19.11 TS1-III.xyz ........................ 237 19.12 TS1-II.xyz ........................ 237 19.13 TS1-IV.xyz ........................ 237 19.14 TS1-I.xyz ......................... 237 19.15 TS1-VI.xyz ........................ 237 19.16 TS1-V.xyz ........................ 237 19.17 TS2-III.xyz ........................ 238 19.18 TS2-IV.xyz ........................ 238 19.19 TSiso.xyz ......................... 238 19.20 TS2-V.xyz ........................ 238 19.21 TS3-IV.xyz ........................ 238 LIST OF TABLES 287 19.22 VC.xyz .......................... 238 A.1 Source files ........................ 247 List of Figures 2.1 Convex function. ..................... 10 2.2 Global search. ...................... 15 3.1 Evolutionary algorithms. ................ 17 3.2 Genes and chromosome example: 4th potential from Table 6.2. .......................... 18 3.3 Single gene mutation. .................. 19 3.4 Multiple gene mutation. ................. 19 3.5 Variable lenght insertion. ................ 20 3.6 Variable lenght deletion. ................. 20 3.7 Permutation. ....................... 20 3.8 Single point crossover. .................. 21 3.9 Variable lenght single point crossover. ......... 21 3.10 Multiple point crossover. ................ 22 3.11 Variable lenght multiple point crossover. ........ 22 3.12 Tree choromosome. ................... 23 3.13 4th potential from Table 6.2. ............... 23 4.1 GA main loop ...................... 29 5.1 [Li(Uracil)]+- Xe example. ............... 38 9.1 MOPAC 2009 interface: normal operation ....... 81 9.2 MOPAC 2009 interface: autoconfigure ......... 82 289 290 LIST OF FIGURES 9.3 Dihedral angles convention ............... 91 10.1 Shepherd algorithm: minimum time .......... 99 10.2 Real four core CPU: minimun time vs maximum concurrent parallel processes per run ............ 100 10.3 Virtual eight core CPU: minimum time vs maximum concurrent parallel processes per run .......... 101 10.4 Real four core CPU: number of times (N) vs parallel processes per run .................... 102 10.5 Virtual eight core CPU: number of times (N) vs parallel processes per run .................... 103 10.6 Average parallel processes per run. 4 core real CPU vs 8 core virtual CPU (4 real) ............... 104 10.7 Behavior in the same one core CPU writing output to a NFS share vs local storage. .............. 105 11.1 uCompiler compiles the expression into fpu machine code. ........................... 107 11.2 Fpu load the machine code and process the variables to obtain V value. ...................... 108 11.3 Fpu overview ...................... 109 11.4 Initial status ....................... 111 11.5 apush 0, apush 1, apush 2 ................ 112 11.6 neg ............................ 112 11.7 apush 3 .......................... 113 11.8 mult ........................... 113 12.1 Two body interaction example plot. .......... 121 12.2 Job Tree Editor main window. ............. 123 12.3 Job Tree Editor menu. .................. 125 12.4 Job Tree Editor editing a key-value pair with a context menu. ........................... 126 13.1 Viewing the points with Molden. ............ 130 13.2 Job Tree Editor editing the ’job.txt’ file included in the uracil example. ...................... 135 13.3 Appliying ’cut defaults’. ................. 136 LIST OF FIGURES 291 13.4 Interaction type 2 plot. ................. 143 13.5 General evaluation plot. ................. 144 14.1 Appliying ’cut defaults’. ................. 147 14.2 Adding new text section. ................ 149 14.3 Analytical job after adding the text section. ...... 150 15.1 Example polynomial plot ................ 156 15.2 Step 1 :GAFit is launched .............. 160 15.3 Step 2 :GAFit overwrites or creates the external.input file. ............................ 161 15.4 Step 3 :GAFit launches the external binary . . . . 162 15.5 Step 5 :external using external.input evaluates the external.values and overwrites or creates the external.fit file ............................ 163 15.6 Step 5 :GAFit reads the external.fit file ...... 164 15.7 Step 6 : if the fit is the best till now, GAFit overwrites or creates the best.txt file ............ 165 15.8 Table 15.3 polynomial plots. .............. 167 16.1 Vinyl cyanide drawn using the coordinates of the first calculation (optimization of the minimum energy structure). ........................... 173 16.2 Three-centered transition state drawn using the coordinates of the last calculation. .............. 173 18.1 Atomic labeling and geometries of [Li(uracil)]+optimized in this work at the MP2/6-31+G(d) level of theory. . . 191 18.2 Percentage of the different channels found in this study, with respect to the total number of trajectories (upper panel) and percentage of RRKM and “shattering” found in the O–Li+dissociations (lower panel). ........ 195 18.3 Scattering maps for uracil obtained for the collision energies of 6, 8 and 10 eV. ................. 196 18.4 Fragmentation channels of [Li(uracil)]+involving ring opening. The MP2/6-31+G(d) and AM1-SRP dissociation energies are indicated in kcal/mol. ....... 199 292 LIST OF FIGURES 18.5 Potential energy profiles involved in the [Li(uracil)]+ring opening channels P0-P2. The profiles are computed at the MP2/6-31+G(d) level of theory and energies are given in kcal/mol. .................... 200 18.6 Comparison between QCT and experimental[17]integral cross sections for Li+production. The error bars in the simulation results represent the 95% confidence limits. The experimental error bars are taken from Rodgers and Armentrout [17]. ..................... 203 18.7 Average energy transfer values computed in this work for Xe + [Li(uracil)]+according to eqn (18.3.6). . . . . 205 18.8 Contour plots for Li+around uracil computed at the MP2/6-31+G(d), AM1 and AM1-SRP levels of theory. 212 18.9 Stationary points found in our study for [Li(uracil)]+at the MP2/6-31+G(d) and AM1-SRP levels of theory. Distances are given in Å. ................ 213 18.10 Analytical potential of eqn (18.3.2) (solid lines) fitted to the RI-MP2(FC)/def2-QZVPP ab initio calculations (circles) for different orientations of Xe and [Li(uracil)]+.214 18.11 Average intermolecular potential and fitted LJ intermolecular potential for different Xe-[Li(uracil)]+distances.215 19.1 Schematic potential energy diagram for paths I-III (leading to HCN formation). The values are the relative energies (in kcal/mol). ................... 231 19.2 Schematic potential energy diagram for paths IV-VII (leading to HNC formation). The values are the relative energies (in kcal/mol). .................. 232 19.3 Schematic potential energy diagram for the vinylideneacetylene isomerization process. The values are the relative energies (in kcal/mol). ............... 233 19.4 Populations, as a function of time, of HCN and HNC obtained in paths I-VII for three different energies and total HCN/HNC ratio. ................. 233 19.5 Final populations of HCN and HNC obtained for paths I-VII and total HCN/HNC ratio as a function of energy. 234 File list 1 Input file example. .................... 3 2 C source code ...................... 3 4.1 ga.c ............................ 25 6.1 job.txt. Genetic algorithm parameters and job settings 41 6.2 Reduced job.txt. ..................... 42 6.3 Geometries file. Molden xyz coordinates ........ 46 6.4 Energies file. Energies and weights ........... 47 6.5 Energies file. Structure ................. 47 6.6 Energies file. Energies with auto weights ........ 47 6.7 Energies file. Structure of Energies file with auto weights 47 6.8 Atom2type. Atom to atom types mapping ....... 48 6.9 Atom2type. Structure .................. 48 6.10 Bounds. Variation range of the coefficients ....... 49 6.11 Bounds. All Coefficients=0. Structure ......... 49 6.12 Bounds. All Coefficients<>0. Structure ........ 49 6.13 Bounds file written with the bedit tool ........ 50 6.14 Charges. Type to charges mapping ........... 50 6.15 Charges. Structure .................... 51 6.16 Job settings with auto weights ............. 53 6.17 External job settings ................... 53 6.18 External input ...................... 53 6.19 External bulk input ................... 53 6.20 External fit: one individual fit ............. 54 293