atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
save_field.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2026 by CNRS and University of Strasbourg */
15
21
22/*
23* This file: 'save_field.c'
24*
25* Contains:
26*
27
28 - The functions to save force field information in the atomes project file format
29
30*
31* List of functions:
32
33 int save_field_atom (FILE * fp);
34 int save_field_shell (FILE * fp);
35 int save_field_constraint (FILE * fp);
36 int save_field_pmf (FILE * fp);
37 int save_field_rigid (FILE * fp);
38 int save_field_tethered (FILE * fp, int fid);
39 int save_field_prop (FILE * fp, int fid, int pid);
40 int save_field_struct (FILE * fp, int fid);
41 int save_field_molecule (FILE * fp, int fid);
42 int save_field_body (FILE * fp, int fid);
43 int save_field_external (FILE * fp, int fid);
44 int save_dlp_field_data (FILE * fp, project * this_proj);
45 int save_lmp_field_data (FILE * fp, project * this_proj);
46
47*/
48
49#include "global.h"
50#include "project.h"
51#include "dlp_field.h"
52
53/*
54typedef struct field field
55struct field
56{
57 gboolean prepare_file[2];
58 // Field and Config files
59 gboolean afp[MAXDATC+MAXDATA];
60 int type;
61 int energy_unit;
62 int atom_init;
63 int molecules;
64 field_molecule * first_molecule;
65 int nbody[5];
66 field_nth_body * first_body[5];
67 // Tersoff potential cross terms
68 double ** cross;
69 int extern_fields;
70 field_external * first_external;
71
72 // Control file
73 double sys_opts[17];
74 double io_opts[23];
75 double ana_opts[17];
76 double elec_opts[11];
77 double vdw_opts[6];
78 double met_opts[2];
79 double equi_opts[17];
80 int ensemble;
81 int thermostat;
82 double thermo_opts[10];
83 double md_opts[20];
84 double out_opts[31];
85};
86
87*/
88
96int save_field_atom (FILE * fp)
97{
98 if (fwrite (& tmp_fat -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
99 if (fwrite (& tmp_fat -> fid, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
100 if (fwrite (& tmp_fat -> afid, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
101 if (fwrite (& tmp_fat -> type, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
102 if (save_this_string (fp, tmp_fat -> name) != OK) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
103 if (fwrite (& tmp_fat -> num, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
104 if (fwrite (& tmp_fat -> sp, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
105 if (fwrite (& tmp_fat -> mass, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
106 if (fwrite (& tmp_fat -> charge, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
107 if (fwrite (& tmp_fat -> frozen, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
108 if (fwrite (tmp_fat -> frozen_id, sizeof(gboolean), tmp_fat -> num, fp) != tmp_fat -> num) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
109 if (fwrite (& tmp_fat -> show, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
110 if (fwrite (tmp_fat -> list, sizeof(int), tmp_fat -> num, fp) != tmp_fat -> num) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
111 if (fwrite (tmp_fat -> list_id, sizeof(int), tmp_fat -> num, fp) != tmp_fat -> num) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
112 return OK;
113}
114
123{
124 if (fwrite (& tmp_fshell -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
125 if (fwrite (tmp_fshell -> ia, sizeof(int), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
126 if (fwrite (& tmp_fshell -> m, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
127 if (fwrite (& tmp_fshell -> z, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
128 if (fwrite (& tmp_fshell -> k2, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
129 if (fwrite (& tmp_fshell -> k4, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
130 if (fwrite (& tmp_fshell -> vdw, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
131 if (fwrite (& tmp_fshell -> show, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
132 if (fwrite (& tmp_fshell -> use, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
133 return OK;
134}
135
144{
145 if (fwrite (& tmp_fcons -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
146 if (fwrite (tmp_fcons -> ia, sizeof(int), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
147 if (fwrite (& tmp_fcons -> av, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
148 if (fwrite (& tmp_fcons -> length, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
149 if (fwrite (& tmp_fcons -> show, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
150 if (fwrite (& tmp_fcons -> use, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
151 return OK;
152}
153
161int save_field_pmf (FILE * fp)
162{
163 if (fwrite (& tmp_fpmf -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
164 if (fwrite (& tmp_fpmf -> av, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
165 if (fwrite (& tmp_fpmf -> length, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
166 if (fwrite (tmp_fpmf -> num, sizeof(int), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
167 int i;
168 for (i=0; i<2; i++)
169 {
170 if (fwrite (tmp_fpmf -> list[i], sizeof(int), tmp_fpmf -> num[i], fp) != tmp_fpmf -> num[i]) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
171 if (fwrite (tmp_fpmf -> weight[i], sizeof(float), tmp_fpmf -> num[i], fp) != tmp_fpmf -> num[i]) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
172 }
173
174 if (fwrite (& tmp_fpmf -> show, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
175 if (fwrite (& tmp_fpmf -> use, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
176 return OK;
177}
178
187{
188 if (fwrite (& tmp_frig -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
189 if (fwrite (& tmp_frig -> num, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
190 if (fwrite (tmp_frig -> list, sizeof(int), tmp_frig -> num, fp) != tmp_frig -> num) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
191 if (fwrite (& tmp_frig -> show, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
192 if (fwrite (& tmp_frig -> use, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
193 return OK;
194}
195
204int save_field_tethered (FILE * fp, int fid)
205{
206 if (fwrite (& tmp_ftet -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
207 if (fwrite (& tmp_ftet -> num, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
208 if (fwrite (& tmp_ftet -> key, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
209 int i = fvalues[fid][0][tmp_ftet -> key];
210 if (fwrite (tmp_ftet -> val, sizeof(float), i, fp) != i) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
211 if (fwrite (& tmp_ftet -> show, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
212 if (fwrite (& tmp_ftet -> use, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
213 return OK;
214}
215
225int save_field_prop (FILE * fp, int fid, int pid)
226{
227 if (fwrite (& tmp_fprop -> pid, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
228 if (fwrite (& tmp_fprop -> fpid, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
229 if (fwrite (& tmp_fprop -> key, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
230 int i = struct_id(pid+7);
231 if (fwrite (tmp_fprop -> aid, sizeof(int), i, fp) != i) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
232 i = fvalues[fid][pid+1][tmp_fprop -> key];
233 if (fwrite (tmp_fprop -> val, sizeof(float), i, fp) != i) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
234 if (fwrite (& tmp_fprop -> show, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
235 if (fwrite (& tmp_fprop -> use, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
236 return OK;
237}
238
247int save_field_struct (FILE * fp, int fid)
248{
249 if (fwrite (& tmp_fstr -> st, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
250 if (fwrite (& tmp_fstr -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
251 if (fwrite (& tmp_fstr -> num, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
252 int i = struct_id(tmp_fstr -> st + 7);
253 if (fwrite (tmp_fstr -> aid, sizeof(int), i, fp) != i) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
254 if (fwrite (& tmp_fstr-> av, sizeof(float), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
255 tmp_fprop = tmp_fstr -> def;
256 if (save_field_prop(fp, fid, tmp_fstr -> st) != OK)
257 {
258 update_error_trace (__FILE__, __func__, __LINE__-2);
259 return ERROR_FIELD;
260 }
261 tmp_fprop = tmp_fstr -> other;
262 i = 0;
263 while (tmp_fprop)
264 {
265 i ++;
266 tmp_fprop = tmp_fprop -> next;
267 }
268 if (fwrite (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
269 if (tmp_fstr -> other)
270 {
271 tmp_fprop = tmp_fstr -> other;
272 while (tmp_fprop)
273 {
274 if (save_field_prop(fp, fid, tmp_fstr -> st) != OK)
275 {
276 update_error_trace (__FILE__, __func__, __LINE__-2);
277 return ERROR_FIELD;
278 }
279 tmp_fprop = tmp_fprop -> next;
280 }
281 }
282 return OK;
283}
284
293int save_field_molecule (FILE * fp, int fid)
294{
295 if (fwrite (& tmp_fmol -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
296 if (fwrite (& tmp_fmol -> mol -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
297 if (save_this_string (fp, tmp_fmol -> name) != OK) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
298 if (fwrite (& tmp_fmol -> multi, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
299 if (fwrite (tmp_fmol -> fragments, sizeof(int), tmp_fmol -> multi, fp) != tmp_fmol -> multi) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
300 int i;
301 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
302 {
303 if (fwrite (tmp_fmol -> atoms_id[i], sizeof(dint), tmp_fmol -> multi, fp) != tmp_fmol -> multi) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
304 }
305 if (fwrite (& tmp_fmol -> atoms, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
306 tmp_fat = tmp_fmol -> first_atom;
307 while (tmp_fat)
308 {
309 if (save_field_atom(fp) != OK)
310 {
311 update_error_trace (__FILE__, __func__, __LINE__-2);
312 return ERROR_FIELD;
313 }
314 tmp_fat = tmp_fat -> next;
315 }
316
317 if (fwrite (& tmp_fmol -> shells, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
318 tmp_fshell = tmp_fmol -> first_shell;
319 while (tmp_fshell)
320 {
321 if (save_field_shell(fp) != OK)
322 {
323 update_error_trace (__FILE__, __func__, __LINE__-2);
324 return ERROR_FIELD;
325 }
326 tmp_fshell = tmp_fshell -> next;
327 }
328
329 if (fwrite (& tmp_fmol -> constraints, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
330 tmp_fcons = tmp_fmol -> first_constraint;
331 while (tmp_fcons)
332 {
334 {
335 update_error_trace (__FILE__, __func__, __LINE__-2);
336 return ERROR_FIELD;
337 }
338 tmp_fcons = tmp_fcons -> next;
339 }
340
341 if (fwrite (& tmp_fmol -> pmfs, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
342 tmp_fpmf = tmp_fmol -> first_pmf;
343 while (tmp_fpmf)
344 {
345 if (save_field_pmf(fp) != OK)
346 {
347 update_error_trace (__FILE__, __func__, __LINE__-2);
348 return ERROR_FIELD;
349 }
350 tmp_fpmf = tmp_fpmf -> next;
351 }
352
353 if (fwrite (& tmp_fmol -> rigids, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
354 tmp_frig = tmp_fmol -> first_rigid;
355 while (tmp_frig)
356 {
357 if (save_field_rigid(fp) != OK)
358 {
359 update_error_trace (__FILE__, __func__, __LINE__-2);
360 return ERROR_FIELD;
361 }
362 tmp_frig = tmp_frig -> next;
363 }
364
365 if (fwrite (& tmp_fmol -> tethered, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
366 tmp_ftet = tmp_fmol -> first_tethered;
367 while (tmp_ftet)
368 {
369 if (save_field_tethered(fp, fid) != OK)
370 {
371 update_error_trace (__FILE__, __func__, __LINE__-2);
372 return ERROR_FIELD;
373 }
374 tmp_ftet = tmp_ftet -> next;
375 }
376 if (fwrite (tmp_fmol -> nstruct, sizeof(int), 8, fp) != 8) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
377 for (i=0; i<8; i++)
378 {
379 tmp_fstr = tmp_fmol -> first_struct[i];
380 while (tmp_fstr)
381 {
382 if (save_field_struct (fp, fid) != OK)
383 {
384 update_error_trace (__FILE__, __func__, __LINE__-2);
385 return ERROR_FIELD;
386 }
387 tmp_fstr = tmp_fstr -> next;
388 }
389 }
390 return OK;
391}
392
401int save_field_body (FILE * fp, int fid)
402{
403 if (fwrite (& tmp_fbody -> bd, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
404 if (fwrite (& tmp_fbody -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
405 if (fwrite (& tmp_fbody -> key, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
406 if (tmp_fbody -> bd == 0) if (fwrite (tmp_fbody -> fpid, sizeof(int), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
407 if (fwrite (tmp_fbody -> na, sizeof(int), body_at(tmp_fbody -> bd), fp) != body_at(tmp_fbody -> bd)) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
408 int i;
409 for (i=0; i<body_at(tmp_fbody -> bd); i++)
410 {
411 if (fwrite (tmp_fbody -> ma[i], sizeof(int), tmp_fbody -> na[i], fp) != tmp_fbody -> na[i]) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
412 if (fwrite (tmp_fbody -> a[i], sizeof(int), tmp_fbody -> na[i], fp) != tmp_fbody -> na[i]) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
413 }
414 i = fvalues[fid][9+tmp_fbody -> bd][tmp_fbody -> key];
415 if (fwrite (tmp_fbody -> val, sizeof(float), i, fp) != i) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
416 if (fwrite (& tmp_fbody -> show, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
417 if (fwrite (& tmp_fbody -> use, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
418 return OK;
419}
420
429int save_field_external (FILE * fp, int fid)
430{
431 if (fwrite (& tmp_fext -> id, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
432 if (fwrite (& tmp_fext -> key, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
433 int i = fvalues[fid][14][tmp_fext -> key];
434 if (fwrite (tmp_fext -> val, sizeof(float), i, fp) != i) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
435 if (fwrite (& tmp_fext -> use, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
436 return OK;
437}
438
447int save_dlp_field_data (FILE * fp, project * this_proj)
448{
449 int i, j;
450 if (this_proj -> force_field[0] == NULL)
451 {
452 i = 0;
453 if (fwrite (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
454 return OK;
455 }
456 i = 1;
457 if (fwrite (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
458 // CONTROL file
459 if (fwrite (this_proj -> force_field[0] -> sys_opts, sizeof(double), 17, fp) != 17) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
460 if (fwrite (this_proj -> force_field[0] -> io_opts, sizeof(double), 23, fp) != 23) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
461 if (fwrite (this_proj -> force_field[0] -> ana_opts, sizeof(double), 17, fp) != 17) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
462 if (fwrite (this_proj -> force_field[0] -> elec_opts, sizeof(double), 11, fp) != 11) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
463 if (fwrite (this_proj -> force_field[0] -> vdw_opts, sizeof(double), 6, fp) != 6) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
464 if (fwrite (this_proj -> force_field[0] -> met_opts, sizeof(double), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
465 if (fwrite (this_proj -> force_field[0] -> equi_opts, sizeof(double), 17, fp) != 17) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
466 if (fwrite (& this_proj -> force_field[0] -> ensemble, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
467 if (fwrite (& this_proj -> force_field[0] -> thermostat, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
468 if (fwrite (this_proj -> force_field[0] -> thermo_opts, sizeof(double), 10, fp) != 10) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
469 if (fwrite (this_proj -> force_field[0] -> md_opts, sizeof(double), 20, fp) != 20) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
470 if (fwrite (this_proj -> force_field[0] -> out_opts, sizeof(double), 31, fp) != 31) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
471 // FIELD file
472 if (fwrite (this_proj -> force_field[0] -> prepare_file, sizeof(gboolean), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
473 if (fwrite (this_proj -> force_field[0] -> afp, sizeof(gboolean), MAXDATC+MAXDATA, fp) != MAXDATC+MAXDATA) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
474 if (fwrite (& this_proj -> force_field[0] -> type, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
475 if (fwrite (& this_proj -> force_field[0] -> energy_unit, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
476 if (fwrite (& this_proj -> force_field[0] -> atom_init, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
477 if (fwrite (& this_proj -> force_field[0] -> molecules, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
478 if (! this_proj -> force_field[0] -> molecules) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
479 tmp_fmol = this_proj -> force_field[0] -> first_molecule;
480 while (tmp_fmol)
481 {
482 if (save_field_molecule (fp, 0) != OK)
483 {
484 update_error_trace (__FILE__, __func__, __LINE__-2);
485 return ERROR_FIELD;
486 }
487 tmp_fmol = tmp_fmol -> next;
488 }
489 if (fwrite (this_proj -> force_field[0] -> nbody, sizeof(int), 5, fp) != 5) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
490 for (i=0; i<5; i++)
491 {
492 if (this_proj -> force_field[0] -> nbody[i])
493 {
494 tmp_fbody = this_proj -> force_field[0] -> first_body[i];
495 while (tmp_fbody)
496 {
497 if (save_field_body (fp, 0) != OK)
498 {
499 update_error_trace (__FILE__, __func__, __LINE__-2);
500 return ERROR_FIELD;
501 }
502 tmp_fbody = tmp_fbody -> next;
503 }
504 }
505 }
506 // Tersoff potential cross terms
507 i = (this_proj -> force_field[0] -> cross) ? 1 : 0;
508 if (fwrite (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
509 if (this_proj -> force_field[0] -> cross)
510 {
511
512 i = this_proj -> force_field[0] -> nbody[2] * (this_proj -> force_field[0] -> nbody[2] - 1) / 2;
513 for (j=0; j<i; j++)
514 {
515 if (fwrite (& this_proj -> force_field[0] -> cross[j], sizeof(double), 3, fp) != 3) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
516 }
517 }
518 if (fwrite (& this_proj -> force_field[0] -> extern_fields, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
519 tmp_fext = this_proj -> force_field[0] -> first_external;
520 while (tmp_fext)
521 {
522 if (save_field_external(fp, 0) != OK)
523 {
524 update_error_trace (__FILE__, __func__, __LINE__-2);
525 return ERROR_FIELD;
526 }
527 tmp_fext = tmp_fext -> next;
528 }
529 return OK;
530}
531
540int save_lmp_field_data (FILE * fp, project * this_proj)
541{
542 int i;
543 if (this_proj -> force_field[1] == NULL)
544 {
545 i = 0;
546 if (fwrite (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_FIELD);
547 return OK;
548 }
549 return OK;
550}
insertion_menu mol[]
Definition w_library.c:193
int atoms[NUM_STYLES][2]
float val
Definition dlp_init.c:117
gchar * sys_opts[10]
int * atoms_id
double *** cross
Definition dlp_edit.c:418
field_constraint * tmp_fcons
Definition dlp_field.c:1049
int fvalues[2][15][21]
Definition dlp_field.c:345
field_nth_body * tmp_fbody
Definition dlp_field.c:1055
field_shell * tmp_fshell
Definition dlp_field.c:1048
field_rigid * tmp_frig
Definition dlp_field.c:1051
int body_at(int b)
find the number of atom(s) in a non bonded interaction
Definition dlp_field.c:1112
field_pmf * tmp_fpmf
Definition dlp_field.c:1050
field_external * tmp_fext
Definition dlp_field.c:1057
field_atom * tmp_fat
Definition dlp_field.c:1047
int struct_id(int f)
number of atoms in a structural element
Definition dlp_field.c:1089
field_struct * tmp_fstr
Definition dlp_field.c:1054
field_molecule * tmp_fmol
Definition dlp_field.c:1045
int atom_init
Definition dlp_field.c:1040
field_prop * tmp_fprop
Definition dlp_field.c:1053
field_tethered * tmp_ftet
Definition dlp_field.c:1052
Variable declarations for the creation of the DL_POLY input file(s).
gboolean afp[MAXDATA]
int multi
Definition dlp_init.c:121
FILE * fp
Global variable declarations Global convenience function declarations Global data structure defin...
int signal_error(const char *file, const char *func, int error_line, int error_id)
Definition callbacks.c:182
#define ERROR_FIELD
#define OK
Definition global.h:295
#define MAXDATC
Number of tabs for the description of the classical calculation.
Definition global.h:771
void update_error_trace(const char *file, const char *func, int trace_line)
Definition callbacks.c:200
#define MAXDATA
Number of tabs for the description of the classical force field.
Definition global.h:776
integer(kind=c_int) function molecules(frag_and_mol, allbonds)
double z
Definition ogl_draw.c:63
Function declarations for reading atomes project file Function declarations for saving atomes proje...
int save_this_string(FILE *fp, gchar *string)
save string to file
Definition save_p.c:50
int save_lmp_field_data(FILE *fp, project *this_proj)
save LAMMPS force field data to file
Definition save_field.c:540
int save_field_struct(FILE *fp, int fid)
save field structural properties to file
Definition save_field.c:247
int save_field_shell(FILE *fp)
save field core shell data to file
Definition save_field.c:122
int save_field_tethered(FILE *fp, int fid)
save field tethered data to file
Definition save_field.c:204
int save_field_prop(FILE *fp, int fid, int pid)
save field property data to file
Definition save_field.c:225
int save_field_atom(FILE *fp)
save field atom data to file
Definition save_field.c:96
int save_field_molecule(FILE *fp, int fid)
save field molecule data to file
Definition save_field.c:293
int save_field_rigid(FILE *fp)
save field rigid constraints data to file
Definition save_field.c:186
int save_field_constraint(FILE *fp)
save field constraint data to file
Definition save_field.c:143
int save_field_pmf(FILE *fp)
save field mean force potential data to file
Definition save_field.c:161
int save_dlp_field_data(FILE *fp, project *this_proj)
save force field data to file
Definition save_field.c:447
int save_field_external(FILE *fp, int fid)
save field external data to file
Definition save_field.c:429
int save_field_body(FILE *fp, int fid)
save field nth body data to file
Definition save_field.c:401
Definition global.h:111