2
Copyright (C) 2003 by Sean David Fleming
6
This program is free software; you can redistribute it and/or
7
modify it under the terms of the GNU General Public License
8
as published by the Free Software Foundation; either version 2
9
of the License, or (at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
The GNU GPL can also be found at http://www.gnu.org
32
#include "interface.h"
34
extern struct elem_pak elements[];
36
/* meta data for computational chemistry archiving */
38
/*****************************************************************/
39
/* split a string containing units into it's raw value and units */
40
/*****************************************************************/
41
void meta_parse_units(gchar **value, gchar **units, gchar *source)
45
buff = g_strsplit(source, " ", 2);
48
*value = g_strdup(*(buff+0));
53
*units = g_strdup(*(buff+1));
63
gint write_meta(gchar *filename, struct model_pak *model)
65
gchar *energy_package=NULL, *energy_value=NULL, *energy_gradient=NULL;
66
gchar *energy_method=NULL, *energy_basis=NULL, *energy_functional=NULL;
67
gchar *value=NULL, *units=NULL;
72
g_return_val_if_fail(model != NULL, 1);
73
g_return_val_if_fail(filename != NULL, 2);
76
fp = fopen(filename,"wt");
80
/* fill in the blanks ... */
81
/* <key> separator <item1> separator <item 2> ... etc */
82
/* separator atm will be '|' */
84
/* structural information */
85
fprintf(fp, "formula|");
86
for (list=model->unique_atom_list ; list ; list=g_slist_next(list))
88
int code = GPOINTER_TO_INT(list->data);
90
select_all_elem(code, model);
91
fprintf(fp, "%s %d ", elements[code].symbol, g_slist_length(model->selection));
94
fprintf(fp, "molecules|%d\n", g_slist_length(model->moles));
95
fprintf(fp, "dimensionality|%d\n", model->periodic);
96
switch(model->periodic)
99
fprintf(fp, "cell|%f %f %f %f %f %f\n",
100
model->pbc[0], model->pbc[1], model->pbc[2],
101
R2D*model->pbc[3], R2D*model->pbc[4], R2D*model->pbc[5]);
102
fprintf(fp, "spacegroup|%s\n", model->sginfo.spacename);
106
fprintf(fp, "cell|%f %f %f \n",
107
model->pbc[0], model->pbc[1], R2D*model->pbc[5]);
111
fprintf(fp, "cell|%f\n", model->pbc[0]);
115
/* energetics information */
116
/* only for recognized output types ... input files only have structual meta data stored */
117
/* check eligible types for energy etc output */
118
/* TODO - include a version number (if available) in package??? */
119
energy_value = property_lookup("Energy", model);
124
energy_package = g_strdup("ABINIT");
125
energy_gradient = property_lookup("RMS Gradient", model);
128
energy_package = g_strdup("CASTEP");
129
energy_gradient = property_lookup("RMS Gradient", model);
130
energy_functional = property_lookup("Functional", model);
133
energy_package = g_strdup("GAMESS");
134
energy_gradient = property_lookup("RMS Gradient", model);
135
energy_basis = property_lookup("Basis", model);
138
energy_package = g_strdup("GAUSSIAN");
139
energy_method = property_lookup("Method", model);
140
energy_gradient = property_lookup("RMS Gradient", model);
141
energy_basis = property_lookup("Basis", model);
144
energy_package = g_strdup("GULP");
145
energy_method = g_strdup("Forcefield");
146
energy_value = property_lookup("Energy", model);
147
energy_gradient = property_lookup("Gnorm", model);
150
energy_package = g_strdup("MARVIN");
151
energy_method = g_strdup("Forcefield");
152
energy_gradient = property_lookup("Gnorm", model);
155
energy_package = g_strdup("NWCHEM");
156
energy_gradient = property_lookup("RMS Gradient", model);
159
energy_package = g_strdup("SIESTA");
160
energy_gradient = property_lookup("Maximum Gradient", model);
161
energy_functional = property_lookup("Functional", model);
167
fprintf(fp, "package|%s\n", energy_package);
168
g_free(energy_package);
172
fprintf(fp, "method|%s\n", energy_method);
173
g_free(energy_method);
177
fprintf(fp, "basis|%s\n", energy_basis);
178
g_free(energy_basis);
180
if (energy_functional)
182
fprintf(fp, "functional|%s\n", energy_functional);
183
g_free(energy_functional);
188
meta_parse_units(&value, &units, energy_value);
191
fprintf(fp, "energy|%s", value);
195
fprintf(fp, "|%s", units);
200
g_free(energy_value);
205
meta_parse_units(&value, &units, energy_gradient);
208
fprintf(fp, "gradient|%s", value);
212
fprintf(fp, "|%s", units);
217
g_free(energy_gradient);