atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
read_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-2024 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'read_field.c'
24*
25* Contains:
26*
27
28 - The functions to read DLPOLY force field data in the atomes project file format
29
30*
31* List of functions:
32
33 int read_field_atom (FILE * fp);
34 int read_field_shell (FILE * fp);
35 int read_field_constraint (FILE * fp);
36 int read_field_pmf (FILE * fp);
37 int read_field_rigid (FILE * fp);
38 int read_field_tethered (FILE * fp, int fid);
39 int read_field_prop (FILE * fp, int fid, int pid);
40 int read_field_struct (FILE * fp, int fid);
41 int read_field_molecule (FILE * fp, int fid);
42 int read_field_body (FILE * fp, int fid);
43 int read_field_external (FILE * fp, int fid);
44 int read_dlp_field_data (FILE * fp, project * this_proj);
45 int read_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
60int read_field_atom (FILE * fp)
61{
62 if (fread (& tmp_fat -> id, sizeof(int), 1, fp) != 1) return ERROR_RW;
63 if (fread (& tmp_fat -> fid, sizeof(int), 1, fp) != 1) return ERROR_RW;
64 if (fread (& tmp_fat -> afid, sizeof(int), 1, fp) != 1) return ERROR_RW;
65 if (fread (& tmp_fat -> type, sizeof(int), 1, fp) != 1) return ERROR_RW;
66 tmp_fat -> name = read_this_string (fp);
67 if (tmp_fat -> name == NULL) return ERROR_RW;
68 if (fread (& tmp_fat -> num, sizeof(int), 1, fp) != 1) return ERROR_RW;
69 if (fread (& tmp_fat -> sp, sizeof(int), 1, fp) != 1) return ERROR_RW;
70 if (fread (& tmp_fat -> mass, sizeof(float), 1, fp) != 1) return ERROR_RW;
71 if (fread (& tmp_fat -> charge, sizeof(float), 1, fp) != 1) return ERROR_RW;
72 if (fread (& tmp_fat -> frozen, sizeof(int), 1, fp) != 1) return ERROR_RW;
73 tmp_fat -> frozen_id = allocbool(tmp_fat -> num);
74 if (fread (tmp_fat -> frozen_id, sizeof(gboolean), tmp_fat -> num, fp) != tmp_fat -> num) return ERROR_RW;
75 if (fread (& tmp_fat -> show, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
76 tmp_fat -> list = allocint(tmp_fat -> num);
77 if (fread (tmp_fat -> list, sizeof(int), tmp_fat -> num, fp) != tmp_fat -> num) return ERROR_RW;
78 tmp_fat -> list_id = allocint(tmp_fat -> num);
79 if (fread (tmp_fat -> list_id, sizeof(int), tmp_fat -> num, fp) != tmp_fat -> num) return ERROR_RW;
80 return OK;
81}
82
90int read_field_shell (FILE * fp)
91{
92 if (fread (& tmp_fshell -> id, sizeof(int), 1, fp) != 1) return ERROR_RW;
93 if (fread (tmp_fshell -> ia, sizeof(int), 2, fp) != 2) return ERROR_RW;
94 if (fread (& tmp_fshell -> m, sizeof(float), 1, fp) != 1) return ERROR_RW;
95 if (fread (& tmp_fshell -> z, sizeof(float), 1, fp) != 1) return ERROR_RW;
96 if (fread (& tmp_fshell -> k2, sizeof(float), 1, fp) != 1) return ERROR_RW;
97 if (fread (& tmp_fshell -> k4, sizeof(float), 1, fp) != 1) return ERROR_RW;
98 if (fread (& tmp_fshell -> vdw, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
99 if (fread (& tmp_fshell -> show, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
100 if (fread (& tmp_fshell -> use, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
101 return OK;
102}
103
112{
113 if (fread (& tmp_fcons -> id, sizeof(int), 1, fp) != 1) return ERROR_RW;
114 if (fread (tmp_fcons -> ia, sizeof(int), 2, fp) != 2) return ERROR_RW;
115 if (fread (& tmp_fcons -> av, sizeof(float), 1, fp) != 1) return ERROR_RW;
116 if (fread (& tmp_fcons -> length, sizeof(float), 1, fp) != 1) return ERROR_RW;
117 if (fread (& tmp_fcons -> show, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
118 if (fread (& tmp_fcons -> use, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
119 return OK;
120}
121
129int read_field_pmf (FILE * fp)
130{
131 if (fread (& tmp_fpmf -> id, sizeof(int), 1, fp) != 1) return ERROR_RW;
132 if (fread (& tmp_fpmf -> av, sizeof(float), 1, fp) != 1) return ERROR_RW;
133 if (fread (& tmp_fpmf -> length, sizeof(float), 1, fp) != 1) return ERROR_RW;
134 if (fread (tmp_fpmf -> num, sizeof(int), 2, fp) != 2) return ERROR_RW;
135 int i;
136 for (i=0; i<2; i++)
137 {
138 tmp_fpmf -> list[i] = allocint (tmp_fpmf -> num[i]);
139 if (fread (tmp_fpmf -> list[i], sizeof(int), tmp_fpmf -> num[i], fp) != tmp_fpmf -> num[i]) return ERROR_RW;
140 tmp_fpmf -> weight[i] = allocfloat (tmp_fpmf -> num[i]);
141 if (fread (tmp_fpmf -> weight[i], sizeof(float), tmp_fpmf -> num[i], fp) != tmp_fpmf -> num[i]) return ERROR_RW;
142 }
143 if (fread (& tmp_fpmf -> show, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
144 if (fread (& tmp_fpmf -> use, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
145 return OK;
146}
147
156{
157 if (fread (& tmp_frig -> id, sizeof(int), 1, fp) != 1) return ERROR_RW;
158 if (fread (& tmp_frig -> num, sizeof(int), 1, fp) != 1) return ERROR_RW;
159 tmp_frig -> list = allocint (tmp_frig -> num);
160 if (fread (tmp_frig -> list, sizeof(int), tmp_frig -> num, fp) != tmp_frig -> num) return ERROR_RW;
161 if (fread (& tmp_frig -> show, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
162 if (fread (& tmp_frig -> use, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
163 return OK;
164}
165
174int read_field_tethered (FILE * fp, int fid)
175{
176 if (fread (& tmp_ftet -> id, sizeof(int), 1, fp) != 1) return ERROR_RW;
177 if (fread (& tmp_ftet -> num, sizeof(int), 1, fp) != 1) return ERROR_RW;
178 if (fread (& tmp_ftet -> key, sizeof(int), 1, fp) != 1) return ERROR_RW;
179 int i = fvalues[fid][0][tmp_ftet -> key];
180 tmp_ftet -> val = allocfloat (i);
181 if (fread (tmp_ftet -> val, sizeof(float), i, fp) != i) return ERROR_RW;
182 if (fread (& tmp_ftet -> show, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
183 if (fread (& tmp_ftet -> use, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
184 return OK;
185}
186
196int read_field_prop (FILE * fp, int fid, int pid)
197{
198 if (fread (& tmp_fprop -> pid, sizeof(int), 1, fp) != 1) return ERROR_RW;
199 if (fread (& tmp_fprop -> fpid, sizeof(int), 1, fp) != 1) return ERROR_RW;
200 if (fread (& tmp_fprop -> key, sizeof(int), 1, fp) != 1) return ERROR_RW;
201 int i = struct_id(pid+7);
202 tmp_fprop -> aid = allocint (i);
203 if (fread (tmp_fprop -> aid, sizeof(int), i, fp) != i) return ERROR_RW;
204 i = fvalues[fid][pid+1][tmp_fprop -> key];
205 tmp_fprop -> val = allocfloat (i);
206 if (fread (tmp_fprop -> val, sizeof(float), i, fp) != i) return ERROR_RW;
207 if (fread (& tmp_fprop -> show, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
208 if (fread (& tmp_fprop -> use, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
209 return OK;
210}
211
220int read_field_struct (FILE * fp, int fid)
221{
222 if (fread (& tmp_fstr -> st, sizeof(int), 1, fp) != 1) return ERROR_RW;
223 if (fread (& tmp_fstr -> id, sizeof(int), 1, fp) != 1) return ERROR_RW;
224 if (fread (& tmp_fstr -> num, sizeof(int), 1, fp) != 1) return ERROR_RW;
225 int i, j;
226 i = struct_id(tmp_fstr -> st + 7);
227 tmp_fstr -> aid = allocint (i);
228 if (fread (tmp_fstr -> aid, sizeof(int), i, fp) != i) return ERROR_RW;
229 if (fread (& tmp_fstr-> av, sizeof(float), 1, fp) != 1) return ERROR_RW;
230 tmp_fstr -> def = g_malloc0(sizeof*tmp_fstr -> def);
231 tmp_fprop = tmp_fstr -> def;
232 if (read_field_prop(fp, fid, tmp_fstr -> st) != OK) return ERROR_RW;
233 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
234 if (i)
235 {
236 tmp_fstr -> other = g_malloc0(sizeof*tmp_fstr -> other);
237 tmp_fprop = tmp_fstr -> other;
238 for (j=0; j<i; j++)
239 {
240 if (read_field_prop(fp, fid, tmp_fstr -> st) != OK) return ERROR_RW;
241 if (j < i-1)
242 {
243 tmp_fprop -> next = g_malloc0(sizeof*tmp_fprop -> next);
244 tmp_fprop = tmp_fprop -> next;
245 }
246 }
247 }
248 return OK;
249}
250
259int read_field_molecule (FILE * fp, int fid)
260{
261 if (fread (& tmp_fmol -> id, sizeof(int), 1, fp) != 1) return ERROR_RW;
262 //tmp_fmol -> mol = g_malloc0(sizeof*tmp_fmol -> mol);
263 int i, j;
264 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
265 // if (i == 20) i = 1;
266 tmp_fmol -> mol = & active_project -> modelfc -> mols[0][i];
267 tmp_fmol -> name = read_this_string (fp);
268 if (tmp_fmol -> name == NULL) return ERROR_RW;
269 if (fread (& tmp_fmol -> multi, sizeof(int), 1, fp) != 1) return ERROR_RW;
270 tmp_fmol -> fragments = allocint (tmp_fmol -> multi);
271 if (fread (tmp_fmol -> fragments, sizeof(int), tmp_fmol -> multi, fp) != tmp_fmol -> multi) return ERROR_RW;
272 tmp_fmol -> atoms_id = g_malloc0(tmp_fmol -> mol -> natoms*sizeof*tmp_fmol -> atoms_id);
273
274 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
275 {
276 tmp_fmol -> atoms_id[i] = g_malloc0(tmp_fmol -> multi*sizeof*tmp_fmol -> atoms_id[i]);
277 if (fread (tmp_fmol -> atoms_id[i], sizeof(dint), tmp_fmol -> multi, fp) != tmp_fmol -> multi) return ERROR_RW;
278 }
279
280 if (fread (& tmp_fmol -> atoms, sizeof(int), 1, fp) != 1) return ERROR_RW;
281 tmp_fmol -> first_atom = g_malloc0(sizeof*tmp_fmol -> first_atom);
282 tmp_fat = tmp_fmol -> first_atom;
283 for (i=0; i<tmp_fmol -> atoms; i++)
284 {
285 if (read_field_atom(fp) != OK) return ERROR_RW;
286 if (i < tmp_fmol -> atoms-1)
287 {
288 tmp_fat -> next = g_malloc0(sizeof*tmp_fat -> next);
289 tmp_fat = tmp_fat -> next;
290 }
291 }
292
293 if (fread (& tmp_fmol -> shells, sizeof(int), 1, fp) != 1) return ERROR_RW;
294 if (tmp_fmol -> shells)
295 {
296 tmp_fmol -> first_shell = g_malloc0(sizeof*tmp_fmol -> first_shell);
297 tmp_fshell = tmp_fmol -> first_shell;
298 for (i=0; i<tmp_fmol -> shells; i++)
299 {
300 if (read_field_shell(fp) != OK) return ERROR_RW;
301 if (i < tmp_fmol -> shells - 1)
302 {
303 tmp_fshell -> next = g_malloc0(sizeof*tmp_fshell -> next);
304 tmp_fshell = tmp_fshell -> next;
305 }
306 }
307 }
308
309 if (fread (& tmp_fmol -> constraints, sizeof(int), 1, fp) != 1) return ERROR_RW;
310 if (tmp_fmol -> constraints)
311 {
312 tmp_fmol -> first_constraint = g_malloc0(sizeof*tmp_fmol -> first_constraint);
313 tmp_fcons = tmp_fmol -> first_constraint;
314 for (i=0; i<tmp_fmol -> constraints; i++)
315 {
316 if (read_field_constraint(fp) != OK) return ERROR_RW;
317 if (i < tmp_fmol -> constraints - 1)
318 {
319 tmp_fcons -> next = g_malloc0(sizeof*tmp_fcons -> next);
320 tmp_fcons = tmp_fcons -> next;
321 }
322 }
323 }
324
325 if (fread (& tmp_fmol -> pmfs, sizeof(int), 1, fp) != 1) return ERROR_RW;
326 if (tmp_fmol -> pmfs)
327 {
328 tmp_fmol -> first_pmf = g_malloc0(sizeof*tmp_fmol -> first_pmf);
329 tmp_fpmf = tmp_fmol -> first_pmf;
330 for (i=0; i<tmp_fmol -> pmfs; i++)
331 {
332 if (read_field_pmf(fp) != OK) return ERROR_RW;
333 if (i < tmp_fmol -> pmfs - 1)
334 {
335 tmp_fpmf -> next = g_malloc0(sizeof*tmp_fpmf -> next);
336 tmp_fpmf = tmp_fpmf -> next;
337 }
338 }
339 }
340
341 if (fread (& tmp_fmol -> rigids, sizeof(int), 1, fp) != 1) return ERROR_RW;
342 if (tmp_fmol -> rigids)
343 {
344 tmp_fmol -> first_rigid = g_malloc0(sizeof*tmp_fmol -> first_rigid);
345 tmp_frig = tmp_fmol -> first_rigid;
346 for (i=0; i<tmp_fmol -> rigids; i++)
347 {
348 if (read_field_rigid(fp) != OK) return ERROR_RW;
349 if (i < tmp_fmol -> rigids - 1)
350 {
351 tmp_frig -> next = g_malloc0(sizeof*tmp_frig -> next);
352 tmp_frig = tmp_frig -> next;
353 }
354 }
355 }
356
357 if (fread (& tmp_fmol -> tethered, sizeof(int), 1, fp) != 1) return ERROR_RW;
358 if (tmp_fmol -> tethered)
359 {
360 tmp_fmol -> first_tethered = g_malloc0(sizeof*tmp_fmol -> first_tethered);
361 tmp_ftet = tmp_fmol -> first_tethered;
362 for (i=0; i<tmp_fmol -> tethered; i++)
363 {
364 if (read_field_tethered(fp, fid) != OK) return ERROR_RW;
365 if (i < tmp_fmol -> tethered - 1)
366 {
367 tmp_ftet -> next = g_malloc0(sizeof*tmp_ftet -> next);
368 tmp_ftet = tmp_ftet -> next;
369 }
370 }
371 }
372
373 if (fread (tmp_fmol -> nstruct, sizeof(int), 8, fp) != 8) return ERROR_RW;
374 for (i=0; i<8; i++)
375 {
376 if (tmp_fmol -> nstruct[i])
377 {
378 tmp_fmol -> first_struct[i] = g_malloc0(sizeof*tmp_fmol -> first_struct[i]);
379 tmp_fstr = tmp_fmol -> first_struct[i];
380 for (j=0; j<tmp_fmol -> nstruct[i]; j++)
381 {
382 if (read_field_struct (fp, fid) != OK) return ERROR_RW;
383 if (j < tmp_fmol -> nstruct[i]-1)
384 {
385 tmp_fstr -> next = g_malloc0(sizeof*tmp_fstr -> next);
386 tmp_fstr = tmp_fstr -> next;
387 }
388 }
389 }
390 }
391 return OK;
392}
393
402int read_field_body (FILE * fp, int fid)
403{
404 if (fread (& tmp_fbody -> bd, sizeof(int), 1, fp) != 1) return ERROR_RW;
405 if (fread (& tmp_fbody -> id, sizeof(int), 1, fp) != 1) return ERROR_RW;
406 if (fread (& tmp_fbody -> key, sizeof(int), 1, fp) != 1) return ERROR_RW;
407 if (tmp_fbody -> bd == 0)
408 {
409 tmp_fbody -> fpid = allocint (2);
410 if (fread (tmp_fbody -> fpid, sizeof(int), 2, fp) != 2) return ERROR_RW;
411 }
412 int i, j;
413 i = body_at(tmp_fbody -> bd);
414 tmp_fbody -> na = allocint(i);
415 if (fread (tmp_fbody -> na, sizeof(int), i, fp) != i) return ERROR_RW;
416 tmp_fbody -> ma = g_malloc0(i*sizeof*tmp_fbody -> ma);
417 tmp_fbody -> a = g_malloc0(i*sizeof*tmp_fbody -> a);
418 for (j=0; j<i; j++)
419 {
420 tmp_fbody -> ma[j] = allocint(tmp_fbody -> na[j]);
421 if (fread (tmp_fbody -> ma[j], sizeof(int), tmp_fbody -> na[j], fp) != tmp_fbody -> na[j]) return ERROR_RW;
422 tmp_fbody -> a[j] = allocint(tmp_fbody -> na[j]);
423 if (fread (tmp_fbody -> a[j], sizeof(int), tmp_fbody -> na[j], fp) != tmp_fbody -> na[j]) return ERROR_RW;
424 }
425 i = fvalues[fid][9+tmp_fbody -> bd][tmp_fbody -> key];
426 tmp_fbody -> val = allocfloat(i);
427 if (fread (tmp_fbody -> val, sizeof(float), i, fp) != i) return ERROR_RW;
428 if (fread (& tmp_fbody -> show, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
429 if (fread (& tmp_fbody -> use, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
430 return OK;
431}
432
441int read_field_external (FILE * fp, int fid)
442{
443 if (fread (& tmp_fext -> id, sizeof(int), 1, fp) != 1) return ERROR_RW;
444 if (fread (& tmp_fext -> key, sizeof(int), 1, fp) != 1) return ERROR_RW;
445 int i = fvalues[fid][14][tmp_fext -> key];
446 tmp_fext -> val = allocfloat(i);
447 if (fread (tmp_fext -> val, sizeof(float), i, fp) != i) return ERROR_RW;
448 if (fread (& tmp_fext -> use, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
449 return OK;
450}
451
460int read_dlp_field_data (FILE * fp, project * this_proj)
461{
462 int i, j, k, l, m, n;
463 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
464 if (! i) return OK;
465 this_proj -> force_field[0] = g_malloc0(sizeof*this_proj -> force_field[0]);
466 // Allocate force field data
467 this_proj -> force_field[0] -> sys_opts = allocdouble (17);
468 this_proj -> force_field[0] -> io_opts = allocdouble (23);
469 this_proj -> force_field[0] -> ana_opts = allocdouble (17);
470 this_proj -> force_field[0] -> elec_opts = allocdouble (11);
471 this_proj -> force_field[0] -> vdw_opts = allocdouble (6);
472 this_proj -> force_field[0] -> met_opts = allocdouble (2);
473 this_proj -> force_field[0] -> equi_opts = allocdouble (17);
474 this_proj -> force_field[0] -> thermo_opts= allocdouble (10);
475 this_proj -> force_field[0] -> md_opts = allocdouble (20);
476 this_proj -> force_field[0] -> out_opts = allocdouble (31);
477 // CONTROL file
478 if (fread (this_proj -> force_field[0] -> sys_opts, sizeof(double), 17, fp) != 17) return ERROR_RW;
479 if (fread (this_proj -> force_field[0] -> io_opts, sizeof(double), 23, fp) != 23) return ERROR_RW;
480 if (fread (this_proj -> force_field[0] -> ana_opts, sizeof(double), 17, fp) != 17) return ERROR_RW;
481 if (fread (this_proj -> force_field[0] -> elec_opts, sizeof(double), 11, fp) != 11) return ERROR_RW;
482 if (fread (this_proj -> force_field[0] -> vdw_opts, sizeof(double), 6, fp) != 6) return ERROR_RW;
483 if (fread (this_proj -> force_field[0] -> met_opts, sizeof(double), 2, fp) != 2) return ERROR_RW;
484 if (fread (this_proj -> force_field[0] -> equi_opts, sizeof(double), 17, fp) != 17) return ERROR_RW;
485 if (fread (& this_proj -> force_field[0] -> ensemble, sizeof(int), 1, fp) != 1) return ERROR_RW;
486 if (fread (& this_proj -> force_field[0] -> thermostat, sizeof(int), 1, fp) != 1) return ERROR_RW;
487 if (fread (this_proj -> force_field[0] -> thermo_opts, sizeof(double), 10, fp) != 10) return ERROR_RW;
488 if (fread (this_proj -> force_field[0] -> md_opts, sizeof(double), 20, fp) != 20) return ERROR_RW;
489 if (fread (this_proj -> force_field[0] -> out_opts, sizeof(double), 31, fp) != 31) return ERROR_RW;
490 // FIELD file
491 if (fread (this_proj -> force_field[0] -> prepare_file, sizeof(gboolean), 2, fp) != 2) return ERROR_RW;
492 if (fread (this_proj -> force_field[0] -> afp, sizeof(gboolean), MAXDATC+MAXDATA, fp) != MAXDATC+MAXDATA) return ERROR_RW;
493 if (fread (& this_proj -> force_field[0] -> type, sizeof(int), 1, fp) != 1) return ERROR_RW;
494 if (fread (& this_proj -> force_field[0] -> energy_unit, sizeof(int), 1, fp) != 1) return ERROR_RW;
495 if (fread (& this_proj -> force_field[0] -> atom_init, sizeof(int), 1, fp) != 1) return ERROR_RW;
496 if (fread (& this_proj -> force_field[0] -> molecules, sizeof(int), 1, fp) != 1) return ERROR_RW;
497 if (! this_proj -> force_field[0] -> molecules) return ERROR_RW;
498 this_proj -> force_field[0] -> first_molecule = g_malloc0(sizeof*this_proj -> force_field[0] -> first_molecule);
499 tmp_fmol = this_proj -> force_field[0] -> first_molecule;
500 for (i=0; i<this_proj -> force_field[0] -> molecules; i++)
501 {
502 if (read_field_molecule (fp, 0) != OK) return ERROR_RW;
503 // setup_field_molecule_neighbors (i, this_proj);
504 for (j=0; j<tmp_fmol -> mol -> natoms; j++)
505 {
506 for (k=0; k<tmp_fmol -> multi; k++)
507 {
508 l = tmp_fmol -> atoms_id[j][k].a;
509 m = tmp_fmol -> atoms_id[j][k].b;
510 tmp_fat = tmp_fmol -> first_atom;
511 while (tmp_fat -> id < l) tmp_fat = tmp_fat -> next;
512 n = tmp_fat -> list[m];
513 this_proj -> atoms[0][n].fid = j;
514 this_proj -> atoms[0][n].faid = l;
515 }
516 }
517 if (i < this_proj -> force_field[0] -> molecules-1)
518 {
519 tmp_fmol -> next = g_malloc0(sizeof*tmp_fmol -> next);
520 tmp_fmol = tmp_fmol -> next;
521 }
522 }
523 if (fread (this_proj -> force_field[0] -> nbody, sizeof(int), 5, fp) != 5) return ERROR_RW;
524 for (i=0; i<5; i++)
525 {
526 if (this_proj -> force_field[0] -> nbody[i])
527 {
528 this_proj -> force_field[0] -> first_body[i] = g_malloc0(sizeof*this_proj -> force_field[0] -> first_body[i]);
529 tmp_fbody = this_proj -> force_field[0] -> first_body[i];
530 for (j=0; j<this_proj -> force_field[0] -> nbody[i]; j++)
531 {
532 if (read_field_body (fp, 0) != OK) return ERROR_RW;
533 if (j < this_proj -> force_field[0] -> nbody[i]-1)
534 {
535 tmp_fbody -> next = g_malloc0(sizeof*tmp_fbody -> next);
536 tmp_fbody = tmp_fbody -> next;
537 }
538 }
539 }
540 }
541 // Tersoff potential cross terms
542 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
543 if (i)
544 {
545 j = this_proj -> force_field[0] -> nbody[2] * (this_proj -> force_field[0] -> nbody[2] - 1) / 2;
546 this_proj -> force_field[0] -> cross = g_malloc0(j*sizeof*this_proj -> force_field[0] -> cross);
547 for (k=0; k<j; k++)
548 {
549 this_proj -> force_field[0] -> cross[k] = g_malloc0(3*sizeof*this_proj -> force_field[0] -> cross[k]);
550 if (fread (& this_proj -> force_field[0] -> cross[k], sizeof(double), 3, fp) != 3) return ERROR_RW;
551 }
552 }
553 if (fread (& this_proj -> force_field[0] -> extern_fields, sizeof(int), 1, fp) != 1) return ERROR_RW;
554 if (this_proj -> force_field[0] -> extern_fields)
555 {
556 this_proj -> force_field[0] -> first_external = g_malloc0(sizeof*this_proj -> force_field[0] -> first_external);
557 tmp_fext = this_proj -> force_field[0] -> first_external;
558 for (i=0; i<this_proj -> force_field[0] -> extern_fields; i++)
559 {
560 if (read_field_external(fp, 0) != OK) return ERROR_RW;
561 if (i < this_proj -> force_field[0] -> extern_fields-1)
562 {
563 tmp_fext -> next = g_malloc0(sizeof*tmp_fext -> next);
564 tmp_fext = tmp_fext -> next;
565 }
566 }
567 }
568 return OK;
569}
570
579int read_lmp_field_data (FILE * fp, project * this_proj)
580{
581 int i;
582 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
583 if (! i) return OK;
584 return OK;
585}
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:959
int fvalues[2][15][21]
Definition dlp_field.c:255
field_nth_body * tmp_fbody
Definition dlp_field.c:965
field_shell * tmp_fshell
Definition dlp_field.c:958
field_rigid * tmp_frig
Definition dlp_field.c:961
int body_at(int b)
find the number of atom(s) in a non bonded interaction
Definition dlp_field.c:1022
field_pmf * tmp_fpmf
Definition dlp_field.c:960
field_external * tmp_fext
Definition dlp_field.c:967
field_atom * tmp_fat
Definition dlp_field.c:957
int struct_id(int f)
number of atoms in a structural element
Definition dlp_field.c:999
field_struct * tmp_fstr
Definition dlp_field.c:964
field_molecule * tmp_fmol
Definition dlp_field.c:955
int atom_init
Definition dlp_field.c:950
field_prop * tmp_fprop
Definition dlp_field.c:963
field_tethered * tmp_ftet
Definition dlp_field.c:962
Variable declarations for the creation of the DL_POLY input file(s)
gboolean afp[MAXDATA]
int multi
Definition dlp_init.c:121
FILE * fp
gboolean * allocbool(int val)
allocate a gboolean * pointer
Definition global.c:266
double * allocdouble(int val)
allocate a double * pointer
Definition global.c:471
int * allocint(int val)
allocate an int * pointer
Definition global.c:326
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:410
Global variable declarations Global convenience function declarations Global data structure defin...
#define ERROR_RW
Definition global.h:252
#define OK
Definition global.h:251
#define MAXDATC
Number of tabs for the description of the classical calculation.
Definition global.h:657
#define MAXDATA
Number of tabs for the description of the classical force field.
Definition global.h:662
project * active_project
Definition project.c:47
integer(kind=c_int) function molecules(frag_and_mol, allbonds)
double z
Definition ogl_draw.c:57
gchar * read_this_string(FILE *fp)
is there a string to read in this file ? yes do it
Definition open_p.c:95
Function declarations for reading atomes project file Function declarations for saving atomes proje...
int read_dlp_field_data(FILE *fp, project *this_proj)
read force field data from file
Definition read_field.c:460
int read_field_molecule(FILE *fp, int fid)
read field molecule from file
Definition read_field.c:259
int read_field_external(FILE *fp, int fid)
read field external data from file
Definition read_field.c:441
int read_field_struct(FILE *fp, int fid)
read field structural properties from file
Definition read_field.c:220
int read_field_atom(FILE *fp)
read field atom properties from file
Definition read_field.c:60
int read_field_shell(FILE *fp)
read field core shell data from file
Definition read_field.c:90
int read_field_rigid(FILE *fp)
read field rigid constraints data from file
Definition read_field.c:155
int read_field_pmf(FILE *fp)
read field mean force potential data from file
Definition read_field.c:129
int read_field_body(FILE *fp, int fid)
read field nth body data from file
Definition read_field.c:402
int read_lmp_field_data(FILE *fp, project *this_proj)
read LAMMPS field data from file
Definition read_field.c:579
int read_field_constraint(FILE *fp)
read field constraint data from file
Definition read_field.c:111
int read_field_tethered(FILE *fp, int fid)
read field tethered data from file
Definition read_field.c:174
int read_field_prop(FILE *fp, int fid, int pid)
read field property from file
Definition read_field.c:196
Definition global.h:91
int a
Definition tab-1.c:95