-
Notifications
You must be signed in to change notification settings - Fork 1
/
forces.h
637 lines (587 loc) · 18.8 KB
/
forces.h
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
635
636
637
// This file is part of the ESPResSo distribution (http://www.espresso.mpg.de).
// It is therefore subject to the ESPResSo license agreement which you accepted upon receiving the distribution
// and by which you are legally bound while utilizing this file in any form or way.
// There is NO WARRANTY, not even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// You should have received a copy of that license along with this program;
// if not, refer to http://www.espresso.mpg.de/license.html where its current version can be found, or
// write to Max-Planck-Institute for Polymer Research, Theory Group, PO Box 3148, 55021 Mainz, Germany.
// Copyright (c) 2002-2009; all rights reserved unless otherwise stated.
#ifndef FORCES_H
#define FORCES_H
/** \file forces.h Force calculation.
*
* \todo Preprocessor switches for all forces (Default: everything is turned on).
* \todo Implement more flexible thermostat, %e.g. which thermostat to use.
*
* For more information see forces.c .
*/
#include <tcl.h>
#include "utils.h"
#include "thermostat.h"
#include "communication.h"
#ifdef MOLFORCES
#include "topology.h"
#endif
#include "npt.h"
#include "adresso.h"
#include "virtual_sites.h"
#include "metadynamics.h"
/* include the force files */
#include "p3m.h"
#include "ewald.h"
#include "lj.h"
#include "ljgen.h"
#include "steppot.h"
#include "hertzian.h"
#include "bmhtf-nacl.h"
#include "buckingham.h"
#include "soft_sphere.h"
#include "maggs.h"
#include "tab.h"
#include "overlap.h"
#include "ljcos.h"
#include "ljcos2.h"
#include "ljangle.h"
#include "gb.h"
#include "fene.h"
#include "harmonic.h"
#include "subt_lj.h"
#include "angle.h"
#include "angledist.h"
#include "dihedral.h"
#include "debye_hueckel.h"
#include "endangledist.h"
#include "reaction_field.h"
#include "mmm1d.h"
#include "mmm2d.h"
#include "comforce.h"
#include "comfixed.h"
#include "molforces.h"
#include "morse.h"
#include "elc.h"
/* end of force files */
/** \name Exported Functions */
/************************************************************/
/*@{*/
/** Calculate forces.
*
* A short list, what the function is doing:
* <ol>
* <li> Initialize forces with: \ref friction_thermo_langevin (ghost forces with zero).
* <li> Calculate \ref tcl_bonded "bonded interaction" forces:<br>
* Loop all local particles (not the ghosts).
* <ul>
* <li> FENE
* <li> ANGLE (cos bend potential)
* </ul>
* <li> Calculate \ref tcl_non_bonded "non-bonded short range interaction" forces:<br>
* Loop all \ref IA_Neighbor::vList "verlet lists" of all \ref #cells.
* <ul>
* <li> Lennard-Jones.
* <li> Buckingham.
* <li> Real space part: Coulomb.
* <li> Ramp.
* </ul>
* <li> Calculate long range interaction forces:<br>
Uses \ref P3M_calc_kspace_forces.
* </ol>
*/
void force_calc();
/** Set forces of all ghosts to zero
*/
void init_forces_ghosts();
MDINLINE void calc_non_bonded_pair_force_parts(Particle *p1, Particle *p2, IA_parameters *ia_params,double d[3],
double dist, double dist2, double force[3],double torgue1[3],double torgue2[3])
{
#ifdef NO_INTRA_NB
if (p1->p.mol_id==p2->p.mol_id) return;
#endif
/* lennard jones */
#ifdef LENNARD_JONES
add_lj_pair_force(p1,p2,ia_params,d,dist, force);
#endif
/* lennard jones generic */
#ifdef LENNARD_JONES_GENERIC
add_ljgen_pair_force(p1,p2,ia_params,d,dist, force);
#endif
/* Directional LJ */
#ifdef LJ_ANGLE
/* The forces are propagated within the function */
add_ljangle_pair_force(p1,p2,ia_params,d,dist);
#endif
/* smooth step */
#ifdef SMOOTH_STEP
add_SmSt_pair_force(p1,p2,ia_params,d,dist,dist2, force);
#endif
/* Hertzian force */
#ifdef HERTZIAN
add_hertzian_pair_force(p1,p2,ia_params,d,dist,dist2, force);
#endif
/* BMHTF NaCl */
#ifdef BMHTF_NACL
add_BMHTF_pair_force(p1,p2,ia_params,d,dist,dist2, force);
#endif
/* buckingham*/
#ifdef BUCKINGHAM
add_buck_pair_force(p1,p2,ia_params,d,dist,force);
#endif
/* morse*/
#ifdef MORSE
add_morse_pair_force(p1,p2,ia_params,d,dist,force);
#endif
/*soft-sphere potential*/
#ifdef SOFT_SPHERE
add_soft_pair_force(p1,p2,ia_params,d,dist,force);
#endif
/* lennard jones cosine */
#ifdef LJCOS
add_ljcos_pair_force(p1,p2,ia_params,d,dist,force);
#endif
/* lennard jones cosine */
#ifdef LJCOS2
add_ljcos2_pair_force(p1,p2,ia_params,d,dist,force);
#endif
/* tabulated */
#ifdef TABULATED
add_tabulated_pair_force(p1,p2,ia_params,d,dist,force);
#endif
/* Gay-Berne */
#ifdef GAY_BERNE
add_gb_pair_force(p1,p2,ia_params,d,dist,force,torgue1,torgue2);
#endif
#ifdef INTER_RF
add_interrf_pair_force(p1,p2,ia_params,d,dist, force);
#endif
#ifdef ADRESS
#ifdef INTERFACE_CORRECTION
add_adress_tab_pair_force(p1,p2,ia_params,d,dist,force);
#endif
#endif
}
MDINLINE void calc_non_bonded_pair_force(Particle *p1,Particle *p2,IA_parameters *ia_params,double d[3],double dist,double dist2,double force[3],double t1[3],double t2[3]){
#ifdef MOL_CUT
//You may want to put a correction factor and correction term for smoothing function else then theta
if (checkIfParticlesInteractViaMolCut(p1,p2,ia_params)==1)
#endif
{
calc_non_bonded_pair_force_parts(p1, p2, ia_params,d, dist, dist2,force,t1,t2);
}
}
MDINLINE void calc_non_bonded_pair_force_simple(Particle *p1,Particle *p2,double d[3],double dist,double dist2,double force[3]){
IA_parameters *ia_params = get_ia_param(p1->p.type,p2->p.type);
double t1[3],t2[3];
#ifdef ADRESS
int j;
double force_weight=adress_non_bonded_force_weight(p1,p2);
if (force_weight<ROUND_ERROR_PREC) return;
#endif
calc_non_bonded_pair_force(p1,p2,ia_params,d,dist,dist2,force,t1,t2);
#ifdef ADRESS
for (j=0;j<3;j++){
force[j]*=force_weight;
}
#endif
}
MDINLINE void calc_non_bonded_pair_force_from_partcfg(Particle *p1,Particle *p2,IA_parameters *ia_params,double d[3],double dist,double dist2,double force[3],double t1[3],double t2[3]){
#ifdef MOL_CUT
//You may want to put a correction factor and correction term for smoothing function else then theta
if (checkIfParticlesInteractViaMolCut_partcfg(p1,p2,ia_params)==1)
#endif
{
calc_non_bonded_pair_force_parts(p1, p2, ia_params,d, dist, dist2,force,t1,t2);
}
}
MDINLINE void calc_non_bonded_pair_force_from_partcfg_simple(Particle *p1,Particle *p2,double d[3],double dist,double dist2,double force[3]){
IA_parameters *ia_params = get_ia_param(p1->p.type,p2->p.type);
double t1[3],t2[3];
calc_non_bonded_pair_force_from_partcfg(p1,p2,ia_params,d,dist,dist2,force,t1,t2);
}
/** Calculate non bonded forces between a pair of particles.
@param p1 pointer to particle 1.
@param p2 pointer to particle 2.
@param d vector between p1 and p2.
@param dist distance between p1 and p2.
@param dist2 distance squared between p1 and p2. */
MDINLINE void add_non_bonded_pair_force(Particle *p1, Particle *p2,
double d[3], double dist, double dist2)
{
IA_parameters *ia_params = get_ia_param(p1->p.type,p2->p.type);
double force[3] = { 0., 0., 0. };
double torque1[3] = { 0., 0., 0. };
double torque2[3] = { 0., 0., 0. };
int j;
#ifdef ADRESS
double tmp,force_weight=adress_non_bonded_force_weight(p1,p2);
if (force_weight<ROUND_ERROR_PREC) return;
#endif
FORCE_TRACE(fprintf(stderr, "%d: interaction %d<->%d dist %f\n", this_node, p1->p.identity, p2->p.identity, dist));
/***********************************************/
/* thermostat */
/***********************************************/
#ifdef DPD
/* DPD thermostat forces */
if ( thermo_switch & THERMO_DPD ) add_dpd_thermo_pair_force(p1,p2,d,dist,dist2);
#endif
#ifdef INTER_DPD
if ( thermo_switch == THERMO_INTER_DPD ) add_interdpd_pair_force(p1,p2,ia_params,d,dist,dist2);
#endif
/***********************************************/
/* non bonded pair potentials */
/***********************************************/
calc_non_bonded_pair_force(p1,p2,ia_params,d,dist,dist2,force,torque1,torque2);
/***********************************************/
/* short range electrostatics */
/***********************************************/
#ifdef ELECTROSTATICS
if (coulomb.method == COULOMB_DH)
add_dh_coulomb_pair_force(p1,p2,d,dist,force);
if (coulomb.method == COULOMB_RF)
add_rf_coulomb_pair_force(p1,p2,d,dist,force);
#endif
/*********************************************************************/
/* everything before this contributes to the virial pressure in NpT, */
/* but nothing afterwards */
/*********************************************************************/
#ifdef NPT
for (j = 0; j < 3; j++)
if(integ_switch == INTEG_METHOD_NPT_ISO)
nptiso.p_vir[j] += force[j] * d[j];
#endif
/***********************************************/
/* long range electrostatics */
/***********************************************/
#ifdef ELECTROSTATICS
/* real space coulomb */
switch (coulomb.method) {
#ifdef ELP3M
case COULOMB_ELC_P3M: {
add_p3m_coulomb_pair_force(p1->p.q*p2->p.q,d,dist2,dist,force);
// forces from the virtual charges
// they go directly onto the particles, since they are not pairwise forces
if (elc_params.dielectric_contrast_on)
ELC_P3M_dielectric_layers_force_contribution(p1, p2, p1->f.f, p2->f.f);
break;
}
case COULOMB_P3M: {
#ifdef NPT
double eng = add_p3m_coulomb_pair_force(p1->p.q*p2->p.q,d,dist2,dist,force);
if(integ_switch == INTEG_METHOD_NPT_ISO)
nptiso.p_vir[0] += eng;
#else
add_p3m_coulomb_pair_force(p1->p.q*p2->p.q,d,dist2,dist,force);
#endif
break;
}
#endif
case COULOMB_EWALD: {
#ifdef NPT
double eng = add_ewald_coulomb_pair_force(p1,p2,d,dist2,dist,force);
if(integ_switch == INTEG_METHOD_NPT_ISO)
nptiso.p_vir[0] += eng;
#else
add_ewald_coulomb_pair_force(p1,p2,d,dist2,dist,force);
#endif
break;
}
case COULOMB_MMM1D:
add_mmm1d_coulomb_pair_force(p1,p2,d,dist2,dist,force);
break;
case COULOMB_MMM2D:
add_mmm2d_coulomb_pair_force(p1->p.q*p2->p.q,d,dist2,dist,force);
break;
case COULOMB_MAGGS:
if(maggs.yukawa == 1)
add_maggs_yukawa_pair_force(p1,p2,d,dist2,dist,force);
break;
case COULOMB_NONE:
break;
}
#endif /*ifdef ELECTROSTATICS */
/***********************************************/
/* long range magnetostatics */
/***********************************************/
#ifdef MAGNETOSTATICS
/* real space magnetic dipole-dipole */
switch (coulomb.Dmethod) {
#ifdef ELP3M
#ifdef MDLC
case DIPOLAR_MDLC_P3M:
//fall trough
#endif
case DIPOLAR_P3M: {
#ifdef NPT
double eng = add_p3m_dipolar_pair_force(p1,p2,d,dist2,dist,force);
if(integ_switch == INTEG_METHOD_NPT_ISO)
nptiso.p_vir[0] += eng;
#else
add_p3m_dipolar_pair_force(p1,p2,d,dist2,dist,force);
#endif
break;
}
#endif /*ifdef ELP3M */
}
#endif /* ifdef MAGNETOSTATICS */
/***********************************************/
/* add total nonbonded forces to particle */
/***********************************************/
for (j = 0; j < 3; j++) {
#ifdef ADRESS
tmp=force_weight*force[j];
p1->f.f[j] += tmp;
p2->f.f[j] -= tmp;
#else
p1->f.f[j] += force[j];
p2->f.f[j] -= force[j];
#endif
#ifdef ROTATION
p1->f.torque[j] += torque1[j];
p2->f.torque[j] += torque2[j];
#endif
}
}
/** Calculate bonded forces for one particle.
@param p1 particle for which to calculate forces
*/
MDINLINE void add_bonded_force(Particle *p1)
{
double dx[3] = { 0., 0., 0. };
double force[3] = { 0., 0., 0. };
double force2[3] = { 0., 0., 0. };
double force3[3] = { 0., 0., 0. };
#ifdef ROTATION
double torque1[3] = { 0., 0., 0. };
double torque2[3] = { 0., 0., 0. };
#endif
char *errtxt;
Particle *p2, *p3 = NULL, *p4 = NULL;
Bonded_ia_parameters *iaparams;
int i, j, type_num, type, n_partners, bond_broken;
#ifdef ADRESS
double tmp, force_weight=1;
//double tmp,force_weight=adress_bonded_force_weight(p1);
//if (force_weight<ROUND_ERROR_PREC) return;
#endif
i = 0;
while(i<p1->bl.n) {
type_num = p1->bl.e[i++];
iaparams = &bonded_ia_params[type_num];
type = iaparams->type;
n_partners = iaparams->num;
/* fetch particle 2, which is always needed */
p2 = local_particles[p1->bl.e[i++]];
if (!p2) {
errtxt = runtime_error(128 + 2*TCL_INTEGER_SPACE);
ERROR_SPRINTF(errtxt,"{078 bond broken between particles %d and %d (particles not stored on the same node)} ",
p1->p.identity, p1->bl.e[i-1]);
return;
}
/* fetch particle 3 eventually */
if (n_partners >= 2) {
p3 = local_particles[p1->bl.e[i++]];
if (!p3) {
errtxt = runtime_error(128 + 3*TCL_INTEGER_SPACE);
ERROR_SPRINTF(errtxt,"{079 bond broken between particles %d, %d and %d (particles not stored on the same node)} ",
p1->p.identity, p1->bl.e[i-2], p1->bl.e[i-1]);
return;
}
}
/* fetch particle 4 eventually */
if (n_partners >= 3) {
p4 = local_particles[p1->bl.e[i++]];
if (!p4) {
errtxt = runtime_error(128 + 4*TCL_INTEGER_SPACE);
ERROR_SPRINTF(errtxt,"{080 bond broken between particles %d, %d, %d and %d (particles not stored on the same node)} ",
p1->p.identity, p1->bl.e[i-3], p1->bl.e[i-2], p1->bl.e[i-1]);
return;
}
}
if (n_partners == 1) {
/* because of the NPT pressure calculation for pair forces, we need the
1->2 distance vector here. For many body interactions this vector is not needed,
and the pressure calculation not yet clear. */
get_mi_vector(dx, p1->r.p, p2->r.p);
}
switch (type) {
case BONDED_IA_FENE:
bond_broken = calc_fene_pair_force(p1, p2, iaparams, dx, force);
break;
case BONDED_IA_HARMONIC:
bond_broken = calc_harmonic_pair_force(p1, p2, iaparams, dx, force);
break;
#ifdef LENNARD_JONES
case BONDED_IA_SUBT_LJ:
bond_broken = calc_subt_lj_pair_force(p1, p2, iaparams, dx, force);
break;
#endif
#ifdef BOND_ANGLE
case BONDED_IA_ANGLE:
bond_broken = calc_angle_force(p1, p2, p3, iaparams, force, force2);
break;
#endif
#ifdef BOND_ANGLEDIST
case BONDED_IA_ANGLEDIST:
bond_broken = calc_angledist_force(p1, p2, p3, iaparams, force, force2);
break;
#endif
#ifdef BOND_ENDANGLEDIST
case BONDED_IA_ENDANGLEDIST:
bond_broken = calc_endangledist_pair_force(p1, p2, iaparams, dx, force, force2);
break;
#endif
case BONDED_IA_DIHEDRAL:
bond_broken = calc_dihedral_force(p1, p2, p3, p4, iaparams, force, force2, force3);
break;
#ifdef BOND_CONSTRAINT
case BONDED_IA_RIGID_BOND:
//add_rigid_bond_pair_force(p1,p2, iaparams, force, force2);
bond_broken = 0;
force[0]=force[1]=force[2]=0.0;
break;
#endif
#ifdef TABULATED
case BONDED_IA_TABULATED:
switch(iaparams->p.tab.type) {
case TAB_BOND_LENGTH:
bond_broken = calc_tab_bond_force(p1, p2, iaparams, dx, force);
break;
case TAB_BOND_ANGLE:
bond_broken = calc_tab_angle_force(p1, p2, p3, iaparams, force, force2);
break;
case TAB_BOND_DIHEDRAL:
bond_broken = calc_tab_dihedral_force(p1, p2, p3, p4, iaparams, force, force2, force3);
break;
default:
errtxt = runtime_error(128 + TCL_INTEGER_SPACE);
ERROR_SPRINTF(errtxt,"{081 add_bonded_force: tabulated bond type of atom %d unknown\n", p1->p.identity);
return;
}
break;
#endif
#ifdef OVERLAPPED
case BONDED_IA_OVERLAPPED:
switch(iaparams->p.overlap.type) {
case OVERLAP_BOND_LENGTH:
bond_broken = calc_overlap_bond_force(p1, p2, iaparams, dx, force);
break;
case OVERLAP_BOND_ANGLE:
bond_broken = calc_overlap_angle_force(p1, p2, p3, iaparams, force, force2);
break;
case OVERLAP_BOND_DIHEDRAL:
bond_broken = calc_overlap_dihedral_force(p1, p2, p3, p4, iaparams, force, force2, force3);
break;
default:
errtxt = runtime_error(128 + TCL_INTEGER_SPACE);
ERROR_SPRINTF(errtxt,"{081 add_bonded_force: overlapped bond type of atom %d unknown\n", p1->p.identity);
return;
}
break;
#endif
#ifdef BOND_VIRTUAL
case BONDED_IA_VIRTUAL_BOND:
bond_broken = 0;
force[0]=force[1]=force[2]=0.0;
break;
#endif
default :
errtxt = runtime_error(128 + TCL_INTEGER_SPACE);
ERROR_SPRINTF(errtxt,"{082 add_bonded_force: bond type of atom %d unknown\n", p1->p.identity);
return;
}
switch (n_partners) {
case 1:
if (bond_broken) {
char *errtext = runtime_error(128 + 2*TCL_INTEGER_SPACE);
ERROR_SPRINTF(errtext,"{083 bond broken between particles %d and %d} ",
p1->p.identity, p2->p.identity);
continue;
}
#ifdef ADRESS
if((get_mol_com_particle(p1))->p.identity == (get_mol_com_particle(p2))->p.identity)
force_weight = 1.0;
else
force_weight = adress_non_bonded_force_weight(p1,p2);
#endif
for (j = 0; j < 3; j++) {
#ifdef ADRESS
tmp=force_weight*force[j];
p1->f.f[j] += tmp;
p2->f.f[j] -= tmp;
#else // ADRESS
switch (type) {
#ifdef BOND_ENDANGLEDIST
case BONDED_IA_ENDANGLEDIST:
p1->f.f[j] += force[j];
p2->f.f[j] += force2[j];
break;
#endif // BOND_ENDANGLEDIST
default:
p1->f.f[j] += force[j];
p2->f.f[j] -= force[j];
#ifdef ROTATION
p1->f.torque[j] += torque1[j];
p2->f.torque[j] += torque2[j];
#endif
}
#endif // NOT ADRESS
#ifdef NPT
if(integ_switch == INTEG_METHOD_NPT_ISO)
nptiso.p_vir[j] += force[j] * dx[j];
#endif
}
break;
case 2:
if (bond_broken) {
char *errtext = runtime_error(128 + 3*TCL_INTEGER_SPACE);
ERROR_SPRINTF(errtext,"{084 bond broken between particles %d, %d and %d} ",
p1->p.identity, p2->p.identity, p3->p.identity);
continue;
}
for (j = 0; j < 3; j++) {
#ifdef ADRESS
p1->f.f[j] += force_weight*force[j];
p2->f.f[j] += force_weight*force2[j];
p3->f.f[j] -= force_weight*(force[j] + force2[j]);
#else
p1->f.f[j] += force[j];
p2->f.f[j] += force2[j];
p3->f.f[j] -= (force[j] + force2[j]);
#endif
}
break;
case 3:
if (bond_broken) {
char *errtext = runtime_error(128 + 4*TCL_INTEGER_SPACE);
ERROR_SPRINTF(errtext,"{085 bond broken between particles %d, %d, %d and %d} ",
p1->p.identity, p2->p.identity, p3->p.identity, p4->p.identity);
continue;
}
for (j = 0; j < 3; j++) {
#ifdef ADRESS
p1->f.f[j] += force_weight*force[j];
p2->f.f[j] += force_weight*force2[j];
p3->f.f[j] += force_weight*force3[j];
p4->f.f[j] -= force_weight*(force[j] + force2[j] + force3[j]);
#else
p1->f.f[j] += force[j];
p2->f.f[j] += force2[j];
p3->f.f[j] += force3[j];
p4->f.f[j] -= (force[j] + force2[j] + force3[j]);
#endif
}
break;
}
}
}
/** add force to another. This is used when collecting ghost forces. */
MDINLINE void add_force(ParticleForce *F_to, ParticleForce *F_add)
{
int i;
for (i = 0; i < 3; i++)
F_to->f[i] += F_add->f[i];
#ifdef ROTATION
for (i = 0; i < 3; i++)
F_to->torque[i] += F_add->torque[i];
#endif
}
/*@}*/
#endif