atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
dlp_comp.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: 'dlp_comp.c'
24*
25* Contains:
26*
27
28 - The functions to compare and adjust field body parameters
29
30*
31* List of functions:
32
33 void compare_body (gchar * fatom, field_nth_body * new_body, int n_body, field_nth_body * old_body, int o_body);
34 void compare_non_bonded (gchar * fatom);
35
36*/
37
38#include "global.h"
39#include "interface.h"
40#include "glwindow.h"
41#include "glview.h"
42#include "dlp_field.h"
43
45
46extern void duplicate_nbody_params (field_nth_body * new_fbody, field_nth_body * old_fbody);
47
59void compare_body (gchar * fatom, field_nth_body * new_body, int n_body, field_nth_body * old_body, int o_body)
60{
61 int i, j, k, l, m, n, o, p;
62 field_nth_body * tmp_new = new_body;
63 field_nth_body * tmp_old;
64 field_nth_body * new_guy;
65 field_nth_body * old_one;
66 field_nth_body * new_one;
67 gboolean doit;
68
69 for (i=0; i<n_body; i++)
70 {
71 tmp_old = old_body;
72 for (j=0; j<o_body; j++)
73 {
74 doit = FALSE;
75 if (g_strcmp0 (fatom, get_active_atom (tmp_new -> ma[0][0], tmp_new -> a[0][0]) -> name) == 0 &&
76 g_strcmp0 (fatom, get_active_atom (tmp_new -> ma[1][0], tmp_new -> a[1][0]) -> name) == 0) new_guy = tmp_new;
77 for (k=0; k<2; k++)
78 {
79 for (l=0; l<2; l++)
80 {
81 if (g_strcmp0 (get_active_atom (tmp_new -> ma[k][0], tmp_new -> a[k][0]) -> name, get_active_atom (tmp_old -> ma[l][0], tmp_old -> a[l][0]) -> name) == 0) doit = TRUE;
82 if (doit) break;
83 }
84 if (g_strcmp0 (get_active_atom (tmp_new -> ma[k][0], tmp_new -> a[k][0]) -> name, get_active_atom (tmp_old -> ma[k][0], tmp_old -> a[k][0]) -> name) == 0) doit = TRUE;
85 if (doit) break;
86 }
87 // Same atoms copy the body params
88 if (doit) duplicate_nbody_params (tmp_new, tmp_old);
89 if (tmp_old -> next != NULL) tmp_old = tmp_old -> next;
90 }
91 if (tmp_new -> next != NULL) tmp_new = tmp_new -> next;
92 }
93
94 for (i=1; i<5; i++)
95 {
96 tmp_fbody = tmp_field -> first_body[i];
97 k = body_at (i);
98 new_one = get_active_body (tmp_field -> nbody[i], i);
99 m = 0;
100 for (j=0; j<tmp_field -> nbody[i]; j++)
101 {
102 for (l=0; l<k; l++)
103 {
104 if (tmp_fbody -> na[l] > 0)
105 {
106 doit = FALSE;
107 for (n=0; n<tmp_fbody -> na[l]; n++)
108 {
109 if (g_strcmp0 (get_active_atom (tmp_fbody -> ma[l][n], tmp_fbody -> a[l][n]) -> name, fatom) == 0)
110 {
111 doit = TRUE;
112 o = n;
113 break;
114 }
115 }
116 if (doit)
117 {
118 if (tmp_fbody -> na[l] > 1)
119 {
120 // Add new nth_body
121 new_one -> next = duplicate_field_nth_body (tmp_fbody);
123 new_one -> next -> prev = new_one;
124 new_one = new_one -> next;
125 new_one -> id ++;
126 new_one -> na[l] = new_guy -> na[0];
127 new_one -> a[l] = duplicate_int (new_guy -> na[0], new_guy -> a[0]);
128 new_one -> ma[l] = duplicate_int (new_guy -> na[0], new_guy -> ma[0]);
129 p = 0;
130 old_one -> na[l] --;
131 old_one -> a[l] = NULL;
132 old_one -> a[l] = g_malloc (old_one -> na[l]*sizeof*old_one -> a[l]);
133 old_one -> ma[l] = NULL;
134 old_one -> ma[l] = g_malloc (old_one -> na[l]*sizeof*old_one -> ma[l]);
135 for (n=0; n<tmp_fbody -> na[l]; n++)
136 {
137 if (n != o)
138 {
139 old_one -> a[l][p] = tmp_fbody -> a[l][n];
140 old_one -> ma[l][p] = tmp_fbody -> ma[l][n];
141 }
142 }
143 tmp_fbody -> a[l] = NULL;
144 tmp_fbody -> ma[l] = NULL;
145 tmp_fbody -> na[l] --;
146 tmp_fbody -> a[l] = duplicate_int (tmp_fbody -> na[l], old_one -> a[l]);
147 tmp_fbody -> ma[l] = duplicate_int (tmp_fbody -> na[l], old_one -> ma[l]);
148 m ++;
149 }
150 else if (tmp_fbody -> na[l] == 1)
151 {
152 tmp_fbody -> a[l][0] = new_guy -> a[0][0];
153 tmp_fbody -> ma[l][0] = new_guy -> ma[0][0];
154 }
155 }
156 }
157 }
158 if (tmp_fbody -> next != NULL) tmp_fbody = tmp_fbody -> next;
159 }
160 tmp_field -> nbody[i] += m;
161 }
162
163 tmp_field -> first_body[0] = NULL;
164 tmp_field -> first_body[0] = duplicate_field_nth_body (new_body);
165 tmp_new = tmp_field -> first_body[0];
166 tmp_old = new_body;
167 for (i=1; i<n_body; i++)
168 {
169 tmp_new -> next = duplicate_field_nth_body (tmp_old -> next);
170 tmp_new -> next -> prev = tmp_new;
171 tmp_new = tmp_new -> next;
172 tmp_old = tmp_old -> next;
173 }
174 tmp_field -> nbody[0] = n_body;
175}
176
184void compare_non_bonded (gchar * fatom)
185{
186 int nbody = init_vdw (FALSE);
187 // comp_fbody is prepared in init_vdw
188 compare_body (fatom, comp_fbody, nbody, tmp_field -> first_body[0], tmp_field -> nbody[0]);
189}
field_atom * get_active_atom(int a, int b)
retrieve field atom
Definition dlp_active.c:145
field_nth_body * get_active_body(int a, int b)
retrieve field nth body interaction
Definition dlp_active.c:106
void duplicate_nbody_params(field_nth_body *new_fbody, field_nth_body *old_fbody)
copy field body parameter list
Definition dlp_copy.c:350
void compare_body(gchar *fatom, field_nth_body *new_body, int n_body, field_nth_body *old_body, int o_body)
compare, and if require ajdust, two lists of field body properties
Definition dlp_comp.c:59
void compare_non_bonded(gchar *fatom)
compare non bond interaction parameters
Definition dlp_comp.c:184
field_nth_body * comp_fbody
Definition dlp_comp.c:44
field_nth_body * duplicate_field_nth_body(field_nth_body *old_fbody)
create copy of a field body property
Definition dlp_copy.c:365
field_nth_body * tmp_fbody
Definition dlp_field.c:965
int body_at(int b)
find the number of atom(s) in a non bonded interaction
Definition dlp_field.c:1022
classical_field * tmp_field
Definition dlp_field.c:951
field_nth_body * new_body
Definition dlp_field.c:966
Variable declarations for the creation of the DL_POLY input file(s)
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:572
int init_vdw(gboolean init)
initialize the VdW section of a classical force field
Definition dlp_init.c:2299
Global variable declarations Global convenience function declarations Global data structure defin...
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
Function declarations for the creation of the OpenGL window.
Messaging function declarations.
int a
Definition tab-1.c:95