Repository navigation
Expand file tree
/
Copy pathsystem.h
More file actions
634 lines (531 loc) · 11.2 KB
/
Copy pathsystem.h
File metadata and controls
634 lines (531 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
#ifndef __SYSTEM_H__
#define __SYSTEM_H__
#define __PROFILING__
//#define DEBUG
#define VERBOSE
// Boltzano's constant
#define Boltz 0.001986
// Fortran max allowed line width, used in neighbor list
#define line_width 25
// Internally used time unit because of ??
#define time_unit 0.020462
// Protein boundary force constant.
// TODO get force constant from md.inp
#define k_pshell 10.0
// Fixed proteins force constant.
#define k_fix 200.0
// Ratio of restrained protein shell that is free, rest is restrained. Has a default of 0.85
// TODO: get from md.inp
#define shell_default 0.85
// Definition of water shells
#define wpolr_layer 3.0001
#define drouter 0.5
// Number density of water in A measure
#define rho_water 0.0335
// Once per how many steps theta_corr should be updated
#define itdis_update 100
// Shake convergence criterion (fraction of distance)
#define shake_tol 0.0001
#define shake_max_iter 1000
void init_variables();
void clean_variables();
/* =============================================
* == DEVICE SETTINGS
* =============================================
*/
// Thread block size
#define BLOCK_SIZE 8
/* =============================================
* == GENERAL
* =============================================
*/
extern int n_atoms;
extern int n_atoms_solute;
extern int n_patoms;
extern int n_qatoms;
extern int n_waters;
extern int n_molecules;
extern char base_folder[1024];
extern double dt;
extern bool run_gpu;
/* =============================================
* == FROM MD FILE
* =============================================
*/
struct md_t {
// [MD]
int steps;
double stepsize;
double temperature;
char thermostat[40];
double bath_coupling;
int random_seed;
double initial_temperature;
bool shake_solvent;
bool shake_solute;
bool shake_hydrogens;
bool lrf;
bool charge_groups;
// [cut-offs]
double solute_solute;
double solvent_solvent;
double solute_solvent;
double q_atom;
// [sphere]
double shell_radius; // Note: this is for the pshell
double shell_force; // Note: this is for the pshell
// [solvent]
double radial_force;
bool polarisation;
double polarisation_force;
// [intervals]
int non_bond;
int output;
int energy;
int trajectory;
// [trajectory_atoms]
// [lambdas]
// [sequence_restraints]
// [distance_restraints]
// [angle_restraints]
// [wall_restraints]
};
extern md_t md;
extern bool separate_scaling;
/* =============================================
* == FROM TOPOLOGY FILE
* =============================================
*/
struct coord_t {
double x;
double y;
double z;
};
struct bond_t {
int ai;
int aj;
int code;
};
struct cbond_t {
int code;
double kb;
double b0;
};
struct angle_t {
int ai;
int aj;
int ak;
int code;
};
struct cangle_t {
int code;
double kth;
double th0;
};
struct torsion_t {
int ai;
int aj;
int ak;
int al;
int code;
};
struct ctorsion_t {
int code;
double k;
double n;
double d;
};
struct improper_t {
int ai;
int aj;
int ak;
int al;
int code;
};
struct cimproper_t {
int code;
double k;
double phi0;
};
struct charge_t {
int a;
int code;
};
struct ccharge_t {
int code;
double charge;
};
struct atype_t {
int a;
int code;
};
struct catype_t {
int code;
double m;
double aii_normal;
double bii_normal;
double aii_polar;
double bii_polar;
double aii_1_4;
double bii_1_4;
};
struct topo_t {
int solvent_type;
double exclusion_radius;
double solvent_radius;
coord_t solute_center;
coord_t solvent_center;
double el14_scale;
double coulomb_constant;
};
struct cgrp_t {
int n_atoms;
int iswitch;
int *a;
};
extern topo_t topo;
extern int n_angles;
extern int n_angles_solute;
extern int n_atypes;
extern int n_bonds;
extern int n_bonds_solute;
extern int n_cangles;
extern int n_catypes;
extern int n_cbonds;
extern int n_ccharges;
extern int n_charges;
extern int n_coords;
extern int n_cimpropers;
extern int n_ctorsions;
extern int n_excluded;
extern int n_impropers;
extern int n_impropers_solute;
extern int n_torsions;
extern int n_torsions_solute;
extern int n_excluded;
extern int n_cgrps_solute;
extern int n_cgrps_solvent;
extern angle_t *angles;
extern atype_t *atypes;
extern bond_t *bonds;
extern cangle_t *cangles;
extern catype_t *catypes;
extern cbond_t *cbonds;
extern charge_t *charges;
extern ccharge_t *ccharges;
extern cimproper_t *cimpropers;
extern ctorsion_t *ctorsions;
extern coord_t *coords_top;
extern coord_t *xcoords;
extern improper_t *impropers;
extern int *LJ_matrix;
extern torsion_t *torsions;
extern bool *excluded;
extern bool *heavy;
extern double *winv;
extern cgrp_t *charge_groups;
extern int *molecules;
/* =============================================
* == FROM FEP FILE
* =============================================
*/
extern int n_lambdas;
extern double *lambdas;
struct q_angcouple_t {
int acode;
int bcode;
};
struct q_angle_t {
int ai;
int aj;
int ak;
int code;
};
struct q_atom_t {
int a;
};
struct q_atype_t {
int code;
};
struct q_bond_t {
int ai;
int aj;
int code;
};
struct q_cangle_t {
double kth;
double th0;
};
struct q_catype_t {
char name[10];
double Ai;
double Bi;
double Ci;
double ai;
double Ai_14;
double Bi_14;
double m;
};
struct q_cbond_t {
double kb;
double b0;
};
struct q_charge_t {
double q;
};
struct q_cimproper_t {
double k;
double phi0;
};
struct q_ctorsion_t {
double k;
double n;
double d;
};
struct q_elscale_t {
int qi;
int qj;
double mu;
};
struct q_exclpair_t {
int ai;
int aj;
int excl;
};
struct q_imprcouple_t {
int icode;
int bcode;
};
struct q_improper_t {
int ai;
int aj;
int ak;
int al;
int code;
};
struct q_offdiag_t {
int i;
int j;
int qk;
int ql;
double Aij;
double muij;
};
struct q_shake_t {
int ai;
int aj;
double dist;
};
struct q_softcore_t {
double s;
};
struct q_softpair_t {
int qi;
int qj;
};
struct q_torcouple_t {
int tcode;
int bcode;
};
struct q_torsion_t {
int ai;
int aj;
int ak;
int al;
int code;
};
extern int n_qangcouples;
extern int n_qangles;
extern int n_qbonds;
extern int n_qcangles;
extern int n_qcatypes;
extern int n_qcbonds;
extern int n_qcimpropers;
extern int n_qctorsions;
extern int n_qelscales;
extern int n_qexclpairs;
extern int n_qimprcouples;
extern int n_qimpropers;
extern int n_qoffdiags;
extern int n_qshakes;
extern int n_qsoftcores;
extern int n_qsoftpairs;
extern int n_qtorcouples;
extern int n_qtorsions;
extern q_angcouple_t *q_angcouples;
extern q_atom_t *q_atoms;
extern q_cangle_t *q_cangles;
extern q_catype_t *q_catypes;
extern q_cbond_t *q_cbonds;
extern q_cimproper_t *q_cimpropers;
extern q_ctorsion_t *q_ctorsions;
extern q_offdiag_t *q_offdiags;
extern q_imprcouple_t *q_imprcouples;
extern q_softpair_t *q_softpairs;
extern q_torcouple_t *q_torcouples;
// NB. Arrays below are 2-dimensional!
extern q_angle_t *q_angles;
extern q_atype_t *q_atypes;
extern q_bond_t *q_bonds;
extern q_charge_t *q_charges;
extern q_elscale_t *q_elscales;
extern q_exclpair_t *q_exclpairs;
extern q_improper_t *q_impropers;
extern q_shake_t *q_shakes;
extern q_softcore_t *q_softcores;
extern q_torsion_t *q_torsions;
/* =============================================
* == RESTRAINTS
* =============================================
*/
struct restrseq_t {
int ai;
int aj;
double k;
bool ih;
int to_center; // Flag for restraining to geom. or mass center
};
struct restrpos_t {
int a;
int ipsi;
coord_t x;
coord_t k;
};
struct restrdis_t {
int ai, aj;
int ipsi;
double d1, d2;
double k;
char itext[20], jtext[20];
};
struct restrang_t {
int ai, aj, ak;
int ipsi;
double ang;
double k;
};
struct restrwall_t {
int ai, aj;
double d, k, aMorse, dMorse;
bool ih;
};
extern int n_restrseqs;
extern int n_restrspos;
extern int n_restrdists;
extern int n_restrangs;
extern int n_restrwalls;
extern restrseq_t *restrseqs;
extern restrpos_t *restrspos;
extern restrdis_t *restrdists;
extern restrang_t *restrangs;
extern restrwall_t *restrwalls;
// Protein shell layout. Defined once per run
extern bool *shell;
void init_pshells();
void init_restrseqs(char* filename);
struct shell_t {
int n_inshell;
double theta_corr;
double avtheta;
double avn_inshell;
double router;
double dr;
double cstb;
};
// Total energy in the system. Defined once per run
extern double crgQtot;
extern double Dwmz, awmz;
// Water shell layout. Defined once per run
extern double *theta, *theta0, *tdum; //array size n_waters
extern int n_max_inshell, n_shells;
extern int **list_sh, **nsort; // array size (n_max_inshell, n_shells)
extern shell_t* wshells;
void init_water_sphere();
void init_wshells();
/* =============================================
* == SHAKE
* =============================================
*/
struct shake_bond_t {
int ai;
int aj;
double dist2;
bool ready;
};
extern int n_shake_constraints, *mol_n_shakes;
extern shake_bond_t *shake_bonds;
void init_shake();
/* =============================================
* == CALCUTED IN THE INTEGRATION
* =============================================
*/
struct p_atom_t {
int a;
};
struct vel_t {
double x;
double y;
double z;
};
struct dvel_t {
double x;
double y;
double z;
};
struct E_bonded_t {
double Ubond;
double Uangle;
double Utor;
double Uimp;
};
struct E_nonbonded_t {
double Ucoul;
double Uvdw;
};
struct E_restraint_t {
double Uradx;
double Upolx;
double Ufix;
double Ushell;
double Upres;
double Urestr;
};
struct energy_t {
double Ukin;
double Upot;
double Utot;
};
extern p_atom_t *p_atoms;
extern coord_t *coords;
extern vel_t* velocities;
extern dvel_t* dvelocities;
extern energy_t E_total;
extern energy_t *EQ_total;
extern E_bonded_t E_bond_p, E_bond_w, E_bond_q, *EQ_bond;
extern E_nonbonded_t E_nonbond_pp, E_nonbond_pw, E_nonbond_ww, E_nonbond_qx;
extern E_nonbonded_t *EQ_nonbond_qq, *EQ_nonbond_qp, *EQ_nonbond_qw, *EQ_nonbond_qx;
extern E_restraint_t E_restraint, *EQ_restraint;
extern double Temp, Tfree, Texcl;
extern double A_O, A_OO, B_O, B_OO, crg_ow, crg_hw; // TODO: don't keep this in system.cu?
void init_velocities();
void init_dvelocities();
void init_energies();
/* =============================================
* == ENERGY & TEMPERATURE
* =============================================
*/
extern double Ndegf, Ndegfree, Ndegf_solvent, Ndegf_solute, Ndegfree_solvent, Ndegfree_solute;
void calc_temperature();
/* =============================================
* == INTEGRATION METHODS
* =============================================
*/
void init_variables();
void clean_variables();
void write_header(const char *filename);
void write_coords(int iteration);
void write_velocities(int iteration);
void write_energies(int iteration);
void calc_integration();
void calc_integration_step(int iteration);
#endif /* __SYSTEM_H__ */