From ee862d8bf5347dd2465a6d4fb907a92cb4780788 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer <akohlmey@gmail.com> Date: Fri, 16 Mar 2018 12:28:13 -0400 Subject: [PATCH] replace leading tabs --- src/BODY/body_nparticle.cpp | 6 +- src/CORESHELL/pair_born_coul_dsf_cs.cpp | 2 +- src/CORESHELL/pair_born_coul_wolf_cs.cpp | 6 +- src/CORESHELL/pair_coul_wolf_cs.cpp | 58 +- src/CORESHELL/pair_lj_cut_coul_long_cs.cpp | 2 +- src/DIPOLE/pair_lj_long_dipole_long.cpp | 280 +- src/GPU/pair_ufm_gpu.cpp | 6 +- src/KOKKOS/atom_vec_angle_kokkos.cpp | 32 +- src/KOKKOS/atom_vec_bond_kokkos.cpp | 44 +- src/KOKKOS/atom_vec_dpd_kokkos.cpp | 6 +- src/KOKKOS/atom_vec_full_kokkos.cpp | 18 +- src/KOKKOS/atom_vec_kokkos.cpp | 4 +- src/KOKKOS/atom_vec_molecular_kokkos.cpp | 26 +- src/KOKKOS/comm_kokkos.cpp | 4 +- src/KOKKOS/dihedral_charmm_kokkos.h | 14 +- src/KOKKOS/pair_coul_debye_kokkos.cpp | 4 +- ..._lj_charmm_coul_charmm_implicit_kokkos.cpp | 4 +- .../pair_lj_charmm_coul_charmm_kokkos.cpp | 4 +- .../pair_lj_charmm_coul_long_kokkos.cpp | 4 +- src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp | 2 +- .../pair_lj_gromacs_coul_gromacs_kokkos.cpp | 8 +- src/KOKKOS/pair_lj_gromacs_kokkos.cpp | 8 +- src/KOKKOS/pair_tersoff_kokkos.cpp | 82 +- src/KOKKOS/pair_tersoff_kokkos.h | 32 +- src/KOKKOS/pair_tersoff_mod_kokkos.cpp | 86 +- src/KOKKOS/pair_tersoff_zbl_kokkos.cpp | 108 +- src/KOKKOS/sna_kokkos_impl.h | 178 +- src/KSPACE/pair_buck_long_coul_long.cpp | 2 +- src/KSPACE/pair_lj_charmmfsw_coul_long.cpp | 2 +- src/KSPACE/pppm_disp.cpp | 946 ++--- src/KSPACE/pppm_disp.h | 38 +- src/KSPACE/pppm_disp_tip4p.cpp | 48 +- src/MANYBODY/pair_comb.cpp | 4 +- src/MANYBODY/pair_comb3.cpp | 800 ++-- src/MANYBODY/pair_comb3.h | 86 +- src/MANYBODY/pair_gw.h | 2 +- src/MANYBODY/pair_nb3b_harmonic.cpp | 78 +- src/MANYBODY/pair_nb3b_harmonic.h | 2 +- src/MANYBODY/pair_polymorphic.cpp | 20 +- src/MANYBODY/pair_polymorphic.h | 8 +- src/MANYBODY/pair_tersoff.cpp | 4 +- src/MANYBODY/pair_tersoff_mod.cpp | 46 +- src/MANYBODY/pair_tersoff_mod.h | 2 +- src/MANYBODY/pair_tersoff_mod_c.cpp | 10 +- src/MANYBODY/pair_vashishta.cpp | 12 +- src/MC/fix_atom_swap.cpp | 42 +- src/MC/fix_bond_break.cpp | 8 +- src/MC/fix_bond_create.cpp | 10 +- src/MC/fix_tfmc.cpp | 10 +- src/MISC/fix_deposit.cpp | 4 +- src/MISC/fix_gld.cpp | 94 +- src/MOLECULE/pair_hbond_dreiding_morse.cpp | 6 +- .../pair_lj_charmmfsw_coul_charmmfsh.cpp | 104 +- src/MPIIO/dump_cfg_mpiio.cpp | 40 +- src/QEQ/fix_qeq_dynamic.cpp | 12 +- src/QEQ/fix_qeq_fire.cpp | 16 +- src/QEQ/fix_qeq_point.cpp | 10 +- src/QEQ/fix_qeq_shielded.cpp | 10 +- src/QEQ/fix_qeq_slater.cpp | 14 +- src/RIGID/fix_rigid.cpp | 8 +- src/RIGID/fix_rigid_small.cpp | 12 +- src/SNAP/compute_sna_atom.cpp | 50 +- src/SNAP/compute_snad_atom.cpp | 80 +- src/SNAP/compute_snav_atom.cpp | 102 +- src/SNAP/pair_snap.cpp | 142 +- src/SNAP/sna.cpp | 352 +- src/SRD/fix_srd.cpp | 28 +- src/USER-CGDNA/pair_oxdna2_coaxstk.cpp | 22 +- src/USER-CGDNA/pair_oxdna2_dh.cpp | 84 +- src/USER-COLVARS/fix_colvars.cpp | 8 +- src/USER-DIFFRACTION/compute_xrd.cpp | 4 +- src/USER-H5MD/dump_h5md.cpp | 134 +- src/USER-INTEL/dihedral_fourier_intel.cpp | 68 +- src/USER-INTEL/dihedral_fourier_intel.h | 2 +- src/USER-INTEL/fix_intel.cpp | 8 +- src/USER-INTEL/intel_buffers.cpp | 10 +- src/USER-INTEL/intel_intrinsics_airebo.h | 282 +- src/USER-INTEL/intel_preprocess.h | 22 +- src/USER-INTEL/nbin_intel.cpp | 4 +- src/USER-INTEL/npair_full_bin_ghost_intel.cpp | 174 +- src/USER-INTEL/npair_full_bin_ghost_intel.h | 2 +- src/USER-INTEL/npair_intel.cpp | 6 +- src/USER-INTEL/pair_airebo_intel.cpp | 382 +- src/USER-INTEL/pair_airebo_intel.h | 4 +- src/USER-INTEL/pair_dpd_intel.cpp | 80 +- .../pair_lj_charmm_coul_charmm_intel.cpp | 24 +- src/USER-INTEL/pair_sw_intel.cpp | 8 +- src/USER-INTEL/pppm_disp_intel.cpp | 60 +- src/USER-INTEL/pppm_intel.cpp | 32 +- src/USER-INTEL/pppm_intel.h | 2 +- src/USER-LB/fix_lb_fluid.cpp | 1756 ++++---- src/USER-LB/fix_lb_momentum.cpp | 250 +- src/USER-LB/fix_lb_pc.cpp | 304 +- src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp | 2 +- src/USER-MISC/angle_dipole.cpp | 2 +- src/USER-MISC/angle_fourier.cpp | 2 +- src/USER-MISC/angle_quartic.cpp | 2 +- src/USER-MISC/bond_harmonic_shift.cpp | 2 +- src/USER-MISC/bond_harmonic_shift_cut.cpp | 2 +- src/USER-MISC/compute_ackland_atom.cpp | 24 +- src/USER-MISC/compute_basal_atom.cpp | 148 +- src/USER-MISC/compute_pressure_grem.cpp | 2 +- src/USER-MISC/dihedral_quadratic.cpp | 24 +- src/USER-MISC/dihedral_spherical.h | 2 +- src/USER-MISC/fix_filter_corotate.h | 2 +- src/USER-MISC/fix_flow_gauss.cpp | 6 +- src/USER-MISC/fix_gle.cpp | 6 +- src/USER-MISC/fix_ipi.cpp | 2 +- src/USER-MISC/fix_pimd.cpp | 2 +- src/USER-MISC/pair_edip_multi.cpp | 72 +- src/USER-MISC/pair_edip_multi.h | 2 +- src/USER-MISC/pair_gauss_cut.cpp | 2 +- src/USER-MISC/pair_lj_sf_dipole_sf.cpp | 10 +- src/USER-MISC/pair_meam_spline.cpp | 6 +- src/USER-MISC/pair_meam_spline.h | 16 +- src/USER-MISC/pair_momb.cpp | 4 +- src/USER-MISC/temper_npt.cpp | 14 +- src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp | 2 +- .../pair_buck6d_coul_gauss_long.cpp | 2 +- src/USER-OMP/angle_dipole_omp.cpp | 2 +- src/USER-OMP/fix_omp.cpp | 40 +- src/USER-OMP/fix_rigid_nh_omp.cpp | 152 +- src/USER-OMP/fix_rigid_omp.cpp | 150 +- src/USER-OMP/fix_rigid_small_omp.cpp | 48 +- src/USER-OMP/improper_fourier_omp.cpp | 44 +- src/USER-OMP/improper_fourier_omp.h | 8 +- src/USER-OMP/pair_buck_long_coul_long_omp.cpp | 6 +- src/USER-OMP/pair_lj_long_coul_long_omp.cpp | 10 +- src/USER-OMP/pair_morse_smooth_linear_omp.cpp | 2 +- src/USER-OMP/pair_reaxc_omp.h | 36 +- src/USER-OMP/pppm_cg_omp.cpp | 92 +- src/USER-OMP/pppm_cg_omp.h | 2 +- src/USER-OMP/pppm_disp_omp.cpp | 62 +- src/USER-OMP/pppm_disp_omp.h | 2 +- src/USER-OMP/pppm_disp_tip4p_omp.cpp | 62 +- src/USER-OMP/pppm_disp_tip4p_omp.h | 2 +- src/USER-OMP/pppm_omp.cpp | 2 +- src/USER-OMP/pppm_omp.h | 2 +- src/USER-OMP/pppm_tip4p_omp.cpp | 2 +- src/USER-OMP/pppm_tip4p_omp.h | 2 +- src/USER-OMP/reaxc_bond_orders_omp.cpp | 398 +- src/USER-OMP/reaxc_bond_orders_omp.h | 4 +- src/USER-OMP/reaxc_bonds_omp.cpp | 78 +- src/USER-OMP/reaxc_forces_omp.cpp | 288 +- src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp | 16 +- src/USER-OMP/reaxc_multi_body_omp.cpp | 26 +- src/USER-OMP/reaxc_nonbonded_omp.cpp | 392 +- src/USER-OMP/reaxc_nonbonded_omp.h | 6 +- src/USER-OMP/reaxc_torsion_angles_omp.cpp | 118 +- src/USER-OMP/reaxc_torsion_angles_omp.h | 2 +- src/USER-OMP/reaxc_valence_angles_omp.cpp | 102 +- src/USER-OMP/respa_omp.cpp | 18 +- src/USER-QTB/fix_qbmsst.cpp | 126 +- src/USER-QTB/fix_qtb.cpp | 6 +- src/USER-REAXC/fix_qeq_reax.cpp | 8 +- src/USER-REAXC/pair_reaxc.cpp | 22 +- src/USER-REAXC/reaxc_allocate.cpp | 4 +- src/USER-REAXC/reaxc_bonds.cpp | 74 +- src/USER-REAXC/reaxc_forces.cpp | 2 +- src/USER-REAXC/reaxc_hydrogen_bonds.cpp | 8 +- src/USER-REAXC/reaxc_multi_body.cpp | 4 +- src/USER-REAXC/reaxc_torsion_angles.cpp | 10 +- src/USER-SMD/atom_vec_smd.cpp | 1932 ++++----- src/USER-SMD/compute_smd_hourglass_error.cpp | 90 +- src/USER-SMD/compute_smd_rho.cpp | 82 +- src/USER-SMD/compute_smd_tlsph_defgrad.cpp | 132 +- src/USER-SMD/compute_smd_tlsph_dt.cpp | 102 +- src/USER-SMD/compute_smd_tlsph_shape.cpp | 128 +- src/USER-SMD/compute_smd_tlsph_strain.cpp | 144 +- .../compute_smd_tlsph_strain_rate.cpp | 90 +- src/USER-SMD/compute_smd_tlsph_stress.cpp | 116 +- .../compute_smd_triangle_mesh_vertices.cpp | 4 +- src/USER-SMD/compute_smd_ulsph_effm.cpp | 102 +- src/USER-SMD/compute_smd_ulsph_strain.cpp | 94 +- .../compute_smd_ulsph_strain_rate.cpp | 110 +- src/USER-SMD/compute_smd_ulsph_stress.cpp | 120 +- src/USER-SMD/compute_smd_vol.cpp | 114 +- src/USER-SMD/fix_smd_adjust_dt.cpp | 260 +- src/USER-SMD/fix_smd_adjust_dt.h | 26 +- src/USER-SMD/fix_smd_integrate_tlsph.cpp | 340 +- src/USER-SMD/fix_smd_integrate_tlsph.h | 4 +- src/USER-SMD/fix_smd_integrate_ulsph.cpp | 448 +- .../fix_smd_move_triangulated_surface.cpp | 836 ++-- .../fix_smd_move_triangulated_surface.h | 30 +- src/USER-SMD/fix_smd_setvel.cpp | 540 +-- .../fix_smd_tlsph_reference_configuration.cpp | 798 ++-- .../fix_smd_tlsph_reference_configuration.h | 64 +- src/USER-SMD/fix_smd_wall_surface.cpp | 790 ++-- src/USER-SMD/fix_smd_wall_surface.h | 26 +- src/USER-SMD/pair_smd_hertz.cpp | 484 +-- src/USER-SMD/pair_smd_tlsph.cpp | 3772 ++++++++--------- src/USER-SMD/pair_smd_tlsph.h | 304 +- .../pair_smd_triangulated_surface.cpp | 1176 ++--- src/USER-SMD/pair_smd_ulsph.cpp | 2840 ++++++------- src/USER-SMD/pair_smd_ulsph.h | 156 +- src/USER-SMD/smd_kernels.h | 182 +- src/USER-SMD/smd_material_models.cpp | 444 +- src/USER-SMD/smd_material_models.h | 18 +- src/USER-SMD/smd_math.h | 346 +- src/VORONOI/compute_voronoi_atom.cpp | 64 +- src/atom.cpp | 20 +- src/atom_vec_body.cpp | 12 +- src/comm.cpp | 8 +- src/compute_chunk_atom.cpp | 16 +- src/compute_hexorder_atom.cpp | 32 +- src/compute_msd.cpp | 30 +- src/compute_orientorder_atom.h | 2 +- src/compute_pressure.cpp | 4 +- src/compute_property_chunk.cpp | 8 +- src/compute_stress_atom.cpp | 92 +- src/compute_temp_chunk.cpp | 46 +- src/compute_vacf.cpp | 6 +- src/domain.cpp | 8 +- src/dump_cfg.cpp | 10 +- src/dump_custom.cpp | 160 +- src/fix_adapt.cpp | 12 +- src/fix_ave_chunk.cpp | 26 +- src/fix_group.cpp | 6 +- src/fix_langevin.cpp | 308 +- src/fix_langevin.h | 4 +- src/fix_nh_sphere.cpp | 2 +- src/fix_nve_sphere.cpp | 2 +- src/fix_store_state.cpp | 8 +- src/fix_wall_lj1043.cpp | 6 +- src/input.cpp | 136 +- src/kspace.cpp | 6 +- src/lammps.cpp | 22 +- src/library.cpp | 8 +- src/neighbor.cpp | 26 +- src/pair.h | 2 +- src/pair_born_coul_dsf.cpp | 2 +- src/pair_coul_streitz.cpp | 34 +- src/pair_coul_streitz.h | 4 +- src/pair_lj_cut_coul_dsf.cpp | 2 +- src/pair_lj_expand.cpp | 4 +- src/pair_morse.h | 2 +- src/pair_zbl.cpp | 34 +- src/rcb.cpp | 264 +- src/read_data.cpp | 12 +- src/region_cylinder.cpp | 8 +- src/region_union.cpp | 2 +- src/set.cpp | 26 +- src/variable.cpp | 96 +- 243 files changed, 14825 insertions(+), 14825 deletions(-) diff --git a/src/BODY/body_nparticle.cpp b/src/BODY/body_nparticle.cpp index b2790c19aa..7e3e6f463c 100644 --- a/src/BODY/body_nparticle.cpp +++ b/src/BODY/body_nparticle.cpp @@ -196,7 +196,7 @@ void BodyNparticle::data_body(int ibonus, int ninteger, int ndouble, ------------------------------------------------------------------------- */ double BodyNparticle::radius_body(int ninteger, int ndouble, - int *ifile, double *dfile) + int *ifile, double *dfile) { int nsub = ifile[0]; if (nsub < 1) @@ -212,8 +212,8 @@ double BodyNparticle::radius_body(int ninteger, int ndouble, double onerad; double maxrad = 0.0; double delta[3]; - - int offset = 6; + + int offset = 6; for (int i = 0; i < nsub; i++) { delta[0] = dfile[offset]; delta[1] = dfile[offset+1]; diff --git a/src/CORESHELL/pair_born_coul_dsf_cs.cpp b/src/CORESHELL/pair_born_coul_dsf_cs.cpp index 2cd2f211ff..4a5c9da07e 100644 --- a/src/CORESHELL/pair_born_coul_dsf_cs.cpp +++ b/src/CORESHELL/pair_born_coul_dsf_cs.cpp @@ -112,7 +112,7 @@ void PairBornCoulDSFCS::compute(int eflag, int vflag) if (rsq < cut_coulsq) { r = sqrt(rsq); prefactor = qqrd2e*qtmp*q[j] / r; - arg = alpha * r ; + arg = alpha * r ; erfcd = MathSpecial::expmsq(arg); erfcc = MathSpecial::my_erfcx(arg) * erfcd; forcecoul = prefactor * (erfcc/r + 2.0*alpha/MY_PIS * erfcd + diff --git a/src/CORESHELL/pair_born_coul_wolf_cs.cpp b/src/CORESHELL/pair_born_coul_wolf_cs.cpp index 3c98f5bf77..f39e2ca816 100644 --- a/src/CORESHELL/pair_born_coul_wolf_cs.cpp +++ b/src/CORESHELL/pair_born_coul_wolf_cs.cpp @@ -106,9 +106,9 @@ void PairBornCoulWolfCS::compute(int eflag, int vflag) jtype = type[j]; if (rsq < cutsq[itype][jtype]) { - rsq += EPSILON; - // Add EPISLON for case: r = 0; Interaction must be removed - // by special bond + rsq += EPSILON; + // Add EPISLON for case: r = 0; Interaction must be removed + // by special bond r2inv = 1.0/rsq; if (rsq < cut_coulsq) { diff --git a/src/CORESHELL/pair_coul_wolf_cs.cpp b/src/CORESHELL/pair_coul_wolf_cs.cpp index 15de7c6777..5f277dcdd2 100644 --- a/src/CORESHELL/pair_coul_wolf_cs.cpp +++ b/src/CORESHELL/pair_coul_wolf_cs.cpp @@ -102,35 +102,35 @@ void PairCoulWolfCS::compute(int eflag, int vflag) rsq = delx*delx + dely*dely + delz*delz; if (rsq < cut_coulsq) { - rsq += EPSILON; - // Add EPISLON for case: r = 0; Interaction must be removed - // by special bond - r = sqrt(rsq); - prefactor = qqrd2e*qtmp*q[j]/r; - erfcc = erfc(alf*r); - erfcd = exp(-alf*alf*r*r); - v_sh = (erfcc - e_shift*r) * prefactor; - dvdrr = (erfcc/rsq + 2.0*alf/MY_PIS * erfcd/r) + f_shift; - forcecoul = dvdrr*rsq*prefactor; - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; - fpair = forcecoul / rsq; - - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; - if (newton_pair || j < nlocal) { - f[j][0] -= delx*fpair; - f[j][1] -= dely*fpair; - f[j][2] -= delz*fpair; - } - - if (eflag) { - ecoul = v_sh; - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; - } else ecoul = 0.0; - - if (evflag) ev_tally(i,j,nlocal,newton_pair, - 0.0,ecoul,fpair,delx,dely,delz); + rsq += EPSILON; + // Add EPISLON for case: r = 0; Interaction must be removed + // by special bond + r = sqrt(rsq); + prefactor = qqrd2e*qtmp*q[j]/r; + erfcc = erfc(alf*r); + erfcd = exp(-alf*alf*r*r); + v_sh = (erfcc - e_shift*r) * prefactor; + dvdrr = (erfcc/rsq + 2.0*alf/MY_PIS * erfcd/r) + f_shift; + forcecoul = dvdrr*rsq*prefactor; + if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + fpair = forcecoul / rsq; + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + + if (eflag) { + ecoul = v_sh; + if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + } else ecoul = 0.0; + + if (evflag) ev_tally(i,j,nlocal,newton_pair, + 0.0,ecoul,fpair,delx,dely,delz); } } } diff --git a/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp b/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp index d418cf20af..c660eee3bc 100644 --- a/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp +++ b/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp @@ -458,7 +458,7 @@ void PairLJCutCoulLongCS::compute_outer(int eflag, int vflag) grij = g_ewald * r; expm2 = exp(-grij*grij); t = 1.0 / (1.0 + EWALD_P*grij); - u = 1. - t; + u = 1. - t; erfc = t * (1.+u*(B0+u*(B1+u*(B2+u*(B3+u*(B4+u*B5)))))) * expm2; //erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; prefactor = qqrd2e * qtmp*q[j]/r; diff --git a/src/DIPOLE/pair_lj_long_dipole_long.cpp b/src/DIPOLE/pair_lj_long_dipole_long.cpp index c9b2b3f4af..262727c5b6 100644 --- a/src/DIPOLE/pair_lj_long_dipole_long.cpp +++ b/src/DIPOLE/pair_lj_long_dipole_long.cpp @@ -68,8 +68,8 @@ void PairLJLongDipoleLong::options(char **arg, int order) for (i=0; option[i]&&strcmp(arg[0], option[i]); ++i); switch (i) { default: error->all(FLERR,"Illegal pair_style lj/long/dipole/long command"); - case 0: ewald_order |= 1<<order; break; // set kspace r^-order - case 2: ewald_off |= 1<<order; // turn r^-order off + case 0: ewald_order |= 1<<order; break; // set kspace r^-order + case 2: ewald_off |= 1<<order; // turn r^-order off case 1: break; } } @@ -99,7 +99,7 @@ void PairLJLongDipoleLong::settings(int narg, char **arg) if (narg == 4) cut_coul = force->numeric(FLERR,*(arg++)); else cut_coul = cut_lj_global; - if (allocated) { // reset explicit cuts + if (allocated) { // reset explicit cuts int i,j; for (i = 1; i <= atom->ntypes; i++) for (j = i; j <= atom->ntypes; j++) @@ -234,7 +234,7 @@ void PairLJLongDipoleLong::init_style() if (!atom->q_flag && (ewald_order&(1<<1))) error->all(FLERR, - "Invoking coulombic in pair style lj/long/dipole/long requires atom attribute q"); + "Invoking coulombic in pair style lj/long/dipole/long requires atom attribute q"); if (!atom->mu && (ewald_order&(1<<3))) error->all(FLERR,"Pair lj/long/dipole/long requires atom attributes mu, torque"); if (!atom->torque && (ewald_order&(1<<3))) @@ -246,14 +246,14 @@ void PairLJLongDipoleLong::init_style() // ensure use of KSpace long-range solver, set g_ewald - if (ewald_order&(1<<3)) { // r^-1 kspace + if (ewald_order&(1<<3)) { // r^-1 kspace if (force->kspace == NULL) error->all(FLERR,"Pair style requires a KSpace style"); for (i=0; style3[i]&&strcmp(force->kspace_style, style3[i]); ++i); if (!style3[i]) error->all(FLERR,"Pair style requires use of kspace_style ewald/disp"); } - if (ewald_order&(1<<6)) { // r^-6 kspace + if (ewald_order&(1<<6)) { // r^-6 kspace if (force->kspace == NULL) error->all(FLERR,"Pair style requires a KSpace style"); for (i=0; style6[i]&&strcmp(force->kspace_style, style6[i]); ++i); @@ -271,7 +271,7 @@ double PairLJLongDipoleLong::init_one(int i, int j) { if ((ewald_order&(1<<6))||(setflag[i][j] == 0)) { epsilon[i][j] = mix_energy(epsilon_read[i][i],epsilon_read[j][j], - sigma_read[i][i],sigma_read[j][j]); + sigma_read[i][i],sigma_read[j][j]); sigma[i][j] = mix_distance(sigma_read[i][i],sigma_read[j][j]); if (ewald_order&(1<<6)) cut_lj[i][j] = cut_lj_global; @@ -436,9 +436,9 @@ void PairLJLongDipoleLong::compute(int eflag, int vflag) ineighn = (ineigh = list->ilist)+list->inum; - for (; ineigh<ineighn; ++ineigh) { // loop over all neighs + for (; ineigh<ineighn; ++ineigh) { // loop over all neighs i = *ineigh; fi = f0+3*i; tqi = tq0+3*i; - qi = q[i]; // initialize constants + qi = q[i]; // initialize constants offseti = offset[typei = type[i]]; lj1i = lj1[typei]; lj2i = lj2[typei]; lj3i = lj3[typei]; lj4i = lj4[typei]; cutsqi = cutsq[typei]; cut_ljsqi = cut_ljsq[typei]; @@ -447,141 +447,141 @@ void PairLJLongDipoleLong::compute(int eflag, int vflag) jneighn = (jneigh = list->firstneigh[i])+list->numneigh[i]; - for (; jneigh<jneighn; ++jneigh) { // loop over neighbors + for (; jneigh<jneighn; ++jneigh) { // loop over neighbors j = *jneigh; - ni = sbmask(j); // special index + ni = sbmask(j); // special index j &= NEIGHMASK; { register double *xj = x0+(j+(j<<1)); - d[0] = xi[0] - xj[0]; // pair vector - d[1] = xi[1] - xj[1]; - d[2] = xi[2] - xj[2]; } + d[0] = xi[0] - xj[0]; // pair vector + d[1] = xi[1] - xj[1]; + d[2] = xi[2] - xj[2]; } if ((rsq = vec_dot(d, d)) >= cutsqi[typej = type[j]]) continue; r2inv = 1.0/rsq; - if (order3 && (rsq < cut_coulsq)) { // dipole - memcpy(muj, jmu = mu0+(j<<2), sizeof(vector)); - { // series real space - register double r = sqrt(rsq); - register double x = g_ewald*r; - register double f = exp(-x*x)*qqrd2e; - - B0 = 1.0/(1.0+EWALD_P*x); // eqn 2.8 - B0 *= ((((A5*B0+A4)*B0+A3)*B0+A2)*B0+A1)*f/r; - B1 = (B0 + C1 * f) * r2inv; - B2 = (3.0*B1 + C2 * f) * r2inv; - B3 = (5.0*B2 + C3 * f) * r2inv; - - mudi = mui[0]*d[0]+mui[1]*d[1]+mui[2]*d[2]; - mudj = muj[0]*d[0]+muj[1]*d[1]+muj[2]*d[2]; - muij = mui[0]*muj[0]+mui[1]*muj[1]+mui[2]*muj[2]; - G0 = qi*(qj = q[j]); // eqn 2.10 - G1 = qi*mudj-qj*mudi+muij; - G2 = -mudi*mudj; - force_coul = G0*B1+G1*B2+G2*B3; - - mudi *= B2; mudj *= B2; // torque contribs - ti[0] = mudj*d[0]+(qj*d[0]-muj[0])*B1; - ti[1] = mudj*d[1]+(qj*d[1]-muj[1])*B1; - ti[2] = mudj*d[2]+(qj*d[2]-muj[2])*B1; - - if (newton_pair || j < nlocal) { - tj[0] = mudi*d[0]-(qi*d[0]+mui[0])*B1; - tj[1] = mudi*d[1]-(qi*d[1]+mui[1])*B1; - tj[2] = mudi*d[2]-(qi*d[2]+mui[2])*B1; - } - - if (eflag) ecoul = G0*B0+G1*B1+G2*B2; - if (ni > 0) { // adj part, eqn 2.13 - force_coul -= (f = qqrd2e*(1.0-special_coul[ni])/r)*( - (3.0*G1+15.0*G2*r2inv)*r2inv+G0)*r2inv; - if (eflag) - ecoul -= f*((G1+3.0*G2*r2inv)*r2inv+G0); - B1 -= f*r2inv; - } - B0 = mudj+qj*B1; B3 = -qi*B1+mudi; // position independent + if (order3 && (rsq < cut_coulsq)) { // dipole + memcpy(muj, jmu = mu0+(j<<2), sizeof(vector)); + { // series real space + register double r = sqrt(rsq); + register double x = g_ewald*r; + register double f = exp(-x*x)*qqrd2e; + + B0 = 1.0/(1.0+EWALD_P*x); // eqn 2.8 + B0 *= ((((A5*B0+A4)*B0+A3)*B0+A2)*B0+A1)*f/r; + B1 = (B0 + C1 * f) * r2inv; + B2 = (3.0*B1 + C2 * f) * r2inv; + B3 = (5.0*B2 + C3 * f) * r2inv; + + mudi = mui[0]*d[0]+mui[1]*d[1]+mui[2]*d[2]; + mudj = muj[0]*d[0]+muj[1]*d[1]+muj[2]*d[2]; + muij = mui[0]*muj[0]+mui[1]*muj[1]+mui[2]*muj[2]; + G0 = qi*(qj = q[j]); // eqn 2.10 + G1 = qi*mudj-qj*mudi+muij; + G2 = -mudi*mudj; + force_coul = G0*B1+G1*B2+G2*B3; + + mudi *= B2; mudj *= B2; // torque contribs + ti[0] = mudj*d[0]+(qj*d[0]-muj[0])*B1; + ti[1] = mudj*d[1]+(qj*d[1]-muj[1])*B1; + ti[2] = mudj*d[2]+(qj*d[2]-muj[2])*B1; + + if (newton_pair || j < nlocal) { + tj[0] = mudi*d[0]-(qi*d[0]+mui[0])*B1; + tj[1] = mudi*d[1]-(qi*d[1]+mui[1])*B1; + tj[2] = mudi*d[2]-(qi*d[2]+mui[2])*B1; + } + + if (eflag) ecoul = G0*B0+G1*B1+G2*B2; + if (ni > 0) { // adj part, eqn 2.13 + force_coul -= (f = qqrd2e*(1.0-special_coul[ni])/r)*( + (3.0*G1+15.0*G2*r2inv)*r2inv+G0)*r2inv; + if (eflag) + ecoul -= f*((G1+3.0*G2*r2inv)*r2inv+G0); + B1 -= f*r2inv; + } + B0 = mudj+qj*B1; B3 = -qi*B1+mudi; // position independent if (ni > 0) B0 -= f*3.0*mudj*r2inv*r2inv/B2; if (ni > 0) B3 -= f*3.0*mudi*r2inv*r2inv/B2; - force_d[0] = B0*mui[0]+B3*muj[0]; // force contribs - force_d[1] = B0*mui[1]+B3*muj[1]; - force_d[2] = B0*mui[2]+B3*muj[2]; + force_d[0] = B0*mui[0]+B3*muj[0]; // force contribs + force_d[1] = B0*mui[1]+B3*muj[1]; + force_d[2] = B0*mui[2]+B3*muj[2]; if (ni > 0) { - ti[0] -= f*(3.0*mudj*r2inv*r2inv*d[0]/B2+(qj*r2inv*d[0]-muj[0]*r2inv)); - ti[1] -= f*(3.0*mudj*r2inv*r2inv*d[1]/B2+(qj*r2inv*d[1]-muj[1]*r2inv)); - ti[2] -= f*(3.0*mudj*r2inv*r2inv*d[2]/B2+(qj*r2inv*d[2]-muj[2]*r2inv)); - if (newton_pair || j < nlocal) { - tj[0] -= f*(3.0*mudi*r2inv*r2inv*d[0]/B2-(qi*r2inv*d[0]+mui[0]*r2inv)); - tj[1] -= f*(3.0*mudi*r2inv*r2inv*d[1]/B2-(qi*r2inv*d[1]+mui[1]*r2inv)); - tj[2] -= f*(3.0*mudi*r2inv*r2inv*d[2]/B2-(qi*r2inv*d[2]+mui[2]*r2inv)); - } + ti[0] -= f*(3.0*mudj*r2inv*r2inv*d[0]/B2+(qj*r2inv*d[0]-muj[0]*r2inv)); + ti[1] -= f*(3.0*mudj*r2inv*r2inv*d[1]/B2+(qj*r2inv*d[1]-muj[1]*r2inv)); + ti[2] -= f*(3.0*mudj*r2inv*r2inv*d[2]/B2+(qj*r2inv*d[2]-muj[2]*r2inv)); + if (newton_pair || j < nlocal) { + tj[0] -= f*(3.0*mudi*r2inv*r2inv*d[0]/B2-(qi*r2inv*d[0]+mui[0]*r2inv)); + tj[1] -= f*(3.0*mudi*r2inv*r2inv*d[1]/B2-(qi*r2inv*d[1]+mui[1]*r2inv)); + tj[2] -= f*(3.0*mudi*r2inv*r2inv*d[2]/B2-(qi*r2inv*d[2]+mui[2]*r2inv)); + } } - } // table real space + } // table real space } else { - force_coul = ecoul = 0.0; - memset(force_d, 0, 3*sizeof(double)); + force_coul = ecoul = 0.0; + memset(force_d, 0, 3*sizeof(double)); } - if (rsq < cut_ljsqi[typej]) { // lj - if (order6) { // long-range lj - register double rn = r2inv*r2inv*r2inv; - register double x2 = g2*rsq, a2 = 1.0/x2; - x2 = a2*exp(-x2)*lj4i[typej]; - if (ni < 0) { - force_lj = - (rn*=rn)*lj1i[typej]-g8*(((6.0*a2+6.0)*a2+3.0)*a2+1.0)*x2*rsq; - if (eflag) evdwl = rn*lj3i[typej]-g6*((a2+1.0)*a2+0.5)*x2; - } - else { // special case - register double f = special_lj[ni], t = rn*(1.0-f); - force_lj = f*(rn *= rn)*lj1i[typej]- - g8*(((6.0*a2+6.0)*a2+3.0)*a2+1.0)*x2*rsq+t*lj2i[typej]; - if (eflag) evdwl = - f*rn*lj3i[typej]-g6*((a2+1.0)*a2+0.5)*x2+t*lj4i[typej]; - } - } - else { // cut lj - register double rn = r2inv*r2inv*r2inv; - if (ni < 0) { - force_lj = rn*(rn*lj1i[typej]-lj2i[typej]); - if (eflag) evdwl = rn*(rn*lj3i[typej]-lj4i[typej])-offseti[typej]; - } - else { // special case - register double f = special_lj[ni]; - force_lj = f*rn*(rn*lj1i[typej]-lj2i[typej]); - if (eflag) evdwl = f*( - rn*(rn*lj3i[typej]-lj4i[typej])-offseti[typej]); - } - } - force_lj *= r2inv; + if (rsq < cut_ljsqi[typej]) { // lj + if (order6) { // long-range lj + register double rn = r2inv*r2inv*r2inv; + register double x2 = g2*rsq, a2 = 1.0/x2; + x2 = a2*exp(-x2)*lj4i[typej]; + if (ni < 0) { + force_lj = + (rn*=rn)*lj1i[typej]-g8*(((6.0*a2+6.0)*a2+3.0)*a2+1.0)*x2*rsq; + if (eflag) evdwl = rn*lj3i[typej]-g6*((a2+1.0)*a2+0.5)*x2; + } + else { // special case + register double f = special_lj[ni], t = rn*(1.0-f); + force_lj = f*(rn *= rn)*lj1i[typej]- + g8*(((6.0*a2+6.0)*a2+3.0)*a2+1.0)*x2*rsq+t*lj2i[typej]; + if (eflag) evdwl = + f*rn*lj3i[typej]-g6*((a2+1.0)*a2+0.5)*x2+t*lj4i[typej]; + } + } + else { // cut lj + register double rn = r2inv*r2inv*r2inv; + if (ni < 0) { + force_lj = rn*(rn*lj1i[typej]-lj2i[typej]); + if (eflag) evdwl = rn*(rn*lj3i[typej]-lj4i[typej])-offseti[typej]; + } + else { // special case + register double f = special_lj[ni]; + force_lj = f*rn*(rn*lj1i[typej]-lj2i[typej]); + if (eflag) evdwl = f*( + rn*(rn*lj3i[typej]-lj4i[typej])-offseti[typej]); + } + } + force_lj *= r2inv; } else force_lj = evdwl = 0.0; - fpair = force_coul+force_lj; // force + fpair = force_coul+force_lj; // force if (newton_pair || j < nlocal) { - register double *fj = f0+(j+(j<<1)); - fi[0] += fx = d[0]*fpair+force_d[0]; fj[0] -= fx; - fi[1] += fy = d[1]*fpair+force_d[1]; fj[1] -= fy; - fi[2] += fz = d[2]*fpair+force_d[2]; fj[2] -= fz; - tqi[0] += mui[1]*ti[2]-mui[2]*ti[1]; // torque - tqi[1] += mui[2]*ti[0]-mui[0]*ti[2]; - tqi[2] += mui[0]*ti[1]-mui[1]*ti[0]; - register double *tqj = tq0+(j+(j<<1)); - tqj[0] += muj[1]*tj[2]-muj[2]*tj[1]; - tqj[1] += muj[2]*tj[0]-muj[0]*tj[2]; - tqj[2] += muj[0]*tj[1]-muj[1]*tj[0]; + register double *fj = f0+(j+(j<<1)); + fi[0] += fx = d[0]*fpair+force_d[0]; fj[0] -= fx; + fi[1] += fy = d[1]*fpair+force_d[1]; fj[1] -= fy; + fi[2] += fz = d[2]*fpair+force_d[2]; fj[2] -= fz; + tqi[0] += mui[1]*ti[2]-mui[2]*ti[1]; // torque + tqi[1] += mui[2]*ti[0]-mui[0]*ti[2]; + tqi[2] += mui[0]*ti[1]-mui[1]*ti[0]; + register double *tqj = tq0+(j+(j<<1)); + tqj[0] += muj[1]*tj[2]-muj[2]*tj[1]; + tqj[1] += muj[2]*tj[0]-muj[0]*tj[2]; + tqj[2] += muj[0]*tj[1]-muj[1]*tj[0]; } else { - fi[0] += fx = d[0]*fpair+force_d[0]; // force - fi[1] += fy = d[1]*fpair+force_d[1]; - fi[2] += fz = d[2]*fpair+force_d[2]; - tqi[0] += mui[1]*ti[2]-mui[2]*ti[1]; // torque - tqi[1] += mui[2]*ti[0]-mui[0]*ti[2]; - tqi[2] += mui[0]*ti[1]-mui[1]*ti[0]; + fi[0] += fx = d[0]*fpair+force_d[0]; // force + fi[1] += fy = d[1]*fpair+force_d[1]; + fi[2] += fz = d[2]*fpair+force_d[2]; + tqi[0] += mui[1]*ti[2]-mui[2]*ti[1]; // torque + tqi[1] += mui[2]*ti[0]-mui[0]*ti[2]; + tqi[2] += mui[0]*ti[1]-mui[1]*ti[0]; } if (evflag) ev_tally_xyz(i,j,nlocal,newton_pair, - evdwl,ecoul,fx,fy,fz,d[0],d[1],d[2]); + evdwl,ecoul,fx,fy,fz,d[0],d[1],d[2]); } } @@ -592,8 +592,8 @@ void PairLJLongDipoleLong::compute(int eflag, int vflag) /* double PairLJLongDipoleLong::single(int i, int j, int itype, int jtype, - double rsq, double factor_coul, double factor_lj, - double &fforce) + double rsq, double factor_coul, double factor_lj, + double &fforce) { double r6inv, force_coul, force_lj; double g2 = g_ewald*g_ewald, g6 = g2*g2*g2, g8 = g6*g2, *q = atom->q; @@ -601,18 +601,18 @@ double PairLJLongDipoleLong::single(int i, int j, int itype, int jtype, double eng = 0.0; double r2inv = 1.0/rsq; - if ((ewald_order&(1<<3)) && (rsq < cut_coulsq)) { // coulombic + if ((ewald_order&(1<<3)) && (rsq < cut_coulsq)) { // coulombic double *mui = atom->mu[i], *muj = atom->mu[j]; double *xi = atom->x[i], *xj = atom->x[j]; double qi = q[i], qj = q[j]; double G0, G1, G2, B0, B1, B2, B3, mudi, mudj, muij; vector d = {xi[0]-xj[0], xi[1]-xj[1], xi[2]-xj[2]}; - { // series real space + { // series real space register double r = sqrt(rsq); register double x = g_ewald*r; register double f = exp(-x*x)*qqrd2e; - B0 = 1.0/(1.0+EWALD_P*x); // eqn 2.8 + B0 = 1.0/(1.0+EWALD_P*x); // eqn 2.8 B0 *= ((((A5*B0+A4)*B0+A3)*B0+A2)*B0+A1)*f/r; B1 = (B0 + C1 * f) * r2inv; B2 = (3.0*B1 + C2 * f) * r2inv; @@ -621,40 +621,40 @@ double PairLJLongDipoleLong::single(int i, int j, int itype, int jtype, mudi = mui[0]*d[0]+mui[1]*d[1]+mui[2]*d[2]; mudj = muj[0]*d[0]+muj[1]*d[1]+muj[2]*d[2]; muij = mui[0]*muj[0]+mui[1]*muj[1]+mui[2]*muj[2]; - G0 = qi*(qj = q[j]); // eqn 2.10 + G0 = qi*(qj = q[j]); // eqn 2.10 G1 = qi*mudj-qj*mudi+muij; G2 = -mudi*mudj; force_coul = G0*B1+G1*B2+G2*B3; eng += G0*B0+G1*B1+G2*B2; - if (factor_coul < 1.0) { // adj part, eqn 2.13 - force_coul -= (f = force->qqrd2e*(1.0-factor_coul)/r)*( - (3.0*G1+6.0*muij+15.0*G2*r2inv)*r2inv+G0); - eng -= f*((G1+3.0*G2*r2inv)*r2inv+G0); - B1 -= f*r2inv; + if (factor_coul < 1.0) { // adj part, eqn 2.13 + force_coul -= (f = force->qqrd2e*(1.0-factor_coul)/r)*( + (3.0*G1+6.0*muij+15.0*G2*r2inv)*r2inv+G0); + eng -= f*((G1+3.0*G2*r2inv)*r2inv+G0); + B1 -= f*r2inv; } - B0 = mudj*B2-qj*B1; B3 = qi*B1+mudi*B2; // position independent - //force_d[0] = B0*mui[0]+B3*muj[0]; // force contributions + B0 = mudj*B2-qj*B1; B3 = qi*B1+mudi*B2; // position independent + //force_d[0] = B0*mui[0]+B3*muj[0]; // force contributions //force_d[1] = B0*mui[1]+B3*muj[1]; //force_d[2] = B0*mui[2]+B3*muj[2]; - } // table real space + } // table real space } else force_coul = 0.0; - if (rsq < cut_ljsq[itype][jtype]) { // lennard-jones + if (rsq < cut_ljsq[itype][jtype]) { // lennard-jones r6inv = r2inv*r2inv*r2inv; - if (ewald_order&0x40) { // long-range + if (ewald_order&0x40) { // long-range register double x2 = g2*rsq, a2 = 1.0/x2, t = r6inv*(1.0-factor_lj); x2 = a2*exp(-x2)*lj4[itype][jtype]; force_lj = factor_lj*(r6inv *= r6inv)*lj1[itype][jtype]- - g8*(((6.0*a2+6.0)*a2+3.0)*a2+a2)*x2*rsq+t*lj2[itype][jtype]; + g8*(((6.0*a2+6.0)*a2+3.0)*a2+a2)*x2*rsq+t*lj2[itype][jtype]; eng += factor_lj*r6inv*lj3[itype][jtype]- - g6*((a2+1.0)*a2+0.5)*x2+t*lj4[itype][jtype]; + g6*((a2+1.0)*a2+0.5)*x2+t*lj4[itype][jtype]; } - else { // cut + else { // cut force_lj = factor_lj*r6inv*(lj1[itype][jtype]*r6inv-lj2[itype][jtype]); eng += factor_lj*(r6inv*(r6inv*lj3[itype][jtype]- - lj4[itype][jtype])-offset[itype][jtype]); + lj4[itype][jtype])-offset[itype][jtype]); } } else force_lj = 0.0; diff --git a/src/GPU/pair_ufm_gpu.cpp b/src/GPU/pair_ufm_gpu.cpp index 96af0dc069..88f2c2d3ad 100644 --- a/src/GPU/pair_ufm_gpu.cpp +++ b/src/GPU/pair_ufm_gpu.cpp @@ -49,7 +49,7 @@ int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1, int ufml_gpu_reinit(const int ntypes, double **cutsq, double **host_uf1, double **host_uf2, double **host_uf3, double **host_uf4, - double **offset); + double **offset); void ufml_gpu_clear(); int ** ufml_gpu_compute_n(const int ago, const int inum, @@ -222,10 +222,10 @@ void PairUFMGPU::cpu_compute(int start, int inum, int eflag, int vflag, jtype = type[j]; if (rsq < cutsq[itype][jtype]) { - expuf = exp(- rsq * uf2[itype][jtype]); + expuf = exp(- rsq * uf2[itype][jtype]); fpair = factor_lj * uf1[itype][jtype] * expuf /(1.0 - expuf); - f[i][0] += delx*fpair; + f[i][0] += delx*fpair; f[i][1] += dely*fpair; f[i][2] += delz*fpair; diff --git a/src/KOKKOS/atom_vec_angle_kokkos.cpp b/src/KOKKOS/atom_vec_angle_kokkos.cpp index a9e55f530a..644ed5280a 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.cpp +++ b/src/KOKKOS/atom_vec_angle_kokkos.cpp @@ -393,22 +393,22 @@ struct AtomVecAngleKokkos_PackCommSelf { /* ---------------------------------------------------------------------- */ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, - const int nfirst, const int &pbc_flag, - const int* const pbc) { + const int & iswap, + const int nfirst, const int &pbc_flag, + const int* const pbc) { if(commKK->forward_comm_on_host) { sync(Host,X_MASK); modified(Host,X_MASK); if(pbc_flag) { if(domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf<LMPHostType,1,1> - f(atomKK->k_x,nfirst,list,iswap, + f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecAngleKokkos_PackCommSelf<LMPHostType,1,0> - f(atomKK->k_x,nfirst,list,iswap, + f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -416,13 +416,13 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li } else { if(domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf<LMPHostType,0,1> - f(atomKK->k_x,nfirst,list,iswap, + f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecAngleKokkos_PackCommSelf<LMPHostType,0,0> - f(atomKK->k_x,nfirst,list,iswap, + f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -434,13 +434,13 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li if(pbc_flag) { if(domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf<LMPDeviceType,1,1> - f(atomKK->k_x,nfirst,list,iswap, + f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecAngleKokkos_PackCommSelf<LMPDeviceType,1,0> - f(atomKK->k_x,nfirst,list,iswap, + f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -448,20 +448,20 @@ int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &li } else { if(domain->triclinic) { struct AtomVecAngleKokkos_PackCommSelf<LMPDeviceType,0,1> - f(atomKK->k_x,nfirst,list,iswap, + f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecAngleKokkos_PackCommSelf<LMPDeviceType,0,0> - f(atomKK->k_x,nfirst,list,iswap, + f(atomKK->k_x,nfirst,list,iswap, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } } } - return n*3; + return n*3; } /* ---------------------------------------------------------------------- */ @@ -1137,7 +1137,7 @@ struct AtomVecAngleKokkos_PackExchangeFunctor { // 1 to store buffer length elements = 17+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom; const int maxsendlist = (buf.template view<DeviceType>().dimension_0()* - buf.template view<DeviceType>().dimension_1())/elements; + buf.template view<DeviceType>().dimension_1())/elements; buffer_view<DeviceType>(_buf,buf,maxsendlist,elements); } @@ -1221,7 +1221,7 @@ int AtomVecAngleKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_ { const int elements = 17+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom; if(nsend > (int) (k_buf.view<LMPHostType>().dimension_0()* - k_buf.view<LMPHostType>().dimension_1())/elements) { + k_buf.view<LMPHostType>().dimension_1())/elements) { int newsize = nsend*elements/k_buf.view<LMPHostType>().dimension_1()+1; k_buf.resize(newsize,k_buf.view<LMPHostType>().dimension_1()); } @@ -1414,7 +1414,7 @@ int AtomVecAngleKokkos::unpack_exchange(double *buf) if (nlocal == nmax) grow(0); modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK | MASK_MASK | IMAGE_MASK | MOLECULE_MASK | BOND_MASK | - ANGLE_MASK | SPECIAL_MASK); + ANGLE_MASK | SPECIAL_MASK); int k; int m = 1; @@ -1705,7 +1705,7 @@ void AtomVecAngleKokkos::write_data(FILE *fp, int n, double **buf) for (int i = 0; i < n; i++) fprintf(fp,"%d %d %d %-1.16e %-1.16e %-1.16e %d %d %d\n", (int) buf[i][0],(int) buf[i][1], (int) buf[i][2], - buf[i][3],buf[i][4],buf[i][5], + buf[i][3],buf[i][4],buf[i][5], (int) buf[i][6],(int) buf[i][7],(int) buf[i][8]); } diff --git a/src/KOKKOS/atom_vec_bond_kokkos.cpp b/src/KOKKOS/atom_vec_bond_kokkos.cpp index bf682c507f..9441373aa5 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.cpp +++ b/src/KOKKOS/atom_vec_bond_kokkos.cpp @@ -598,24 +598,24 @@ struct AtomVecBondKokkos_PackExchangeFunctor { _type(atom->k_type.view<DeviceType>()), _mask(atom->k_mask.view<DeviceType>()), _image(atom->k_image.view<DeviceType>()), - _molecule(atom->k_molecule.view<DeviceType>()), - _nspecial(atom->k_nspecial.view<DeviceType>()), - _special(atom->k_special.view<DeviceType>()), - _num_bond(atom->k_num_bond.view<DeviceType>()), - _bond_type(atom->k_bond_type.view<DeviceType>()), - _bond_atom(atom->k_bond_atom.view<DeviceType>()), + _molecule(atom->k_molecule.view<DeviceType>()), + _nspecial(atom->k_nspecial.view<DeviceType>()), + _special(atom->k_special.view<DeviceType>()), + _num_bond(atom->k_num_bond.view<DeviceType>()), + _bond_type(atom->k_bond_type.view<DeviceType>()), + _bond_atom(atom->k_bond_atom.view<DeviceType>()), _xw(atom->k_x.view<DeviceType>()), _vw(atom->k_v.view<DeviceType>()), _tagw(atom->k_tag.view<DeviceType>()), _typew(atom->k_type.view<DeviceType>()), _maskw(atom->k_mask.view<DeviceType>()), _imagew(atom->k_image.view<DeviceType>()), - _moleculew(atom->k_molecule.view<DeviceType>()), - _nspecialw(atom->k_nspecial.view<DeviceType>()), - _specialw(atom->k_special.view<DeviceType>()), - _num_bondw(atom->k_num_bond.view<DeviceType>()), - _bond_typew(atom->k_bond_type.view<DeviceType>()), - _bond_atomw(atom->k_bond_atom.view<DeviceType>()), + _moleculew(atom->k_molecule.view<DeviceType>()), + _nspecialw(atom->k_nspecial.view<DeviceType>()), + _specialw(atom->k_special.view<DeviceType>()), + _num_bondw(atom->k_num_bond.view<DeviceType>()), + _bond_typew(atom->k_bond_type.view<DeviceType>()), + _bond_atomw(atom->k_bond_atom.view<DeviceType>()), _sendlist(sendlist.template view<DeviceType>()), _copylist(copylist.template view<DeviceType>()), _nlocal(nlocal),_dim(dim), @@ -625,7 +625,7 @@ struct AtomVecBondKokkos_PackExchangeFunctor { // 1 to store buffer lenght elements = 16+atom->maxspecial+atom->bond_per_atom+atom->bond_per_atom; const int maxsendlist = (buf.template view<DeviceType>().dimension_0()* - buf.template view<DeviceType>().dimension_1())/elements; + buf.template view<DeviceType>().dimension_1())/elements; buffer_view<DeviceType>(_buf,buf,maxsendlist,elements); } @@ -695,7 +695,7 @@ int AtomVecBondKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2 { const int elements = 16+atomKK->maxspecial+atomKK->bond_per_atom+atomKK->bond_per_atom; if(nsend > (int) (k_buf.view<LMPHostType>().dimension_0()* - k_buf.view<LMPHostType>().dimension_1())/elements) { + k_buf.view<LMPHostType>().dimension_1())/elements) { int newsize = nsend*elements/k_buf.view<LMPHostType>().dimension_1()+1; k_buf.resize(newsize,k_buf.view<LMPHostType>().dimension_1()); } @@ -785,17 +785,17 @@ struct AtomVecBondKokkos_UnpackExchangeFunctor { _type(atom->k_type.view<DeviceType>()), _mask(atom->k_mask.view<DeviceType>()), _image(atom->k_image.view<DeviceType>()), - _molecule(atom->k_molecule.view<DeviceType>()), - _nspecial(atom->k_nspecial.view<DeviceType>()), - _special(atom->k_special.view<DeviceType>()), - _num_bond(atom->k_num_bond.view<DeviceType>()), - _bond_type(atom->k_bond_type.view<DeviceType>()), - _bond_atom(atom->k_bond_atom.view<DeviceType>()), + _molecule(atom->k_molecule.view<DeviceType>()), + _nspecial(atom->k_nspecial.view<DeviceType>()), + _special(atom->k_special.view<DeviceType>()), + _num_bond(atom->k_num_bond.view<DeviceType>()), + _bond_type(atom->k_bond_type.view<DeviceType>()), + _bond_atom(atom->k_bond_atom.view<DeviceType>()), _nlocal(nlocal.template view<DeviceType>()),_dim(dim), _lo(lo),_hi(hi){ elements = 16+atom->maxspecial+atom->bond_per_atom+atom->bond_per_atom; const int maxsendlist = (buf.template view<DeviceType>().dimension_0()* - buf.template view<DeviceType>().dimension_1())/elements; + buf.template view<DeviceType>().dimension_1())/elements; buffer_view<DeviceType>(_buf,buf,maxsendlist,elements); } @@ -1127,7 +1127,7 @@ void AtomVecBondKokkos::write_data(FILE *fp, int n, double **buf) for (int i = 0; i < n; i++) fprintf(fp,"%d %d %d %-1.16e %-1.16e %-1.16e %d %d %d\n", (int) buf[i][0],(int) buf[i][1], (int) buf[i][2], - buf[i][3],buf[i][4],buf[i][5], + buf[i][3],buf[i][4],buf[i][5], (int) buf[i][6],(int) buf[i][7],(int) buf[i][8]); } diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index 9c54ffccc5..8f453f1e0d 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -335,7 +335,7 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, } } - return n*size_forward; + return n*size_forward; } /* ---------------------------------------------------------------------- */ @@ -404,7 +404,7 @@ struct AtomVecDPDKokkos_PackCommSelf { /* ---------------------------------------------------------------------- */ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, const int & iswap, - const int nfirst, const int &pbc_flag, const int* const pbc) { + const int nfirst, const int &pbc_flag, const int* const pbc) { if(commKK->forward_comm_on_host) { sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); modified(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); @@ -478,7 +478,7 @@ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list } } } - return n*3; + return n*3; } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/atom_vec_full_kokkos.cpp b/src/KOKKOS/atom_vec_full_kokkos.cpp index 9369d7e844..0560c99037 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.cpp +++ b/src/KOKKOS/atom_vec_full_kokkos.cpp @@ -81,22 +81,22 @@ void AtomVecFullKokkos::grow(int n) memoryKK->grow_kokkos(atomKK->k_nspecial,atomKK->nspecial,nmax,3,"atom:nspecial"); memoryKK->grow_kokkos(atomKK->k_special,atomKK->special,nmax,atomKK->maxspecial, - "atom:special"); + "atom:special"); memoryKK->grow_kokkos(atomKK->k_num_bond,atomKK->num_bond,nmax,"atom:num_bond"); memoryKK->grow_kokkos(atomKK->k_bond_type,atomKK->bond_type,nmax,atomKK->bond_per_atom, - "atom:bond_type"); + "atom:bond_type"); memoryKK->grow_kokkos(atomKK->k_bond_atom,atomKK->bond_atom,nmax,atomKK->bond_per_atom, - "atom:bond_atom"); + "atom:bond_atom"); memoryKK->grow_kokkos(atomKK->k_num_angle,atomKK->num_angle,nmax,"atom:num_angle"); memoryKK->grow_kokkos(atomKK->k_angle_type,atomKK->angle_type,nmax,atomKK->angle_per_atom, - "atom:angle_type"); + "atom:angle_type"); memoryKK->grow_kokkos(atomKK->k_angle_atom1,atomKK->angle_atom1,nmax,atomKK->angle_per_atom, - "atom:angle_atom1"); + "atom:angle_atom1"); memoryKK->grow_kokkos(atomKK->k_angle_atom2,atomKK->angle_atom2,nmax,atomKK->angle_per_atom, - "atom:angle_atom2"); + "atom:angle_atom2"); memoryKK->grow_kokkos(atomKK->k_angle_atom3,atomKK->angle_atom3,nmax,atomKK->angle_per_atom, - "atom:angle_atom3"); + "atom:angle_atom3"); memoryKK->grow_kokkos(atomKK->k_num_dihedral,atomKK->num_dihedral,nmax,"atom:num_dihedral"); memoryKK->grow_kokkos(atomKK->k_dihedral_type,atomKK->dihedral_type,nmax, @@ -956,7 +956,7 @@ int AtomVecFullKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2 const int elements = 20+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; if(nsend > (int) (k_buf.view<LMPHostType>().dimension_0()* - k_buf.view<LMPHostType>().dimension_1())/elements) { + k_buf.view<LMPHostType>().dimension_1())/elements) { int newsize = nsend*elements/k_buf.view<LMPHostType>().dimension_1()+1; k_buf.resize(newsize,k_buf.view<LMPHostType>().dimension_1()); } @@ -1255,7 +1255,7 @@ int AtomVecFullKokkos::unpack_exchange(double *buf) h_nspecial(nlocal,1) = (int) ubuf(buf[m++]).i; h_nspecial(nlocal,2) = (int) ubuf(buf[m++]).i; for (k = 0; k < h_nspecial(nlocal,2); k++) - h_special(nlocal,k) = (tagint) ubuf(buf[m++]).i; + h_special(nlocal,k) = (tagint) ubuf(buf[m++]).i; if (atom->nextra_grow) for (int iextra = 0; iextra < atom->nextra_grow; iextra++) diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 03fb2a4ead..885f190f84 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -147,7 +147,7 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, } } - return n*size_forward; + return n*size_forward; } /* ---------------------------------------------------------------------- */ @@ -261,7 +261,7 @@ int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, c } } } - return n*3; + return n*3; } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.cpp b/src/KOKKOS/atom_vec_molecular_kokkos.cpp index 6f232a319b..380aa0fb7e 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.cpp +++ b/src/KOKKOS/atom_vec_molecular_kokkos.cpp @@ -79,22 +79,22 @@ void AtomVecMolecularKokkos::grow(int n) memoryKK->grow_kokkos(atomKK->k_molecule,atomKK->molecule,nmax,"atom:molecule"); memoryKK->grow_kokkos(atomKK->k_nspecial,atomKK->nspecial,nmax,3,"atom:nspecial"); memoryKK->grow_kokkos(atomKK->k_special,atomKK->special,nmax,atomKK->maxspecial, - "atom:special"); + "atom:special"); memoryKK->grow_kokkos(atomKK->k_num_bond,atomKK->num_bond,nmax,"atom:num_bond"); memoryKK->grow_kokkos(atomKK->k_bond_type,atomKK->bond_type,nmax,atomKK->bond_per_atom, - "atom:bond_type"); + "atom:bond_type"); memoryKK->grow_kokkos(atomKK->k_bond_atom,atomKK->bond_atom,nmax,atomKK->bond_per_atom, - "atom:bond_atom"); + "atom:bond_atom"); memoryKK->grow_kokkos(atomKK->k_num_angle,atomKK->num_angle,nmax,"atom:num_angle"); memoryKK->grow_kokkos(atomKK->k_angle_type,atomKK->angle_type,nmax,atomKK->angle_per_atom, - "atom:angle_type"); + "atom:angle_type"); memoryKK->grow_kokkos(atomKK->k_angle_atom1,atomKK->angle_atom1,nmax,atomKK->angle_per_atom, - "atom:angle_atom1"); + "atom:angle_atom1"); memoryKK->grow_kokkos(atomKK->k_angle_atom2,atomKK->angle_atom2,nmax,atomKK->angle_per_atom, - "atom:angle_atom2"); + "atom:angle_atom2"); memoryKK->grow_kokkos(atomKK->k_angle_atom3,atomKK->angle_atom3,nmax,atomKK->angle_per_atom, - "atom:angle_atom3"); + "atom:angle_atom3"); memoryKK->grow_kokkos(atomKK->k_num_dihedral,atomKK->num_dihedral,nmax,"atom:num_dihedral"); memoryKK->grow_kokkos(atomKK->k_dihedral_type,atomKK->dihedral_type,nmax, @@ -320,7 +320,7 @@ struct AtomVecMolecularKokkos_PackComm { _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz) { const size_t maxsend = (buf.view<DeviceType>().dimension_0() - *buf.view<DeviceType>().dimension_1())/3; + *buf.view<DeviceType>().dimension_1())/3; const size_t elements = 3; buffer_view<DeviceType>(_buf,buf,maxsend,elements); _pbc[0] = pbc[0]; _pbc[1] = pbc[1]; _pbc[2] = pbc[2]; @@ -416,7 +416,7 @@ int AtomVecMolecularKokkos::pack_comm_kokkos(const int &n, } } - return n*size_forward; + return n*size_forward; } /* ---------------------------------------------------------------------- */ @@ -533,7 +533,7 @@ int AtomVecMolecularKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d } } } - return n*3; + return n*3; } /* ---------------------------------------------------------------------- */ @@ -1369,7 +1369,7 @@ int AtomVecMolecularKokkos::pack_exchange_kokkos(const int &nsend,DAT::tdual_xfl const int elements = 19+atom->maxspecial+2*atom->bond_per_atom+4*atom->angle_per_atom+ 5*atom->dihedral_per_atom + 5*atom->improper_per_atom; if(nsend > (int) (k_buf.view<LMPHostType>().dimension_0()* - k_buf.view<LMPHostType>().dimension_1())/elements) { + k_buf.view<LMPHostType>().dimension_1())/elements) { int newsize = nsend*elements/k_buf.view<LMPHostType>().dimension_1()+1; k_buf.resize(newsize,k_buf.view<LMPHostType>().dimension_1()); } @@ -1617,7 +1617,7 @@ int AtomVecMolecularKokkos::unpack_exchange(double *buf) if (nlocal == nmax) grow(0); modified(Host,X_MASK | V_MASK | TAG_MASK | TYPE_MASK | MASK_MASK | IMAGE_MASK | MOLECULE_MASK | BOND_MASK | - ANGLE_MASK | DIHEDRAL_MASK | IMPROPER_MASK | SPECIAL_MASK); + ANGLE_MASK | DIHEDRAL_MASK | IMPROPER_MASK | SPECIAL_MASK); int k; int m = 1; @@ -1968,7 +1968,7 @@ void AtomVecMolecularKokkos::write_data(FILE *fp, int n, double **buf) for (int i = 0; i < n; i++) fprintf(fp,"%d %d %d %-1.16e %-1.16e %-1.16e %d %d %d\n", (int) buf[i][0],(int) buf[i][1], (int) buf[i][2], - buf[i][3],buf[i][4],buf[i][5], + buf[i][3],buf[i][4],buf[i][5], (int) buf[i][6],(int) buf[i][7],(int) buf[i][8]); } diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index de35431eb9..e8eb8b2b82 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -736,8 +736,8 @@ void CommKokkos::borders() template<class DeviceType> struct BuildBorderListFunctor { - typedef DeviceType device_type; - typedef ArrayTypes<DeviceType> AT; + typedef DeviceType device_type; + typedef ArrayTypes<DeviceType> AT; X_FLOAT lo,hi; typename AT::t_x_array x; int iswap,maxsendlist; diff --git a/src/KOKKOS/dihedral_charmm_kokkos.h b/src/KOKKOS/dihedral_charmm_kokkos.h index 2ee596353a..613886d21c 100644 --- a/src/KOKKOS/dihedral_charmm_kokkos.h +++ b/src/KOKKOS/dihedral_charmm_kokkos.h @@ -35,13 +35,13 @@ struct s_EVM_FLOAT { F_FLOAT vp[6]; KOKKOS_INLINE_FUNCTION s_EVM_FLOAT() { - evdwl = 0; - ecoul = 0; - emol = 0; - v[0] = 0; v[1] = 0; v[2] = 0; - v[3] = 0; v[4] = 0; v[5] = 0; - vp[0] = 0; vp[1] = 0; vp[2] = 0; - vp[3] = 0; vp[4] = 0; vp[5] = 0; + evdwl = 0; + ecoul = 0; + emol = 0; + v[0] = 0; v[1] = 0; v[2] = 0; + v[3] = 0; v[4] = 0; v[5] = 0; + vp[0] = 0; vp[1] = 0; vp[2] = 0; + vp[3] = 0; vp[4] = 0; vp[5] = 0; } KOKKOS_INLINE_FUNCTION diff --git a/src/KOKKOS/pair_coul_debye_kokkos.cpp b/src/KOKKOS/pair_coul_debye_kokkos.cpp index 4cac18cacf..729b24ff29 100644 --- a/src/KOKKOS/pair_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_coul_debye_kokkos.cpp @@ -181,7 +181,7 @@ compute_fcoul(const F_FLOAT& rsq, const int& i, const int&j, F_FLOAT forcecoul; forcecoul = qqrd2e * qtmp * q(j) * screening * (kappa + rinv) * - (STACKPARAMS?m_params[itype][jtype].scale:params(itype,jtype).scale); + (STACKPARAMS?m_params[itype][jtype].scale:params(itype,jtype).scale); return factor_coul*forcecoul*r2inv; @@ -203,7 +203,7 @@ compute_ecoul(const F_FLOAT& rsq, const int& i, const int&j, const F_FLOAT screening = exp(-kappa*r); return factor_coul * qqrd2e * qtmp * q(j) * rinv * screening * - (STACKPARAMS?m_params[itype][jtype].scale:params(itype,jtype).scale); + (STACKPARAMS?m_params[itype][jtype].scale:params(itype,jtype).scale); } diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp index 7d395cb3b4..70f0c3e00a 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp @@ -217,8 +217,8 @@ compute_fpair(const F_FLOAT& rsq, const int& i, const int&j, (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; switch2 = 12.0*rsq * (cut_ljsq-rsq) * (rsq-cut_lj_innersq) / denom_lj; englj = r6inv * - ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - - (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); + ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - + (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); forcelj = forcelj*switch1 + englj*switch2; } diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp index 2663d71a1f..0316b65aed 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp @@ -217,8 +217,8 @@ compute_fpair(const F_FLOAT& rsq, const int& i, const int&j, (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; switch2 = 12.0*rsq * (cut_ljsq-rsq) * (rsq-cut_lj_innersq) / denom_lj; englj = r6inv * - ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - - (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); + ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - + (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); forcelj = forcelj*switch1 + englj*switch2; } diff --git a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp index 81271c7d8a..4d27373824 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp @@ -217,8 +217,8 @@ compute_fpair(const F_FLOAT& rsq, const int& i, const int&j, (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; switch2 = 12.0*rsq * (cut_ljsq-rsq) * (rsq-cut_lj_innersq) / denom_lj; englj = r6inv * - ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - - (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); + ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - + (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); forcelj = forcelj*switch1 + englj*switch2; } diff --git a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp index 0da5e7f5f5..b64d9fa31a 100644 --- a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp @@ -245,7 +245,7 @@ compute_fcoul(const F_FLOAT& rsq, const int& i, const int&j, const F_FLOAT erfcc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * erfcd; return prefactor * (erfcc/r + 2.0*alpha/MY_PIS * erfcd + r*f_shift) * - r2inv; + r2inv; } /* ---------------------------------------------------------------------- diff --git a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp index bf269288e0..1cc8d9b3e2 100644 --- a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp +++ b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp @@ -206,8 +206,8 @@ compute_fpair(const F_FLOAT& rsq, const int& i, const int&j, const F_FLOAT r = sqrt(rsq); const F_FLOAT tlj = r - cut_lj_inner; const F_FLOAT fswitch = r*tlj*tlj* - ((STACKPARAMS?m_params[itype][jtype].ljsw1:params(itype,jtype).ljsw1) + - (STACKPARAMS?m_params[itype][jtype].ljsw2:params(itype,jtype).ljsw2)*tlj); + ((STACKPARAMS?m_params[itype][jtype].ljsw1:params(itype,jtype).ljsw1) + + (STACKPARAMS?m_params[itype][jtype].ljsw2:params(itype,jtype).ljsw2)*tlj); forcelj += fswitch; } return forcelj*r2inv; @@ -234,8 +234,8 @@ compute_evdwl(const F_FLOAT& rsq, const int& i, const int&j, const F_FLOAT r = sqrt(rsq); const F_FLOAT tlj = r - cut_lj_inner; const F_FLOAT eswitch = tlj*tlj*tlj * - ((STACKPARAMS?m_params[itype][jtype].ljsw3:params(itype,jtype).ljsw3) + - (STACKPARAMS?m_params[itype][jtype].ljsw4:params(itype,jtype).ljsw4)*tlj); + ((STACKPARAMS?m_params[itype][jtype].ljsw3:params(itype,jtype).ljsw3) + + (STACKPARAMS?m_params[itype][jtype].ljsw4:params(itype,jtype).ljsw4)*tlj); englj += eswitch; } return englj; diff --git a/src/KOKKOS/pair_lj_gromacs_kokkos.cpp b/src/KOKKOS/pair_lj_gromacs_kokkos.cpp index f24ff718c1..f0ad935769 100644 --- a/src/KOKKOS/pair_lj_gromacs_kokkos.cpp +++ b/src/KOKKOS/pair_lj_gromacs_kokkos.cpp @@ -193,8 +193,8 @@ compute_fpair(const F_FLOAT& rsq, const int& i, const int&j, const F_FLOAT r = sqrt(rsq); const F_FLOAT tlj = r - (STACKPARAMS?m_params[itype][jtype].cut_inner:params(itype,jtype).cut_inner); const F_FLOAT fswitch = r*tlj*tlj* - ((STACKPARAMS?m_params[itype][jtype].ljsw1:params(itype,jtype).ljsw1) + - (STACKPARAMS?m_params[itype][jtype].ljsw2:params(itype,jtype).ljsw2)*tlj); + ((STACKPARAMS?m_params[itype][jtype].ljsw1:params(itype,jtype).ljsw1) + + (STACKPARAMS?m_params[itype][jtype].ljsw2:params(itype,jtype).ljsw2)*tlj); forcelj += fswitch; } return forcelj*r2inv; @@ -221,8 +221,8 @@ compute_evdwl(const F_FLOAT& rsq, const int& i, const int&j, const F_FLOAT r = sqrt(rsq); const F_FLOAT tlj = r - (STACKPARAMS?m_params[itype][jtype].cut_inner:params(itype,jtype).cut_inner); const F_FLOAT eswitch = tlj*tlj*tlj * - ((STACKPARAMS?m_params[itype][jtype].ljsw3:params(itype,jtype).ljsw3) + - (STACKPARAMS?m_params[itype][jtype].ljsw4:params(itype,jtype).ljsw4)*tlj); + ((STACKPARAMS?m_params[itype][jtype].ljsw3:params(itype,jtype).ljsw3) + + (STACKPARAMS?m_params[itype][jtype].ljsw4:params(itype,jtype).ljsw4)*tlj); englj += eswitch; } return englj; diff --git a/src/KOKKOS/pair_tersoff_kokkos.cpp b/src/KOKKOS/pair_tersoff_kokkos.cpp index c585da6029..b64b2f6d43 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_kokkos.cpp @@ -75,7 +75,7 @@ void PairTersoffKokkos<DeviceType>::allocate() int n = atom->ntypes; k_params = Kokkos::DualView<params_ters***,Kokkos::LayoutRight,DeviceType> - ("PairTersoff::paramskk",n+1,n+1,n+1); + ("PairTersoff::paramskk",n+1,n+1,n+1); paramskk = k_params.template view<DeviceType>(); } @@ -355,7 +355,7 @@ void PairTersoffKokkos<DeviceType>::operator()(TagPairTersoffComputeHalf<NEIGHFL const F_FLOAT tmp_fcd = ters_dfc(itype,jtype,jtype,r); const F_FLOAT tmp_exp = exp(-paramskk(itype,jtype,jtype).lam1 * r); const F_FLOAT frep = -paramskk(itype,jtype,jtype).biga * tmp_exp * - (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1) / r; + (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1) / r; const F_FLOAT eng = tmp_fce * paramskk(itype,jtype,jtype).biga * tmp_exp; f_x += delx*frep; @@ -524,7 +524,7 @@ void PairTersoffKokkos<DeviceType>::operator()(TagPairTersoffComputeFullA<NEIGHF const F_FLOAT tmp_fcd = ters_dfc(itype,jtype,jtype,r); const F_FLOAT tmp_exp = exp(-paramskk(itype,jtype,jtype).lam1 * r); const F_FLOAT frep = -paramskk(itype,jtype,jtype).biga * tmp_exp * - (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1) / r; + (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1) / r; const F_FLOAT eng = tmp_fce * paramskk(itype,jtype,jtype).biga * tmp_exp; f_x += delx*frep; @@ -535,7 +535,7 @@ void PairTersoffKokkos<DeviceType>::operator()(TagPairTersoffComputeFullA<NEIGHF if (eflag) ev.evdwl += 0.5*eng; if (vflag_either || eflag_atom) - this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,frep,delx,dely,delz); + this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,frep,delx,dely,delz); } } @@ -589,7 +589,7 @@ void PairTersoffKokkos<DeviceType>::operator()(TagPairTersoffComputeFullA<NEIGHF if (EVFLAG) { if (eflag) ev.evdwl += 0.5*eng; if (vflag_either || eflag_atom) - this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); + this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); } // attractive: three-body force @@ -609,17 +609,17 @@ void PairTersoffKokkos<DeviceType>::operator()(TagPairTersoffComputeFullA<NEIGHF if (rsq2 > cutsq2) continue; rik = sqrt(rsq2); ters_dthb(itype,jtype,ktype,prefactor,rij,delx1,dely1,delz1, - rik,delx2,dely2,delz2,fi,fj,fk); + rik,delx2,dely2,delz2,fi,fj,fk); f_x += fi[0]; f_y += fi[1]; f_z += fi[2]; if (vflag_atom) { - F_FLOAT delrij[3], delrik[3]; - delrij[0] = -delx1; delrij[1] = -dely1; delrij[2] = -delz1; - delrik[0] = -delx2; delrik[1] = -dely2; delrik[2] = -delz2; - if (vflag_either) this->template v_tally3<NEIGHFLAG>(ev,i,j,k,fj,fk,delrij,delrik); + F_FLOAT delrij[3], delrik[3]; + delrij[0] = -delx1; delrij[1] = -dely1; delrij[2] = -delz1; + delrik[0] = -delx2; delrik[1] = -dely2; delrik[2] = -delz2; + if (vflag_either) this->template v_tally3<NEIGHFLAG>(ev,i,j,k,fj,fk,delrij,delrik); } } } @@ -715,7 +715,7 @@ void PairTersoffKokkos<DeviceType>::operator()(TagPairTersoffComputeFullB<NEIGHF if (eflag) ev.evdwl += 0.5 * eng; if (vflag_either || eflag_atom) - this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); + this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); } // attractive: three-body force @@ -735,22 +735,22 @@ void PairTersoffKokkos<DeviceType>::operator()(TagPairTersoffComputeFullB<NEIGHF if (rsq2 > cutsq2) continue; rik = sqrt(rsq2); ters_dthbj(jtype,itype,ktype,prefactor,rij,delx1,dely1,delz1, - rik,delx2,dely2,delz2,fj,fk); + rik,delx2,dely2,delz2,fj,fk); f_x += fj[0]; f_y += fj[1]; f_z += fj[2]; if (vflag_atom) { - F_FLOAT delrji[3], delrjk[3]; - delrji[0] = -delx1; delrji[1] = -dely1; delrji[2] = -delz1; - delrjk[0] = -delx2; delrjk[1] = -dely2; delrjk[2] = -delz2; - if (vflag_either) v_tally3_atom(ev,i,j,k,fj,fk,delrji,delrjk); + F_FLOAT delrji[3], delrjk[3]; + delrji[0] = -delx1; delrji[1] = -dely1; delrji[2] = -delz1; + delrjk[0] = -delx2; delrjk[1] = -dely2; delrjk[2] = -delz2; + if (vflag_either) v_tally3_atom(ev,i,j,k,fj,fk,delrji,delrjk); } const F_FLOAT fa_jk = ters_fa_k(jtype,ktype,itype,rik); const F_FLOAT prefactor_jk = 0.5*fa_jk * ters_dbij(jtype,ktype,itype,bo_ij); ters_dthbk(jtype,ktype,itype,prefactor_jk,rik,delx2,dely2,delz2, - rij,delx1,dely1,delz1,fk); + rij,delx1,dely1,delz1,fk); f_x += fk[0]; f_y += fk[1]; f_z += fk[2]; @@ -774,7 +774,7 @@ void PairTersoffKokkos<DeviceType>::operator()(TagPairTersoffComputeFullB<NEIGHF template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffKokkos<DeviceType>::ters_fc_k(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { const F_FLOAT ters_R = paramskk(i,j,k).bigr; const F_FLOAT ters_D = paramskk(i,j,k).bigd; @@ -789,7 +789,7 @@ double PairTersoffKokkos<DeviceType>::ters_fc_k(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffKokkos<DeviceType>::ters_dfc(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { const F_FLOAT ters_R = paramskk(i,j,k).bigr; const F_FLOAT ters_D = paramskk(i,j,k).bigd; @@ -804,8 +804,8 @@ double PairTersoffKokkos<DeviceType>::ters_dfc(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffKokkos<DeviceType>::bondorder(const int &i, const int &j, const int &k, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2) const + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2) const { F_FLOAT arg, ex_delr; @@ -827,7 +827,7 @@ double PairTersoffKokkos<DeviceType>::bondorder(const int &i, const int &j, cons template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffKokkos<DeviceType>:: - ters_gijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const + ters_gijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const { const F_FLOAT ters_c = paramskk(i,j,k).c * paramskk(i,j,k).c; const F_FLOAT ters_d = paramskk(i,j,k).d * paramskk(i,j,k).d; @@ -841,7 +841,7 @@ double PairTersoffKokkos<DeviceType>:: template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffKokkos<DeviceType>:: - ters_dgijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const + ters_dgijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const { const F_FLOAT ters_c = paramskk(i,j,k).c * paramskk(i,j,k).c; const F_FLOAT ters_d = paramskk(i,j,k).d * paramskk(i,j,k).d; @@ -856,11 +856,11 @@ double PairTersoffKokkos<DeviceType>:: template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffKokkos<DeviceType>::ters_fa_k(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { if (r > paramskk(i,j,k).bigr + paramskk(i,j,k).bigd) return 0.0; return -paramskk(i,j,k).bigb * exp(-paramskk(i,j,k).lam2 * r) - * ters_fc_k(i,j,k,r); + * ters_fc_k(i,j,k,r); } /* ---------------------------------------------------------------------- */ @@ -868,7 +868,7 @@ double PairTersoffKokkos<DeviceType>::ters_fa_k(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffKokkos<DeviceType>::ters_dfa(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { if (r > paramskk(i,j,k).bigr + paramskk(i,j,k).bigd) return 0.0; return paramskk(i,j,k).bigb * exp(-paramskk(i,j,k).lam2 * r) * @@ -880,7 +880,7 @@ double PairTersoffKokkos<DeviceType>::ters_dfa(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffKokkos<DeviceType>::ters_bij_k(const int &i, const int &j, - const int &k, const F_FLOAT &bo) const + const int &k, const F_FLOAT &bo) const { const F_FLOAT tmp = paramskk(i,j,k).beta * bo; if (tmp > paramskk(i,j,k).c1) return 1.0/sqrt(tmp); @@ -897,7 +897,7 @@ double PairTersoffKokkos<DeviceType>::ters_bij_k(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffKokkos<DeviceType>::ters_dbij(const int &i, const int &j, - const int &k, const F_FLOAT &bo) const + const int &k, const F_FLOAT &bo) const { const F_FLOAT tmp = paramskk(i,j,k).beta * bo; if (tmp > paramskk(i,j,k).c1) return paramskk(i,j,k).beta * -0.5/sqrt(tmp*tmp);//*pow(tmp,-1.5); @@ -918,10 +918,10 @@ double PairTersoffKokkos<DeviceType>::ters_dbij(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION void PairTersoffKokkos<DeviceType>::ters_dthb( - const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk) const + const int &i, const int &j, const int &k, const F_FLOAT &prefactor, + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk) const { // from PairTersoff::attractive F_FLOAT rij_hat[3],rik_hat[3]; @@ -991,10 +991,10 @@ void PairTersoffKokkos<DeviceType>::ters_dthb( template<class DeviceType> KOKKOS_INLINE_FUNCTION void PairTersoffKokkos<DeviceType>::ters_dthbj( - const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fj, F_FLOAT *fk) const + const int &i, const int &j, const int &k, const F_FLOAT &prefactor, + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fj, F_FLOAT *fk) const { F_FLOAT rij_hat[3],rik_hat[3]; F_FLOAT rijinv,rikinv; @@ -1053,10 +1053,10 @@ void PairTersoffKokkos<DeviceType>::ters_dthbj( template<class DeviceType> KOKKOS_INLINE_FUNCTION void PairTersoffKokkos<DeviceType>::ters_dthbk( - const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fk) const + const int &i, const int &j, const int &k, const F_FLOAT &prefactor, + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fk) const { F_FLOAT rij_hat[3],rik_hat[3]; F_FLOAT rijinv,rikinv; @@ -1179,7 +1179,7 @@ template<class DeviceType> template<int NEIGHFLAG> KOKKOS_INLINE_FUNCTION void PairTersoffKokkos<DeviceType>::v_tally3(EV_FLOAT &ev, const int &i, const int &j, const int &k, - F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const + F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const { // The eatom and vatom arrays are atomic for Half/Thread neighbor style diff --git a/src/KOKKOS/pair_tersoff_kokkos.h b/src/KOKKOS/pair_tersoff_kokkos.h index 86427bbc66..f40d28b72b 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.h +++ b/src/KOKKOS/pair_tersoff_kokkos.h @@ -102,8 +102,8 @@ class PairTersoffKokkos : public PairTersoff { KOKKOS_INLINE_FUNCTION double bondorder(const int &i, const int &j, const int &k, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2) const; + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2) const; KOKKOS_INLINE_FUNCTION double ters_gijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const; @@ -113,21 +113,21 @@ class PairTersoffKokkos : public PairTersoff { KOKKOS_INLINE_FUNCTION void ters_dthb(const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk) const; + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk) const; KOKKOS_INLINE_FUNCTION void ters_dthbj(const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fj, F_FLOAT *fk) const; + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fj, F_FLOAT *fk) const; KOKKOS_INLINE_FUNCTION void ters_dthbk(const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fk) const; + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fk) const; KOKKOS_INLINE_FUNCTION double vec3_dot(const F_FLOAT x[3], const double y[3]) const { @@ -155,12 +155,12 @@ class PairTersoffKokkos : public PairTersoff { struct params_ters{ KOKKOS_INLINE_FUNCTION params_ters(){powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; - bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;}; + bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;}; KOKKOS_INLINE_FUNCTION params_ters(int i){powerm=0;gamma=0;lam3=0;c=0;d=0;h=0;powern=0;beta=0;lam2=0;bigb=0; - bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;}; + bigr=0;bigd=0;lam1=0;biga=0;cutsq=0;c1=0;c2=0;c3=0;c4=0;}; F_FLOAT powerm, gamma, lam3, c, d, h, powern, beta, lam2, bigb, bigr, - bigd, lam1, biga, cutsq, c1, c2, c3, c4; + bigd, lam1, biga, cutsq, c1, c2, c3, c4; }; template<int NEIGHFLAG> @@ -172,11 +172,11 @@ class PairTersoffKokkos : public PairTersoff { template<int NEIGHFLAG> KOKKOS_INLINE_FUNCTION void v_tally3(EV_FLOAT &ev, const int &i, const int &j, const int &k, - F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const; + F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const; KOKKOS_INLINE_FUNCTION void v_tally3_atom(EV_FLOAT &ev, const int &i, const int &j, const int &k, - F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drji, F_FLOAT *drjk) const; + F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drji, F_FLOAT *drjk) const; void allocate(); void setup_params(); diff --git a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp index 8e718fbf6f..21c7fbb727 100644 --- a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp @@ -75,7 +75,7 @@ void PairTersoffMODKokkos<DeviceType>::allocate() int n = atom->ntypes; k_params = Kokkos::DualView<params_ters***,Kokkos::LayoutRight,DeviceType> - ("PairTersoffMOD::paramskk",n+1,n+1,n+1); + ("PairTersoffMOD::paramskk",n+1,n+1,n+1); paramskk = k_params.template view<DeviceType>(); } @@ -355,7 +355,7 @@ void PairTersoffMODKokkos<DeviceType>::operator()(TagPairTersoffMODComputeHalf<N const F_FLOAT tmp_fcd = ters_dfc(itype,jtype,jtype,r); const F_FLOAT tmp_exp = exp(-paramskk(itype,jtype,jtype).lam1 * r); const F_FLOAT frep = -paramskk(itype,jtype,jtype).biga * tmp_exp * - (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1) / r; + (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1) / r; const F_FLOAT eng = tmp_fce * paramskk(itype,jtype,jtype).biga * tmp_exp; f_x += delx*frep; @@ -524,7 +524,7 @@ void PairTersoffMODKokkos<DeviceType>::operator()(TagPairTersoffMODComputeFullA< const F_FLOAT tmp_fcd = ters_dfc(itype,jtype,jtype,r); const F_FLOAT tmp_exp = exp(-paramskk(itype,jtype,jtype).lam1 * r); const F_FLOAT frep = -paramskk(itype,jtype,jtype).biga * tmp_exp * - (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1) / r; + (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1) / r; const F_FLOAT eng = tmp_fce * paramskk(itype,jtype,jtype).biga * tmp_exp; f_x += delx*frep; @@ -535,7 +535,7 @@ void PairTersoffMODKokkos<DeviceType>::operator()(TagPairTersoffMODComputeFullA< if (eflag) ev.evdwl += 0.5*eng; if (vflag_either || eflag_atom) - this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,frep,delx,dely,delz); + this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,frep,delx,dely,delz); } } @@ -589,7 +589,7 @@ void PairTersoffMODKokkos<DeviceType>::operator()(TagPairTersoffMODComputeFullA< if (EVFLAG) { if (eflag) ev.evdwl += 0.5*eng; if (vflag_either || eflag_atom) - this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); + this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); } // attractive: three-body force @@ -609,17 +609,17 @@ void PairTersoffMODKokkos<DeviceType>::operator()(TagPairTersoffMODComputeFullA< if (rsq2 > cutsq2) continue; rik = sqrt(rsq2); ters_dthb(itype,jtype,ktype,prefactor,rij,delx1,dely1,delz1, - rik,delx2,dely2,delz2,fi,fj,fk); + rik,delx2,dely2,delz2,fi,fj,fk); f_x += fi[0]; f_y += fi[1]; f_z += fi[2]; if (vflag_atom) { - F_FLOAT delrij[3], delrik[3]; - delrij[0] = -delx1; delrij[1] = -dely1; delrij[2] = -delz1; - delrik[0] = -delx2; delrik[1] = -dely2; delrik[2] = -delz2; - if (vflag_either) this->template v_tally3<NEIGHFLAG>(ev,i,j,k,fj,fk,delrij,delrik); + F_FLOAT delrij[3], delrik[3]; + delrij[0] = -delx1; delrij[1] = -dely1; delrij[2] = -delz1; + delrik[0] = -delx2; delrik[1] = -dely2; delrik[2] = -delz2; + if (vflag_either) this->template v_tally3<NEIGHFLAG>(ev,i,j,k,fj,fk,delrij,delrik); } } } @@ -715,7 +715,7 @@ void PairTersoffMODKokkos<DeviceType>::operator()(TagPairTersoffMODComputeFullB< if (eflag) ev.evdwl += 0.5 * eng; if (vflag_either || eflag_atom) - this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); + this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); } // attractive: three-body force @@ -735,22 +735,22 @@ void PairTersoffMODKokkos<DeviceType>::operator()(TagPairTersoffMODComputeFullB< if (rsq2 > cutsq2) continue; rik = sqrt(rsq2); ters_dthbj(jtype,itype,ktype,prefactor,rij,delx1,dely1,delz1, - rik,delx2,dely2,delz2,fj,fk); + rik,delx2,dely2,delz2,fj,fk); f_x += fj[0]; f_y += fj[1]; f_z += fj[2]; if (vflag_atom) { - F_FLOAT delrji[3], delrjk[3]; - delrji[0] = -delx1; delrji[1] = -dely1; delrji[2] = -delz1; - delrjk[0] = -delx2; delrjk[1] = -dely2; delrjk[2] = -delz2; - if (vflag_either) v_tally3_atom(ev,i,j,k,fj,fk,delrji,delrjk); + F_FLOAT delrji[3], delrjk[3]; + delrji[0] = -delx1; delrji[1] = -dely1; delrji[2] = -delz1; + delrjk[0] = -delx2; delrjk[1] = -dely2; delrjk[2] = -delz2; + if (vflag_either) v_tally3_atom(ev,i,j,k,fj,fk,delrji,delrjk); } const F_FLOAT fa_jk = ters_fa_k(jtype,ktype,itype,rik); const F_FLOAT prefactor_jk = 0.5*fa_jk * ters_dbij(jtype,ktype,itype,bo_ij); ters_dthbk(jtype,ktype,itype,prefactor_jk,rik,delx2,dely2,delz2, - rij,delx1,dely1,delz1,fk); + rij,delx1,dely1,delz1,fk); f_x += fk[0]; f_y += fk[1]; f_z += fk[2]; @@ -774,7 +774,7 @@ void PairTersoffMODKokkos<DeviceType>::operator()(TagPairTersoffMODComputeFullB< template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffMODKokkos<DeviceType>::ters_fc_k(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { const F_FLOAT ters_R = paramskk(i,j,k).bigr; const F_FLOAT ters_D = paramskk(i,j,k).bigd; @@ -790,7 +790,7 @@ double PairTersoffMODKokkos<DeviceType>::ters_fc_k(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffMODKokkos<DeviceType>::ters_dfc(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { const F_FLOAT ters_R = paramskk(i,j,k).bigr; const F_FLOAT ters_D = paramskk(i,j,k).bigd; @@ -806,8 +806,8 @@ double PairTersoffMODKokkos<DeviceType>::ters_dfc(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffMODKokkos<DeviceType>::bondorder(const int &i, const int &j, const int &k, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2) const + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2) const { F_FLOAT arg, ex_delr; @@ -828,7 +828,7 @@ double PairTersoffMODKokkos<DeviceType>::bondorder(const int &i, const int &j, c template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffMODKokkos<DeviceType>:: - ters_gijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const + ters_gijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const { const F_FLOAT ters_c1 = paramskk(i,j,k).c1; const F_FLOAT ters_c2 = paramskk(i,j,k).c2; @@ -847,7 +847,7 @@ double PairTersoffMODKokkos<DeviceType>:: template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffMODKokkos<DeviceType>:: - ters_dgijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const + ters_dgijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const { const F_FLOAT ters_c2 = paramskk(i,j,k).c2; const F_FLOAT ters_c3 = paramskk(i,j,k).c3; @@ -866,11 +866,11 @@ double PairTersoffMODKokkos<DeviceType>:: template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffMODKokkos<DeviceType>::ters_fa_k(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { if (r > paramskk(i,j,k).bigr + paramskk(i,j,k).bigd) return 0.0; return -paramskk(i,j,k).bigb * exp(-paramskk(i,j,k).lam2 * r) - * ters_fc_k(i,j,k,r); + * ters_fc_k(i,j,k,r); } /* ---------------------------------------------------------------------- */ @@ -878,7 +878,7 @@ double PairTersoffMODKokkos<DeviceType>::ters_fa_k(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffMODKokkos<DeviceType>::ters_dfa(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { if (r > paramskk(i,j,k).bigr + paramskk(i,j,k).bigd) return 0.0; return paramskk(i,j,k).bigb * exp(-paramskk(i,j,k).lam2 * r) * @@ -890,7 +890,7 @@ double PairTersoffMODKokkos<DeviceType>::ters_dfa(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffMODKokkos<DeviceType>::ters_bij_k(const int &i, const int &j, - const int &k, const F_FLOAT &bo) const + const int &k, const F_FLOAT &bo) const { const F_FLOAT tmp = paramskk(i,j,k).beta * bo; if (tmp > paramskk(i,j,k).ca1) @@ -905,18 +905,18 @@ double PairTersoffMODKokkos<DeviceType>::ters_bij_k(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffMODKokkos<DeviceType>::ters_dbij(const int &i, const int &j, - const int &k, const F_FLOAT &bo) const + const int &k, const F_FLOAT &bo) const { const F_FLOAT tmp = paramskk(i,j,k).beta * bo; if (tmp > paramskk(i,j,k).ca1) return -0.5*(paramskk(i,j,k).powern/paramskk(i,j,k).powern_del)* - pow(tmp,-0.5*(paramskk(i,j,k).powern/paramskk(i,j,k).powern_del)) / bo; + pow(tmp,-0.5*(paramskk(i,j,k).powern/paramskk(i,j,k).powern_del)) / bo; if (tmp < paramskk(i,j,k).ca4) return 0.0; const F_FLOAT tmp_n = pow(tmp,paramskk(i,j,k).powern); return -0.5 *(paramskk(i,j,k).powern/paramskk(i,j,k).powern_del)* - pow(1.0+tmp_n, -1.0-(1.0/(2.0*paramskk(i,j,k).powern_del)))*tmp_n / bo; + pow(1.0+tmp_n, -1.0-(1.0/(2.0*paramskk(i,j,k).powern_del)))*tmp_n / bo; } /* ---------------------------------------------------------------------- */ @@ -924,10 +924,10 @@ double PairTersoffMODKokkos<DeviceType>::ters_dbij(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION void PairTersoffMODKokkos<DeviceType>::ters_dthb( - const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk) const + const int &i, const int &j, const int &k, const F_FLOAT &prefactor, + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk) const { // from PairTersoffMOD::attractive F_FLOAT rij_hat[3],rik_hat[3]; @@ -996,10 +996,10 @@ void PairTersoffMODKokkos<DeviceType>::ters_dthb( template<class DeviceType> KOKKOS_INLINE_FUNCTION void PairTersoffMODKokkos<DeviceType>::ters_dthbj( - const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fj, F_FLOAT *fk) const + const int &i, const int &j, const int &k, const F_FLOAT &prefactor, + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fj, F_FLOAT *fk) const { F_FLOAT rij_hat[3],rik_hat[3]; F_FLOAT rijinv,rikinv; @@ -1057,10 +1057,10 @@ void PairTersoffMODKokkos<DeviceType>::ters_dthbj( template<class DeviceType> KOKKOS_INLINE_FUNCTION void PairTersoffMODKokkos<DeviceType>::ters_dthbk( - const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fk) const + const int &i, const int &j, const int &k, const F_FLOAT &prefactor, + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fk) const { F_FLOAT rij_hat[3],rik_hat[3]; F_FLOAT rijinv,rikinv; @@ -1182,7 +1182,7 @@ template<class DeviceType> template<int NEIGHFLAG> KOKKOS_INLINE_FUNCTION void PairTersoffMODKokkos<DeviceType>::v_tally3(EV_FLOAT &ev, const int &i, const int &j, const int &k, - F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const + F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const { // The eatom and vatom arrays are atomic for Half/Thread neighbor style diff --git a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp index 11a5ff1007..8a34dc34ab 100644 --- a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp @@ -86,7 +86,7 @@ void PairTersoffZBLKokkos<DeviceType>::allocate() int n = atom->ntypes; k_params = Kokkos::DualView<params_ters***,Kokkos::LayoutRight,DeviceType> - ("PairTersoffZBL::paramskk",n+1,n+1,n+1); + ("PairTersoffZBL::paramskk",n+1,n+1,n+1); paramskk = k_params.template view<DeviceType>(); } @@ -371,19 +371,19 @@ void PairTersoffZBLKokkos<DeviceType>::operator()(TagPairTersoffZBLComputeHalf<N const F_FLOAT tmp_fcd = ters_dfc(itype,jtype,jtype,r); const F_FLOAT tmp_exp = exp(-paramskk(itype,jtype,jtype).lam1 * r); const F_FLOAT frep_t = paramskk(itype,jtype,jtype).biga * tmp_exp * - (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1); + (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1); const F_FLOAT eng_t = tmp_fce * paramskk(itype,jtype,jtype).biga * tmp_exp; // ZBL repulsive portion const F_FLOAT esq = pow(global_e,2.0); const F_FLOAT a_ij = (0.8854*global_a_0) / - (pow(paramskk(itype,jtype,jtype).Z_i,0.23) + pow(paramskk(itype,jtype,jtype).Z_j,0.23)); + (pow(paramskk(itype,jtype,jtype).Z_i,0.23) + pow(paramskk(itype,jtype,jtype).Z_j,0.23)); const F_FLOAT premult = (paramskk(itype,jtype,jtype).Z_i * paramskk(itype,jtype,jtype).Z_j * esq)/ - (4.0*MY_PI*global_epsilon_0); + (4.0*MY_PI*global_epsilon_0); const F_FLOAT r_ov_a = r/a_ij; const F_FLOAT phi = 0.1818*exp(-3.2*r_ov_a) + 0.5099*exp(-0.9423*r_ov_a) + - 0.2802*exp(-0.4029*r_ov_a) + 0.02817*exp(-0.2016*r_ov_a); + 0.2802*exp(-0.4029*r_ov_a) + 0.02817*exp(-0.2016*r_ov_a); const F_FLOAT dphi = (1.0/a_ij) * (-3.2*0.1818*exp(-3.2*r_ov_a) - 0.9423*0.5099*exp(-0.9423*r_ov_a) - 0.4029*0.2802*exp(-0.4029*r_ov_a) - @@ -400,7 +400,7 @@ void PairTersoffZBLKokkos<DeviceType>::operator()(TagPairTersoffZBLComputeHalf<N if (eflag) eng = (1.0 - fermi_k(itype,jtype,jtype,r)) * eng_z + - fermi_k(itype,jtype,jtype,r) * eng_t; + fermi_k(itype,jtype,jtype,r) * eng_t; f_x += delx*frep; f_y += dely*frep; @@ -570,19 +570,19 @@ void PairTersoffZBLKokkos<DeviceType>::operator()(TagPairTersoffZBLComputeFullA< const F_FLOAT tmp_fcd = ters_dfc(itype,jtype,jtype,r); const F_FLOAT tmp_exp = exp(-paramskk(itype,jtype,jtype).lam1 * r); const F_FLOAT frep_t = paramskk(itype,jtype,jtype).biga * tmp_exp * - (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1); + (tmp_fcd - tmp_fce*paramskk(itype,jtype,jtype).lam1); const F_FLOAT eng_t = tmp_fce * paramskk(itype,jtype,jtype).biga * tmp_exp; // ZBL repulsive portion const F_FLOAT esq = pow(global_e,2.0); const F_FLOAT a_ij = (0.8854*global_a_0) / - (pow(paramskk(itype,jtype,jtype).Z_i,0.23) + pow(paramskk(itype,jtype,jtype).Z_j,0.23)); + (pow(paramskk(itype,jtype,jtype).Z_i,0.23) + pow(paramskk(itype,jtype,jtype).Z_j,0.23)); const F_FLOAT premult = (paramskk(itype,jtype,jtype).Z_i * paramskk(itype,jtype,jtype).Z_j * esq)/ - (4.0*MY_PI*global_epsilon_0); + (4.0*MY_PI*global_epsilon_0); const F_FLOAT r_ov_a = r/a_ij; const F_FLOAT phi = 0.1818*exp(-3.2*r_ov_a) + 0.5099*exp(-0.9423*r_ov_a) + - 0.2802*exp(-0.4029*r_ov_a) + 0.02817*exp(-0.2016*r_ov_a); + 0.2802*exp(-0.4029*r_ov_a) + 0.02817*exp(-0.2016*r_ov_a); const F_FLOAT dphi = (1.0/a_ij) * (-3.2*0.1818*exp(-3.2*r_ov_a) - 0.9423*0.5099*exp(-0.9423*r_ov_a) - 0.4029*0.2802*exp(-0.4029*r_ov_a) - @@ -599,7 +599,7 @@ void PairTersoffZBLKokkos<DeviceType>::operator()(TagPairTersoffZBLComputeFullA< if (eflag) eng = (1.0 - fermi_k(itype,jtype,jtype,r)) * eng_z + - fermi_k(itype,jtype,jtype,r) * eng_t; + fermi_k(itype,jtype,jtype,r) * eng_t; f_x += delx*frep; f_y += dely*frep; @@ -609,7 +609,7 @@ void PairTersoffZBLKokkos<DeviceType>::operator()(TagPairTersoffZBLComputeFullA< if (eflag) ev.evdwl += 0.5*eng; if (vflag_either || eflag_atom) - this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,frep,delx,dely,delz); + this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,frep,delx,dely,delz); } } @@ -663,7 +663,7 @@ void PairTersoffZBLKokkos<DeviceType>::operator()(TagPairTersoffZBLComputeFullA< if (EVFLAG) { if (eflag) ev.evdwl += 0.5*eng; if (vflag_either || eflag_atom) - this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); + this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); } // attractive: three-body force @@ -683,17 +683,17 @@ void PairTersoffZBLKokkos<DeviceType>::operator()(TagPairTersoffZBLComputeFullA< if (rsq2 > cutsq2) continue; rik = sqrt(rsq2); ters_dthb(itype,jtype,ktype,prefactor,rij,delx1,dely1,delz1, - rik,delx2,dely2,delz2,fi,fj,fk); + rik,delx2,dely2,delz2,fi,fj,fk); f_x += fi[0]; f_y += fi[1]; f_z += fi[2]; if (vflag_atom) { - F_FLOAT delrij[3], delrik[3]; - delrij[0] = -delx1; delrij[1] = -dely1; delrij[2] = -delz1; - delrik[0] = -delx2; delrik[1] = -dely2; delrik[2] = -delz2; - if (vflag_either) this->template v_tally3<NEIGHFLAG>(ev,i,j,k,fj,fk,delrij,delrik); + F_FLOAT delrij[3], delrik[3]; + delrij[0] = -delx1; delrij[1] = -dely1; delrij[2] = -delz1; + delrik[0] = -delx2; delrik[1] = -dely2; delrik[2] = -delz2; + if (vflag_either) this->template v_tally3<NEIGHFLAG>(ev,i,j,k,fj,fk,delrij,delrik); } } } @@ -789,7 +789,7 @@ void PairTersoffZBLKokkos<DeviceType>::operator()(TagPairTersoffZBLComputeFullB< if (eflag) ev.evdwl += 0.5 * eng; if (vflag_either || eflag_atom) - this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); + this->template ev_tally<NEIGHFLAG>(ev,i,j,eng,fatt,delx1,dely1,delz1); } // attractive: three-body force @@ -809,22 +809,22 @@ void PairTersoffZBLKokkos<DeviceType>::operator()(TagPairTersoffZBLComputeFullB< if (rsq2 > cutsq2) continue; rik = sqrt(rsq2); ters_dthbj(jtype,itype,ktype,prefactor,rij,delx1,dely1,delz1, - rik,delx2,dely2,delz2,fj,fk); + rik,delx2,dely2,delz2,fj,fk); f_x += fj[0]; f_y += fj[1]; f_z += fj[2]; if (vflag_atom) { - F_FLOAT delrji[3], delrjk[3]; - delrji[0] = -delx1; delrji[1] = -dely1; delrji[2] = -delz1; - delrjk[0] = -delx2; delrjk[1] = -dely2; delrjk[2] = -delz2; - if (vflag_either) v_tally3_atom(ev,i,j,k,fj,fk,delrji,delrjk); + F_FLOAT delrji[3], delrjk[3]; + delrji[0] = -delx1; delrji[1] = -dely1; delrji[2] = -delz1; + delrjk[0] = -delx2; delrjk[1] = -dely2; delrjk[2] = -delz2; + if (vflag_either) v_tally3_atom(ev,i,j,k,fj,fk,delrji,delrjk); } const F_FLOAT fa_jk = ters_fa_k(jtype,ktype,itype,rik); const F_FLOAT prefactor_jk = 0.5*fa_jk * ters_dbij(jtype,ktype,itype,bo_ij); ters_dthbk(jtype,ktype,itype,prefactor_jk,rik,delx2,dely2,delz2, - rij,delx1,dely1,delz1,fk); + rij,delx1,dely1,delz1,fk); f_x += fk[0]; f_y += fk[1]; f_z += fk[2]; @@ -848,7 +848,7 @@ void PairTersoffZBLKokkos<DeviceType>::operator()(TagPairTersoffZBLComputeFullB< template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>::ters_fc_k(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { const F_FLOAT ters_R = paramskk(i,j,k).bigr; const F_FLOAT ters_D = paramskk(i,j,k).bigd; @@ -863,7 +863,7 @@ double PairTersoffZBLKokkos<DeviceType>::ters_fc_k(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>::ters_dfc(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { const F_FLOAT ters_R = paramskk(i,j,k).bigr; const F_FLOAT ters_D = paramskk(i,j,k).bigd; @@ -878,8 +878,8 @@ double PairTersoffZBLKokkos<DeviceType>::ters_dfc(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>::bondorder(const int &i, const int &j, const int &k, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2) const + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2) const { F_FLOAT arg, ex_delr; @@ -900,7 +900,7 @@ double PairTersoffZBLKokkos<DeviceType>::bondorder(const int &i, const int &j, c template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>:: - ters_gijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const + ters_gijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const { const F_FLOAT ters_c = paramskk(i,j,k).c * paramskk(i,j,k).c; const F_FLOAT ters_d = paramskk(i,j,k).d * paramskk(i,j,k).d; @@ -914,7 +914,7 @@ double PairTersoffZBLKokkos<DeviceType>:: template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>:: - ters_dgijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const + ters_dgijk(const int &i, const int &j, const int &k, const F_FLOAT &cos) const { const F_FLOAT ters_c = paramskk(i,j,k).c * paramskk(i,j,k).c; @@ -930,11 +930,11 @@ double PairTersoffZBLKokkos<DeviceType>:: template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>::ters_fa_k(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { if (r > paramskk(i,j,k).bigr + paramskk(i,j,k).bigd) return 0.0; return -paramskk(i,j,k).bigb * exp(-paramskk(i,j,k).lam2 * r) - * ters_fc_k(i,j,k,r) * fermi_k(i,j,k,r); + * ters_fc_k(i,j,k,r) * fermi_k(i,j,k,r); } /* ---------------------------------------------------------------------- */ @@ -942,7 +942,7 @@ double PairTersoffZBLKokkos<DeviceType>::ters_fa_k(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>::ters_dfa(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { if (r > paramskk(i,j,k).bigr + paramskk(i,j,k).bigd) return 0.0; return paramskk(i,j,k).bigb * exp(-paramskk(i,j,k).lam2 * r) * @@ -956,7 +956,7 @@ double PairTersoffZBLKokkos<DeviceType>::ters_dfa(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>::ters_bij_k(const int &i, const int &j, - const int &k, const F_FLOAT &bo) const + const int &k, const F_FLOAT &bo) const { const F_FLOAT tmp = paramskk(i,j,k).beta * bo; if (tmp > paramskk(i,j,k).c1) return 1.0/sqrt(tmp); @@ -973,7 +973,7 @@ double PairTersoffZBLKokkos<DeviceType>::ters_bij_k(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>::ters_dbij(const int &i, const int &j, - const int &k, const F_FLOAT &bo) const + const int &k, const F_FLOAT &bo) const { const F_FLOAT tmp = paramskk(i,j,k).beta * bo; if (tmp > paramskk(i,j,k).c1) return paramskk(i,j,k).beta * -0.5*pow(tmp,-1.5); @@ -994,10 +994,10 @@ double PairTersoffZBLKokkos<DeviceType>::ters_dbij(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION void PairTersoffZBLKokkos<DeviceType>::ters_dthb( - const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk) const + const int &i, const int &j, const int &k, const F_FLOAT &prefactor, + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk) const { // from PairTersoffZBL::attractive F_FLOAT rij_hat[3],rik_hat[3]; @@ -1066,10 +1066,10 @@ void PairTersoffZBLKokkos<DeviceType>::ters_dthb( template<class DeviceType> KOKKOS_INLINE_FUNCTION void PairTersoffZBLKokkos<DeviceType>::ters_dthbj( - const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fj, F_FLOAT *fk) const + const int &i, const int &j, const int &k, const F_FLOAT &prefactor, + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fj, F_FLOAT *fk) const { F_FLOAT rij_hat[3],rik_hat[3]; F_FLOAT rijinv,rikinv; @@ -1127,10 +1127,10 @@ void PairTersoffZBLKokkos<DeviceType>::ters_dthbj( template<class DeviceType> KOKKOS_INLINE_FUNCTION void PairTersoffZBLKokkos<DeviceType>::ters_dthbk( - const int &i, const int &j, const int &k, const F_FLOAT &prefactor, - const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, - const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, - F_FLOAT *fk) const + const int &i, const int &j, const int &k, const F_FLOAT &prefactor, + const F_FLOAT &rij, const F_FLOAT &dx1, const F_FLOAT &dy1, const F_FLOAT &dz1, + const F_FLOAT &rik, const F_FLOAT &dx2, const F_FLOAT &dy2, const F_FLOAT &dz2, + F_FLOAT *fk) const { F_FLOAT rij_hat[3],rik_hat[3]; F_FLOAT rijinv,rikinv; @@ -1184,10 +1184,10 @@ void PairTersoffZBLKokkos<DeviceType>::ters_dthbk( template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>::fermi_k(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { return 1.0 / (1.0 + exp(-paramskk(i,j,k).ZBLexpscale * - (r - paramskk(i,j,k).ZBLcut))); + (r - paramskk(i,j,k).ZBLcut))); } /* ---------------------------------------------------------------------- */ @@ -1195,12 +1195,12 @@ double PairTersoffZBLKokkos<DeviceType>::fermi_k(const int &i, const int &j, template<class DeviceType> KOKKOS_INLINE_FUNCTION double PairTersoffZBLKokkos<DeviceType>::fermi_d_k(const int &i, const int &j, - const int &k, const F_FLOAT &r) const + const int &k, const F_FLOAT &r) const { return paramskk(i,j,k).ZBLexpscale * exp(-paramskk(i,j,k).ZBLexpscale * - (r - paramskk(i,j,k).ZBLcut)) / + (r - paramskk(i,j,k).ZBLcut)) / pow(1.0 + exp(-paramskk(i,j,k).ZBLexpscale * - (r - paramskk(i,j,k).ZBLcut)),2.0); + (r - paramskk(i,j,k).ZBLcut)),2.0); } /* ---------------------------------------------------------------------- */ @@ -1276,7 +1276,7 @@ template<class DeviceType> template<int NEIGHFLAG> KOKKOS_INLINE_FUNCTION void PairTersoffZBLKokkos<DeviceType>::v_tally3(EV_FLOAT &ev, const int &i, const int &j, const int &k, - F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const + F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const { // The eatom and vatom arrays are atomic for Half/Thread neighbor style diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index 8454140671..ccc4010f68 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -249,27 +249,27 @@ void SNAKokkos<DeviceType>::compute_zi(const typename Kokkos::TeamPolicy<DeviceT const int bound = (j+2)/2; Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,(j+1)*bound), [&] (const int mbma ) { - //for(int mb = 0; 2*mb <= j; mb++) - //for(int ma = 0; ma <= j; ma++) { + //for(int mb = 0; 2*mb <= j; mb++) + //for(int ma = 0; ma <= j; ma++) { const int ma = mbma%(j+1); const int mb = mbma/(j+1); - //zarray_r(j1,j2,j,ma,mb) = 0.0; - //zarray_i(j1,j2,j,ma,mb) = 0.0; + //zarray_r(j1,j2,j,ma,mb) = 0.0; + //zarray_i(j1,j2,j,ma,mb) = 0.0; double z_r = 0.0; double z_i = 0.0; - for(int ma1 = MAX(0, (2 * ma - j - j2 + j1) / 2); - ma1 <= MIN(j1, (2 * ma - j + j2 + j1) / 2); ma1++) { - double sumb1_r = 0.0; - double sumb1_i = 0.0; + for(int ma1 = MAX(0, (2 * ma - j - j2 + j1) / 2); + ma1 <= MIN(j1, (2 * ma - j + j2 + j1) / 2); ma1++) { + double sumb1_r = 0.0; + double sumb1_i = 0.0; - const int ma2 = (2 * ma - j - (2 * ma1 - j1) + j2) / 2; + const int ma2 = (2 * ma - j - (2 * ma1 - j1) + j2) / 2; - for(int mb1 = MAX( 0, (2 * mb - j - j2 + j1) / 2); + for(int mb1 = MAX( 0, (2 * mb - j - j2 + j1) / 2); mb1 <= MIN(j1, (2 * mb - j + j2 + j1) / 2); mb1++) { - const int mb2 = (2 * mb - j - (2 * mb1 - j1) + j2) / 2; + const int mb2 = (2 * mb - j - (2 * mb1 - j1) + j2) / 2; const double cga = cgarray(j1,j2,j,mb1,mb2); const double uat1_r = uarraytot_r(j1,ma1,mb1); const double uat1_i = uarraytot_i(j1,ma1,mb1); @@ -277,21 +277,21 @@ void SNAKokkos<DeviceType>::compute_zi(const typename Kokkos::TeamPolicy<DeviceT const double uat2_i = uarraytot_i(j2,ma2,mb2); sumb1_r += cga * (uat1_r * uat2_r - uat1_i * uat2_i); sumb1_i += cga * (uat1_r * uat2_i + uat1_i * uat2_r); - /*sumb1_r += cgarray(j1,j2,j,mb1,mb2) * - (uarraytot_r(j1,ma1,mb1) * uarraytot_r(j2,ma2,mb2) - - uarraytot_i(j1,ma1,mb1) * uarraytot_i(j2,ma2,mb2)); - sumb1_i += cgarray(j1,j2,j,mb1,mb2) * - (uarraytot_r(j1,ma1,mb1) * uarraytot_i(j2,ma2,mb2) + - uarraytot_i(j1,ma1,mb1) * uarraytot_r(j2,ma2,mb2));*/ - } // end loop over mb1 + /*sumb1_r += cgarray(j1,j2,j,mb1,mb2) * + (uarraytot_r(j1,ma1,mb1) * uarraytot_r(j2,ma2,mb2) - + uarraytot_i(j1,ma1,mb1) * uarraytot_i(j2,ma2,mb2)); + sumb1_i += cgarray(j1,j2,j,mb1,mb2) * + (uarraytot_r(j1,ma1,mb1) * uarraytot_i(j2,ma2,mb2) + + uarraytot_i(j1,ma1,mb1) * uarraytot_r(j2,ma2,mb2));*/ + } // end loop over mb1 const double cga = cgarray(j1,j2,j,ma1,ma2); - z_r += sumb1_r * cga;//rray(j1,j2,j,ma1,ma2); - z_i += sumb1_i * cga;//rray(j1,j2,j,ma1,ma2); - } // end loop over ma1 + z_r += sumb1_r * cga;//rray(j1,j2,j,ma1,ma2); + z_i += sumb1_i * cga;//rray(j1,j2,j,ma1,ma2); + } // end loop over ma1 zarray_r(j1,j2,j,mb,ma) = z_r; - zarray_i(j1,j2,j,mb,ma) = z_i; - }); // end loop over ma, mb + zarray_i(j1,j2,j,mb,ma) = z_i; + }); // end loop over ma, mb // } //} }); @@ -675,7 +675,7 @@ void SNAKokkos<DeviceType>::copy_dbi2dbvec(const typename Kokkos::TeamPolicy<Dev for(j2 = 0; j2 <= j1; j2++) for(j = abs(j1 - j2); j <= MIN(twojmax, j1 + j2); j += 2) - if (j >= j1) {*/ + if (j >= j1) {*/ Kokkos::parallel_for(Kokkos::ThreadVectorRange(team,idxj_max), [&] (const int& JJ) { //for(int JJ = 0; JJ < idxj_max; JJ++) { @@ -796,25 +796,25 @@ void SNAKokkos<DeviceType>::compute_uarray(const typename Kokkos::TeamPolicy<Dev uarray_i(j,0,mb) = 0.0; for (int ma = 0; ma < j; ma++) { - rootpq = rootpqarray(j - ma,j - mb); + rootpq = rootpqarray(j - ma,j - mb); uarray_r(j,ma,mb) += rootpq * (a_r * uarray_r(j - 1,ma,mb) + - a_i * uarray_i(j - 1,ma,mb)); + a_i * uarray_i(j - 1,ma,mb)); uarray_i(j,ma,mb) += rootpq * (a_r * uarray_i(j - 1,ma,mb) - - a_i * uarray_r(j - 1,ma,mb)); + a_i * uarray_r(j - 1,ma,mb)); - rootpq = rootpqarray(ma + 1,j - mb); + rootpq = rootpqarray(ma + 1,j - mb); uarray_r(j,ma + 1,mb) = -rootpq * (b_r * uarray_r(j - 1,ma,mb) + - b_i * uarray_i(j - 1,ma,mb)); + b_i * uarray_i(j - 1,ma,mb)); uarray_i(j,ma + 1,mb) = -rootpq * (b_r * uarray_i(j - 1,ma,mb) - - b_i * uarray_r(j - 1,ma,mb)); + b_i * uarray_r(j - 1,ma,mb)); } }); @@ -828,16 +828,16 @@ void SNAKokkos<DeviceType>::compute_uarray(const typename Kokkos::TeamPolicy<Dev int mbpar = (mb)%2==0?1:-1; int mapar = -mbpar; for (int ma = 0; ma <= j; ma++) { - mapar = -mapar; - if (mapar == 1) { - uarray_r(j,j-ma,j-mb) = uarray_r(j,ma,mb); - uarray_i(j,j-ma,j-mb) = -uarray_i(j,ma,mb); - } else { - uarray_r(j,j-ma,j-mb) = -uarray_r(j,ma,mb); - uarray_i(j,j-ma,j-mb) = uarray_i(j,ma,mb); - } - //OK - //printf("%lf %lf %lf %lf %lf %lf %lf SNAP-COMPARE: UARRAY\n",x,y,z,z0,r,uarray_r(j,ma,mb),uarray_i(j,ma,mb)); + mapar = -mapar; + if (mapar == 1) { + uarray_r(j,j-ma,j-mb) = uarray_r(j,ma,mb); + uarray_i(j,j-ma,j-mb) = -uarray_i(j,ma,mb); + } else { + uarray_r(j,j-ma,j-mb) = -uarray_r(j,ma,mb); + uarray_i(j,j-ma,j-mb) = uarray_i(j,ma,mb); + } + //OK + //printf("%lf %lf %lf %lf %lf %lf %lf SNAP-COMPARE: UARRAY\n",x,y,z,z0,r,uarray_r(j,ma,mb),uarray_i(j,ma,mb)); } }); } @@ -854,7 +854,7 @@ KOKKOS_INLINE_FUNCTION void SNAKokkos<DeviceType>::compute_duarray(const typename Kokkos::TeamPolicy<DeviceType>::member_type& team, double x, double y, double z, double z0, double r, double dz0dr, - double wj, double rcut) + double wj, double rcut) { double r0inv; double a_r, a_i, b_r, b_i; @@ -943,7 +943,7 @@ void SNAKokkos<DeviceType>::compute_duarray(const typename Kokkos::TeamPolicy<De a_i * duarray_r(j - 1,mb,ma,k)); } - rootpq = rootpqarray(ma + 1,j - mb); + rootpq = rootpqarray(ma + 1,j - mb); uarray_r(j,ma + 1,mb) = -rootpq * (b_r * uarray_r(j - 1,ma,mb) + b_i * uarray_i(j - 1,ma,mb)); @@ -973,22 +973,22 @@ void SNAKokkos<DeviceType>::compute_duarray(const typename Kokkos::TeamPolicy<De int mbpar = (mb)%2==0?1:-1; int mapar = -mbpar; for (int ma = 0; ma <= j; ma++) { - mapar = -mapar; - if (mapar == 1) { - uarray_r(j,j-ma,j-mb) = uarray_r(j,ma,mb); - uarray_i(j,j-ma,j-mb) = -uarray_i(j,ma,mb); - for (int k = 0; k < 3; k++) { - duarray_r(j,j-mb,j-ma,k) = duarray_r(j,mb,ma,k); - duarray_i(j,j-mb,j-ma,k) = -duarray_i(j,mb,ma,k); - } - } else { - uarray_r(j,j-ma,j-mb) = -uarray_r(j,ma,mb); - uarray_i(j,j-ma,j-mb) = uarray_i(j,ma,mb); - for (int k = 0; k < 3; k++) { - duarray_r(j,j-mb,j-ma,k) = -duarray_r(j,mb,ma,k); - duarray_i(j,j-mb,j-ma,k) = duarray_i(j,mb,ma,k); - } - } + mapar = -mapar; + if (mapar == 1) { + uarray_r(j,j-ma,j-mb) = uarray_r(j,ma,mb); + uarray_i(j,j-ma,j-mb) = -uarray_i(j,ma,mb); + for (int k = 0; k < 3; k++) { + duarray_r(j,j-mb,j-ma,k) = duarray_r(j,mb,ma,k); + duarray_i(j,j-mb,j-ma,k) = -duarray_i(j,mb,ma,k); + } + } else { + uarray_r(j,j-ma,j-mb) = -uarray_r(j,ma,mb); + uarray_i(j,j-ma,j-mb) = uarray_i(j,ma,mb); + for (int k = 0; k < 3; k++) { + duarray_r(j,j-mb,j-ma,k) = -duarray_r(j,mb,ma,k); + duarray_i(j,j-mb,j-ma,k) = duarray_i(j,mb,ma,k); + } + } } }); } @@ -1149,37 +1149,37 @@ void SNAKokkos<DeviceType>::init_clebsch_gordan() if(m < 0 || m > j) continue; - sum = 0.0; - - for (int z = MAX(0, MAX(-(j - j2 + aa2) - / 2, -(j - j1 - bb2) / 2)); - z <= MIN((j1 + j2 - j) / 2, - MIN((j1 - aa2) / 2, (j2 + bb2) / 2)); - z++) { - ifac = z % 2 ? -1 : 1; - sum += ifac / - (factorial(z) * - factorial((j1 + j2 - j) / 2 - z) * - factorial((j1 - aa2) / 2 - z) * - factorial((j2 + bb2) / 2 - z) * - factorial((j - j2 + aa2) / 2 + z) * - factorial((j - j1 - bb2) / 2 + z)); - } - - cc2 = 2 * m - j; - dcg = deltacg(j1, j2, j); - sfaccg = sqrt(factorial((j1 + aa2) / 2) * - factorial((j1 - aa2) / 2) * - factorial((j2 + bb2) / 2) * - factorial((j2 - bb2) / 2) * - factorial((j + cc2) / 2) * - factorial((j - cc2) / 2) * - (j + 1)); - - h_cgarray(j1,j2,j,m1,m2) = sum * dcg * sfaccg; - //printf("SNAP-COMPARE: CG: %i %i %i %i %i %e\n",j1,j2,j,m1,m2,cgarray(j1,j2,j,m1,m2)); - } - } + sum = 0.0; + + for (int z = MAX(0, MAX(-(j - j2 + aa2) + / 2, -(j - j1 - bb2) / 2)); + z <= MIN((j1 + j2 - j) / 2, + MIN((j1 - aa2) / 2, (j2 + bb2) / 2)); + z++) { + ifac = z % 2 ? -1 : 1; + sum += ifac / + (factorial(z) * + factorial((j1 + j2 - j) / 2 - z) * + factorial((j1 - aa2) / 2 - z) * + factorial((j2 + bb2) / 2 - z) * + factorial((j - j2 + aa2) / 2 + z) * + factorial((j - j1 - bb2) / 2 + z)); + } + + cc2 = 2 * m - j; + dcg = deltacg(j1, j2, j); + sfaccg = sqrt(factorial((j1 + aa2) / 2) * + factorial((j1 - aa2) / 2) * + factorial((j2 + bb2) / 2) * + factorial((j2 - bb2) / 2) * + factorial((j + cc2) / 2) * + factorial((j - cc2) / 2) * + (j + 1)); + + h_cgarray(j1,j2,j,m1,m2) = sum * dcg * sfaccg; + //printf("SNAP-COMPARE: CG: %i %i %i %i %i %e\n",j1,j2,j,m1,m2,cgarray(j1,j2,j,m1,m2)); + } + } Kokkos::deep_copy(cgarray,h_cgarray); } diff --git a/src/KSPACE/pair_buck_long_coul_long.cpp b/src/KSPACE/pair_buck_long_coul_long.cpp index 7df8ebac68..7781e24a5e 100644 --- a/src/KSPACE/pair_buck_long_coul_long.cpp +++ b/src/KSPACE/pair_buck_long_coul_long.cpp @@ -905,7 +905,7 @@ void PairBuckLongCoulLong::compute_outer(int eflag, int vflag) force_buck = r*expr*buck1i[typej]-g8*(((6.0*a2+6.0)*a2+3.0)*a2+1.0)*x2*rsq-respa_buck; if (eflag) evdwl = expr*buckai[typej]-g6*((a2+1.0)*a2+0.5)*x2; - } + } else { // correct for special register double f = special_lj[ni], t = rn*(1.0-f); force_buck = f*r*expr*buck1i[typej]- diff --git a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp index 859f421763..1fb83db28c 100644 --- a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp +++ b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp @@ -609,7 +609,7 @@ void PairLJCharmmfswCoulLong::compute_outer(int eflag, int vflag) if (rsq < cut_coulsq) { if (!ncoultablebits || rsq <= tabinnersq) { forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; } else { table = vtable[itable] + fraction*dvtable[itable]; forcecoul = qtmp*q[j] * table; diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 43b2c8236a..821cfd06d5 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -268,7 +268,7 @@ void PPPMDisp::init() error->all(FLERR,"Cannot use nonperiodic boundaries with PPPMDisp"); if (slabflag == 1) { if (domain->xperiodic != 1 || domain->yperiodic != 1 || - domain->boundary[2][0] != 1 || domain->boundary[2][1] != 1) + domain->boundary[2][0] != 1 || domain->boundary[2][1] != 1) error->all(FLERR,"Incorrect boundaries with slab PPPMDisp"); } @@ -306,22 +306,22 @@ void PPPMDisp::init() int ewald_order = ptr ? *((int *) ptr) : 1<<1; int ewald_mix = ptr ? *((int *) pair->extract("ewald_mix",tmp)) : GEOMETRIC; memset(function, 0, EWALD_FUNCS*sizeof(int)); - for (int i=0; i<=EWALD_MAXORDER; ++i) // transcribe order - if (ewald_order&(1<<i)) { // from pair_style + for (int i=0; i<=EWALD_MAXORDER; ++i) // transcribe order + if (ewald_order&(1<<i)) { // from pair_style int k=0; char str[128]; switch (i) { - case 1: - k = 0; break; - case 6: - if ((ewald_mix==GEOMETRIC || ewald_mix==SIXTHPOWER || + case 1: + k = 0; break; + case 6: + if ((ewald_mix==GEOMETRIC || ewald_mix==SIXTHPOWER || mixflag == 1) && mixflag!= 2) { k = 1; break; } - else if (ewald_mix==ARITHMETIC && mixflag!=2) { k = 2; break; } - else if (mixflag == 2) { k = 3; break; } - default: - sprintf(str, "Unsupported order in kspace_style " + else if (ewald_mix==ARITHMETIC && mixflag!=2) { k = 2; break; } + else if (mixflag == 2) { k = 3; break; } + default: + sprintf(str, "Unsupported order in kspace_style " "pppm/disp, pair_style %s", force->pair_style); - error->all(FLERR,str); + error->all(FLERR,str); } function[k] = 1; } @@ -377,10 +377,10 @@ void PPPMDisp::init() if (force->angle == NULL || force->bond == NULL) error->all(FLERR,"Bond and angle potentials must be defined for TIP4P"); if (typeA < 1 || typeA > atom->nangletypes || - force->angle->setflag[typeA] == 0) + force->angle->setflag[typeA] == 0) error->all(FLERR,"Bad TIP4P angle type for PPPMDisp/TIP4P"); if (typeB < 1 || typeB > atom->nbondtypes || - force->bond->setflag[typeB] == 0) + force->bond->setflag[typeB] == 0) error->all(FLERR,"Bad TIP4P bond type for PPPMDisp/TIP4P"); double theta = force->angle->equilibrium_angle(typeA); double blen = force->bond->equilibrium_distance(typeB); @@ -486,7 +486,7 @@ void PPPMDisp::init() acc/two_charge_force); fprintf(screen," using %s precision FFTs\n",fft_prec); fprintf(screen," 3d grid and FFT values/proc = %d %d\n", - ngrid_max, nfft_both_max); + ngrid_max, nfft_both_max); } if (logfile) { fprintf(logfile," Coulomb G vector (1/distance) = %g\n",g_ewald); @@ -499,7 +499,7 @@ void PPPMDisp::init() acc/two_charge_force); fprintf(logfile," using %s precision FFTs\n",fft_prec); fprintf(logfile," 3d grid and FFT values/proc = %d %d\n", - ngrid_max, nfft_both_max); + ngrid_max, nfft_both_max); } } } @@ -656,7 +656,7 @@ void PPPMDisp::setup() error->all(FLERR,"Cannot use nonperiodic boundaries with PPPMDisp"); if (slabflag == 1) { if (domain->xperiodic != 1 || domain->yperiodic != 1 || - domain->boundary[2][0] != 1 || domain->boundary[2][1] != 1) + domain->boundary[2][0] != 1 || domain->boundary[2][1] != 1) error->all(FLERR,"Incorrect boundaries with slab PPPMDisp"); } @@ -723,27 +723,27 @@ void PPPMDisp::setup() for (k = nzlo_fft; k <= nzhi_fft; k++) { for (j = nylo_fft; j <= nyhi_fft; j++) { for (i = nxlo_fft; i <= nxhi_fft; i++) { - sqk = fkx[i]*fkx[i] + fky[j]*fky[j] + fkz[k]*fkz[k]; - if (sqk == 0.0) { - vg[n][0] = 0.0; - vg[n][1] = 0.0; - vg[n][2] = 0.0; - vg[n][3] = 0.0; - vg[n][4] = 0.0; - vg[n][5] = 0.0; - } else { - vterm = -2.0 * (1.0/sqk + 0.25*gew2inv); - vg[n][0] = 1.0 + vterm*fkx[i]*fkx[i]; - vg[n][1] = 1.0 + vterm*fky[j]*fky[j]; - vg[n][2] = 1.0 + vterm*fkz[k]*fkz[k]; - vg[n][3] = vterm*fkx[i]*fky[j]; - vg[n][4] = vterm*fkx[i]*fkz[k]; - vg[n][5] = vterm*fky[j]*fkz[k]; + sqk = fkx[i]*fkx[i] + fky[j]*fky[j] + fkz[k]*fkz[k]; + if (sqk == 0.0) { + vg[n][0] = 0.0; + vg[n][1] = 0.0; + vg[n][2] = 0.0; + vg[n][3] = 0.0; + vg[n][4] = 0.0; + vg[n][5] = 0.0; + } else { + vterm = -2.0 * (1.0/sqk + 0.25*gew2inv); + vg[n][0] = 1.0 + vterm*fkx[i]*fkx[i]; + vg[n][1] = 1.0 + vterm*fky[j]*fky[j]; + vg[n][2] = 1.0 + vterm*fkz[k]*fkz[k]; + vg[n][3] = vterm*fkx[i]*fky[j]; + vg[n][4] = vterm*fkx[i]*fkz[k]; + vg[n][5] = vterm*fky[j]*fkz[k]; vg2[n][0] = vterm*0.5*(fkx[i]*fky[j] + fkx2[i]*fky2[j]); vg2[n][1] = vterm*0.5*(fkx[i]*fkz[k] + fkx2[i]*fkz2[k]); vg2[n][2] = vterm*0.5*(fky[j]*fkz[k] + fky2[j]*fkz2[k]); - } - n++; + } + n++; } } } @@ -789,15 +789,15 @@ void PPPMDisp::setup() for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) { for (j = nylo_fft_6; j <= nyhi_fft_6; j++) { for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - sqk = fkx_6[i]*fkx_6[i] + fky_6[j]*fky_6[j] + fkz_6[k]*fkz_6[k]; - if (sqk == 0.0) { - vg_6[n][0] = 0.0; - vg_6[n][1] = 0.0; - vg_6[n][2] = 0.0; - vg_6[n][3] = 0.0; - vg_6[n][4] = 0.0; - vg_6[n][5] = 0.0; - } else { + sqk = fkx_6[i]*fkx_6[i] + fky_6[j]*fky_6[j] + fkz_6[k]*fkz_6[k]; + if (sqk == 0.0) { + vg_6[n][0] = 0.0; + vg_6[n][1] = 0.0; + vg_6[n][2] = 0.0; + vg_6[n][3] = 0.0; + vg_6[n][4] = 0.0; + vg_6[n][5] = 0.0; + } else { b = 0.5*sqrt(sqk)*gewinv; bs = b*b; bt = bs*b; @@ -807,17 +807,17 @@ void PPPMDisp::setup() denom = nom + expt; if (denom == 0) vterm = 3.0/sqk; else vterm = 3.0*nom/(sqk*denom); - vg_6[n][0] = 1.0 + vterm*fkx_6[i]*fkx_6[i]; - vg_6[n][1] = 1.0 + vterm*fky_6[j]*fky_6[j]; - vg_6[n][2] = 1.0 + vterm*fkz_6[k]*fkz_6[k]; - vg_6[n][3] = vterm*fkx_6[i]*fky_6[j]; - vg_6[n][4] = vterm*fkx_6[i]*fkz_6[k]; - vg_6[n][5] = vterm*fky_6[j]*fkz_6[k]; + vg_6[n][0] = 1.0 + vterm*fkx_6[i]*fkx_6[i]; + vg_6[n][1] = 1.0 + vterm*fky_6[j]*fky_6[j]; + vg_6[n][2] = 1.0 + vterm*fkz_6[k]*fkz_6[k]; + vg_6[n][3] = vterm*fkx_6[i]*fky_6[j]; + vg_6[n][4] = vterm*fkx_6[i]*fkz_6[k]; + vg_6[n][5] = vterm*fky_6[j]*fkz_6[k]; vg2_6[n][0] = vterm*0.5*(fkx_6[i]*fky_6[j] + fkx2_6[i]*fky2_6[j]); vg2_6[n][1] = vterm*0.5*(fkx_6[i]*fkz_6[k] + fkx2_6[i]*fkz2_6[k]); vg2_6[n][2] = vterm*0.5*(fky_6[j]*fkz_6[k] + fky2_6[j]*fkz2_6[k]); - } - n++; + } + n++; } } } @@ -926,7 +926,7 @@ void PPPMDisp::compute(int eflag, int vflag) if (eflag || vflag) ev_setup(eflag,vflag); else evflag = evflag_atom = eflag_global = vflag_global = - eflag_atom = vflag_atom = 0; + eflag_atom = vflag_atom = 0; if (evflag_atom && !peratom_allocate_flag) { allocate_peratom(); @@ -983,7 +983,7 @@ void PPPMDisp::compute(int eflag, int vflag) cg->reverse_comm(this,REVERSE_RHO); brick2fft(nxlo_in, nylo_in, nzlo_in, nxhi_in, nyhi_in, nzhi_in, - density_brick, density_fft, work1,remap); + density_brick, density_fft, work1,remap); if (differentiation_flag == 1) { @@ -1007,7 +1007,7 @@ void PPPMDisp::compute(int eflag, int vflag) nxlo_fft, nylo_fft, nzlo_fft, nxhi_fft, nyhi_fft, nzhi_fft, nxlo_in, nylo_in, nzlo_in, nxhi_in, nyhi_in, nzhi_in, energy_1, greensfn, - fkx, fky, fkz,fkx2, fky2, fkz2, + fkx, fky, fkz,fkx2, fky2, fkz2, vdx_brick, vdy_brick, vdz_brick, virial_1, vg,vg2, u_brick, v0_brick, v1_brick, v2_brick, v3_brick, v4_brick, v5_brick); @@ -1030,7 +1030,7 @@ void PPPMDisp::compute(int eflag, int vflag) cg_6->reverse_comm(this, REVERSE_RHO_G); brick2fft(nxlo_in_6, nylo_in_6, nzlo_in_6, nxhi_in_6, nyhi_in_6, nzhi_in_6, - density_brick_g, density_fft_g, work1_6,remap_6); + density_brick_g, density_fft_g, work1_6,remap_6); if (differentiation_flag == 1) { @@ -1054,7 +1054,7 @@ void PPPMDisp::compute(int eflag, int vflag) nxlo_fft_6, nylo_fft_6, nzlo_fft_6, nxhi_fft_6, nyhi_fft_6, nzhi_fft_6, nxlo_in_6, nylo_in_6, nzlo_in_6, nxhi_in_6, nyhi_in_6, nzhi_in_6, energy_6, greensfn_6, - fkx_6, fky_6, fkz_6,fkx2_6, fky2_6, fkz2_6, + fkx_6, fky_6, fkz_6,fkx2_6, fky2_6, fkz2_6, vdx_brick_g, vdy_brick_g, vdz_brick_g, virial_6, vg_6, vg2_6, u_brick_g, v0_brick_g, v1_brick_g, v2_brick_g, v3_brick_g, v4_brick_g, v5_brick_g); @@ -1110,7 +1110,7 @@ void PPPMDisp::compute(int eflag, int vflag) nxlo_fft_6, nylo_fft_6, nzlo_fft_6, nxhi_fft_6, nyhi_fft_6, nzhi_fft_6, nxlo_in_6, nylo_in_6, nzlo_in_6, nxhi_in_6, nyhi_in_6, nzhi_in_6, energy_6, greensfn_6, - fkx_6, fky_6, fkz_6,fkx2_6, fky2_6, fkz2_6, + fkx_6, fky_6, fkz_6,fkx2_6, fky2_6, fkz2_6, vdx_brick_a3, vdy_brick_a3, vdz_brick_a3, virial_6, vg_6, vg2_6, u_brick_a3, v0_brick_a3, v1_brick_a3, v2_brick_a3, v3_brick_a3, v4_brick_a3, v5_brick_a3); poisson_2s_ik(density_fft_a0, density_fft_a6, @@ -1274,7 +1274,7 @@ void PPPMDisp::compute(int eflag, int vflag) initialize coefficients needed for the dispersion density on the grids ------------------------------------------------------------------------- */ -void PPPMDisp::init_coeffs() // local pair coeffs +void PPPMDisp::init_coeffs() // local pair coeffs { int tmp; int n = atom->ntypes; @@ -1402,13 +1402,13 @@ void PPPMDisp::init_coeffs() // local pair coeffs memory->destroy(A); memory->destroy(Q); } - if (function[1]) { // geometric 1/r^6 + if (function[1]) { // geometric 1/r^6 double **b = (double **) force->pair->extract("B",tmp); B = new double[n+1]; B[0] = 0.0; for (int i=1; i<=n; ++i) B[i] = sqrt(fabs(b[i][i])); } - if (function[2]) { // arithmetic 1/r^6 + if (function[2]) { // arithmetic 1/r^6 //cannot use epsilon, because this has not been set yet double **epsilon = (double **) force->pair->extract("epsilon",tmp); //cannot use sigma, because this has not been set yet @@ -1685,10 +1685,10 @@ void PPPMDisp::allocate() memory->create(vg2,nfft_both,3,"pppm/disp:vg2"); memory->create3d_offset(density_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:density_brick"); + nxlo_out,nxhi_out,"pppm/disp:density_brick"); if ( differentiation_flag == 1) { memory->create3d_offset(u_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:u_brick"); + nxlo_out,nxhi_out,"pppm/disp:u_brick"); memory->create(sf_precoeff1,nfft_both,"pppm/disp:sf_precoeff1"); memory->create(sf_precoeff2,nfft_both,"pppm/disp:sf_precoeff2"); memory->create(sf_precoeff3,nfft_both,"pppm/disp:sf_precoeff3"); @@ -1698,30 +1698,30 @@ void PPPMDisp::allocate() } else { memory->create3d_offset(vdx_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:vdx_brick"); + nxlo_out,nxhi_out,"pppm/disp:vdx_brick"); memory->create3d_offset(vdy_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:vdy_brick"); + nxlo_out,nxhi_out,"pppm/disp:vdy_brick"); memory->create3d_offset(vdz_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:vdz_brick"); + nxlo_out,nxhi_out,"pppm/disp:vdz_brick"); } memory->create(density_fft,nfft_both,"pppm/disp:density_fft"); int tmp; fft1 = new FFT3d(lmp,world,nx_pppm,ny_pppm,nz_pppm, - nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, - nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, - 0,0,&tmp,collective_flag); + nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, + nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, + 0,0,&tmp,collective_flag); fft2 = new FFT3d(lmp,world,nx_pppm,ny_pppm,nz_pppm, - nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, - nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in, - 0,0,&tmp,collective_flag); + nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, + nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in, + 0,0,&tmp,collective_flag); remap = new Remap(lmp,world, - nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in, - nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, - 1,0,0,FFT_PRECISION,collective_flag); + nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in, + nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, + 1,0,0,FFT_PRECISION,collective_flag); // create ghost grid object for rho and electric field communication @@ -1762,10 +1762,10 @@ void PPPMDisp::allocate() memory->create(vg2_6,nfft_both_6,3,"pppm/disp:vg2_6"); memory->create3d_offset(density_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_g"); if ( differentiation_flag == 1) { memory->create3d_offset(u_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_g"); memory->create(sf_precoeff1_6,nfft_both_6,"pppm/disp:sf_precoeff1_6"); memory->create(sf_precoeff2_6,nfft_both_6,"pppm/disp:sf_precoeff2_6"); @@ -1776,11 +1776,11 @@ void PPPMDisp::allocate() } else { memory->create3d_offset(vdx_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_g"); memory->create3d_offset(vdy_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_g"); memory->create3d_offset(vdz_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_g"); } memory->create(density_fft_g,nfft_both_6,"pppm/disp:density_fft_g"); @@ -1788,19 +1788,19 @@ void PPPMDisp::allocate() int tmp; fft1_6 = new FFT3d(lmp,world,nx_pppm_6,ny_pppm_6,nz_pppm_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - 0,0,&tmp,collective_flag); + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + 0,0,&tmp,collective_flag); fft2_6 = new FFT3d(lmp,world,nx_pppm_6,ny_pppm_6,nz_pppm_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, - 0,0,&tmp,collective_flag); + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, + 0,0,&tmp,collective_flag); remap_6 = new Remap(lmp,world, - nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - 1,0,0,FFT_PRECISION,collective_flag); + nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + 1,0,0,FFT_PRECISION,collective_flag); // create ghost grid object for rho and electric field communication @@ -1841,19 +1841,19 @@ void PPPMDisp::allocate() memory->create(vg2_6,nfft_both_6,3,"pppm/disp:vg2_6"); memory->create3d_offset(density_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a0"); memory->create3d_offset(density_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a1"); memory->create3d_offset(density_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a2"); memory->create3d_offset(density_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a3"); memory->create3d_offset(density_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a4"); memory->create3d_offset(density_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a5"); memory->create3d_offset(density_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_a6"); memory->create(density_fft_a0,nfft_both_6,"pppm/disp:density_fft_a0"); memory->create(density_fft_a1,nfft_both_6,"pppm/disp:density_fft_a1"); @@ -1866,19 +1866,19 @@ void PPPMDisp::allocate() if ( differentiation_flag == 1 ) { memory->create3d_offset(u_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a0"); memory->create3d_offset(u_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a1"); memory->create3d_offset(u_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a2"); memory->create3d_offset(u_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a3"); memory->create3d_offset(u_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a4"); memory->create3d_offset(u_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a5"); memory->create3d_offset(u_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a6"); memory->create(sf_precoeff1_6,nfft_both_6,"pppm/disp:sf_precoeff1_6"); memory->create(sf_precoeff2_6,nfft_both_6,"pppm/disp:sf_precoeff2_6"); @@ -1890,53 +1890,53 @@ void PPPMDisp::allocate() } else { memory->create3d_offset(vdx_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a0"); memory->create3d_offset(vdy_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a0"); memory->create3d_offset(vdz_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a0"); memory->create3d_offset(vdx_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a1"); memory->create3d_offset(vdy_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a1"); memory->create3d_offset(vdz_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a1"); memory->create3d_offset(vdx_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a2"); memory->create3d_offset(vdy_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a2"); memory->create3d_offset(vdz_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a2"); memory->create3d_offset(vdx_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a3"); memory->create3d_offset(vdy_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a3"); memory->create3d_offset(vdz_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a3"); memory->create3d_offset(vdx_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a4"); memory->create3d_offset(vdy_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a4"); memory->create3d_offset(vdz_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a4"); memory->create3d_offset(vdx_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a5"); memory->create3d_offset(vdy_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a5"); memory->create3d_offset(vdz_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a5"); memory->create3d_offset(vdx_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_a6"); memory->create3d_offset(vdy_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_a6"); memory->create3d_offset(vdz_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_a6"); } @@ -1944,19 +1944,19 @@ void PPPMDisp::allocate() int tmp; fft1_6 = new FFT3d(lmp,world,nx_pppm_6,ny_pppm_6,nz_pppm_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - 0,0,&tmp,collective_flag); + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + 0,0,&tmp,collective_flag); fft2_6 = new FFT3d(lmp,world,nx_pppm_6,ny_pppm_6,nz_pppm_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, - 0,0,&tmp,collective_flag); + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, + 0,0,&tmp,collective_flag); remap_6 = new Remap(lmp,world, - nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - 1,0,0,FFT_PRECISION,collective_flag); + nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + 1,0,0,FFT_PRECISION,collective_flag); // create ghost grid object for rho and electric field communication @@ -1998,10 +1998,10 @@ void PPPMDisp::allocate() memory->create(vg2_6,nfft_both_6,3,"pppm/disp:vg2_6"); memory->create4d_offset(density_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:density_brick_none"); if ( differentiation_flag == 1) { memory->create4d_offset(u_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_none"); memory->create(sf_precoeff1_6,nfft_both_6,"pppm/disp:sf_precoeff1_6"); memory->create(sf_precoeff2_6,nfft_both_6,"pppm/disp:sf_precoeff2_6"); @@ -2012,11 +2012,11 @@ void PPPMDisp::allocate() } else { memory->create4d_offset(vdx_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdx_brick_none"); memory->create4d_offset(vdy_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdy_brick_none"); memory->create4d_offset(vdz_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:vdz_brick_none"); } memory->create(density_fft_none,nsplit_alloc,nfft_both_6,"pppm/disp:density_fft_none"); @@ -2024,19 +2024,19 @@ void PPPMDisp::allocate() int tmp; fft1_6 = new FFT3d(lmp,world,nx_pppm_6,ny_pppm_6,nz_pppm_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - 0,0,&tmp,collective_flag); + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + 0,0,&tmp,collective_flag); fft2_6 = new FFT3d(lmp,world,nx_pppm_6,ny_pppm_6,nz_pppm_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, - 0,0,&tmp,collective_flag); + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, + 0,0,&tmp,collective_flag); remap_6 = new Remap(lmp,world, - nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, - nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, - 1,0,0,FFT_PRECISION,collective_flag); + nxlo_in_6,nxhi_in_6,nylo_in_6,nyhi_in_6,nzlo_in_6,nzhi_in_6, + nxlo_fft_6,nxhi_fft_6,nylo_fft_6,nyhi_fft_6,nzlo_fft_6,nzhi_fft_6, + 1,0,0,FFT_PRECISION,collective_flag); // create ghost grid object for rho and electric field communication @@ -2070,20 +2070,20 @@ void PPPMDisp::allocate_peratom() if (differentiation_flag != 1) memory->create3d_offset(u_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:u_brick"); + nxlo_out,nxhi_out,"pppm/disp:u_brick"); memory->create3d_offset(v0_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:v0_brick"); + nxlo_out,nxhi_out,"pppm/disp:v0_brick"); memory->create3d_offset(v1_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:v1_brick"); + nxlo_out,nxhi_out,"pppm/disp:v1_brick"); memory->create3d_offset(v2_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:v2_brick"); + nxlo_out,nxhi_out,"pppm/disp:v2_brick"); memory->create3d_offset(v3_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:v3_brick"); + nxlo_out,nxhi_out,"pppm/disp:v3_brick"); memory->create3d_offset(v4_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:v4_brick"); + nxlo_out,nxhi_out,"pppm/disp:v4_brick"); memory->create3d_offset(v5_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm/disp:v5_brick"); + nxlo_out,nxhi_out,"pppm/disp:v5_brick"); // create ghost grid object for rho and electric field communication @@ -2109,20 +2109,20 @@ void PPPMDisp::allocate_peratom() if ( differentiation_flag != 1 ) memory->create3d_offset(u_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_g"); memory->create3d_offset(v0_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_g"); memory->create3d_offset(v1_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_g"); memory->create3d_offset(v2_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_g"); memory->create3d_offset(v3_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_g"); memory->create3d_offset(v4_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_g"); memory->create3d_offset(v5_brick_g,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_g"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_g"); // create ghost grid object for rho and electric field communication @@ -2147,111 +2147,111 @@ void PPPMDisp::allocate_peratom() if ( differentiation_flag != 1 ) { memory->create3d_offset(u_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a0"); memory->create3d_offset(u_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a1"); memory->create3d_offset(u_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a2"); memory->create3d_offset(u_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a3"); memory->create3d_offset(u_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a4"); memory->create3d_offset(u_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a5"); memory->create3d_offset(u_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_a6"); } memory->create3d_offset(v0_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a0"); memory->create3d_offset(v1_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a0"); memory->create3d_offset(v2_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a0"); memory->create3d_offset(v3_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a0"); memory->create3d_offset(v4_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a0"); memory->create3d_offset(v5_brick_a0,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a0"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a0"); memory->create3d_offset(v0_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a1"); memory->create3d_offset(v1_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a1"); memory->create3d_offset(v2_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a1"); memory->create3d_offset(v3_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a1"); memory->create3d_offset(v4_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a1"); memory->create3d_offset(v5_brick_a1,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a1"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a1"); memory->create3d_offset(v0_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a2"); memory->create3d_offset(v1_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a2"); memory->create3d_offset(v2_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a2"); memory->create3d_offset(v3_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a2"); memory->create3d_offset(v4_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a2"); memory->create3d_offset(v5_brick_a2,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a2"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a2"); memory->create3d_offset(v0_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a3"); memory->create3d_offset(v1_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a3"); memory->create3d_offset(v2_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a3"); memory->create3d_offset(v3_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a3"); memory->create3d_offset(v4_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a3"); memory->create3d_offset(v5_brick_a3,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a3"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a3"); memory->create3d_offset(v0_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a4"); memory->create3d_offset(v1_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a4"); memory->create3d_offset(v2_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a4"); memory->create3d_offset(v3_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a4"); memory->create3d_offset(v4_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a4"); memory->create3d_offset(v5_brick_a4,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a4"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a4"); memory->create3d_offset(v0_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a5"); memory->create3d_offset(v1_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a5"); memory->create3d_offset(v2_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a5"); memory->create3d_offset(v3_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a5"); memory->create3d_offset(v4_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a5"); memory->create3d_offset(v5_brick_a5,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a5"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a5"); memory->create3d_offset(v0_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_a6"); memory->create3d_offset(v1_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_a6"); memory->create3d_offset(v2_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_a6"); memory->create3d_offset(v3_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_a6"); memory->create3d_offset(v4_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_a6"); memory->create3d_offset(v5_brick_a6,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a6"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_a6"); // create ghost grid object for rho and electric field communication @@ -2276,20 +2276,20 @@ void PPPMDisp::allocate_peratom() if ( differentiation_flag != 1 ) memory->create4d_offset(u_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:u_brick_none"); memory->create4d_offset(v0_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v0_brick_none"); memory->create4d_offset(v1_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v1_brick_none"); memory->create4d_offset(v2_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v2_brick_none"); memory->create4d_offset(v3_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v3_brick_none"); memory->create4d_offset(v4_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v4_brick_none"); memory->create4d_offset(v5_brick_none,nsplit_alloc,nzlo_out_6,nzhi_out_6,nylo_out_6,nyhi_out_6, - nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_none"); + nxlo_out_6,nxhi_out_6,"pppm/disp:v5_brick_none"); // create ghost grid object for rho and electric field communication @@ -2687,9 +2687,9 @@ void PPPMDisp::set_fft_parameters(int& nx_p,int& ny_p,int& nz_p, int& nxhi_i,int& nyhi_i,int& nzhi_i, int& nxlo_o,int& nylo_o,int& nzlo_o, int& nxhi_o,int& nyhi_o,int& nzhi_o, - int& nlow, int& nupp, + int& nlow, int& nupp, int& ng, int& nf, int& nfb, - double& sft,double& sftone, int& ord) + double& sft,double& sftone, int& ord) { // global indices of PPPM grid range from 0 to N-1 // nlo_in,nhi_in = lower/upper limits of the 3d sub-brick of @@ -2851,8 +2851,8 @@ int PPPMDisp::factorable(int n) while (n > 1) { for (i = 0; i < nfactors; i++) { if (n % factors[i] == 0) { - n /= factors[i]; - break; + n /= factors[i]; + break; } } if (i == nfactors) return 0; @@ -3080,12 +3080,12 @@ double PPPMDisp::compute_qopt_ik() u2 = pow(wx*wy*wz,2.0); sum1 += sx*sy*sz*sx*sy*sz/dot2*4.0*4.0*MY_PI*MY_PI; sum2 += u2*sx*sy*sz*4.0*MY_PI/dot2*dot1; - sum3 += u2; + sum3 += u2; } } } - sum2 *= sum2; - sum3 *= sum3*sqk; + sum2 *= sum2; + sum3 *= sum3*sqk; qopt += sum1 -sum2/sum3; } } @@ -3255,17 +3255,17 @@ double PPPMDisp::compute_qopt_6_ik() dot2 = qx*qx+qy*qy+qz*qz; rtdot2 = sqrt(dot2); term = (1-2*dot2*inv2ew*inv2ew)*sx*sy*sz + - 2*dot2*rtdot2*inv2ew*inv2ew*inv2ew*rtpi*erfc(rtdot2*inv2ew); + 2*dot2*rtdot2*inv2ew*inv2ew*inv2ew*rtpi*erfc(rtdot2*inv2ew); term *= g_ewald_6*g_ewald_6*g_ewald_6; u2 = pow(wx*wy*wz,2.0); sum1 += term*term*MY_PI*MY_PI*MY_PI/9.0 * dot2; sum2 += -u2*term*MY_PI*rtpi/3.0*dot1; - sum3 += u2; + sum3 += u2; } } } - sum2 *= sum2; - sum3 *= sum3*sqk; + sum2 *= sum2; + sum3 *= sum3*sqk; qopt += sum1 -sum2/sum3; } } @@ -3349,7 +3349,7 @@ double PPPMDisp::compute_qopt_6_ad() dot2 = qx*qx+qy*qy+qz*qz; rtdot2 = sqrt(dot2); term = (1-2*dot2*inv2ew*inv2ew)*sx*sy*sz + - 2*dot2*rtdot2*inv2ew*inv2ew*inv2ew*rtpi*erfc(rtdot2*inv2ew); + 2*dot2*rtdot2*inv2ew*inv2ew*inv2ew*rtpi*erfc(rtdot2*inv2ew); term *= g_ewald_6*g_ewald_6*g_ewald_6; u2 = pow(wx*wy*wz,2.0); sum1 += term*term*MY_PI*MY_PI*MY_PI/9.0 * dot2; @@ -3482,11 +3482,11 @@ void PPPMDisp::calc_csum() for (i=1; i<=ntypes; i++) { for (j=1; j<=ntypes; j++) { for (k=0; k<nsplit; k++) { - csumi[i] += neach_all[j]*B[k]*B[nsplit*i+k]*B[nsplit*j+k]; - d1 = neach_all[i]*B[nsplit*i+k]; - d2 = neach_all[j]*B[nsplit*j+k]; + csumi[i] += neach_all[j]*B[k]*B[nsplit*i+k]*B[nsplit*j+k]; + d1 = neach_all[i]*B[nsplit*i+k]; + d2 = neach_all[j]*B[nsplit*j+k]; csumij += B[k]*d1*d2; - } + } } } } @@ -3984,24 +3984,24 @@ void PPPMDisp::compute_gf_6() wy *= wy; for (k = nxlo_fft_6; k <= nxhi_fft_6; k++) { - kper = k - nx_pppm_6*(2*k/nx_pppm_6); + kper = k - nx_pppm_6*(2*k/nx_pppm_6); qx = unitkx*kper; - snx = sin(0.5*unitkx*kper*xprd/nx_pppm_6); - snx2 = snx*snx; + snx = sin(0.5*unitkx*kper*xprd/nx_pppm_6); + snx2 = snx*snx; sx = exp(-qx*qx*inv2ew*inv2ew); - wx = 1.0; - argx = 0.5*qx*xprd/nx_pppm_6; - if (argx != 0.0) wx = pow(sin(argx)/argx,order_6); + wx = 1.0; + argx = 0.5*qx*xprd/nx_pppm_6; + if (argx != 0.0) wx = pow(sin(argx)/argx,order_6); wx *= wx; - sqk = pow(qx,2.0) + pow(qy,2.0) + pow(qz,2.0); + sqk = pow(qx,2.0) + pow(qy,2.0) + pow(qz,2.0); if (sqk != 0.0) { - denominator = gf_denom(snx2,sny2,snz2, gf_b_6, order_6); - rtsqk = sqrt(sqk); + denominator = gf_denom(snx2,sny2,snz2, gf_b_6, order_6); + rtsqk = sqrt(sqk); term = (1-2*sqk*inv2ew*inv2ew)*sx*sy*sz + 2*sqk*rtsqk*inv2ew*inv2ew*inv2ew*rtpi*erfc(rtsqk*inv2ew); - greensfn_6[n++] = numerator*term*wx*wy*wz/denominator; + greensfn_6[n++] = numerator*term*wx*wy*wz/denominator; } else greensfn_6[n++] = 0.0; } } @@ -4193,7 +4193,7 @@ void PPPMDisp::brick2fft(int nxlo_i, int nylo_i, int nzlo_i, for (iz = nzlo_i; iz <= nzhi_i; iz++) for (iy = nylo_i; iy <= nyhi_i; iy++) for (ix = nxlo_i; ix <= nxhi_i; ix++) - dfft[n++] = dbrick[iz][iy][ix]; + dfft[n++] = dbrick[iz][iy][ix]; rmp->perform(dfft,dfft,work); } @@ -4299,8 +4299,8 @@ void PPPMDisp::particle_map(double delx, double dely, double delz, // check that entire stencil around nx,ny,nz will fit in my 3d brick if (nx+nlow < nxlo || nx+nup > nxhi || - ny+nlow < nylo || ny+nup > nyhi || - nz+nlow < nzlo || nz+nup > nzhi) + ny+nlow < nylo || ny+nup > nyhi || + nz+nlow < nzlo || nz+nup > nzhi) flag = 1; } @@ -4332,7 +4332,7 @@ void PPPMDisp::make_rho_c() // clear 3d density array memset(&(density_brick[nzlo_out][nylo_out][nxlo_out]),0, - ngrid*sizeof(FFT_SCALAR)); + ngrid*sizeof(FFT_SCALAR)); // loop over my charges, add their contribution to nearby grid points // (nx,ny,nz) = global coords of grid pt to "lower left" of charge @@ -4359,12 +4359,12 @@ void PPPMDisp::make_rho_c() mz = n+nz; y0 = z0*rho1d[2][n]; for (m = nlower; m <= nupper; m++) { - my = m+ny; - x0 = y0*rho1d[1][m]; - for (l = nlower; l <= nupper; l++) { - mx = l+nx; - density_brick[mz][my][mx] += x0*rho1d[0][l]; - } + my = m+ny; + x0 = y0*rho1d[1][m]; + for (l = nlower; l <= nupper; l++) { + mx = l+nx; + density_brick[mz][my][mx] += x0*rho1d[0][l]; + } } } } @@ -4385,7 +4385,7 @@ void PPPMDisp::make_rho_g() // clear 3d density array memset(&(density_brick_g[nzlo_out_6][nylo_out_6][nxlo_out_6]),0, - ngrid_6*sizeof(FFT_SCALAR)); + ngrid_6*sizeof(FFT_SCALAR)); // loop over my charges, add their contribution to nearby grid points // (nx,ny,nz) = global coords of grid pt to "lower left" of charge @@ -4411,12 +4411,12 @@ void PPPMDisp::make_rho_g() mz = n+nz; y0 = z0*rho1d_6[2][n]; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - x0 = y0*rho1d_6[1][m]; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; - density_brick_g[mz][my][mx] += x0*rho1d_6[0][l]; - } + my = m+ny; + x0 = y0*rho1d_6[1][m]; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; + density_brick_g[mz][my][mx] += x0*rho1d_6[0][l]; + } } } } @@ -4438,19 +4438,19 @@ void PPPMDisp::make_rho_a() // clear 3d density array memset(&(density_brick_a0[nzlo_out_6][nylo_out_6][nxlo_out_6]),0, - ngrid_6*sizeof(FFT_SCALAR)); + ngrid_6*sizeof(FFT_SCALAR)); memset(&(density_brick_a1[nzlo_out_6][nylo_out_6][nxlo_out_6]),0, - ngrid_6*sizeof(FFT_SCALAR)); + ngrid_6*sizeof(FFT_SCALAR)); memset(&(density_brick_a2[nzlo_out_6][nylo_out_6][nxlo_out_6]),0, - ngrid_6*sizeof(FFT_SCALAR)); + ngrid_6*sizeof(FFT_SCALAR)); memset(&(density_brick_a3[nzlo_out_6][nylo_out_6][nxlo_out_6]),0, - ngrid_6*sizeof(FFT_SCALAR)); + ngrid_6*sizeof(FFT_SCALAR)); memset(&(density_brick_a4[nzlo_out_6][nylo_out_6][nxlo_out_6]),0, - ngrid_6*sizeof(FFT_SCALAR)); + ngrid_6*sizeof(FFT_SCALAR)); memset(&(density_brick_a5[nzlo_out_6][nylo_out_6][nxlo_out_6]),0, - ngrid_6*sizeof(FFT_SCALAR)); + ngrid_6*sizeof(FFT_SCALAR)); memset(&(density_brick_a6[nzlo_out_6][nylo_out_6][nxlo_out_6]),0, - ngrid_6*sizeof(FFT_SCALAR)); + ngrid_6*sizeof(FFT_SCALAR)); // loop over my particles, add their contribution to nearby grid points // (nx,ny,nz) = global coords of grid pt to "lower left" of charge @@ -4476,19 +4476,19 @@ void PPPMDisp::make_rho_a() mz = n+nz; y0 = z0*rho1d_6[2][n]; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - x0 = y0*rho1d_6[1][m]; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; + my = m+ny; + x0 = y0*rho1d_6[1][m]; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; w = x0*rho1d_6[0][l]; - density_brick_a0[mz][my][mx] += w*B[7*type]; - density_brick_a1[mz][my][mx] += w*B[7*type+1]; - density_brick_a2[mz][my][mx] += w*B[7*type+2]; - density_brick_a3[mz][my][mx] += w*B[7*type+3]; - density_brick_a4[mz][my][mx] += w*B[7*type+4]; - density_brick_a5[mz][my][mx] += w*B[7*type+5]; - density_brick_a6[mz][my][mx] += w*B[7*type+6]; - } + density_brick_a0[mz][my][mx] += w*B[7*type]; + density_brick_a1[mz][my][mx] += w*B[7*type+1]; + density_brick_a2[mz][my][mx] += w*B[7*type+2]; + density_brick_a3[mz][my][mx] += w*B[7*type+3]; + density_brick_a4[mz][my][mx] += w*B[7*type+4]; + density_brick_a5[mz][my][mx] += w*B[7*type+5]; + density_brick_a6[mz][my][mx] += w*B[7*type+6]; + } } } } @@ -4509,7 +4509,7 @@ void PPPMDisp::make_rho_none() // clear 3d density array for (k = 0; k < nsplit_alloc; k++) memset(&(density_brick_none[k][nzlo_out_6][nylo_out_6][nxlo_out_6]),0, - ngrid_6*sizeof(FFT_SCALAR)); + ngrid_6*sizeof(FFT_SCALAR)); // loop over my particles, add their contribution to nearby grid points @@ -4536,14 +4536,14 @@ void PPPMDisp::make_rho_none() mz = n+nz; y0 = z0*rho1d_6[2][n]; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - x0 = y0*rho1d_6[1][m]; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; + my = m+ny; + x0 = y0*rho1d_6[1][m]; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; w = x0*rho1d_6[0][l]; for (k = 0; k < nsplit; k++) - density_brick_none[k][mz][my][mx] += w*B[nsplit*type + k]; - } + density_brick_none[k][mz][my][mx] += w*B[nsplit*type + k]; + } } } } @@ -4592,17 +4592,17 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, if (vflag_global) { n = 0; for (i = 0; i < nft; i++) { - eng = s2 * gfn[i] * (wk1[n]*wk1[n] + wk1[n+1]*wk1[n+1]); - for (j = 0; j < 6; j++) vir[j] += eng*vcoeff[i][j]; - if (eflag_global) egy += eng; - n += 2; + eng = s2 * gfn[i] * (wk1[n]*wk1[n] + wk1[n+1]*wk1[n+1]); + for (j = 0; j < 6; j++) vir[j] += eng*vcoeff[i][j]; + if (eflag_global) egy += eng; + n += 2; } } else { n = 0; for (i = 0; i < nft; i++) { - egy += - s2 * gfn[i] * (wk1[n]*wk1[n] + wk1[n+1]*wk1[n+1]); - n += 2; + egy += + s2 * gfn[i] * (wk1[n]*wk1[n] + wk1[n+1]*wk1[n+1]); + n += 2; } } } @@ -4626,9 +4626,9 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_ft; k <= nzhi_ft; k++) for (j = nylo_ft; j <= nyhi_ft; j++) for (i = nxlo_ft; i <= nxhi_ft; i++) { - wk2[n] = 0.5*(kx[i]-kx2[i])*wk1[n+1] + 0.5*(ky[j]-ky2[j])*wk1[n]; - wk2[n+1] = -0.5*(kx[i]-kx2[i])*wk1[n] + 0.5*(ky[j]-ky2[j])*wk1[n+1]; - n += 2; + wk2[n] = 0.5*(kx[i]-kx2[i])*wk1[n+1] + 0.5*(ky[j]-ky2[j])*wk1[n]; + wk2[n+1] = -0.5*(kx[i]-kx2[i])*wk1[n] + 0.5*(ky[j]-ky2[j])*wk1[n+1]; + n += 2; } ft2->compute(wk2,wk2,-1); @@ -4637,8 +4637,8 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_i; k <= nzhi_i; k++) for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { - vx_brick[k][j][i] = wk2[n++]; - vy_brick[k][j][i] = wk2[n++]; + vx_brick[k][j][i] = wk2[n++]; + vy_brick[k][j][i] = wk2[n++]; } if (!eflag_atom) { @@ -4648,9 +4648,9 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_ft; k <= nzhi_ft; k++) for (j = nylo_ft; j <= nyhi_ft; j++) for (i = nxlo_ft; i <= nxhi_ft; i++) { - wk2[n] = kz[k]*wk1[n+1]; - wk2[n+1] = -kz[k]*wk1[n]; - n += 2; + wk2[n] = kz[k]*wk1[n+1]; + wk2[n+1] = -kz[k]*wk1[n]; + n += 2; } ft2->compute(wk2,wk2,-1); @@ -4660,8 +4660,8 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_i; k <= nzhi_i; k++) for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { - vz_brick[k][j][i] = wk2[n]; - n += 2; + vz_brick[k][j][i] = wk2[n]; + n += 2; } } @@ -4673,9 +4673,9 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_ft; k <= nzhi_ft; k++) for (j = nylo_ft; j <= nyhi_ft; j++) for (i = nxlo_ft; i <= nxhi_ft; i++) { - wk2[n] = 0.5*(kz[k]-kz2[k])*wk1[n+1] - wk1[n+1]; - wk2[n+1] = -0.5*(kz[k]-kz2[k])*wk1[n] + wk1[n]; - n += 2; + wk2[n] = 0.5*(kz[k]-kz2[k])*wk1[n+1] - wk1[n+1]; + wk2[n+1] = -0.5*(kz[k]-kz2[k])*wk1[n] + wk1[n]; + n += 2; } ft2->compute(wk2,wk2,-1); @@ -4684,8 +4684,8 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_i; k <= nzhi_i; k++) for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { - vz_brick[k][j][i] = wk2[n++]; - u_pa[k][j][i] = wk2[n++];; + vz_brick[k][j][i] = wk2[n++]; + u_pa[k][j][i] = wk2[n++];; } } @@ -4733,17 +4733,17 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, if (vflag_global) { n = 0; for (i = 0; i < nft; i++) { - eng = s2 * gfn[i] * (wk1[n]*wk1[n] + wk1[n+1]*wk1[n+1]); - for (j = 0; j < 6; j++) vir[j] += eng*vcoeff[i][j]; - if (eflag_global) egy += eng; - n += 2; + eng = s2 * gfn[i] * (wk1[n]*wk1[n] + wk1[n+1]*wk1[n+1]); + for (j = 0; j < 6; j++) vir[j] += eng*vcoeff[i][j]; + if (eflag_global) egy += eng; + n += 2; } } else { n = 0; for (i = 0; i < nft; i++) { - egy += - s2 * gfn[i] * (wk1[n]*wk1[n] + wk1[n+1]*wk1[n+1]); - n += 2; + egy += + s2 * gfn[i] * (wk1[n]*wk1[n] + wk1[n+1]*wk1[n+1]); + n += 2; } } } @@ -4763,8 +4763,8 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (j = nylo_ft; j <= nyhi_ft; j++) for (i = nxlo_ft; i <= nxhi_ft; i++) { wk2[n] = wk1[n]; - wk2[n+1] = wk1[n+1]; - n += 2; + wk2[n+1] = wk1[n+1]; + n += 2; } ft2->compute(wk2,wk2,-1); @@ -4774,7 +4774,7 @@ void PPPMDisp::poisson_ad(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (k = nzlo_i; k <= nzhi_i; k++) for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { - u_pa[k][j][i] = wk2[n++]; + u_pa[k][j][i] = wk2[n++]; n++; } @@ -4905,17 +4905,17 @@ void PPPMDisp::poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, if (vflag_global) { n = 0; for (i = 0; i < nfft_6; i++) { - eng = 2 * s2 * greensfn_6[i] * (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); - for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; - if (eflag_global)energy_6 += eng; - n += 2; + eng = 2 * s2 * greensfn_6[i] * (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); + for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; + if (eflag_global)energy_6 += eng; + n += 2; } } else { n = 0; for (i = 0; i < nfft_6; i++) { - energy_6 += - 2 * s2 * greensfn_6[i] * (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); - n += 2; + energy_6 += + 2 * s2 * greensfn_6[i] * (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); + n += 2; } } // unify the two transformed vectors for efficient calculations later @@ -4940,9 +4940,9 @@ void PPPMDisp::poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n]; - n += 2; + work2_6[n] = 0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n+1]; + work2_6[n+1] = -0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n]; + n += 2; } fft2_6->compute(work2_6,work2_6,-1); @@ -4951,7 +4951,7 @@ void PPPMDisp::poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_in_6; k <= nzhi_in_6; k++) for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { - vxbrick_1[k][j][i] = work2_6[n++]; + vxbrick_1[k][j][i] = work2_6[n++]; vxbrick_2[k][j][i] = work2_6[n++]; } @@ -4961,9 +4961,9 @@ void PPPMDisp::poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fky_6[j]-fky2_6[j])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fky_6[j]-fky2_6[j])*work1_6[n]; - n += 2; + work2_6[n] = 0.5*(fky_6[j]-fky2_6[j])*work1_6[n+1]; + work2_6[n+1] = -0.5*(fky_6[j]-fky2_6[j])*work1_6[n]; + n += 2; } fft2_6->compute(work2_6,work2_6,-1); @@ -4972,7 +4972,7 @@ void PPPMDisp::poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_in_6; k <= nzhi_in_6; k++) for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { - vybrick_1[k][j][i] = work2_6[n++]; + vybrick_1[k][j][i] = work2_6[n++]; vybrick_2[k][j][i] = work2_6[n++]; } @@ -4982,9 +4982,9 @@ void PPPMDisp::poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n]; - n += 2; + work2_6[n] = 0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n+1]; + work2_6[n+1] = -0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n]; + n += 2; } fft2_6->compute(work2_6,work2_6,-1); @@ -4993,8 +4993,8 @@ void PPPMDisp::poisson_2s_ik(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, for (k = nzlo_in_6; k <= nzhi_in_6; k++) for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { - vzbrick_1[k][j][i] = work2_6[n++]; - vzbrick_2[k][j][i] = work2_6[n++]; + vzbrick_1[k][j][i] = work2_6[n++]; + vzbrick_2[k][j][i] = work2_6[n++]; } //Per-atom energy @@ -5073,17 +5073,17 @@ void PPPMDisp::poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* df if (vflag_global) { n = 0; for (i = 0; i < nfft_6; i++) { - eng = s2 * greensfn_6[i] * (B[n1]*(work1_6[n]*work1_6[n] + work1_6[n+1]*work1_6[n+1]) + B[n2]*(work2_6[n]*work2_6[n] + work2_6[n+1]*work2_6[n+1])); - for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; - if (eflag_global)energy_6 += eng; - n += 2; + eng = s2 * greensfn_6[i] * (B[n1]*(work1_6[n]*work1_6[n] + work1_6[n+1]*work1_6[n+1]) + B[n2]*(work2_6[n]*work2_6[n] + work2_6[n+1]*work2_6[n+1])); + for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; + if (eflag_global)energy_6 += eng; + n += 2; } } else { n = 0; for (i = 0; i < nfft_6; i++) { - energy_6 += - s2 * greensfn_6[i] * (B[n1]*(work1_6[n]*work1_6[n] + work1_6[n+1]*work1_6[n+1]) + B[n2]*(work2_6[n]*work2_6[n] + work2_6[n+1]*work2_6[n+1])); - n += 2; + energy_6 += + s2 * greensfn_6[i] * (B[n1]*(work1_6[n]*work1_6[n] + work1_6[n+1]*work1_6[n+1]) + B[n2]*(work2_6[n]*work2_6[n] + work2_6[n+1]*work2_6[n+1])); + n += 2; } } // unify the two transformed vectors for efficient calculations later @@ -5108,9 +5108,9 @@ void PPPMDisp::poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* df for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n]; - n += 2; + work2_6[n] = 0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n+1]; + work2_6[n+1] = -0.5*(fkx_6[i]-fkx2_6[i])*work1_6[n]; + n += 2; } fft2_6->compute(work2_6,work2_6,-1); @@ -5119,7 +5119,7 @@ void PPPMDisp::poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* df for (k = nzlo_in_6; k <= nzhi_in_6; k++) for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { - vxbrick_1[k][j][i] = B[n1]*work2_6[n++]; + vxbrick_1[k][j][i] = B[n1]*work2_6[n++]; vxbrick_2[k][j][i] = B[n2]*work2_6[n++]; } @@ -5129,9 +5129,9 @@ void PPPMDisp::poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* df for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fky_6[j]-fky2_6[j])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fky_6[j]-fky2_6[j])*work1_6[n]; - n += 2; + work2_6[n] = 0.5*(fky_6[j]-fky2_6[j])*work1_6[n+1]; + work2_6[n+1] = -0.5*(fky_6[j]-fky2_6[j])*work1_6[n]; + n += 2; } fft2_6->compute(work2_6,work2_6,-1); @@ -5140,7 +5140,7 @@ void PPPMDisp::poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* df for (k = nzlo_in_6; k <= nzhi_in_6; k++) for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { - vybrick_1[k][j][i] = B[n1]*work2_6[n++]; + vybrick_1[k][j][i] = B[n1]*work2_6[n++]; vybrick_2[k][j][i] = B[n2]*work2_6[n++]; } @@ -5150,9 +5150,9 @@ void PPPMDisp::poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* df for (k = nzlo_fft_6; k <= nzhi_fft_6; k++) for (j = nylo_fft_6; j <= nyhi_fft_6; j++) for (i = nxlo_fft_6; i <= nxhi_fft_6; i++) { - work2_6[n] = 0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n+1]; - work2_6[n+1] = -0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n]; - n += 2; + work2_6[n] = 0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n+1]; + work2_6[n+1] = -0.5*(fkz_6[k]-fkz2_6[k])*work1_6[n]; + n += 2; } fft2_6->compute(work2_6,work2_6,-1); @@ -5161,8 +5161,8 @@ void PPPMDisp::poisson_none_ik(int n1, int n2,FFT_SCALAR* dfft_1, FFT_SCALAR* df for (k = nzlo_in_6; k <= nzhi_in_6; k++) for (j = nylo_in_6; j <= nyhi_in_6; j++) for (i = nxlo_in_6; i <= nxhi_in_6; i++) { - vzbrick_1[k][j][i] = B[n1]*work2_6[n++]; - vzbrick_2[k][j][i] = B[n2]*work2_6[n++]; + vzbrick_1[k][j][i] = B[n1]*work2_6[n++]; + vzbrick_2[k][j][i] = B[n2]*work2_6[n++]; } //Per-atom energy @@ -5239,17 +5239,17 @@ void PPPMDisp::poisson_2s_ad(FFT_SCALAR* dfft_1, FFT_SCALAR* dfft_2, if (vflag_global) { n = 0; for (i = 0; i < nfft_6; i++) { - eng = 2 * s2 * greensfn_6[i] * (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); - for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; - if (eflag_global)energy_6 += eng; - n += 2; + eng = 2 * s2 * greensfn_6[i] * (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); + for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; + if (eflag_global)energy_6 += eng; + n += 2; } } else { n = 0; for (i = 0; i < nfft_6; i++) { - energy_6 += - 2 * s2 * greensfn_6[i] * (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); - n += 2; + energy_6 += + 2 * s2 * greensfn_6[i] * (work1_6[n]*work2_6[n+1] - work1_6[n+1]*work2_6[n]); + n += 2; } } // unify the two transformed vectors for efficient calculations later @@ -5333,17 +5333,17 @@ void PPPMDisp::poisson_none_ad(int n1, int n2, FFT_SCALAR* dfft_1, FFT_SCALAR* d if (vflag_global) { n = 0; for (i = 0; i < nfft_6; i++) { - eng = s2 * greensfn_6[i] * (B[n1]*(work1_6[n]*work1_6[n] + work1_6[n+1]*work1_6[n+1]) + B[n2]*(work2_6[n]*work2_6[n] + work2_6[n+1]*work2_6[n+1])); - for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; - if (eflag_global)energy_6 += eng; - n += 2; + eng = s2 * greensfn_6[i] * (B[n1]*(work1_6[n]*work1_6[n] + work1_6[n+1]*work1_6[n+1]) + B[n2]*(work2_6[n]*work2_6[n] + work2_6[n+1]*work2_6[n+1])); + for (j = 0; j < 6; j++) virial_6[j] += eng*vg_6[i][j]; + if (eflag_global)energy_6 += eng; + n += 2; } } else { n = 0; for (i = 0; i < nfft_6; i++) { - energy_6 += - s2 * greensfn_6[i] * (B[n1]*(work1_6[n]*work1_6[n] + work1_6[n+1]*work1_6[n+1]) + B[n2]*(work2_6[n]*work2_6[n] + work2_6[n+1]*work2_6[n+1])); - n += 2; + energy_6 += + s2 * greensfn_6[i] * (B[n1]*(work1_6[n]*work1_6[n] + work1_6[n+1]*work1_6[n+1]) + B[n2]*(work2_6[n]*work2_6[n] + work2_6[n+1]*work2_6[n+1])); + n += 2; } } // unify the two transformed vectors for efficient calculations later @@ -5671,15 +5671,15 @@ void PPPMDisp::fieldforce_c_ik() mz = n+nz; z0 = rho1d[2][n]; for (m = nlower; m <= nupper; m++) { - my = m+ny; - y0 = z0*rho1d[1][m]; - for (l = nlower; l <= nupper; l++) { - mx = l+nx; - x0 = y0*rho1d[0][l]; - ekx -= x0*vdx_brick[mz][my][mx]; - eky -= x0*vdy_brick[mz][my][mx]; - ekz -= x0*vdz_brick[mz][my][mx]; - } + my = m+ny; + y0 = z0*rho1d[1][m]; + for (l = nlower; l <= nupper; l++) { + mx = l+nx; + x0 = y0*rho1d[0][l]; + ekx -= x0*vdx_brick[mz][my][mx]; + eky -= x0*vdy_brick[mz][my][mx]; + ekz -= x0*vdz_brick[mz][my][mx]; + } } } @@ -5817,13 +5817,13 @@ void PPPMDisp::fieldforce_c_peratom() mz = n+nz; z0 = rho1d[2][n]; for (m = nlower; m <= nupper; m++) { - my = m+ny; - y0 = z0*rho1d[1][m]; - for (l = nlower; l <= nupper; l++) { - mx = l+nx; - x0 = y0*rho1d[0][l]; - if (eflag_atom) u_pa += x0*u_brick[mz][my][mx]; - if (vflag_atom) { + my = m+ny; + y0 = z0*rho1d[1][m]; + for (l = nlower; l <= nupper; l++) { + mx = l+nx; + x0 = y0*rho1d[0][l]; + if (eflag_atom) u_pa += x0*u_brick[mz][my][mx]; + if (vflag_atom) { v0 += x0*v0_brick[mz][my][mx]; v1 += x0*v1_brick[mz][my][mx]; v2 += x0*v2_brick[mz][my][mx]; @@ -5831,7 +5831,7 @@ void PPPMDisp::fieldforce_c_peratom() v4 += x0*v4_brick[mz][my][mx]; v5 += x0*v5_brick[mz][my][mx]; } - } + } } } @@ -5890,15 +5890,15 @@ void PPPMDisp::fieldforce_g_ik() mz = n+nz; z0 = rho1d_6[2][n]; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - y0 = z0*rho1d_6[1][m]; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; - x0 = y0*rho1d_6[0][l]; - ekx -= x0*vdx_brick_g[mz][my][mx]; - eky -= x0*vdy_brick_g[mz][my][mx]; - ekz -= x0*vdz_brick_g[mz][my][mx]; - } + my = m+ny; + y0 = z0*rho1d_6[1][m]; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; + x0 = y0*rho1d_6[0][l]; + ekx -= x0*vdx_brick_g[mz][my][mx]; + eky -= x0*vdy_brick_g[mz][my][mx]; + ekz -= x0*vdz_brick_g[mz][my][mx]; + } } } @@ -6045,13 +6045,13 @@ void PPPMDisp::fieldforce_g_peratom() mz = n+nz; z0 = rho1d_6[2][n]; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - y0 = z0*rho1d_6[1][m]; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; - x0 = y0*rho1d_6[0][l]; - if (eflag_atom) u_pa += x0*u_brick_g[mz][my][mx]; - if (vflag_atom) { + my = m+ny; + y0 = z0*rho1d_6[1][m]; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; + x0 = y0*rho1d_6[0][l]; + if (eflag_atom) u_pa += x0*u_brick_g[mz][my][mx]; + if (vflag_atom) { v0 += x0*v0_brick_g[mz][my][mx]; v1 += x0*v1_brick_g[mz][my][mx]; v2 += x0*v2_brick_g[mz][my][mx]; @@ -6059,7 +6059,7 @@ void PPPMDisp::fieldforce_g_peratom() v4 += x0*v4_brick_g[mz][my][mx]; v5 += x0*v5_brick_g[mz][my][mx]; } - } + } } } @@ -6125,33 +6125,33 @@ void PPPMDisp::fieldforce_a_ik() mz = n+nz; z0 = rho1d_6[2][n]; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - y0 = z0*rho1d_6[1][m]; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; - x0 = y0*rho1d_6[0][l]; - ekx0 -= x0*vdx_brick_a0[mz][my][mx]; - eky0 -= x0*vdy_brick_a0[mz][my][mx]; - ekz0 -= x0*vdz_brick_a0[mz][my][mx]; - ekx1 -= x0*vdx_brick_a1[mz][my][mx]; - eky1 -= x0*vdy_brick_a1[mz][my][mx]; - ekz1 -= x0*vdz_brick_a1[mz][my][mx]; + my = m+ny; + y0 = z0*rho1d_6[1][m]; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; + x0 = y0*rho1d_6[0][l]; + ekx0 -= x0*vdx_brick_a0[mz][my][mx]; + eky0 -= x0*vdy_brick_a0[mz][my][mx]; + ekz0 -= x0*vdz_brick_a0[mz][my][mx]; + ekx1 -= x0*vdx_brick_a1[mz][my][mx]; + eky1 -= x0*vdy_brick_a1[mz][my][mx]; + ekz1 -= x0*vdz_brick_a1[mz][my][mx]; ekx2 -= x0*vdx_brick_a2[mz][my][mx]; - eky2 -= x0*vdy_brick_a2[mz][my][mx]; - ekz2 -= x0*vdz_brick_a2[mz][my][mx]; - ekx3 -= x0*vdx_brick_a3[mz][my][mx]; - eky3 -= x0*vdy_brick_a3[mz][my][mx]; - ekz3 -= x0*vdz_brick_a3[mz][my][mx]; - ekx4 -= x0*vdx_brick_a4[mz][my][mx]; - eky4 -= x0*vdy_brick_a4[mz][my][mx]; - ekz4 -= x0*vdz_brick_a4[mz][my][mx]; + eky2 -= x0*vdy_brick_a2[mz][my][mx]; + ekz2 -= x0*vdz_brick_a2[mz][my][mx]; + ekx3 -= x0*vdx_brick_a3[mz][my][mx]; + eky3 -= x0*vdy_brick_a3[mz][my][mx]; + ekz3 -= x0*vdz_brick_a3[mz][my][mx]; + ekx4 -= x0*vdx_brick_a4[mz][my][mx]; + eky4 -= x0*vdy_brick_a4[mz][my][mx]; + ekz4 -= x0*vdz_brick_a4[mz][my][mx]; ekx5 -= x0*vdx_brick_a5[mz][my][mx]; - eky5 -= x0*vdy_brick_a5[mz][my][mx]; - ekz5 -= x0*vdz_brick_a5[mz][my][mx]; + eky5 -= x0*vdy_brick_a5[mz][my][mx]; + ekz5 -= x0*vdz_brick_a5[mz][my][mx]; ekx6 -= x0*vdx_brick_a6[mz][my][mx]; - eky6 -= x0*vdy_brick_a6[mz][my][mx]; - ekz6 -= x0*vdz_brick_a6[mz][my][mx]; - } + eky6 -= x0*vdy_brick_a6[mz][my][mx]; + ekz6 -= x0*vdz_brick_a6[mz][my][mx]; + } } } // convert D-field to force @@ -6233,9 +6233,9 @@ void PPPMDisp::fieldforce_a_ad() for (n = nlower_6; n <= nupper_6; n++) { mz = n+nz; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; + my = m+ny; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; x0 = drho1d_6[0][l]*rho1d_6[1][m]*rho1d_6[2][n]; y0 = rho1d_6[0][l]*drho1d_6[1][m]*rho1d_6[2][n]; z0 = rho1d_6[0][l]*rho1d_6[1][m]*drho1d_6[2][n]; @@ -6267,7 +6267,7 @@ void PPPMDisp::fieldforce_a_ad() ekx6 += x0*u_brick_a6[mz][my][mx]; eky6 += y0*u_brick_a6[mz][my][mx]; ekz6 += z0*u_brick_a6[mz][my][mx]; - } + } } } @@ -6380,11 +6380,11 @@ void PPPMDisp::fieldforce_a_peratom() mz = n+nz; z0 = rho1d_6[2][n]; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - y0 = z0*rho1d_6[1][m]; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; - x0 = y0*rho1d_6[0][l]; + my = m+ny; + y0 = z0*rho1d_6[1][m]; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; + x0 = y0*rho1d_6[0][l]; if (eflag_atom) { u_pa0 += x0*u_brick_a0[mz][my][mx]; u_pa1 += x0*u_brick_a1[mz][my][mx]; @@ -6393,7 +6393,7 @@ void PPPMDisp::fieldforce_a_peratom() u_pa4 += x0*u_brick_a4[mz][my][mx]; u_pa5 += x0*u_brick_a5[mz][my][mx]; u_pa6 += x0*u_brick_a6[mz][my][mx]; - } + } if (vflag_atom) { v00 += x0*v0_brick_a0[mz][my][mx]; v10 += x0*v1_brick_a0[mz][my][mx]; @@ -6438,7 +6438,7 @@ void PPPMDisp::fieldforce_a_peratom() v46 += x0*v4_brick_a6[mz][my][mx]; v56 += x0*v5_brick_a6[mz][my][mx]; } - } + } } } // convert D-field to force @@ -6514,17 +6514,17 @@ void PPPMDisp::fieldforce_none_ik() mz = n+nz; z0 = rho1d_6[2][n]; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - y0 = z0*rho1d_6[1][m]; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; - x0 = y0*rho1d_6[0][l]; + my = m+ny; + y0 = z0*rho1d_6[1][m]; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; + x0 = y0*rho1d_6[0][l]; for (k = 0; k < nsplit; k++) { - ekx[k] -= x0*vdx_brick_none[k][mz][my][mx]; - eky[k] -= x0*vdy_brick_none[k][mz][my][mx]; - ekz[k] -= x0*vdz_brick_none[k][mz][my][mx]; + ekx[k] -= x0*vdx_brick_none[k][mz][my][mx]; + eky[k] -= x0*vdy_brick_none[k][mz][my][mx]; + ekz[k] -= x0*vdz_brick_none[k][mz][my][mx]; } - } + } } } // convert D-field to force @@ -6606,9 +6606,9 @@ void PPPMDisp::fieldforce_none_ad() for (n = nlower_6; n <= nupper_6; n++) { mz = n+nz; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; + my = m+ny; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; x0 = drho1d_6[0][l]*rho1d_6[1][m]*rho1d_6[2][n]; y0 = rho1d_6[0][l]*drho1d_6[1][m]*rho1d_6[2][n]; z0 = rho1d_6[0][l]*rho1d_6[1][m]*drho1d_6[2][n]; @@ -6618,7 +6618,7 @@ void PPPMDisp::fieldforce_none_ad() eky[k] += y0*u_brick_none[k][mz][my][mx]; ekz[k] += z0*u_brick_none[k][mz][my][mx]; } - } + } } } @@ -6712,15 +6712,15 @@ void PPPMDisp::fieldforce_none_peratom() mz = n+nz; z0 = rho1d_6[2][n]; for (m = nlower_6; m <= nupper_6; m++) { - my = m+ny; - y0 = z0*rho1d_6[1][m]; - for (l = nlower_6; l <= nupper_6; l++) { - mx = l+nx; - x0 = y0*rho1d_6[0][l]; + my = m+ny; + y0 = z0*rho1d_6[1][m]; + for (l = nlower_6; l <= nupper_6; l++) { + mx = l+nx; + x0 = y0*rho1d_6[0][l]; if (eflag_atom) { for (k = 0; k < nsplit; k++) u_pa[k] += x0*u_brick_none[k][mz][my][mx]; - } + } if (vflag_atom) { for (k = 0; k < nsplit; k++) { v0[k] += x0*v0_brick_none[k][mz][my][mx]; @@ -6731,7 +6731,7 @@ void PPPMDisp::fieldforce_none_peratom() v5[k] += x0*v5_brick_none[k][mz][my][mx]; } } - } + } } } // convert D-field to force @@ -7919,12 +7919,12 @@ void PPPMDisp::procs2grid2d(int nprocs, int nx, int ny, int *px, int *py) if (ny % ipy) boxy++; surf = boxx + boxy; if (surf < bestsurf || - (surf == bestsurf && boxx*boxy > bestboxx*bestboxy)) { - bestsurf = surf; - bestboxx = boxx; - bestboxy = boxy; - *px = ipx; - *py = ipy; + (surf == bestsurf && boxx*boxy > bestboxx*bestboxy)) { + bestsurf = surf; + bestboxx = boxx; + bestboxy = boxy; + *px = ipx; + *py = ipy; } } ipx++; @@ -7937,7 +7937,7 @@ void PPPMDisp::procs2grid2d(int nprocs, int nx, int ny, int *px, int *py) ------------------------------------------------------------------------- */ void PPPMDisp::compute_rho1d(const FFT_SCALAR &dx, const FFT_SCALAR &dy, - const FFT_SCALAR &dz, int ord, + const FFT_SCALAR &dz, int ord, FFT_SCALAR **rho_c, FFT_SCALAR **r1d) { int k,l; @@ -8020,13 +8020,13 @@ void PPPMDisp::compute_rho_coeff(FFT_SCALAR **coeff , FFT_SCALAR **dcoeff, for (k = -j; k <= j; k += 2) { s = 0.0; for (l = 0; l < j; l++) { - a[l+1][k] = (a[l][k+1]-a[l][k-1]) / (l+1); + a[l+1][k] = (a[l][k+1]-a[l][k-1]) / (l+1); #ifdef FFT_SINGLE - s += powf(0.5,(float) l+1) * - (a[l][k-1] + powf(-1.0,(float) l) * a[l][k+1]) / (l+1); + s += powf(0.5,(float) l+1) * + (a[l][k-1] + powf(-1.0,(float) l) * a[l][k+1]) / (l+1); #else - s += pow(0.5,(double) l+1) * - (a[l][k-1] + pow(-1.0,(double) l) * a[l][k+1]) / (l+1); + s += pow(0.5,(double) l+1) * + (a[l][k-1] + pow(-1.0,(double) l) * a[l][k+1]) / (l+1); #endif } a[0][k] = s; diff --git a/src/KSPACE/pppm_disp.h b/src/KSPACE/pppm_disp.h index 6993ad6c91..89df3d947e 100644 --- a/src/KSPACE/pppm_disp.h +++ b/src/KSPACE/pppm_disp.h @@ -36,8 +36,8 @@ typedef double FFT_SCALAR; namespace LAMMPS_NS { -#define EWALD_MAXORDER 6 -#define EWALD_FUNCS 4 +#define EWALD_MAXORDER 6 +#define EWALD_FUNCS 4 class PPPMDisp : public KSpace { public: @@ -218,8 +218,8 @@ Variables needed for calculating the 1/r and 1/r^6 potential int&, int&,int&, int&, int&,int&, int&, int&,int&, int&, int&,int&, int&, int&,int&, int&, int&, - int&, int&, int&, - double&, double&, int&); + int&, int&, int&, + double&, double&, int&); void set_n_pppm_6(); void adjust_gewald(); void adjust_gewald_6(); @@ -266,7 +266,7 @@ Variables needed for calculating the 1/r and 1/r^6 potential int, int, int, int, int, int); virtual void particle_map_c(double, double, double, - double, int **, int, int, + double, int **, int, int, int, int, int, int, int, int ); virtual void make_rho_c(); @@ -275,19 +275,19 @@ Variables needed for calculating the 1/r and 1/r^6 potential virtual void make_rho_none(); virtual void brick2fft(int, int, int, int, int, int, - FFT_SCALAR ***, FFT_SCALAR *, FFT_SCALAR *, + FFT_SCALAR ***, FFT_SCALAR *, FFT_SCALAR *, LAMMPS_NS::Remap *); virtual void brick2fft_a(); virtual void brick2fft_none(); virtual void poisson_ik(FFT_SCALAR *, FFT_SCALAR *, - FFT_SCALAR *, LAMMPS_NS::FFT3d *,LAMMPS_NS::FFT3d *, + FFT_SCALAR *, LAMMPS_NS::FFT3d *,LAMMPS_NS::FFT3d *, int, int, int, int, int, int, int, - int, int, int, int, int, int, + int, int, int, int, int, int, int, int, int, double&, double *, double *, double *, double *, double *, double *, double *, - FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, double *, double **, double **, + FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, double *, double **, double **, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***); @@ -310,31 +310,31 @@ Variables needed for calculating the 1/r and 1/r^6 potential FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, - FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, + FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, - FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***); + FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***); virtual void poisson_2s_ad(FFT_SCALAR *, FFT_SCALAR *, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, - FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, + FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, - FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***); + FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***); virtual void poisson_2s_peratom(FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, - FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, + FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***); virtual void poisson_none_ad(int, int, FFT_SCALAR *, FFT_SCALAR *, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ****, FFT_SCALAR ****, FFT_SCALAR ****, - FFT_SCALAR ****, FFT_SCALAR ****, FFT_SCALAR ****); + FFT_SCALAR ****, FFT_SCALAR ****, FFT_SCALAR ****); virtual void poisson_none_ik(int, int, FFT_SCALAR *, FFT_SCALAR *, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ****, FFT_SCALAR ****, FFT_SCALAR ****, FFT_SCALAR ****, - FFT_SCALAR ****, FFT_SCALAR ****, FFT_SCALAR ****); + FFT_SCALAR ****, FFT_SCALAR ****, FFT_SCALAR ****); virtual void poisson_none_peratom(int, int, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, - FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, + FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***); @@ -353,9 +353,9 @@ Variables needed for calculating the 1/r and 1/r^6 potential virtual void fieldforce_none_peratom(); void procs2grid2d(int,int,int,int *, int*); void compute_rho1d(const FFT_SCALAR &, const FFT_SCALAR &, - const FFT_SCALAR &, int, FFT_SCALAR **, FFT_SCALAR **); + const FFT_SCALAR &, int, FFT_SCALAR **, FFT_SCALAR **); void compute_drho1d(const FFT_SCALAR &, const FFT_SCALAR &, - const FFT_SCALAR &, int, FFT_SCALAR **, FFT_SCALAR **); + const FFT_SCALAR &, int, FFT_SCALAR **, FFT_SCALAR **); void compute_rho_coeff(FFT_SCALAR **,FFT_SCALAR **, int); void slabcorr(int); diff --git a/src/KSPACE/pppm_disp_tip4p.cpp b/src/KSPACE/pppm_disp_tip4p.cpp index cf3a3943b9..686ed3df8e 100644 --- a/src/KSPACE/pppm_disp_tip4p.cpp +++ b/src/KSPACE/pppm_disp_tip4p.cpp @@ -103,8 +103,8 @@ void PPPMDispTIP4P::particle_map_c(double delx, double dely, double delz, // check that entire stencil around nx,ny,nz will fit in my 3d brick if (nx+nlow < nxlo || nx+nup > nxhi || - ny+nlow < nylo || ny+nup > nyhi || - nz+nlow < nzlo || nz+nup > nzhi) + ny+nlow < nylo || ny+nup > nyhi || + nz+nlow < nzlo || nz+nup > nzhi) flag = 1; } @@ -159,12 +159,12 @@ void PPPMDispTIP4P::make_rho_c() mz = n+nz; y0 = z0*rho1d[2][n]; for (m = nlower; m <= nupper; m++) { - my = m+ny; - x0 = y0*rho1d[1][m]; - for (l = nlower; l <= nupper; l++) { - mx = l+nx; - density_brick[mz][my][mx] += x0*rho1d[0][l]; - } + my = m+ny; + x0 = y0*rho1d[1][m]; + for (l = nlower; l <= nupper; l++) { + mx = l+nx; + density_brick[mz][my][mx] += x0*rho1d[0][l]; + } } } } @@ -217,14 +217,14 @@ void PPPMDispTIP4P::fieldforce_c_ik() mz = n+nz; z0 = rho1d[2][n]; for (m = nlower; m <= nupper; m++) { - my = m+ny; - y0 = z0*rho1d[1][m]; - for (l = nlower; l <= nupper; l++) { - mx = l+nx; - x0 = y0*rho1d[0][l]; - ekx -= x0*vdx_brick[mz][my][mx]; - eky -= x0*vdy_brick[mz][my][mx]; - ekz -= x0*vdz_brick[mz][my][mx]; + my = m+ny; + y0 = z0*rho1d[1][m]; + for (l = nlower; l <= nupper; l++) { + mx = l+nx; + x0 = y0*rho1d[0][l]; + ekx -= x0*vdx_brick[mz][my][mx]; + eky -= x0*vdy_brick[mz][my][mx]; + ekz -= x0*vdz_brick[mz][my][mx]; } } } @@ -426,20 +426,20 @@ void PPPMDispTIP4P::fieldforce_c_peratom() mz = n+nz; z0 = rho1d[2][n]; for (m = nlower; m <= nupper; m++) { - my = m+ny; - y0 = z0*rho1d[1][m]; - for (l = nlower; l <= nupper; l++) { - mx = l+nx; - x0 = y0*rho1d[0][l]; - if (eflag_atom) u_pa += x0*u_brick[mz][my][mx]; - if (vflag_atom) { + my = m+ny; + y0 = z0*rho1d[1][m]; + for (l = nlower; l <= nupper; l++) { + mx = l+nx; + x0 = y0*rho1d[0][l]; + if (eflag_atom) u_pa += x0*u_brick[mz][my][mx]; + if (vflag_atom) { v0 += x0*v0_brick[mz][my][mx]; v1 += x0*v1_brick[mz][my][mx]; v2 += x0*v2_brick[mz][my][mx]; v3 += x0*v3_brick[mz][my][mx]; v4 += x0*v4_brick[mz][my][mx]; v5 += x0*v5_brick[mz][my][mx]; - } + } } } } diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 00ff865173..5a2b4c2540 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -1245,8 +1245,8 @@ double PairComb::comb_bij_d(double zeta, Param *param) if (tmp > param->c1) return param->beta * -0.5*pow(tmp,-1.5); if (tmp > param->c2) return param->beta * (-0.5*pow(tmp,-1.5) * - // error in negligible 2nd term fixed 9/30/2015 - // (1.0 - 0.5*(1.0 + 1.0/(2.0*param->powern)) * + // error in negligible 2nd term fixed 9/30/2015 + // (1.0 - 0.5*(1.0 + 1.0/(2.0*param->powern)) * (1.0 - (1.0 + 1.0/(2.0*param->powern)) * pow(tmp,-param->powern))); if (tmp < param->c4) return 0.0; diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index 51445cccdd..743511e753 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -166,11 +166,11 @@ void PairComb3::settings(int narg, char **arg) if (strcmp(arg[0],"polar_on") == 0) { pol_flag = 1; if (comm->me == 0 && screen) fprintf(screen, - " PairComb3: polarization is on \n"); + " PairComb3: polarization is on \n"); } else if (strcmp(arg[0],"polar_off") == 0) { pol_flag = 0; if (comm->me == 0 && screen) fprintf(screen, - " PairComb3: polarization is off \n"); + " PairComb3: polarization is off \n"); } else { error->all(FLERR,"Illegal pair_style command"); } @@ -209,7 +209,7 @@ void PairComb3::coeff(int narg, char **arg) for (i = 3; i < narg; i++) { if ((strcmp(arg[i],"C") == 0) && (cflag == 0)) { if( comm->me == 0 && screen) fprintf(screen, - " PairComb3: Found C: reading additional library file\n"); + " PairComb3: Found C: reading additional library file\n"); read_lib(); cflag = 1; } @@ -248,8 +248,8 @@ void PairComb3::coeff(int narg, char **arg) for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; + setflag[i][j] = 1; + count++; } if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); @@ -417,7 +417,7 @@ void PairComb3::read_lib() pcn_gridx[ll][ii][jj][kk] = atof(words[5]); pcn_gridy[ll][ii][jj][kk] = atof(words[6]); pcn_gridz[ll][ii][jj][kk] = atof(words[7]); - } + } for (l=0; l<nsplpcn; l++) for (i=0; i<maxx; i++) @@ -439,9 +439,9 @@ void PairComb3::read_lib() for(m=0; m<32 ; m++) { mm=iii*32+m; pcn_cubs[ll][ii][jj][kk][mm] = atof(words[m]); - } - } - } + } + } + } for (l=0; l<nsplrad; l++) for (i=0; i<maxxc+1; i++) @@ -459,7 +459,7 @@ void PairComb3::read_lib() rad_gridx[ll][ii][jj][kk] = atof(words[5]); rad_gridy[ll][ii][jj][kk] = atof(words[6]); rad_gridz[ll][ii][jj][kk] = atof(words[7]); - } + } for (l=0; l<nsplrad; l++) for (i=0; i<maxxc; i++) @@ -481,9 +481,9 @@ void PairComb3::read_lib() for(m=0; m<32 ; m++){ mm=iii*32+m; rad_spl[ll][ii][jj][kk][mm] = atof(words[m]); - } - } - } + } + } + } for (l=0; l<nspltor; l++) for (i=0; i<maxxc+1; i++) @@ -501,7 +501,7 @@ void PairComb3::read_lib() tor_gridx[ll][ii][jj][kk] = atof(words[5]); tor_gridy[ll][ii][jj][kk] = atof(words[6]); tor_gridz[ll][ii][jj][kk] = atof(words[7]); - } + } for (l=0; l<nspltor; l++) for (i=0; i<maxxc; i++) @@ -523,9 +523,9 @@ void PairComb3::read_lib() for (m=0; m<32 ; m++){ mm=iii*32+m; tor_spl[ll][ii][jj][kk][mm] = atof(words[m]); - } - } - } + } + } + } fclose(fp); } @@ -623,8 +623,8 @@ void PairComb3::read_file(char *file) if (comm->me == 0) { ptr = fgets(line,MAXLINE,fp); if (ptr == NULL) { - eof = 1; - fclose(fp); + eof = 1; + fclose(fp); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -647,8 +647,8 @@ void PairComb3::read_file(char *file) if (comm->me == 0) { ptr = fgets(&line[n],MAXLINE-n,fp); if (ptr == NULL) { - eof = 1; - fclose(fp); + eof = 1; + fclose(fp); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -689,7 +689,7 @@ void PairComb3::read_file(char *file) if (nparams == maxparam) { maxparam += DELTA; params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); + "pair:params"); } params[nparams].ielement = ielement; @@ -771,20 +771,20 @@ void PairComb3::read_file(char *file) // parameter sanity checks if (params[nparams].lambda < 0.0 || params[nparams].powern < 0.0 || - params[nparams].beta < 0.0 || params[nparams].alpha1 < 0.0 || - params[nparams].bigB1< 0.0 || params[nparams].bigA< 0.0 || - params[nparams].bigB2< 0.0 || params[nparams].alpha2 <0.0 || - params[nparams].bigB3< 0.0 || params[nparams].alpha3 <0.0 || - params[nparams].bigr < 0.0 || params[nparams].bigd < 0.0 || - params[nparams].bigd > params[nparams].bigr || - params[nparams].powerm - params[nparams].powermint != 0.0 || - params[nparams].addrepr < 0.0 || params[nparams].powermint < 1.0 || - params[nparams].QL > 0.0 || params[nparams].QU < 0.0 || - params[nparams].DL < 0.0 || params[nparams].DU > 0.0 || - params[nparams].pcross < 0.0 || - params[nparams].esm < 0.0 || params[nparams].veps < 0.0 || - params[nparams].vsig < 0.0 || params[nparams].vdwflag < 0.0 - ) + params[nparams].beta < 0.0 || params[nparams].alpha1 < 0.0 || + params[nparams].bigB1< 0.0 || params[nparams].bigA< 0.0 || + params[nparams].bigB2< 0.0 || params[nparams].alpha2 <0.0 || + params[nparams].bigB3< 0.0 || params[nparams].alpha3 <0.0 || + params[nparams].bigr < 0.0 || params[nparams].bigd < 0.0 || + params[nparams].bigd > params[nparams].bigr || + params[nparams].powerm - params[nparams].powermint != 0.0 || + params[nparams].addrepr < 0.0 || params[nparams].powermint < 1.0 || + params[nparams].QL > 0.0 || params[nparams].QU < 0.0 || + params[nparams].DL < 0.0 || params[nparams].DU > 0.0 || + params[nparams].pcross < 0.0 || + params[nparams].esm < 0.0 || params[nparams].veps < 0.0 || + params[nparams].vsig < 0.0 || params[nparams].vdwflag < 0.0 + ) error->all(FLERR,"Illegal COMB3 parameter"); nparams++; @@ -809,16 +809,16 @@ void PairComb3::setup_params() for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) for (k = 0; k < nelements; k++) { - n = -1; - for (m = 0; m < nparams; m++) { - if (i == params[m].ielement && j == params[m].jelement && - k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); - n = m; - } - } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + n = -1; + for (m = 0; m < nparams; m++) { + if (i == params[m].ielement && j == params[m].jelement && + k == params[m].kelement) { + if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + n = m; + } + } + if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + elem2param[i][j][k] = n; } // compute parameter values derived from inputs @@ -837,9 +837,9 @@ void PairComb3::setup_params() (1.0-pow(fabs(params[m].Qo/params[m].dQ),10)); // (A20) params[m].bB = pow(fabs(params[m].aB),0.1)/params[m].dQ; // (A19) params[m].nD = log(params[m].DU/(params[m].DU-params[m].DL))/ - log(params[m].QU/(params[m].QU-params[m].QL)); + log(params[m].QU/(params[m].QU-params[m].QL)); params[m].bD = (pow((params[m].DL-params[m].DU),(1.0/params[m].nD)))/ - (params[m].QU-params[m].QL); + (params[m].QU-params[m].QL); params[m].lcut = params[m].coulcut; params[m].lcutsq = params[m].lcut*params[m].lcut; @@ -873,7 +873,7 @@ void PairComb3::Short_neigh() memory->sfree(sht_first); nmax = atom->nmax; sht_first = (int **) memory->smalloc(nmax*sizeof(int *), - "pair:sht_first"); + "pair:sht_first"); memory->grow(dpl,nmax,3,"pair:dpl"); memory->grow(xcctmp,nmax,"pair:xcctmp"); memory->grow(xchtmp,nmax,"pair:xchtmp"); @@ -929,9 +929,9 @@ void PairComb3::Short_neigh() if( icontrol == 1) xcctmp[i] += comb_fc(rr1,¶ms[iparam_ij]) * params[iparam_ij].pcross; if (icontrol == 2) - xchtmp[i] += comb_fc(rr1,¶ms[iparam_ij]) * params[iparam_ij].pcross; + xchtmp[i] += comb_fc(rr1,¶ms[iparam_ij]) * params[iparam_ij].pcross; if (icontrol == 3) - xcotmp[i] += comb_fc(rr1,¶ms[iparam_ij]) * params[iparam_ij].pcross; + xcotmp[i] += comb_fc(rr1,¶ms[iparam_ij]) * params[iparam_ij].pcross; } @@ -1125,20 +1125,20 @@ void PairComb3::compute(int eflag, int vflag) f[j][2] -= delz*fpair; if (evflag) - ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); + ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); // Q-dependent: Coulombic, field, polarization // 1/r energy and forces direct(¶ms[iparam_ij], ¶ms[iparam_ji], - mr1, mr2, mr3, rsq, sr1, sr2, sr3, iq, jq, - fac11, fac11e, eng_tmp, fvionij, i, j); + mr1, mr2, mr3, rsq, sr1, sr2, sr3, iq, jq, + fac11, fac11e, eng_tmp, fvionij, i, j); vionij = eng_tmp; // field correction to self energy field(¶ms[iparam_ij], ¶ms[iparam_ji],rsq,iq,jq, - eng_tmp,fvionij); + eng_tmp,fvionij); vionij += eng_tmp; // sums up long range Q-dependent forces (excluding dipole) @@ -1151,18 +1151,18 @@ void PairComb3::compute(int eflag, int vflag) // sums up long range Q-dependent energies (excluding dipole) if (evflag) - ev_tally(i,j,nlocal,newton_pair,0.0,vionij,fvionij,delx,dely,delz); + ev_tally(i,j,nlocal,newton_pair,0.0,vionij,fvionij,delx,dely,delz); // polarization field if (pol_flag) { dipole_calc(¶ms[iparam_ij], ¶ms[iparam_ji],fac11, - delx,dely,delz,rsq,mr1,mr2,mr3, - sr1,sr2,sr3,iq,jq,i,j,eng_tmp,fvionij,ddprx); - vionij = eng_tmp; + delx,dely,delz,rsq,mr1,mr2,mr3, + sr1,sr2,sr3,iq,jq,i,j,eng_tmp,fvionij,ddprx); + vionij = eng_tmp; // sums up dipole energies if (evflag) - ev_tally(i,j,nlocal,newton_pair,0.0,vionij,fvionij,delx,dely,delz); + ev_tally(i,j,nlocal,newton_pair,0.0,vionij,fvionij,delx,dely,delz); // sums up dipole forces f[i][0] += (ddprx[0] + delx*fvionij); @@ -1176,7 +1176,7 @@ void PairComb3::compute(int eflag, int vflag) if (rsq > params[iparam_ij].cutsq) continue; repulsive(¶ms[iparam_ij], ¶ms[iparam_ji], rsq, - fpair, eflag, eng_tmp, iq, jq); + fpair, eflag, eng_tmp, iq, jq); evdwl = eng_tmp; @@ -1189,7 +1189,7 @@ void PairComb3::compute(int eflag, int vflag) f[j][2] -= delz*fpair; if (evflag) - ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); + ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } // many-body interactions: start of short-range @@ -1222,27 +1222,27 @@ void PairComb3::compute(int eflag, int vflag) bbtor = 0.0; kconjug = 0.0; - for (kk = 0; kk < sht_jnum; kk++) { // kk is neighbor of ii - k = sht_jlist[kk]; - if (j == k) continue; + for (kk = 0; kk < sht_jnum; kk++) { // kk is neighbor of ii + k = sht_jlist[kk]; + if (j == k) continue; - ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; - iparam_ikj = elem2param[itype][ktype][jtype]; - iparam_jik = elem2param[jtype][itype][ktype]; - iparam_ik = elem2param[itype][ktype][ktype]; - delrk[0] = x[k][0] - xtmp; - delrk[1] = x[k][1] - ytmp; - delrk[2] = x[k][2] - ztmp; - rsq2 = vec3_dot(delrk,delrk); + ktype = map[type[k]]; + iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ikj = elem2param[itype][ktype][jtype]; + iparam_jik = elem2param[jtype][itype][ktype]; + iparam_ik = elem2param[itype][ktype][ktype]; + delrk[0] = x[k][0] - xtmp; + delrk[1] = x[k][1] - ytmp; + delrk[2] = x[k][2] - ztmp; + rsq2 = vec3_dot(delrk,delrk); - if (rsq2 > params[iparam_ik].cutsq) continue; + if (rsq2 > params[iparam_ik].cutsq) continue; - // 3-body zeta in bond order - zeta_ij += zeta(¶ms[iparam_ijk], ¶ms[iparam_ik], - rsq1, rsq2, delrj, delrk, i, xcn); + // 3-body zeta in bond order + zeta_ij += zeta(¶ms[iparam_ijk], ¶ms[iparam_ik], + rsq1, rsq2, delrj, delrk, i, xcn); - // radical initialization: apply only to CC,CO,OC bonds + // radical initialization: apply only to CC,CO,OC bonds if (params[iparam_ij].rad_flag > 0 && params[iparam_ik].ielementgp == 1 && params[iparam_ik].jelementgp == 1) { @@ -1252,68 +1252,68 @@ void PairComb3::compute(int eflag, int vflag) } - // torsion: i-j-k-l: apply to all C-C bonds + // torsion: i-j-k-l: apply to all C-C bonds - if( params[iparam_ij].tor_flag != 0 ) { - srmu = vec3_dot(delrj,delrk)/(sqrt(rsq1*rsq2)); - srmu = sqrt(1.0-srmu*srmu); + if( params[iparam_ij].tor_flag != 0 ) { + srmu = vec3_dot(delrj,delrk)/(sqrt(rsq1*rsq2)); + srmu = sqrt(1.0-srmu*srmu); - if(srmu > 0.1) { - for (ll = 0; ll < sht_lnum; ll++) { // ll is neighbor of jj - l = sht_llist[ll]; + if(srmu > 0.1) { + for (ll = 0; ll < sht_lnum; ll++) { // ll is neighbor of jj + l = sht_llist[ll]; - if(l==i || l==j || l==k) continue; + if(l==i || l==j || l==k) continue; - ltype = map[type[l]]; + ltype = map[type[l]]; - delrl[0] = x[l][0] - x[j][0]; - delrl[1] = x[l][1] - x[j][1]; - delrl[2] = x[l][2] - x[j][2]; - rsq3 = vec3_dot(delrl,delrl); - iparam_jl = elem2param[jtype][ltype][ltype]; + delrl[0] = x[l][0] - x[j][0]; + delrl[1] = x[l][1] - x[j][1]; + delrl[2] = x[l][2] - x[j][2]; + rsq3 = vec3_dot(delrl,delrl); + iparam_jl = elem2param[jtype][ltype][ltype]; - if (rsq3 > params[iparam_jl].cutsq) continue; + if (rsq3 > params[iparam_jl].cutsq) continue; - iparam_ikl = elem2param[itype][ktype][ltype]; + iparam_ikl = elem2param[itype][ktype][ltype]; torindx = params[iparam_ij].tor_flag; - bbtor += bbtor1(torindx, ¶ms[iparam_ikl],¶ms[iparam_jl], + bbtor += bbtor1(torindx, ¶ms[iparam_ikl],¶ms[iparam_jl], rsq1,rsq2,rsq3,delrj,delrk,delrl,srmu); - } - } - } + } + } + } } zeta_ji = 0.0; lconjug = 0.0; for (ll = 0; ll < sht_lnum; ll++) { - l = sht_llist[ll]; - if (l == i) continue; + l = sht_llist[ll]; + if (l == i) continue; - ltype = map[type[l]]; - iparam_jil = elem2param[jtype][itype][ltype]; - iparam_ijl = elem2param[itype][jtype][ltype]; - iparam_jl = elem2param[jtype][ltype][ltype]; - iparam_lj = elem2param[ltype][jtype][jtype]; + ltype = map[type[l]]; + iparam_jil = elem2param[jtype][itype][ltype]; + iparam_ijl = elem2param[itype][jtype][ltype]; + iparam_jl = elem2param[jtype][ltype][ltype]; + iparam_lj = elem2param[ltype][jtype][jtype]; - delrk[0] = x[l][0] - x[j][0]; - delrk[1] = x[l][1] - x[j][1]; - delrk[2] = x[l][2] - x[j][2]; - rsq2 = vec3_dot(delrk,delrk); + delrk[0] = x[l][0] - x[j][0]; + delrk[1] = x[l][1] - x[j][1]; + delrk[2] = x[l][2] - x[j][2]; + rsq2 = vec3_dot(delrk,delrk); - delrl[0] = x[l][0] - x[j][0]; - delrl[1] = x[l][1] - x[j][1]; - delrl[2] = x[l][2] - x[j][2]; - rsq2 = vec3_dot(delrl,delrl); + delrl[0] = x[l][0] - x[j][0]; + delrl[1] = x[l][1] - x[j][1]; + delrl[2] = x[l][2] - x[j][2]; + rsq2 = vec3_dot(delrl,delrl); - if (rsq2 > params[iparam_jl].cutsq) continue; + if (rsq2 > params[iparam_jl].cutsq) continue; - vec3_scale(-1,delrj,delrl); // ji_hat is -(ij_hat) + vec3_scale(-1,delrj,delrl); // ji_hat is -(ij_hat) - zeta_ji += zeta(¶ms[iparam_jil], ¶ms[iparam_jl] - , rsq1, rsq2, delrl, delrk, j, ycn); + zeta_ji += zeta(¶ms[iparam_jil], ¶ms[iparam_jl] + , rsq1, rsq2, delrl, delrk, j, ycn); - // radical initialization: apply only to CC,CO,OC bonds + // radical initialization: apply only to CC,CO,OC bonds if(params[iparam_ji].rad_flag > 0 && params[iparam_jl].ielementgp == 1 && params[iparam_jl].jelementgp == 1) { @@ -1324,10 +1324,10 @@ void PairComb3::compute(int eflag, int vflag) } force_zeta(¶ms[iparam_ij], ¶ms[iparam_ji], - rsq1, xcn, ycn, zeta_ij, zeta_ji, fpair, - prefac_ij1, prefac_ij2, prefac_ij3, prefac_ij4, prefac_ij5, - prefac_ji1, prefac_ji2, prefac_ji3, prefac_ji4, prefac_ji5, - eflag, eng_tmp, iq, jq, i, j, nj, bbtor, kconjug, lconjug); + rsq1, xcn, ycn, zeta_ij, zeta_ji, fpair, + prefac_ij1, prefac_ij2, prefac_ij3, prefac_ij4, prefac_ij5, + prefac_ji1, prefac_ji2, prefac_ji3, prefac_ji4, prefac_ji5, + eflag, eng_tmp, iq, jq, i, j, nj, bbtor, kconjug, lconjug); evdwl = eng_tmp; selfp6p(¶ms[iparam_ij],¶ms[iparam_ji],rsq1,eng_tmp,fpair); @@ -1347,77 +1347,77 @@ void PairComb3::compute(int eflag, int vflag) zet_addj=0; for (kk = 0; kk < sht_jnum; kk++) { - k = sht_jlist[kk]; - if (j == k) continue; + k = sht_jlist[kk]; + if (j == k) continue; sht_mlist = sht_first[k]; sht_mnum = sht_num[k]; - ktype = map[type[k]]; - iparam_ijk = elem2param[itype][jtype][ktype]; - iparam_ikj = elem2param[itype][ktype][jtype]; - iparam_jik = elem2param[jtype][itype][ktype]; - iparam_ik = elem2param[itype][ktype][ktype]; - delrk[0] = x[k][0] - xtmp; - delrk[1] = x[k][1] - ytmp; - delrk[2] = x[k][2] - ztmp; - rsq2 = vec3_dot(delrk,delrk); - if (rsq2 > params[iparam_ik].cutsq) continue; - - // BO-dependent 3-body E & F - attractive(¶ms[iparam_ijk], ¶ms[iparam_jik],¶ms[iparam_ikj], - prefac_ij1, prefac_ij2, prefac_ij3, prefac_ij4, prefac_ij5, - rsq1,rsq2,delrj,delrk,fi,fj,fk,i,xcn); - - ep6p_ij = ep6p(¶ms[iparam_ijk],¶ms[iparam_ikj],rsq1,rsq2,delrj,delrk,zet_addi); - fp6p(¶ms[iparam_ijk],¶ms[iparam_ikj],rsq1,rsq2,delrj,delrk,fip6p,fjp6p,fkp6p); - - // Sums up i-j-k forces: LP contribution - for (im = 0; im < 3; im++) { - fi[im] += fip6p[im]; - fj[im] += fjp6p[im]; - fk[im] += fkp6p[im]; - } - - // Sums up i-j-k forces: Tallies into global force vector - for (im = 0; im < 3; im++) { - f[i][im] += fi[im]; - f[j][im] += fj[im]; - f[k][im] += fk[im]; - } - - // torsion and radical: apply to all C-C bonds - if( params[iparam_ijk].tor_flag != 0 && fabs(ptorr)>1.0e-8) { - srmu = vec3_dot(delrj,delrk)/(sqrt(rsq1*rsq2)); - srmu = sqrt(1.0-srmu*srmu); - - if(srmu > 0.1) { - for (ll = 0; ll < sht_lnum; ll++) { // ll is neighbor of jj - l = sht_llist[ll]; - if (l==i||l==j||l==k) continue; - - ltype = map[type[l]]; - - delrl[0] = x[l][0] - x[j][0]; - delrl[1] = x[l][1] - x[j][1]; - delrl[2] = x[l][2] - x[j][2]; - rsq3 = vec3_dot(delrl,delrl); - - iparam_jl = elem2param[jtype][ltype][ltype]; - if (rsq3 > params[iparam_jl].cutsq) continue; - iparam_ikl = elem2param[itype][ktype][ltype]; + ktype = map[type[k]]; + iparam_ijk = elem2param[itype][jtype][ktype]; + iparam_ikj = elem2param[itype][ktype][jtype]; + iparam_jik = elem2param[jtype][itype][ktype]; + iparam_ik = elem2param[itype][ktype][ktype]; + delrk[0] = x[k][0] - xtmp; + delrk[1] = x[k][1] - ytmp; + delrk[2] = x[k][2] - ztmp; + rsq2 = vec3_dot(delrk,delrk); + if (rsq2 > params[iparam_ik].cutsq) continue; + + // BO-dependent 3-body E & F + attractive(¶ms[iparam_ijk], ¶ms[iparam_jik],¶ms[iparam_ikj], + prefac_ij1, prefac_ij2, prefac_ij3, prefac_ij4, prefac_ij5, + rsq1,rsq2,delrj,delrk,fi,fj,fk,i,xcn); + + ep6p_ij = ep6p(¶ms[iparam_ijk],¶ms[iparam_ikj],rsq1,rsq2,delrj,delrk,zet_addi); + fp6p(¶ms[iparam_ijk],¶ms[iparam_ikj],rsq1,rsq2,delrj,delrk,fip6p,fjp6p,fkp6p); + + // Sums up i-j-k forces: LP contribution + for (im = 0; im < 3; im++) { + fi[im] += fip6p[im]; + fj[im] += fjp6p[im]; + fk[im] += fkp6p[im]; + } + + // Sums up i-j-k forces: Tallies into global force vector + for (im = 0; im < 3; im++) { + f[i][im] += fi[im]; + f[j][im] += fj[im]; + f[k][im] += fk[im]; + } + + // torsion and radical: apply to all C-C bonds + if( params[iparam_ijk].tor_flag != 0 && fabs(ptorr)>1.0e-8) { + srmu = vec3_dot(delrj,delrk)/(sqrt(rsq1*rsq2)); + srmu = sqrt(1.0-srmu*srmu); + + if(srmu > 0.1) { + for (ll = 0; ll < sht_lnum; ll++) { // ll is neighbor of jj + l = sht_llist[ll]; + if (l==i||l==j||l==k) continue; + + ltype = map[type[l]]; + + delrl[0] = x[l][0] - x[j][0]; + delrl[1] = x[l][1] - x[j][1]; + delrl[2] = x[l][2] - x[j][2]; + rsq3 = vec3_dot(delrl,delrl); + + iparam_jl = elem2param[jtype][ltype][ltype]; + if (rsq3 > params[iparam_jl].cutsq) continue; + iparam_ikl = elem2param[itype][ktype][ltype]; torindx = params[iparam_ij].tor_flag; - tor_force(torindx, ¶ms[iparam_ikl], ¶ms[iparam_jl],srmu, + tor_force(torindx, ¶ms[iparam_ikl], ¶ms[iparam_jl],srmu, rsq1,rsq2,rsq3,delrj,delrk,delrl); - for (im = 0; im < 3; im++) { - f[i][im] += fi_tor[im]; - f[j][im] += fj_tor[im]; - f[k][im] += fk_tor[im]; - f[l][im] += fl_tor[im]; - } - } - } - } + for (im = 0; im < 3; im++) { + f[i][im] += fi_tor[im]; + f[j][im] += fj_tor[im]; + f[k][im] += fk_tor[im]; + f[l][im] += fl_tor[im]; + } + } + } + } if( params[iparam_ijk].rad_flag>=1 && params[iparam_ijk].ielementgp==1 && @@ -1427,95 +1427,95 @@ void PairComb3::compute(int eflag, int vflag) double rik=sqrt(rsq2); kradtot = -comb_fc(rik,¶ms[iparam_ki])*params[iparam_ki].pcross+kcn; - rad_forceik(¶ms[iparam_ki],rsq2,delrk,kconjug,kradtot); + rad_forceik(¶ms[iparam_ki],rsq2,delrk,kconjug,kradtot); - for (im = 0; im < 3; im++) { - f[i][im] += fi_rad[im]; - f[k][im] += fk_rad[im]; - } + for (im = 0; im < 3; im++) { + f[i][im] += fi_rad[im]; + f[k][im] += fk_rad[im]; + } if (fabs(radtmp) > 1.0e-12) { - for (mm = 0; mm < sht_mnum; mm++) { // mm is neighbor of kk - m = sht_mlist[mm]; - if (m == k) continue; + for (mm = 0; mm < sht_mnum; mm++) { // mm is neighbor of kk + m = sht_mlist[mm]; + if (m == k) continue; mtype = map[type[m]]; - delrm[0] = x[m][0] - x[k][0]; - delrm[1] = x[m][1] - x[k][1]; - delrm[2] = x[m][2] - x[k][2]; - rsq3 = vec3_dot(delrm,delrm); + delrm[0] = x[m][0] - x[k][0]; + delrm[1] = x[m][1] - x[k][1]; + delrm[2] = x[m][2] - x[k][2]; + rsq3 = vec3_dot(delrm,delrm); - iparam_km = elem2param[ktype][mtype][mtype]; - iparam_ki = elem2param[ktype][itype][itype]; + iparam_km = elem2param[ktype][mtype][mtype]; + iparam_ki = elem2param[ktype][itype][itype]; - if (rsq3 > params[iparam_km].cutsq) continue; + if (rsq3 > params[iparam_km].cutsq) continue; - rad_force(¶ms[iparam_km],rsq3,delrm,radtmp); + rad_force(¶ms[iparam_km],rsq3,delrm,radtmp); - for (im = 0; im < 3; im++) { - f[k][im] += fj_rad[im]; - f[m][im] += fk_rad[im]; - } - } - } - } + for (im = 0; im < 3; im++) { + f[k][im] += fj_rad[im]; + f[m][im] += fk_rad[im]; + } + } + } + } if (evflag) - ev_tally(i,j,nlocal,newton_pair,ep6p_ij,0.0,0.0,0.0,0.0,0.0); - if (vflag_atom) - v_tally3(i,j,k,fj,fk,delrj,delrk); + ev_tally(i,j,nlocal,newton_pair,ep6p_ij,0.0,0.0,0.0,0.0,0.0); + if (vflag_atom) + v_tally3(i,j,k,fj,fk,delrj,delrk); - } // k-loop + } // k-loop // attractive term via loop over l (3-body forces: j-i-l) for (ll = 0; ll < sht_lnum; ll++) { - l = sht_llist[ll]; - if (l == i) continue; + l = sht_llist[ll]; + if (l == i) continue; sht_plist = sht_first[l]; sht_pnum = sht_num[l]; - ltype = map[type[l]]; - iparam_jil = elem2param[jtype][itype][ltype]; - iparam_jli = elem2param[jtype][ltype][itype]; - iparam_ijl = elem2param[itype][jtype][ltype]; - iparam_jl = elem2param[jtype][ltype][ltype]; - delrk[0] = x[l][0] - x[j][0]; - delrk[1] = x[l][1] - x[j][1]; - delrk[2] = x[l][2] - x[j][2]; + ltype = map[type[l]]; + iparam_jil = elem2param[jtype][itype][ltype]; + iparam_jli = elem2param[jtype][ltype][itype]; + iparam_ijl = elem2param[itype][jtype][ltype]; + iparam_jl = elem2param[jtype][ltype][ltype]; + delrk[0] = x[l][0] - x[j][0]; + delrk[1] = x[l][1] - x[j][1]; + delrk[2] = x[l][2] - x[j][2]; - rsq2 = vec3_dot(delrk,delrk); - if (rsq2 > params[iparam_jl].cutsq) continue; - vec3_scale(-1,delrj,delrl); + rsq2 = vec3_dot(delrk,delrk); + if (rsq2 > params[iparam_jl].cutsq) continue; + vec3_scale(-1,delrj,delrl); - attractive(¶ms[iparam_jil],¶ms[iparam_ijl],¶ms[iparam_jli], - prefac_ji1,prefac_ji2,prefac_ji3,prefac_ji4,prefac_ji5, - rsq1,rsq2,delrl,delrk,fj,fi,fl,j,ycn); + attractive(¶ms[iparam_jil],¶ms[iparam_ijl],¶ms[iparam_jli], + prefac_ji1,prefac_ji2,prefac_ji3,prefac_ji4,prefac_ji5, + rsq1,rsq2,delrl,delrk,fj,fi,fl,j,ycn); - // BO-independent 3-body j-i-l LP and BB correction and forces - ep6p_ji = ep6p(¶ms[iparam_jil],¶ms[iparam_jli],rsq1,rsq2,delrl,delrk,zet_addj); - fp6p(¶ms[iparam_jil],¶ms[iparam_jli],rsq1,rsq2,delrl,delrk,fjp6p,fip6p,flp6p); + // BO-independent 3-body j-i-l LP and BB correction and forces + ep6p_ji = ep6p(¶ms[iparam_jil],¶ms[iparam_jli],rsq1,rsq2,delrl,delrk,zet_addj); + fp6p(¶ms[iparam_jil],¶ms[iparam_jli],rsq1,rsq2,delrl,delrk,fjp6p,fip6p,flp6p); if (evflag) - ev_tally(j,i,nlocal,newton_pair,ep6p_ji,0.0,0.0,0.0,0.0,0.0); - - // BO-dependent 3-body E & F - for (im = 0; im < 3; im++) { - fj[im] += fjp6p[im]; - fi[im] += fip6p[im]; - fl[im] += flp6p[im]; - } - - // Sums up j-i-l forces: Tallies into global force vector - for (im = 0; im < 3; im++) { - f[j][im] += fj[im]; - f[i][im] += fi[im]; - f[l][im] += fl[im]; - } - - // radical i-j-l-p: apply to all CC,CO,OC bonds - if( params[iparam_jil].rad_flag >= 1 && + ev_tally(j,i,nlocal,newton_pair,ep6p_ji,0.0,0.0,0.0,0.0,0.0); + + // BO-dependent 3-body E & F + for (im = 0; im < 3; im++) { + fj[im] += fjp6p[im]; + fi[im] += fip6p[im]; + fl[im] += flp6p[im]; + } + + // Sums up j-i-l forces: Tallies into global force vector + for (im = 0; im < 3; im++) { + f[j][im] += fj[im]; + f[i][im] += fi[im]; + f[l][im] += fl[im]; + } + + // radical i-j-l-p: apply to all CC,CO,OC bonds + if( params[iparam_jil].rad_flag >= 1 && params[iparam_jil].ielementgp == 1 && params[iparam_jil].kelementgp == 1 ) { iparam_lj = elem2param[ltype][jtype][jtype]; @@ -1525,39 +1525,39 @@ void PairComb3::compute(int eflag, int vflag) rad_forceik(¶ms[iparam_lj],rsq2,delrk,lconjug,lradtot); - for (im = 0; im < 3; im++) { - f[j][im] += fi_rad[im]; - f[l][im] += fk_rad[im]; - } + for (im = 0; im < 3; im++) { + f[j][im] += fi_rad[im]; + f[l][im] += fk_rad[im]; + } if (fabs(radtmp)>1.0e-12) { - for (pp = 0; pp < sht_pnum; pp++) { // pp is neighbor of ll - p = sht_plist[pp]; - if (p == l) continue; - ptype = map[type[p]]; - - delrp[0] = x[p][0] - x[l][0]; - delrp[1] = x[p][1] - x[l][1]; - delrp[2] = x[p][2] - x[l][2]; - rsq3 = vec3_dot(delrp,delrp); - - iparam_lp = elem2param[ltype][ptype][ptype]; - - if (rsq3 > params[iparam_lp].cutsq) continue; - - vec3_scale(-1,delrj,delrj); - rad_force(¶ms[iparam_lp],rsq3,delrp,radtmp); - vec3_scale(-1,delrj,delrj); - for (im = 0; im < 3; im++) { - f[l][im] += fj_rad[im]; - f[p][im] += fk_rad[im]; - } - } - } - } - - if (vflag_atom) - v_tally3(j,i,l,fi,fl,delrl,delrk); + for (pp = 0; pp < sht_pnum; pp++) { // pp is neighbor of ll + p = sht_plist[pp]; + if (p == l) continue; + ptype = map[type[p]]; + + delrp[0] = x[p][0] - x[l][0]; + delrp[1] = x[p][1] - x[l][1]; + delrp[2] = x[p][2] - x[l][2]; + rsq3 = vec3_dot(delrp,delrp); + + iparam_lp = elem2param[ltype][ptype][ptype]; + + if (rsq3 > params[iparam_lp].cutsq) continue; + + vec3_scale(-1,delrj,delrj); + rad_force(¶ms[iparam_lp],rsq3,delrp,radtmp); + vec3_scale(-1,delrj,delrj); + for (im = 0; im < 3; im++) { + f[l][im] += fj_rad[im]; + f[p][im] += fk_rad[im]; + } + } + } + } + + if (vflag_atom) + v_tally3(j,i,l,fi,fl,delrl,delrk); } } } @@ -1569,7 +1569,7 @@ void PairComb3::compute(int eflag, int vflag) /* ---------------------------------------------------------------------- */ void PairComb3::repulsive(Param *parami, Param *paramj, double rsq, - double &fforce,int eflag, double &eng, double iq, double jq) + double &fforce,int eflag, double &eng, double iq, double jq) { double r,tmp_fc,tmp_fc_d,Di,Dj; double caj,vrcs,fvrcs; @@ -1614,7 +1614,7 @@ void PairComb3::repulsive(Param *parami, Param *paramj, double rsq, /* ---------------------------------------------------------------------- */ double PairComb3::zeta(Param *parami, Param *paramj, double rsqij, - double rsqik, double *delrij, double *delrik, int i, double xcn) + double rsqik, double *delrij, double *delrik, int i, double xcn) { double rij,rik,costheta,arg,ex_delr,rlm3; @@ -1635,7 +1635,7 @@ double PairComb3::zeta(Param *parami, Param *paramj, double rsqij, /* ---------------------------------------------------------------------- */ void PairComb3::selfp6p(Param *parami, Param *paramj, double rsq, - double &eng, double &force) + double &eng, double &force) { double r,comtti,comttj,fcj,fcj_d; @@ -1661,7 +1661,7 @@ void PairComb3::selfp6p(Param *parami, Param *paramj, double rsq, /* ---------------------------------------------------------------------- */ double PairComb3::ep6p(Param *paramj, Param *paramk, double rsqij, double rsqik, - double *delrij, double *delrik , double &zet_add) + double *delrij, double *delrik , double &zet_add) { double comtt; double pplp0 = paramj->p6p0; @@ -1693,8 +1693,8 @@ double PairComb3::ep6p(Param *paramj, Param *paramk, double rsqij, double rsqik, /*---------------------------------------------------------------------- */ void PairComb3::fp6p(Param *paramij,Param *paramik, double rsqij, double rsqik, - double *delrij, double *delrik, double *drilp, - double *drjlp, double *drklp) + double *delrij, double *delrik, double *drilp, + double *drjlp, double *drklp) { double pplp0 = paramij->p6p0; double pplp1 = paramij->p6p1, pplp2 = paramij->p6p2, pplp3 = paramij->p6p3; @@ -1760,13 +1760,13 @@ void PairComb3::fp6p(Param *paramij,Param *paramik, double rsqij, double rsqik, /* ---------------------------------------------------------------------- */ void PairComb3::force_zeta(Param *parami, Param *paramj, double rsq, - double xcn, double ycn, double &zeta_ij, double &zeta_ji, double &fforce, - double &prefac_ij1, double &prefac_ij2, double &prefac_ij3, - double &prefac_ij4, double &prefac_ij5, + double xcn, double ycn, double &zeta_ij, double &zeta_ji, double &fforce, + double &prefac_ij1, double &prefac_ij2, double &prefac_ij3, + double &prefac_ij4, double &prefac_ij5, double &prefac_ji1, double &prefac_ji2, double &prefac_ji3, double &prefac_ji4, double &prefac_ji5, int eflag, double &eng, double iq, double jq, - int i, int j, int nj, double bbtor, double kconjug, double lconjug) + int i, int j, int nj, double bbtor, double kconjug, double lconjug) { double r,att_eng,att_force,bij; // att_eng is -cbj double boij, dbij1, dbij2, dbij3, dbij4, dbij5; @@ -1803,17 +1803,17 @@ void PairComb3::force_zeta(Param *parami, Param *paramj, double rsq, fforce = 1.0*bij*att_force/r; // divide by r will done compute bbij[i][nj] = bij; - prefac_ij1 = -0.5*att_eng*dbij1; // prefac_ij1 = -pfij - prefac_ij2 = -0.5*att_eng*dbij2; // prefac_ij2 = -pfij1 - prefac_ij3 = -0.5*att_eng*dbij3; // prefac_ij3 = -pfij2 - prefac_ij4 = -0.5*att_eng*dbij4; // prefac_ij4 = -pfij3 - prefac_ij5 = -0.5*att_eng*dbij5; // prefac_ij5 = -pfij4 + prefac_ij1 = -0.5*att_eng*dbij1; // prefac_ij1 = -pfij + prefac_ij2 = -0.5*att_eng*dbij2; // prefac_ij2 = -pfij1 + prefac_ij3 = -0.5*att_eng*dbij3; // prefac_ij3 = -pfij2 + prefac_ij4 = -0.5*att_eng*dbij4; // prefac_ij4 = -pfij3 + prefac_ij5 = -0.5*att_eng*dbij5; // prefac_ij5 = -pfij4 - prefac_ji1 = -0.5*att_eng*dbji1; // prefac_ji1 = -pfji - prefac_ji2 = -0.5*att_eng*dbji2; // prefac_ji2 = -pfji1 - prefac_ji3 = -0.5*att_eng*dbji3; // prefac_ji3 = -pfji2 - prefac_ji4 = -0.5*att_eng*dbji4; // prefac_ji4 = -pfji3 - prefac_ji5 = -0.5*att_eng*dbji5; // prefac_ji5 = -pfji4 + prefac_ji1 = -0.5*att_eng*dbji1; // prefac_ji1 = -pfji + prefac_ji2 = -0.5*att_eng*dbji2; // prefac_ji2 = -pfji1 + prefac_ji3 = -0.5*att_eng*dbji3; // prefac_ji3 = -pfji2 + prefac_ji4 = -0.5*att_eng*dbji4; // prefac_ji4 = -pfji3 + prefac_ji5 = -0.5*att_eng*dbji5; // prefac_ji5 = -pfji4 // combines com6 & com7 below if ( parami->rad_flag>0 || parami->tor_flag!=0 ) { @@ -1954,7 +1954,7 @@ double PairComb3::self(Param *param, double qi) /* ---------------------------------------------------------------------- */ void PairComb3::comb_fa(double r, Param *parami, Param *paramj, double iq, - double jq, double &att_eng, double &att_force) + double jq, double &att_eng, double &att_force) { double Bsi; double qi,qj,Di,Dj; @@ -1977,12 +1977,12 @@ void PairComb3::comb_fa(double r, Param *parami, Param *paramj, double iq, if (YYBn*YYBj > 0.0 ) { AlfDiAlfDj = exp(0.5*(parami->alfi*Di+paramj->alfi*Dj)); Bsi = (pbij1*exp(-alfij1*r)+pbij2*exp(-alfij2*r)+pbij3*exp(-alfij3*r))* - sqrt(YYBn*YYBj)*AlfDiAlfDj; // Bsi is cbj + sqrt(YYBn*YYBj)*AlfDiAlfDj; // Bsi is cbj att_eng = -Bsi * comb_fc(r,parami); att_force = -(Bsi*comb_fc_d(r,parami)-comb_fc(r,parami)*sqrt(YYBn*YYBj)* - AlfDiAlfDj*(alfij1*pbij1*exp(-alfij1*r)+ - alfij2*pbij2*exp(-alfij2*r)+alfij3*pbij3*exp(-alfij3*r))); + AlfDiAlfDj*(alfij1*pbij1*exp(-alfij1*r)+ + alfij2*pbij2*exp(-alfij2*r)+alfij3*pbij3*exp(-alfij3*r))); } else { att_eng = 0.0; @@ -1994,15 +1994,15 @@ void PairComb3::comb_fa(double r, Param *parami, Param *paramj, double iq, /* ---------------------------------------------------------------------- */ void PairComb3::comb_bij_d(double zet, Param *param, double r, int i, - double &tbij, double &tbij1, double &tbij2, - double &tbij3, double &tbij4, double &tbij5, double xcn) + double &tbij, double &tbij1, double &tbij2, + double &tbij3, double &tbij4, double &tbij5, double xcn) { double pcorn,dpcorn,dxccij,dxchij,dxcoij; double zeta = zet; double zetang,tmp_tbij, pow_n; pcorn = dpcorn = dxccij = dxchij = dxcoij = 0.0; - coord(param,r,i,pcorn,dpcorn,dxccij,dxchij,dxcoij,xcn); // coordination term + coord(param,r,i,pcorn,dpcorn,dxccij,dxchij,dxcoij,xcn); // coordination term zetang=zeta; pow_n=param->powern; @@ -2042,8 +2042,8 @@ void PairComb3::comb_bij_d(double zet, Param *param, double r, int i, /* ---------------------------------------------------------------------- */ void PairComb3::coord(Param *param, double r, int i, - double &pcorn, double &dpcorn, double &dxccij, - double &dxchij, double &dxcoij, double xcn) + double &pcorn, double &dpcorn, double &dxccij, + double &dxchij, double &dxcoij, double xcn) { int ixmin,iymin,izmin; double xcntot,xcccn,xchcn,xcocn; @@ -2109,7 +2109,7 @@ void PairComb3::coord(Param *param, double r, int i, void PairComb3::cntri_int(int tri_flag, double xval, double yval, double zval, int ixmin, int iymin, int izmin, double &vval, - double &dvalx, double &dvaly, double &dvalz, Param *param) + double &dvalx, double &dvaly, double &dvalz, Param *param) { double x; vval = 0.0; dvalx = 0.0; dvaly = 0.0; dvalz = 0.0; @@ -2183,7 +2183,7 @@ double PairComb3::comb_gijk(double costheta, Param *param, double nco_tmp) /* ---------------------------------------------------------------------- */ void PairComb3::comb_gijk_d(double costheta, Param *param, double nco_tmp, - double &gijk_d, double &com3jk) + double &gijk_d, double &com3jk) { double rmu1 = costheta; double rmu2 = rmu1*rmu1; @@ -2252,9 +2252,9 @@ void PairComb3::comb_gijk_d(double costheta, Param *param, double nco_tmp, /*------------------------------------------------------------------------- */ void PairComb3::attractive(Param *parami, Param *paramj , Param *paramk, double prefac_ij1, - double prefac_ij2, double prefac_ij3, double prefac_ij4, - double prefac_ij5, double rsqij, double rsqik, double *delrij, - double *delrik, double *fi, double *fj,double *fk, int i, double xcn) + double prefac_ij2, double prefac_ij3, double prefac_ij4, + double prefac_ij5, double rsqij, double rsqik, double *delrij, + double *delrik, double *fi, double *fj,double *fk, int i, double xcn) { double rij_hat[3],rik_hat[3]; double rij,rijinv,rik,rikinv; @@ -2268,16 +2268,16 @@ void PairComb3::attractive(Param *parami, Param *paramj , Param *paramk, double vec3_scale(rikinv,delrik,rik_hat); comb_zetaterm_d(prefac_ij1, prefac_ij2, prefac_ij3, prefac_ij4, prefac_ij5, - rij_hat, rij,rik_hat, rik, fi, fj, fk, parami, paramj, paramk,xcn); + rij_hat, rij,rik_hat, rik, fi, fj, fk, parami, paramj, paramk,xcn); } /* ---------------------------------------------------------------------- */ void PairComb3::comb_zetaterm_d(double prefac_ij1, double prefac_ij2, - double prefac_ij3, double prefac_ij4, double prefac_ij5, - double *rij_hat, double rij, double *rik_hat, double rik, double *dri, - double *drj, double *drk, Param *parami, Param *paramj, Param *paramk, double xcn) + double prefac_ij3, double prefac_ij4, double prefac_ij5, + double *rij_hat, double rij, double *rik_hat, double rik, double *dri, + double *drj, double *drk, Param *parami, Param *paramj, Param *paramk, double xcn) { double gijk,gijk_d,ex_delr,ex_delr_d,fc_k,cos_theta,tmp,rlm3; double dcosdri[3],dcosdrj[3],dcosdrk[3],dfc_i,dfc_k; @@ -2325,32 +2325,32 @@ void PairComb3::comb_zetaterm_d(double prefac_ij1, double prefac_ij2, } ex_delr_d = mint*pow(rlm3,mint)*pow((rij-rik),(mint-1))*ex_delr; // com3 - vec3_scale(-dfc_k*gijk*ex_delr,rik_hat,dri); // com1 - vec3_scaleadd(fc_k*gijk_d*ex_delr,dcosdri,dri,dri); // com2 - vec3_scaleadd(fc_k*gijk*ex_delr_d,rik_hat,dri,dri); // com3 cont'd - vec3_scaleadd(-fc_k*gijk*ex_delr_d,rij_hat,dri,dri); // com3 sums j - vec3_scaleadd(-com3k,rik_hat,dri,dri); // com3k - vec3_scaleadd(-com3j,rij_hat,dri,dri); // com3j + vec3_scale(-dfc_k*gijk*ex_delr,rik_hat,dri); // com1 + vec3_scaleadd(fc_k*gijk_d*ex_delr,dcosdri,dri,dri); // com2 + vec3_scaleadd(fc_k*gijk*ex_delr_d,rik_hat,dri,dri); // com3 cont'd + vec3_scaleadd(-fc_k*gijk*ex_delr_d,rij_hat,dri,dri); // com3 sums j + vec3_scaleadd(-com3k,rik_hat,dri,dri); // com3k + vec3_scaleadd(-com3j,rij_hat,dri,dri); // com3j vec3_scale(prefac_ij1,dri,dri); - vec3_scaleadd(-com6,rik_hat,dri,dri); // com6 + vec3_scaleadd(-com6,rik_hat,dri,dri); // com6 - vec3_scale(fc_k*gijk_d*ex_delr,dcosdrj,drj); // com2 - vec3_scaleadd(fc_k*gijk*ex_delr_d,rij_hat,drj,drj); // com3 cont'd - vec3_scaleadd(com3j,rij_hat,drj,drj); // com3j + vec3_scale(fc_k*gijk_d*ex_delr,dcosdrj,drj); // com2 + vec3_scaleadd(fc_k*gijk*ex_delr_d,rij_hat,drj,drj); // com3 cont'd + vec3_scaleadd(com3j,rij_hat,drj,drj); // com3j vec3_scale(prefac_ij1,drj,drj); - vec3_scale(dfc_k*gijk*ex_delr,rik_hat,drk); // com1 - vec3_scaleadd(fc_k*gijk_d*ex_delr,dcosdrk,drk,drk); // com2 - vec3_scaleadd(-fc_k*gijk*ex_delr_d,rik_hat,drk,drk); // com3 cont'd - vec3_scaleadd(com3k,rik_hat,drk,drk); // com3k + vec3_scale(dfc_k*gijk*ex_delr,rik_hat,drk); // com1 + vec3_scaleadd(fc_k*gijk_d*ex_delr,dcosdrk,drk,drk); // com2 + vec3_scaleadd(-fc_k*gijk*ex_delr_d,rik_hat,drk,drk); // com3 cont'd + vec3_scaleadd(com3k,rik_hat,drk,drk); // com3k vec3_scale(prefac_ij1,drk,drk); - vec3_scaleadd(com6,rik_hat,drk,drk); // com6 + vec3_scaleadd(com6,rik_hat,drk,drk); // com6 } /* ---------------------------------------------------------------------- */ void PairComb3::costheta_d(double *rij_hat, double rij, double *rik_hat, - double rik, double *dri, double *drj, double *drk) + double rik, double *dri, double *drj, double *drk) { double cos_theta = vec3_dot(rij_hat,rik_hat); @@ -2641,11 +2641,11 @@ void PairComb3::tables() drf13= 12.0*(1.0/vrc[12]-1.0/r13); vvdw[k][inty] = vepst*(vsigt*vsigt*rf12-vsigt*rf6); vdvdw[k][inty] = vepst*(vsigt*vsigt*drf13-vsigt*drf7); - } - } else { + } + } else { vvdw[k][inty]=0.0; vdvdw[k][inty]=0.0; - } + } r += dra; } } @@ -2673,7 +2673,7 @@ void PairComb3::potal_calc(double &calc1, double &calc2, double &calc3) esucon = force->qqr2e; calc2 = (erfc(rcoul*alf)/rcoul/rcoul+2.0*alf/MY_PIS* - exp(-alf*alf*rcoul*rcoul)/rcoul)*esucon/rcoul; + exp(-alf*alf*rcoul*rcoul)/rcoul)*esucon/rcoul; calc3 = (erfc(rcoul*alf)/rcoul)*esucon; calc1 = -(alf/MY_PIS*esucon+calc3*0.5); } @@ -2681,7 +2681,7 @@ void PairComb3::potal_calc(double &calc1, double &calc2, double &calc3) /* ---------------------------------------------------------------------- */ void PairComb3::tri_point(double rsq, int &mr1, int &mr2, - int &mr3, double &sr1, double &sr2, double &sr3) + int &mr3, double &sr1, double &sr2, double &sr3) { double r, rin, dr, dd, rr1, rridr, rridr2; @@ -2710,8 +2710,8 @@ void PairComb3::tri_point(double rsq, int &mr1, int &mr2, /* ---------------------------------------------------------------------- */ void PairComb3::vdwaals(int inty, int mr1, int mr2, int mr3, double rsq, - double sr1, double sr2, double sr3, - double &eng, double &fforce) + double sr1, double sr2, double sr3, + double &eng, double &fforce) { double r = sqrt(rsq); @@ -2722,9 +2722,9 @@ void PairComb3::vdwaals(int inty, int mr1, int mr2, int mr3, double rsq, /* ---------------------------------------------------------------------- */ void PairComb3::direct(Param *parami, Param *paramj, int mr1, - int mr2, int mr3, double rsq, double sr1, double sr2, double sr3, - double iq, double jq, double fac11, double fac11e, - double &pot_tmp, double &for_tmp, int i, int j) + int mr2, int mr3, double rsq, double sr1, double sr2, double sr3, + double iq, double jq, double fac11, double fac11e, + double &pot_tmp, double &for_tmp, int i, int j) { double r,erfcc,fafbnl,potij,esucon; double r3,erfcd,dfafbnl,smf2,dvdrr,alf,alfdpi; @@ -2814,7 +2814,7 @@ void PairComb3::direct(Param *parami, Param *paramj, int mr1, /* ---------------------------------------------------------------------- */ void PairComb3::field(Param *parami, Param *paramj, double rsq, double iq, - double jq, double &eng_tmp,double &for_tmp) + double jq, double &eng_tmp,double &for_tmp) { double r,r3,r4,r5,rc,rc2,rc3,rc4,rc5; double cmi1,cmi2,cmj1,cmj2,pcmi1,pcmi2; @@ -2868,7 +2868,7 @@ void PairComb3::field(Param *parami, Param *paramj, double rsq, double iq, /* ---------------------------------------------------------------------- */ double PairComb3::rad_init(double rsq2,Param *param,int i, - double &radtot, double cnconj) + double &radtot, double cnconj) { double r, fc1k, radcut; @@ -2882,7 +2882,7 @@ double PairComb3::rad_init(double rsq2,Param *param,int i, /* ---------------------------------------------------------------------- */ void PairComb3::rad_calc(double r, Param *parami, Param *paramj, - double kconjug, double lconjug, int i, int j, double xcn, double ycn) + double kconjug, double lconjug, int i, int j, double xcn, double ycn) { int ixmin, iymin, izmin; int radindx; @@ -2907,7 +2907,7 @@ void PairComb3::rad_calc(double r, Param *parami, Param *paramj, fabs(float(iymin)-yrad)>1.0e-8 || fabs(float(izmin)-zcon)>1.0e-8) { rad_int(radindx,xrad,yrad,zcon,ixmin,iymin,izmin, - vrad,pradx,prady,pradz); + vrad,pradx,prady,pradz); } else { vrad = rad_grid[radindx][ixmin][iymin][izmin-1]; pradx = rad_gridx[radindx][ixmin][iymin][izmin-1]; @@ -2924,8 +2924,8 @@ void PairComb3::rad_calc(double r, Param *parami, Param *paramj, /* ---------------------------------------------------------------------- */ void PairComb3::rad_int(int radindx,double xrad, double yrad, double zcon, int l, - int m, int n, double &vrad, double &pradx, double &prady, - double &pradz) + int m, int n, double &vrad, double &pradx, double &prady, + double &pradz) { int j; double x; @@ -2936,7 +2936,7 @@ void PairComb3::rad_int(int radindx,double xrad, double yrad, double zcon, int l for (j=0; j<64; j++) { x = rad_spl[radindx][l][m][n-1][j] * pow(xrad,iin3[j][0]) - * pow(yrad,iin3[j][1]) * pow(zcon,iin3[j][2]); + * pow(yrad,iin3[j][1]) * pow(zcon,iin3[j][2]); vrad += x; if(xrad > 1.0e-8) pradx += x*iin3[j][0]/xrad; if(yrad > 1.0e-8) prady += x*iin3[j][1]/yrad; @@ -2983,7 +2983,7 @@ void PairComb3::rad_forceik(Param *paramk, double rsq2, double *delrk, /* ---------------------------------------------------------------------- */ void PairComb3::rad_force(Param *paramm, double rsq3, - double *delrm, double dpradk) + double *delrm, double dpradk) { int nm; double rkm, fcp1m; @@ -3061,7 +3061,7 @@ double PairComb3::bbtor1(int torindx, Param *paramk, Param *paraml, /* ---------------------------------------------------------------------- */ void PairComb3::tor_calc(double r, Param *parami, Param *paramj, - double kconjug, double lconjug, int i, int j, double xcn, double ycn) + double kconjug, double lconjug, int i, int j, double xcn, double ycn) { int ixmin, iymin, izmin; double vtor, dtorx, dtory, dtorz; @@ -3115,7 +3115,7 @@ void PairComb3::tor_calc(double r, Param *parami, Param *paramj, /* ---------------------------------------------------------------------- */ void PairComb3::tor_int(int torindx,double xtor, double ytor, double zcon, int l, - int m, int n, double &vtor, double &dtorx, double &dtory, double &dtorz) + int m, int n, double &vtor, double &dtorx, double &dtory, double &dtorz) { int j; double x; @@ -3127,7 +3127,7 @@ void PairComb3::tor_int(int torindx,double xtor, double ytor, double zcon, int l for (j=0; j<64; j++) { x = tor_spl[torindx][l][m][n-1][j] * pow(xtor,iin3[j][0]) - * pow(ytor,iin3[j][1]) * pow(zcon,iin3[j][2]); + * pow(ytor,iin3[j][1]) * pow(zcon,iin3[j][2]); vtor += x; if(xtor > 1.0e-8 ) dtorx += x*iin3[j][0]/xtor; @@ -3191,11 +3191,11 @@ void PairComb3::tor_force(int torindx, Param *paramk, Param *paraml, dt2djl[1] = delrj[2]*tork[0] - delrj[0]*tork[2]; dt2djl[2] = delrj[0]*tork[1] - delrj[1]*tork[0]; dt2dij[0] = -delrk[2]*torl[1] + delrl[2]*tork[1] - + delrk[1]*torl[2] - delrl[1]*tork[2]; + + delrk[1]*torl[2] - delrl[1]*tork[2]; dt2dij[1] = -delrk[0]*torl[2] + delrl[0]*tork[2] - + delrk[2]*torl[0] - delrl[2]*tork[0]; + + delrk[2]*torl[0] - delrl[2]*tork[0]; dt2dij[2] = -delrk[1]*torl[0] + delrl[1]*tork[0] - + delrk[0]*torl[1] - delrl[0]*tork[1]; + + delrk[0]*torl[1] - delrl[0]*tork[1]; rmut = TT2/TT1; @@ -3217,10 +3217,10 @@ void PairComb3::tor_force(int torindx, Param *paramk, Param *paraml, tfij[3] = AA2/rij/rij - dt1djl*AA2*rmul/rij/rij; tfik[0] = tfij[0]; tfik[1] = (AA2/rik - btt*ptorr*fc1l*fcp1k)/rik - - dt1dik*AA2*rmu/rik/rik; + dt1dik*AA2*rmu/rik/rik; tfjl[0] = tfij[2]; tfjl[1] = (AA2/rjl - btt*ptorr*fc1k*fcp1l)/rjl - - dt1djl*AA2*rmul/rjl/rjl; + dt1djl*AA2*rmul/rjl/rjl; tjx[0] = tfij[0]*delrk[0] - tfij[1]*delrj[0]; tjy[0] = tfij[0]*delrk[1] - tfij[1]*delrj[1]; @@ -3338,7 +3338,7 @@ double PairComb3::combqeq(double *qf_fix, int &igroup) for (jj = 0; jj < jnum; jj++) { j = jlist[jj] & NEIGHMASK; - jtag = tag[j]; + jtag = tag[j]; if (itag >= jtag) continue; jtype = map[type[j]]; @@ -3362,30 +3362,30 @@ double PairComb3::combqeq(double *qf_fix, int &igroup) // 1/r charge forces qfo_direct(¶ms[iparam_ij],¶ms[iparam_ji], - mr1,mr2,mr3,rsq1,sr1,sr2,sr3,fac11e,fqij,fqji, - iq,jq,i,j); + mr1,mr2,mr3,rsq1,sr1,sr2,sr3,fac11e,fqij,fqji, + iq,jq,i,j); fqi += fqij; qf[j] += fqji; // field correction to self energy and charge force qfo_field(¶ms[iparam_ij],¶ms[iparam_ji],rsq1, - iq,jq,fqij,fqji); + iq,jq,fqij,fqji); fqi += fqij; qf[j] += fqji; // polarization field charge force - if (pol_flag) { - qfo_dipole(fac11,mr1,mr2,mr3,inty,rsq1,delrj,sr1,sr2,sr3, - fqij,fqji,i,j); + if (pol_flag) { + qfo_dipole(fac11,mr1,mr2,mr3,inty,rsq1,delrj,sr1,sr2,sr3, + fqij,fqji,i,j); fqi += fqij; qf[j] += fqji; - } + } } for (jj = 0; jj < sht_jnum; jj++) { j = sht_jlist[jj]; - jtag = tag[j]; + jtag = tag[j]; if (itag >= jtag) continue; jtype = map[type[j]]; @@ -3401,11 +3401,11 @@ double PairComb3::combqeq(double *qf_fix, int &igroup) iparam_ji = elem2param[jtype][itype][itype]; if (rsq1 >= params[iparam_ij].cutsq) continue; - nj ++; + nj ++; // charge force in Aij and Bij qfo_short(¶ms[iparam_ij],¶ms[iparam_ji], - rsq1,iq,jq,fqij,fqji,i,j,nj); + rsq1,iq,jq,fqij,fqji,i,j,nj); fqi += fqij; qf[j] += fqji; } @@ -3422,7 +3422,7 @@ double PairComb3::combqeq(double *qf_fix, int &igroup) i = ilist[ii]; if (mask[i] & groupbit){ eneg += qf[i]; - itag=tag[i]; + itag=tag[i]; } } @@ -3458,9 +3458,9 @@ double PairComb3::qfo_self(Param *param, double qi) /* ---------------------------------------------------------------------- */ void PairComb3::qfo_direct(Param *parami, Param *paramj, int mr1, - int mr2, int mr3, double rsq, double sr1, double sr2, - double sr3, double fac11e, double &fqij, double &fqji, - double iq, double jq, int i, int j) + int mr2, int mr3, double rsq, double sr1, double sr2, + double sr3, double fac11e, double &fqij, double &fqji, + double iq, double jq, int i, int j) { double r, erfcc, fafbnl, vm, vmfafb, esucon; double afbn, afbj, sme1n, sme1j; @@ -3519,7 +3519,7 @@ void PairComb3::qfo_direct(Param *parami, Param *paramj, int mr1, /* ---------------------------------------------------------------------- */ void PairComb3::qfo_field(Param *parami, Param *paramj, double rsq, - double iq,double jq, double &fqij, double &fqji) + double iq,double jq, double &fqij, double &fqji) { double r,r3,r5,rc,rc2,rc3,rc4,rc5; double cmi1,cmi2,cmj1,cmj2,pcmi1,pcmi2; @@ -3561,8 +3561,8 @@ void PairComb3::qfo_field(Param *parami, Param *paramj, double rsq, /* ---------------------------------------------------------------------- */ void PairComb3::qfo_dipole(double fac11, int mr1, int mr2, int mr3, - int inty, double rsq, double *delrj, double sr1, double sr2, - double sr3, double &fqij, double &fqji, int i, int j) + int inty, double rsq, double *delrj, double sr1, double sr2, + double sr3, double &fqij, double &fqji, int i, int j) { double erfcc, erfcd, dvdrr, dfafbnl, smf2; double r, r3, alfdpi, esucon; @@ -3588,8 +3588,8 @@ void PairComb3::qfo_dipole(double fac11, int mr1, int mr2, int mr3, /* ---------------------------------------------------------------------- */ void PairComb3::qfo_short(Param *parami, Param *paramj, double rsq, - double iq, double jq, double &fqij, double &fqji, - int i, int j, int nj) + double iq, double jq, double &fqij, double &fqji, + int i, int j, int nj) { double r, tmp_fc; double Di, Dj, dDi, dDj, Bsi, Bsj, dBsi, dBsj; @@ -3623,10 +3623,10 @@ void PairComb3::qfo_short(Param *parami, Param *paramj, double rsq, Di = parami->DU; dDi = Bsi = dBsi = 0.0; } else { - Di = parami->DU + pow(QUchi,parami->nD); // YYDin - dDi = -parami->nD * parami->bD * pow(QUchi,(parami->nD-1.0)); // YYDiqp - Bsi = parami->aB - pow(QOchi,10); // YYBsin - dBsi = -parami->bB * 10.0 * pow(QOchi,9.0); // YYBsiqp + Di = parami->DU + pow(QUchi,parami->nD); // YYDin + dDi = -parami->nD * parami->bD * pow(QUchi,(parami->nD-1.0)); // YYDiqp + Bsi = parami->aB - pow(QOchi,10); // YYBsin + dBsi = -parami->bB * 10.0 * pow(QOchi,9.0); // YYBsiqp } if (jq < paramj->QL-0.2) { @@ -3638,10 +3638,10 @@ void PairComb3::qfo_short(Param *parami, Param *paramj, double rsq, Dj = paramj->DU; dDj = Bsj = dBsj = 0.0; } else { - Dj = paramj->DU + pow(QUchj,paramj->nD); // YYDij - dDj = -paramj->nD * paramj->bD * pow(QUchj,(paramj->nD-1.0)); // YYDiqpj - Bsj = paramj->aB - pow(QOchj,10); // YYBsij - dBsj = -paramj->bB * 10.0 * pow(QOchj,9.0); // YYBsiqpj + Dj = paramj->DU + pow(QUchj,paramj->nD); // YYDij + dDj = -paramj->nD * paramj->bD * pow(QUchj,(paramj->nD-1.0)); // YYDiqpj + Bsj = paramj->aB - pow(QOchj,10); // YYBsij + dBsj = -paramj->bB * 10.0 * pow(QOchj,9.0); // YYBsiqpj } LamDiLamDj = exp(0.5*(parami->lami*Di+paramj->lami*Dj)-rlm1*r); @@ -3668,8 +3668,8 @@ void PairComb3::qfo_short(Param *parami, Param *paramj, double rsq, /* ---------------------------------------------------------------------- */ void PairComb3::dipole_init(Param *parami, Param *paramj, double fac11, - double *delrj, double rsq, int mr1, int mr2, int mr3, double sr1, - double sr2, double sr3, double iq, double jq, int i, int j) + double *delrj, double rsq, int mr1, int mr2, int mr3, double sr1, + double sr2, double sr3, double iq, double jq, int i, int j) { double erfcc, erfcd, dvdrr, dfafbnl, smf2, phinn, phinj, efn, efj; double r, r3, alfdpi, esucon; @@ -3730,10 +3730,10 @@ double PairComb3::dipole_self(Param *parami, int i) /* ---------------------------------------------------------------------- */ void PairComb3::dipole_calc(Param *parami, Param *paramj, double fac11, - double delx, double dely, double delz, double rsq, - int mr1, int mr2, int mr3, double sr1, double sr2, double sr3, - double iq, double jq, int i, int j, double &vionij, - double &fvionij, double *ddprx) + double delx, double dely, double delz, double rsq, + int mr1, int mr2, int mr3, double sr1, double sr2, double sr3, + double iq, double jq, int i, int j, double &vionij, + double &fvionij, double *ddprx) { double erfcc, erfcd, dvdrr, dfafbnl, ef, phinn, phinj, efn, efj; double r, r3, alf, alfdpi, esucon, dphinn, dphinj, ddfafbnl; @@ -3803,7 +3803,7 @@ void PairComb3::dipole_calc(Param *parami, Param *paramj, double fac11, for (nm = 0; nm < 3; nm ++) { ddprx[nm] = dcoef * (ddpr*delr1[nm] - tmurn*dpl[j][nm] - tmurj*dpl[i][nm]) - + demuTmu * delr1[nm]; + + demuTmu * delr1[nm]; } // dipole - charge force @@ -3847,7 +3847,7 @@ double PairComb3::switching(double rr) if (rr <= 0.0) return 1.0; else if (rr >= 1.0) return 0.0; else return heaviside(-rr)+heaviside(rr)*heaviside(1.0-rr) - * (1.0-(3.0-2.0*rr)*rr*rr); + * (1.0-(3.0-2.0*rr)*rr*rr); } /* ---------------------------------------------------------------------- */ @@ -3857,7 +3857,7 @@ double PairComb3::switching_d(double rr) if (rr <= 0.0) return 0.0; else if (rr >= 1.0) return 0.0; else return heaviside(rr)*heaviside(1.0-rr) - * 6.0*rr*(rr-1.0); + * 6.0*rr*(rr-1.0); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_comb3.h b/src/MANYBODY/pair_comb3.h index bc21120e8e..5d7e5d6beb 100644 --- a/src/MANYBODY/pair_comb3.h +++ b/src/MANYBODY/pair_comb3.h @@ -42,8 +42,8 @@ class PairComb3 : public Pair { protected: struct Param { int ielement,jelement,kelement,powermint; - int ielementgp,jelementgp,kelementgp; //element group - int ang_flag,pcn_flag,rad_flag,tor_flag; //angle, coordination,radical, torsion flag + int ielementgp,jelementgp,kelementgp; //element group + int ang_flag,pcn_flag,rad_flag,tor_flag; //angle, coordination,radical, torsion flag double lami,lambda,alfi,alpha1,alpha2,alpha3,beta; double pcos6,pcos5,pcos4,pcos3,pcos2,pcos1,pcos0; double gamma,powerm,powern,bigA,bigB1,bigB2,bigB3; @@ -60,18 +60,18 @@ class PairComb3 : public Pair { }; // general setups - int nelements; // # of unique elements - int ***elem2param; // mapping from element triplets to parameters - int *map; // mapping from atom types to elements - int nparams; // # of stored parameter sets - int maxparam; // max # of parameter sets - double PI,PI2,PI4,PIsq; // PIs - double cutmin; // min cutoff for all elements - double cutmax; // max cutoff for all elements - double precision; // tolerance for QEq convergence - char **elements; // names of unique elements - Param *params; // parameter set for an I-J-K interaction - int debug_eng1, debug_eng2, debug_fq; // logic controlling debugging outputs + int nelements; // # of unique elements + int ***elem2param; // mapping from element triplets to parameters + int *map; // mapping from atom types to elements + int nparams; // # of stored parameter sets + int maxparam; // max # of parameter sets + double PI,PI2,PI4,PIsq; // PIs + double cutmin; // min cutoff for all elements + double cutmax; // max cutoff for all elements + double precision; // tolerance for QEq convergence + char **elements; // names of unique elements + Param *params; // parameter set for an I-J-K interaction + int debug_eng1, debug_eng2, debug_fq; // logic controlling debugging outputs int pack_flag; // Short range neighbor list @@ -105,8 +105,8 @@ class PairComb3 : public Pair { double ccutoff[6],ch_a[7]; //COMB3-v18 arrays for CHO - // We wanna dynamic arrays - // C angle arrays, size = ntab+1 + // We wanna dynamic arrays + // C angle arrays, size = ntab+1 double pang[20001]; double dpang[20001]; double ddpang[20001]; @@ -153,12 +153,12 @@ class PairComb3 : public Pair { // short range terms void attractive(Param *, Param *, Param *, double, double, double, double, - double, double, double, double *, double *, double *, - double *, double *, int, double); + double, double, double, double *, double *, double *, + double *, double *, int, double); virtual void comb_fa(double, Param *, Param *, double, double, - double &, double &); + double &, double &); virtual void repulsive(Param *, Param *,double, double &, int, - double &, double, double); + double &, double, double); // bond order terms double comb_bij(double, Param *, double, int, double); @@ -166,19 +166,19 @@ class PairComb3 : public Pair { void comb_gijk_d(double, Param *, double, double &, double &); double zeta(Param *, Param *, double, double, double *, double *, int, double); void comb_bij_d(double, Param *, double, int, double &, - double &, double &, double &, double &, double &, double); + double &, double &, double &, double &, double &, double); void coord(Param *, double, int, double &, double &, - double &, double &, double &, double); + double &, double &, double &, double); void comb_zetaterm_d(double, double, double, double, double, - double *, double, double *, double, double *, double *, - double *, Param *, Param *, Param *, double); + double *, double, double *, double, double *, double *, + double *, Param *, Param *, Param *, double); void costheta_d(double *, double, double *, double, - double *, double *, double *); + double *, double *, double *); void force_zeta(Param *, Param *, double, double, double, double &, - double &, double &, double &, double &, double &, double &, - double &, double &, double &, double &, double &, double &, - int, double &, double,double, int, int, int, - double , double , double); + double &, double &, double &, double &, double &, double &, + double &, double &, double &, double &, double &, double &, + int, double &, double,double, int, int, int, + double , double , double); void cntri_int(int, double, double, double, int, int, int, double &, double &, double &, double &, Param *); @@ -186,18 +186,18 @@ class PairComb3 : public Pair { void selfp6p(Param *, Param *, double, double &, double &); double ep6p(Param *, Param *, double, double, double *, double * ,double &); void fp6p(Param *, Param *, double, double, double *, double *, double *, - double *, double *); + double *, double *); // long range q-dependent terms double self(Param *, double); void tables(); void potal_calc(double &, double &, double &); void tri_point(double, int &, int &, int &, double &, double &, - double &); + double &); void vdwaals(int,int,int,int,double,double,double,double, - double &, double &); + double &, double &); void direct(Param *, Param *, int,int,int,double,double, - double,double,double,double, double,double,double &,double &, + double,double,double,double, double,double,double &,double &, int, int); void field(Param *, Param *,double,double,double,double &,double &); int heaviside(double); @@ -208,9 +208,9 @@ class PairComb3 : public Pair { // radical terms double rad_init(double, Param *, int, double &, double); void rad_calc(double, Param *, Param *, double, double, int, - int, double, double); + int, double, double); void rad_int(int , double, double, double, int, int, int, - double &, double &, double &, double &); + double &, double &, double &, double &); void rad_forceik(Param *, double, double *, double, double); void rad_force(Param *, double, double *, double); @@ -218,7 +218,7 @@ class PairComb3 : public Pair { double bbtor1(int, Param *, Param *, double, double, double, double *, double *, double *, double); //modified by TAO void tor_calc(double, Param *, Param *, double, double, int, - int, double, double); + int, double, double); void tor_int(int , double, double, double, int, int, int, double &, double &, double &, double &); void tor_force(int, Param *, Param *, double, double, double, @@ -227,22 +227,22 @@ class PairComb3 : public Pair { // charge force terms double qfo_self(Param *, double); void qfo_short(Param *, Param *, double, double, double, - double &, double &, int, int, int); + double &, double &, int, int, int); void qfo_direct(Param *, Param *, int, int, int, double, - double, double, double, double, double &, double &, - double, double, int, int); + double, double, double, double, double &, double &, + double, double, int, int); void qfo_field(Param *, Param *,double,double ,double ,double &, double &); void qfo_dipole(double, int, int, int, int, double, double *, double, - double, double, double &, double &, int, int); + double, double, double &, double &, int, int); void qsolve(double *); // dipole - polarization terms double dipole_self(Param *, int); void dipole_init(Param *, Param *, double, double *, double, - int, int, int, double, double, double, double, double, int , int); + int, int, int, double, double, double, double, double, int , int); void dipole_calc(Param *, Param *, double, double, double, double, double, - int, int, int, double, double, double, double, double, int , int, - double &, double &, double *); + int, int, int, double, double, double, double, double, int , int, + double &, double &, double *); // communication functions int pack_reverse_comm(int, int, double *); diff --git a/src/MANYBODY/pair_gw.h b/src/MANYBODY/pair_gw.h index eedc2a1f9f..00cbaa2beb 100644 --- a/src/MANYBODY/pair_gw.h +++ b/src/MANYBODY/pair_gw.h @@ -101,7 +101,7 @@ class PairGW : public Pair { const double gw_d = param->d * param->d; const double hcth = param->h - costheta; - //printf("gw_gijk: gw_c=%f gw_d=%f hcth=%f=%f-%f\n", gw_c, gw_d, hcth, param->h, costheta); + //printf("gw_gijk: gw_c=%f gw_d=%f hcth=%f=%f-%f\n", gw_c, gw_d, hcth, param->h, costheta); return param->gamma*(1.0 + gw_c/gw_d - gw_c / (gw_d + hcth*hcth)); } diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index d1d5880839..0b930c7360 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -124,32 +124,32 @@ void PairNb3bHarmonic::compute(int eflag, int vflag) if (rsq1 > params[ijparam].cutsq) continue; for (kk = jj+1; kk < jnum; kk++) { - k = jlist[kk]; - k &= NEIGHMASK; - ktype = map[type[k]]; - ikparam = elem2param[itype][ktype][ktype]; - ijkparam = elem2param[itype][jtype][ktype]; - - delr2[0] = x[k][0] - xtmp; - delr2[1] = x[k][1] - ytmp; - delr2[2] = x[k][2] - ztmp; - rsq2 = delr2[0]*delr2[0] + delr2[1]*delr2[1] + delr2[2]*delr2[2]; - if (rsq2 > params[ikparam].cutsq) continue; + k = jlist[kk]; + k &= NEIGHMASK; + ktype = map[type[k]]; + ikparam = elem2param[itype][ktype][ktype]; + ijkparam = elem2param[itype][jtype][ktype]; + + delr2[0] = x[k][0] - xtmp; + delr2[1] = x[k][1] - ytmp; + delr2[2] = x[k][2] - ztmp; + rsq2 = delr2[0]*delr2[0] + delr2[1]*delr2[1] + delr2[2]*delr2[2]; + if (rsq2 > params[ikparam].cutsq) continue; threebody(¶ms[ijparam],¶ms[ikparam],¶ms[ijkparam], rsq1,rsq2,delr1,delr2,fj,fk,eflag,evdwl); - f[i][0] -= fj[0] + fk[0]; - f[i][1] -= fj[1] + fk[1]; - f[i][2] -= fj[2] + fk[2]; - f[j][0] += fj[0]; - f[j][1] += fj[1]; - f[j][2] += fj[2]; - f[k][0] += fk[0]; - f[k][1] += fk[1]; - f[k][2] += fk[2]; - - if (evflag) ev_tally3(i,j,k,evdwl,0.0,fj,fk,delr1,delr2); + f[i][0] -= fj[0] + fk[0]; + f[i][1] -= fj[1] + fk[1]; + f[i][2] -= fj[2] + fk[2]; + f[j][0] += fj[0]; + f[j][1] += fj[1]; + f[j][2] += fj[2]; + f[k][0] += fk[0]; + f[k][1] += fk[1]; + f[k][2] += fk[2]; + + if (evflag) ev_tally3(i,j,k,evdwl,0.0,fj,fk,delr1,delr2); } } } @@ -244,8 +244,8 @@ void PairNb3bHarmonic::coeff(int narg, char **arg) for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; + setflag[i][j] = 1; + count++; } if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); @@ -316,8 +316,8 @@ void PairNb3bHarmonic::read_file(char *file) if (comm->me == 0) { ptr = fgets(line,MAXLINE,fp); if (ptr == NULL) { - eof = 1; - fclose(fp); + eof = 1; + fclose(fp); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -338,8 +338,8 @@ void PairNb3bHarmonic::read_file(char *file) if (comm->me == 0) { ptr = fgets(&line[n],MAXLINE-n,fp); if (ptr == NULL) { - eof = 1; - fclose(fp); + eof = 1; + fclose(fp); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -378,7 +378,7 @@ void PairNb3bHarmonic::read_file(char *file) if (nparams == maxparam) { maxparam += DELTA; params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); + "pair:params"); } params[nparams].ielement = ielement; @@ -415,16 +415,16 @@ void PairNb3bHarmonic::setup_params() for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) for (k = 0; k < nelements; k++) { - n = -1; - for (m = 0; m < nparams; m++) { - if (i == params[m].ielement && j == params[m].jelement && - k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); - n = m; - } - } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + n = -1; + for (m = 0; m < nparams; m++) { + if (i == params[m].ielement && j == params[m].jelement && + k == params[m].kelement) { + if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + n = m; + } + } + if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + elem2param[i][j][k] = n; } // compute parameter values derived from inputs diff --git a/src/MANYBODY/pair_nb3b_harmonic.h b/src/MANYBODY/pair_nb3b_harmonic.h index 8445a98970..75a378e35b 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.h +++ b/src/MANYBODY/pair_nb3b_harmonic.h @@ -55,7 +55,7 @@ class PairNb3bHarmonic : public Pair { void setup_params(); void twobody(Param *, double, double &, int, double &); void threebody(Param *, Param *, Param *, double, double, double *, double *, - double *, double *, int, double &); + double *, double *, int, double &); }; } diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index 02075ed5b4..110fc0a44d 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -234,13 +234,13 @@ void PairPolymorphic::compute(int eflag, int vflag) jtag = tag[j]; if (itag > jtag) { - if ((itag+jtag) % 2 == 0) continue; + if ((itag+jtag) % 2 == 0) continue; } else if (itag < jtag) { - if ((itag+jtag) % 2 == 1) continue; + if ((itag+jtag) % 2 == 1) continue; } else { - if (x[j][2] < x[i][2]) continue; - if (x[j][2] == ztmp && x[j][1] < ytmp) continue; - if (x[j][2] == ztmp && x[j][1] == ytmp && x[j][0] < xtmp) continue; + if (x[j][2] < x[i][2]) continue; + if (x[j][2] == ztmp && x[j][1] < ytmp) continue; + if (x[j][2] == ztmp && x[j][1] == ytmp && x[j][0] < xtmp) continue; } if (rsq >= (p.U)->get_xmaxsq() || (p.U)->get_vmax() <= epsilon) continue; @@ -255,7 +255,7 @@ void PairPolymorphic::compute(int eflag, int vflag) f[j][2] -= delz*fpair; if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + evdwl,0.0,fpair,delx,dely,delz); } if (eta) { @@ -524,8 +524,8 @@ void PairPolymorphic::coeff(int narg, char **arg) for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; + setflag[i][j] = 1; + count++; } if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); @@ -851,8 +851,8 @@ void PairPolymorphic::ters_zetaterm_d(double prefactor, /* ---------------------------------------------------------------------- */ void PairPolymorphic::costheta_d(double *rij_hat, double rij, - double *rik_hat, double rik, - double *dri, double *drj, double *drk) + double *rik_hat, double rik, + double *dri, double *drj, double *drk) { // first element is devative wrt Ri, second wrt Rj, third wrt Rk diff --git a/src/MANYBODY/pair_polymorphic.h b/src/MANYBODY/pair_polymorphic.h index 1ce7600f10..8855ce7c25 100644 --- a/src/MANYBODY/pair_polymorphic.h +++ b/src/MANYBODY/pair_polymorphic.h @@ -288,7 +288,7 @@ class PairPolymorphic : public Pair { void ters_zetaterm_d(double, double *, double, double *, double, double *, double *, double *, PairParameters *, TripletParameters *); void costheta_d(double *, double, double *, double, - double *, double *, double *); + double *, double *, double *); // inlined functions for efficiency @@ -297,17 +297,17 @@ class PairPolymorphic : public Pair { } inline void vec3_add(const double x[3], const double y[3], - double * const z) const { + double * const z) const { z[0] = x[0]+y[0]; z[1] = x[1]+y[1]; z[2] = x[2]+y[2]; } inline void vec3_scale(const double k, const double x[3], - double y[3]) const { + double y[3]) const { y[0] = k*x[0]; y[1] = k*x[1]; y[2] = k*x[2]; } inline void vec3_scaleadd(const double k, const double x[3], - const double y[3], double * const z) const { + const double y[3], double * const z) const { z[0] = k*x[0]+y[0]; z[1] = k*x[1]+y[1]; z[2] = k*x[2]+y[2]; diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index 9f976281c8..047c59fc87 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -720,8 +720,8 @@ double PairTersoff::ters_bij_d(double zeta, Param *param) if (tmp > param->c1) return param->beta * -0.5*pow(tmp,-1.5); if (tmp > param->c2) return param->beta * (-0.5*pow(tmp,-1.5) * - // error in negligible 2nd term fixed 9/30/2015 - // (1.0 - 0.5*(1.0 + 1.0/(2.0*param->powern)) * + // error in negligible 2nd term fixed 9/30/2015 + // (1.0 - 0.5*(1.0 + 1.0/(2.0*param->powern)) * (1.0 - (1.0 + 1.0/(2.0*param->powern)) * pow(tmp,-param->powern))); if (tmp < param->c4) return 0.0; diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index e810130dba..a90cf3bb77 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -76,8 +76,8 @@ void PairTersoffMOD::read_file(char *file) if (comm->me == 0) { ptr = fgets(line,MAXLINE,fp); if (ptr == NULL) { - eof = 1; - fclose(fp); + eof = 1; + fclose(fp); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -98,8 +98,8 @@ void PairTersoffMOD::read_file(char *file) if (comm->me == 0) { ptr = fgets(&line[n],MAXLINE-n,fp); if (ptr == NULL) { - eof = 1; - fclose(fp); + eof = 1; + fclose(fp); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -138,7 +138,7 @@ void PairTersoffMOD::read_file(char *file) if (nparams == maxparam) { maxparam += DELTA; params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); + "pair:params"); } params[nparams].ielement = ielement; @@ -203,16 +203,16 @@ void PairTersoffMOD::setup_params() for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) for (k = 0; k < nelements; k++) { - n = -1; - for (m = 0; m < nparams; m++) { - if (i == params[m].ielement && j == params[m].jelement && - k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); - n = m; - } - } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + n = -1; + for (m = 0; m < nparams; m++) { + if (i == params[m].ielement && j == params[m].jelement && + k == params[m].kelement) { + if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + n = m; + } + } + if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + elem2param[i][j][k] = n; } @@ -236,14 +236,14 @@ void PairTersoffMOD::setup_params() /* ---------------------------------------------------------------------- */ double PairTersoffMOD::zeta(Param *param, double rsqij, double rsqik, - double *delrij, double *delrik) + double *delrij, double *delrik) { double rij,rik,costheta,arg,ex_delr; rij = sqrt(rsqij); rik = sqrt(rsqik); costheta = (delrij[0]*delrik[0] + delrij[1]*delrik[1] + - delrij[2]*delrik[2]) / (rij*rik); + delrij[2]*delrik[2]) / (rij*rik); if (param->powermint == 3) arg = pow(param->lam3 * (rij-rik),3.0); else arg = param->lam3 * (rij-rik); @@ -297,21 +297,21 @@ double PairTersoffMOD::ters_bij_d(double zeta, Param *param) { double tmp = param->beta * zeta; if (tmp > param->ca1) return -0.5*(param->powern/param->powern_del)* - pow(tmp,-0.5*(param->powern/param->powern_del)) / zeta; + pow(tmp,-0.5*(param->powern/param->powern_del)) / zeta; if (tmp < param->ca4) return 0.0; double tmp_n = pow(tmp,param->powern); return -0.5 *(param->powern/param->powern_del)* - pow(1.0+tmp_n, -1.0-(1.0/(2.0*param->powern_del)))*tmp_n / zeta; + pow(1.0+tmp_n, -1.0-(1.0/(2.0*param->powern_del)))*tmp_n / zeta; } /* ---------------------------------------------------------------------- */ void PairTersoffMOD::ters_zetaterm_d(double prefactor, - double *rij_hat, double rij, - double *rik_hat, double rik, - double *dri, double *drj, double *drk, - Param *param) + double *rij_hat, double rij, + double *rik_hat, double rik, + double *dri, double *drj, double *drk, + Param *param) { double gijk,gijk_d,ex_delr,ex_delr_d,fc,dfc,cos_theta,tmp; double dcosdri[3],dcosdrj[3],dcosdrk[3]; diff --git a/src/MANYBODY/pair_tersoff_mod.h b/src/MANYBODY/pair_tersoff_mod.h index fea3919be3..42a3a2b26c 100644 --- a/src/MANYBODY/pair_tersoff_mod.h +++ b/src/MANYBODY/pair_tersoff_mod.h @@ -40,7 +40,7 @@ class PairTersoffMOD : public PairTersoff { double ters_bij(double, Param *); double ters_bij_d(double, Param *); void ters_zetaterm_d(double, double *, double, double *, double, - double *, double *, double *, Param *); + double *, double *, double *, Param *); // inlined functions for efficiency // these replace but do not override versions in PairTersoff diff --git a/src/MANYBODY/pair_tersoff_mod_c.cpp b/src/MANYBODY/pair_tersoff_mod_c.cpp index 0edf2ddef9..c0d6cb164a 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.cpp +++ b/src/MANYBODY/pair_tersoff_mod_c.cpp @@ -71,8 +71,8 @@ void PairTersoffMODC::read_file(char *file) if (comm->me == 0) { ptr = fgets(line,MAXLINE,fp); if (ptr == NULL) { - eof = 1; - fclose(fp); + eof = 1; + fclose(fp); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -93,8 +93,8 @@ void PairTersoffMODC::read_file(char *file) if (comm->me == 0) { ptr = fgets(&line[n],MAXLINE-n,fp); if (ptr == NULL) { - eof = 1; - fclose(fp); + eof = 1; + fclose(fp); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -133,7 +133,7 @@ void PairTersoffMODC::read_file(char *file) if (nparams == maxparam) { maxparam += DELTA; params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); + "pair:params"); } params[nparams].ielement = ielement; diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index 2b867bc046..9f2ed03945 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -170,7 +170,7 @@ void PairVashishta::compute(int eflag, int vflag) f[j][2] -= delz*fpair; if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + evdwl,0.0,fpair,delx,dely,delz); } jnumm1 = numshort - 1; @@ -585,12 +585,12 @@ void PairVashishta::twobody(Param *param, double rsq, double &fforce, vc3 = param->mbigd * r4inv*exp(-lam4r); fforce = (param->dvrc*r - - (4.0*vc3 + lam4r*vc3+param->big6w*r6inv - - param->heta*reta - vc2 - lam1r*vc2) - ) * rinvsq; + - (4.0*vc3 + lam4r*vc3+param->big6w*r6inv + - param->heta*reta - vc2 - lam1r*vc2) + ) * rinvsq; if (eflag) eng = param->bigh*reta - + vc2 - vc3 - param->bigw*r6inv - - r*param->dvrc + param->c0; + + vc2 - vc3 - param->bigw*r6inv + - r*param->dvrc + param->c0; } /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_atom_swap.cpp b/src/MC/fix_atom_swap.cpp index 6500707bf3..669afb5d48 100644 --- a/src/MC/fix_atom_swap.cpp +++ b/src/MC/fix_atom_swap.cpp @@ -167,9 +167,9 @@ void FixAtomSwap::options(int narg, char **arg) iarg++; while (iarg < narg) { if (isalpha(arg[iarg][0])) break; - if (nswaptypes >= atom->ntypes) error->all(FLERR,"Illegal fix atom/swap command"); + if (nswaptypes >= atom->ntypes) error->all(FLERR,"Illegal fix atom/swap command"); type_list[nswaptypes] = force->numeric(FLERR,arg[iarg]); - nswaptypes++; + nswaptypes++; iarg++; } } else if (strcmp(arg[iarg],"mu") == 0) { @@ -178,7 +178,7 @@ void FixAtomSwap::options(int narg, char **arg) while (iarg < narg) { if (isalpha(arg[iarg][0])) break; nmutypes++; - if (nmutypes > atom->ntypes) error->all(FLERR,"Illegal fix atom/swap command"); + if (nmutypes > atom->ntypes) error->all(FLERR,"Illegal fix atom/swap command"); mu[nmutypes] = force->numeric(FLERR,arg[iarg]); iarg++; } @@ -246,14 +246,14 @@ void FixAtomSwap::init() first = 1; for (int i = 0; i < atom->nlocal; i++) { if (atom->mask[i] & groupbit) { - if (type[i] == type_list[iswaptype]) { - if (first) { - qtype[iswaptype] = atom->q[i]; - first = 0; - } else if (qtype[iswaptype] != atom->q[i]) - error->one(FLERR,"All atoms of a swapped type must have the same charge."); - } - } + if (type[i] == type_list[iswaptype]) { + if (first) { + qtype[iswaptype] = atom->q[i]; + first = 0; + } else if (qtype[iswaptype] != atom->q[i]) + error->one(FLERR,"All atoms of a swapped type must have the same charge."); + } + } } MPI_Allreduce(&first,&firstall,1,MPI_INT,MPI_MIN,world); if (firstall) error->all(FLERR,"At least one atom of each swapped type must be present to define charges."); @@ -600,11 +600,11 @@ void FixAtomSwap::update_semi_grand_atoms_list() for (int i = 0; i < nlocal; i++) { if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]) == 1) { if (atom->mask[i] & groupbit) { - int itype = atom->type[i]; - int iswaptype; - for (iswaptype = 0; iswaptype < nswaptypes; iswaptype++) - if (itype == type_list[iswaptype]) break; - if (iswaptype == nswaptypes) continue; + int itype = atom->type[i]; + int iswaptype; + for (iswaptype = 0; iswaptype < nswaptypes; iswaptype++) + if (itype == type_list[iswaptype]) break; + if (iswaptype == nswaptypes) continue; local_swap_atom_list[nswap_local] = i; nswap_local++; } @@ -614,11 +614,11 @@ void FixAtomSwap::update_semi_grand_atoms_list() } else { for (int i = 0; i < nlocal; i++) { if (atom->mask[i] & groupbit) { - int itype = atom->type[i]; - int iswaptype; - for (iswaptype = 0; iswaptype < nswaptypes; iswaptype++) - if (itype == type_list[iswaptype]) break; - if (iswaptype == nswaptypes) continue; + int itype = atom->type[i]; + int iswaptype; + for (iswaptype = 0; iswaptype < nswaptypes; iswaptype++) + if (itype == type_list[iswaptype]) break; + if (iswaptype == nswaptypes) continue; local_swap_atom_list[nswap_local] = i; nswap_local++; } diff --git a/src/MC/fix_bond_break.cpp b/src/MC/fix_bond_break.cpp index afb18cc1c2..711f764282 100644 --- a/src/MC/fix_bond_break.cpp +++ b/src/MC/fix_bond_break.cpp @@ -806,18 +806,18 @@ void FixBondBreak::print_bb() printf("TAG " TAGINT_FORMAT ": %d nangles: ",atom->tag[i],atom->num_angle[i]); for (int j = 0; j < atom->num_angle[i]; j++) { printf(" %d %d %d,",atom->angle_atom1[i][j], - atom->angle_atom2[i][j],atom->angle_atom3[i][j]); + atom->angle_atom2[i][j],atom->angle_atom3[i][j]); } printf("\n"); printf("TAG " TAGINT_FORMAT ": %d ndihedrals: ",atom->tag[i],atom->num_dihedral[i]); for (int j = 0; j < atom->num_dihedral[i]; j++) { printf(" %d %d %d %d,",atom->dihedral_atom1[i][j], - atom->dihedral_atom2[i][j],atom->dihedral_atom3[i][j], - atom->dihedral_atom4[i][j]); + atom->dihedral_atom2[i][j],atom->dihedral_atom3[i][j], + atom->dihedral_atom4[i][j]); } printf("\n"); printf("TAG " TAGINT_FORMAT ": %d %d %d nspecial: ",atom->tag[i], - atom->nspecial[i][0],atom->nspecial[i][1],atom->nspecial[i][2]); + atom->nspecial[i][0],atom->nspecial[i][1],atom->nspecial[i][2]); for (int j = 0; j < atom->nspecial[i][2]; j++) { printf(" %d",atom->special[i][j]); } diff --git a/src/MC/fix_bond_create.cpp b/src/MC/fix_bond_create.cpp index 14270e7c77..789f1794f1 100644 --- a/src/MC/fix_bond_create.cpp +++ b/src/MC/fix_bond_create.cpp @@ -1414,20 +1414,20 @@ void FixBondCreate::print_bb() for (int j = 0; j < atom->num_dihedral[i]; j++) { printf(" " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT ",", atom->dihedral_atom1[i][j], - atom->dihedral_atom2[i][j],atom->dihedral_atom3[i][j], - atom->dihedral_atom4[i][j]); + atom->dihedral_atom2[i][j],atom->dihedral_atom3[i][j], + atom->dihedral_atom4[i][j]); } printf("\n"); printf("TAG " TAGINT_FORMAT ": %d nimpropers: ",atom->tag[i],atom->num_improper[i]); for (int j = 0; j < atom->num_improper[i]; j++) { printf(" " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT ",",atom->improper_atom1[i][j], - atom->improper_atom2[i][j],atom->improper_atom3[i][j], - atom->improper_atom4[i][j]); + atom->improper_atom2[i][j],atom->improper_atom3[i][j], + atom->improper_atom4[i][j]); } printf("\n"); printf("TAG " TAGINT_FORMAT ": %d %d %d nspecial: ",atom->tag[i], - atom->nspecial[i][0],atom->nspecial[i][1],atom->nspecial[i][2]); + atom->nspecial[i][0],atom->nspecial[i][1],atom->nspecial[i][2]); for (int j = 0; j < atom->nspecial[i][2]; j++) { printf(" " TAGINT_FORMAT,atom->special[i][j]); } diff --git a/src/MC/fix_tfmc.cpp b/src/MC/fix_tfmc.cpp index 01bb7456e0..46a93914a7 100644 --- a/src/MC/fix_tfmc.cpp +++ b/src/MC/fix_tfmc.cpp @@ -255,11 +255,11 @@ void FixTFMC::initial_integrate(int vflag) group->xcm(igroup,masstotal,cm); // to zero rotations, we can employ the same principles the - // velocity command uses to zero the angular momentum. of course, - // there is no (conserved) momentum in MC, but we can substitute - // "velocities" by a displacement vector and proceed from there. - // this of course requires "forking" group->angmom(), which is - // what we do here. + // velocity command uses to zero the angular momentum. of course, + // there is no (conserved) momentum in MC, but we can substitute + // "velocities" by a displacement vector and proceed from there. + // this of course requires "forking" group->angmom(), which is + // what we do here. double p[3]; p[0] = p[1] = p[2] = 0.0; diff --git a/src/MISC/fix_deposit.cpp b/src/MISC/fix_deposit.cpp index 9c1082f816..023ec797df 100644 --- a/src/MISC/fix_deposit.cpp +++ b/src/MISC/fix_deposit.cpp @@ -543,9 +543,9 @@ void FixDeposit::pre_exchange() atom->v[n][1] = vnew[1]; atom->v[n][2] = vnew[2]; if (mode == MOLECULE) { - onemols[imol]->quat_external = quat; + onemols[imol]->quat_external = quat; atom->add_molecule_atom(onemols[imol],m,n,maxtag_all); - } + } modify->create_attribute(n); } } diff --git a/src/MISC/fix_gld.cpp b/src/MISC/fix_gld.cpp index 945ddb531b..a515ade91f 100644 --- a/src/MISC/fix_gld.cpp +++ b/src/MISC/fix_gld.cpp @@ -71,7 +71,7 @@ FixGLD::FixGLD(LAMMPS *lmp, int narg, char **arg) : // 7 = series type if(strcmp(arg[7],"pprony") == 0) { - series_type = 1; // series type 1 is 'positive Prony series' + series_type = 1; // series type 1 is 'positive Prony series' } else { error->all(FLERR,"Fix gld series type must be pprony for now"); } @@ -131,13 +131,13 @@ FixGLD::FixGLD(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"zero") == 0) { if (iarg+2 > narg) { - error->all(FLERR, "Illegal fix gld command"); + error->all(FLERR, "Illegal fix gld command"); } if (strcmp(arg[iarg+1],"no") == 0) { } else if (strcmp(arg[iarg+1],"yes") == 0) { - zeroflag = 1; + zeroflag = 1; } else { - error->all(FLERR,"Illegal fix gld command"); + error->all(FLERR,"Illegal fix gld command"); } iarg += 2; } @@ -248,28 +248,28 @@ void FixGLD::initial_integrate(int vflag) for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { dtfm = dtf / rmass[i]; - // Advance V by dt/2 + // Advance V by dt/2 v[i][0] += dtfm * f[i][0]; v[i][1] += dtfm * f[i][1]; v[i][2] += dtfm * f[i][2]; for (int k = 0; k < 3*prony_terms; k=k+3) { - v[i][0] += dtfm * s_gld[i][k]; - v[i][1] += dtfm * s_gld[i][k+1]; - v[i][2] += dtfm * s_gld[i][k+2]; - } + v[i][0] += dtfm * s_gld[i][k]; + v[i][1] += dtfm * s_gld[i][k+1]; + v[i][2] += dtfm * s_gld[i][k+2]; + } - // Advance X by dt + // Advance X by dt x[i][0] += dtv * v[i][0]; x[i][1] += dtv * v[i][1]; x[i][2] += dtv * v[i][2]; - // Advance S by dt - icoeff = 0; - for (int k = 0; k < 3*prony_terms; k=k+3) { - double theta = exp(-dtv/prony_tau[icoeff]); + // Advance S by dt + icoeff = 0; + for (int k = 0; k < 3*prony_terms; k=k+3) { + double theta = exp(-dtv/prony_tau[icoeff]); double ck = prony_c[icoeff]; double vmult = (theta-1.)*ck/ftm2v; - double rmult = sqrt(2.0*kT*ck/dtv)*(1.-theta)/ftm2v; + double rmult = sqrt(2.0*kT*ck/dtv)*(1.-theta)/ftm2v; // random force #ifdef GLD_GAUSSIAN_DISTRO @@ -286,9 +286,9 @@ void FixGLD::initial_integrate(int vflag) #endif // sum of random forces - fsum[0] += fran[0]; - fsum[1] += fran[1]; - fsum[2] += fran[2]; + fsum[0] += fran[0]; + fsum[1] += fran[1]; + fsum[2] += fran[2]; s_gld[i][k] *= theta; s_gld[i][k+1] *= theta; @@ -300,36 +300,36 @@ void FixGLD::initial_integrate(int vflag) s_gld[i][k+1] += fran[1]; s_gld[i][k+2] += fran[2]; - icoeff += 1; - } + icoeff += 1; + } } } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { dtfm = dtf / mass[type[i]]; - // Advance V by dt/2 + // Advance V by dt/2 v[i][0] += dtfm * f[i][0]; v[i][1] += dtfm * f[i][1]; v[i][2] += dtfm * f[i][2]; for (int k = 0; k < 3*prony_terms; k=k+3) { - v[i][0] += dtfm * s_gld[i][k]; - v[i][1] += dtfm * s_gld[i][k+1]; - v[i][2] += dtfm * s_gld[i][k+2]; - } + v[i][0] += dtfm * s_gld[i][k]; + v[i][1] += dtfm * s_gld[i][k+1]; + v[i][2] += dtfm * s_gld[i][k+2]; + } - // Advance X by dt + // Advance X by dt x[i][0] += dtv * v[i][0]; x[i][1] += dtv * v[i][1]; x[i][2] += dtv * v[i][2]; - // Advance S by dt - icoeff = 0; - for (int k = 0; k < 3*prony_terms; k=k+3) { - double theta = exp(-dtv/prony_tau[icoeff]); + // Advance S by dt + icoeff = 0; + for (int k = 0; k < 3*prony_terms; k=k+3) { + double theta = exp(-dtv/prony_tau[icoeff]); double ck = prony_c[icoeff]; double vmult = (theta-1.)*ck/ftm2v; - double rmult = sqrt(2.0*kT*ck/dtv)*(1.-theta)/ftm2v; + double rmult = sqrt(2.0*kT*ck/dtv)*(1.-theta)/ftm2v; // random force #ifdef GLD_GAUSSIAN_DISTRO @@ -339,16 +339,16 @@ void FixGLD::initial_integrate(int vflag) #endif #ifdef GLD_UNIFORM_DISTRO - rmult *= sqrt(12.0); // correct variance of uniform distribution + rmult *= sqrt(12.0); // correct variance of uniform distribution fran[0] = rmult*(random->uniform() - 0.5); fran[1] = rmult*(random->uniform() - 0.5); fran[2] = rmult*(random->uniform() - 0.5); #endif // sum of random forces - fsum[0] += fran[0]; - fsum[1] += fran[1]; - fsum[2] += fran[2]; + fsum[0] += fran[0]; + fsum[1] += fran[1]; + fsum[2] += fran[2]; s_gld[i][k] *= theta; s_gld[i][k+1] *= theta; @@ -360,9 +360,9 @@ void FixGLD::initial_integrate(int vflag) s_gld[i][k+1] += fran[1]; s_gld[i][k+2] += fran[2]; - icoeff += 1; + icoeff += 1; - } + } } } @@ -377,11 +377,11 @@ void FixGLD::initial_integrate(int vflag) fsumall[2] /= (count*prony_terms); for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - for (int k = 0; k < 3*prony_terms; k=k+3) { + for (int k = 0; k < 3*prony_terms; k=k+3) { s_gld[i][k] -= fsumall[0]; s_gld[i][k+1] -= fsumall[1]; s_gld[i][k+2] -= fsumall[2]; - } + } } } } @@ -415,10 +415,10 @@ void FixGLD::final_integrate() v[i][1] += dtfm * f[i][1]; v[i][2] += dtfm * f[i][2]; for (int k = 0; k < 3*prony_terms; k=k+3) { - v[i][0] += dtfm * s_gld[i][k]; - v[i][1] += dtfm * s_gld[i][k+1]; - v[i][2] += dtfm * s_gld[i][k+2]; - } + v[i][0] += dtfm * s_gld[i][k]; + v[i][1] += dtfm * s_gld[i][k+1]; + v[i][2] += dtfm * s_gld[i][k+2]; + } } } else { @@ -429,10 +429,10 @@ void FixGLD::final_integrate() v[i][1] += dtfm * f[i][1]; v[i][2] += dtfm * f[i][2]; for (int k = 0; k < 3*prony_terms; k=k+3) { - v[i][0] += dtfm * s_gld[i][k]; - v[i][1] += dtfm * s_gld[i][k+1]; - v[i][2] += dtfm * s_gld[i][k+2]; - } + v[i][0] += dtfm * s_gld[i][k]; + v[i][1] += dtfm * s_gld[i][k+1]; + v[i][2] += dtfm * s_gld[i][k+2]; + } } } diff --git a/src/MOLECULE/pair_hbond_dreiding_morse.cpp b/src/MOLECULE/pair_hbond_dreiding_morse.cpp index 5c61ea4a45..83b03f9a2f 100644 --- a/src/MOLECULE/pair_hbond_dreiding_morse.cpp +++ b/src/MOLECULE/pair_hbond_dreiding_morse.cpp @@ -162,7 +162,7 @@ void PairHbondDreidingMorse::compute(int eflag, int vflag) eng_morse = pm.d0 * (dexp*dexp - 2.0*dexp); force_kernel = pm.morse1*(dexp*dexp - dexp)/r * powint(c,pm.ap); force_angle = pm.ap * eng_morse * powint(c,pm.ap-1)*s; - force_switch = 0.0; + force_switch = 0.0; if (rsq > pm.cut_innersq) { switch1 = (pm.cut_outersq-rsq) * (pm.cut_outersq-rsq) * @@ -172,8 +172,8 @@ void PairHbondDreidingMorse::compute(int eflag, int vflag) (rsq-pm.cut_innersq) / pm.denom_vdw; force_kernel *= switch1; - force_angle *= switch1; - force_switch = eng_morse*switch2/rsq; + force_angle *= switch1; + force_switch = eng_morse*switch2/rsq; eng_morse *= switch1; } diff --git a/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp b/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp index 0d2159b671..7d69995fed 100644 --- a/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp +++ b/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp @@ -145,43 +145,43 @@ void PairLJCharmmfswCoulCharmmfsh::compute(int eflag, int vflag) rsq = delx*delx + dely*dely + delz*delz; if (rsq < cut_bothsq) { - r2inv = 1.0/rsq; - r = sqrt(rsq); + r2inv = 1.0/rsq; + r = sqrt(rsq); - if (rsq < cut_coulsq) { - forcecoul = qqrd2e * qtmp*q[j]* + if (rsq < cut_coulsq) { + forcecoul = qqrd2e * qtmp*q[j]* (sqrt(r2inv) - r*cut_coulinv*cut_coulinv); - } else forcecoul = 0.0; - - if (rsq < cut_ljsq) { - r6inv = r2inv*r2inv*r2inv; - jtype = type[j]; - forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); - if (rsq > cut_lj_innersq) { - switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) * - (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; - forcelj = forcelj*switch1; - } - } else forcelj = 0.0; - - fpair = (factor_coul*forcecoul + factor_lj*forcelj) * r2inv; - - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; - if (newton_pair || j < nlocal) { - f[j][0] -= delx*fpair; - f[j][1] -= dely*fpair; - f[j][2] -= delz*fpair; - } - - if (eflag) { - if (rsq < cut_coulsq) { - ecoul = qqrd2e * qtmp*q[j]* + } else forcecoul = 0.0; + + if (rsq < cut_ljsq) { + r6inv = r2inv*r2inv*r2inv; + jtype = type[j]; + forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); + if (rsq > cut_lj_innersq) { + switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) * + (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; + forcelj = forcelj*switch1; + } + } else forcelj = 0.0; + + fpair = (factor_coul*forcecoul + factor_lj*forcelj) * r2inv; + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + + if (eflag) { + if (rsq < cut_coulsq) { + ecoul = qqrd2e * qtmp*q[j]* (sqrt(r2inv) + cut_coulinv*cut_coulinv*r - 2.0*cut_coulinv); - ecoul *= factor_coul; - } else ecoul = 0.0; - if (rsq < cut_ljsq) { + ecoul *= factor_coul; + } else ecoul = 0.0; + if (rsq < cut_ljsq) { if (rsq > cut_lj_innersq) { rinv = 1.0/r; r3inv = rinv*rinv*rinv; @@ -197,12 +197,12 @@ void PairLJCharmmfswCoulCharmmfsh::compute(int eflag, int vflag) lj4[itype][jtype]*cut_lj_inner3inv*cut_lj3inv; evdwl = evdwl12 + evdwl6; } - evdwl *= factor_lj; - } else evdwl = 0.0; - } + evdwl *= factor_lj; + } else evdwl = 0.0; + } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair, + evdwl,ecoul,fpair,delx,dely,delz); } } } @@ -345,10 +345,10 @@ double PairLJCharmmfswCoulCharmmfsh::init_one(int i, int j) { if (setflag[i][j] == 0) { epsilon[i][j] = mix_energy(epsilon[i][i],epsilon[j][j], - sigma[i][i],sigma[j][j]); + sigma[i][i],sigma[j][j]); sigma[i][j] = mix_distance(sigma[i][i],sigma[j][j]); eps14[i][j] = mix_energy(eps14[i][i],eps14[j][j], - sigma14[i][i],sigma14[j][j]); + sigma14[i][i],sigma14[j][j]); sigma14[i][j] = mix_distance(sigma14[i][i],sigma14[j][j]); } @@ -437,16 +437,16 @@ void PairLJCharmmfswCoulCharmmfsh::read_restart(FILE *fp) if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); if (setflag[i][j]) { - if (me == 0) { - fread(&epsilon[i][j],sizeof(double),1,fp); - fread(&sigma[i][j],sizeof(double),1,fp); - fread(&eps14[i][j],sizeof(double),1,fp); - fread(&sigma14[i][j],sizeof(double),1,fp); - } - MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&eps14[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&sigma14[i][j],1,MPI_DOUBLE,0,world); + if (me == 0) { + fread(&epsilon[i][j],sizeof(double),1,fp); + fread(&sigma[i][j],sizeof(double),1,fp); + fread(&eps14[i][j],sizeof(double),1,fp); + fread(&sigma14[i][j],sizeof(double),1,fp); + } + MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&eps14[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&sigma14[i][j],1,MPI_DOUBLE,0,world); } } } @@ -508,7 +508,7 @@ single(int i, int j, int itype, int jtype, forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); if (rsq > cut_lj_innersq) { switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) * - (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; + (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; forcelj = forcelj*switch1; } } else forcelj = 0.0; diff --git a/src/MPIIO/dump_cfg_mpiio.cpp b/src/MPIIO/dump_cfg_mpiio.cpp index 50683ecf64..1cca047bb2 100644 --- a/src/MPIIO/dump_cfg_mpiio.cpp +++ b/src/MPIIO/dump_cfg_mpiio.cpp @@ -137,10 +137,10 @@ void DumpCFGMPIIO::write() { #ifdef LMP_USER_IO_TIMER - long startTimeBase, endTimeBase; - MPI_Barrier(world); // timestamp barrier - if (me == 0) - startTimeBase = GetTimeBase(); + long startTimeBase, endTimeBase; + MPI_Barrier(world); // timestamp barrier + if (me == 0) + startTimeBase = GetTimeBase(); #endif if (domain->triclinic == 0) { @@ -211,23 +211,23 @@ void DumpCFGMPIIO::write() MPI_Bcast(&sumFileSize, 1, MPI_LMP_BIGINT, (nprocs-1), world); #ifdef LMP_USER_IO_TIMER - MPI_Barrier(world); // timestamp barrier - dumpCFGTimestamps[0] = GetTimeBase(); + MPI_Barrier(world); // timestamp barrier + dumpCFGTimestamps[0] = GetTimeBase(); #endif openfile(); #ifdef LMP_USER_IO_TIMER - MPI_Barrier(world); // timestamp barrier - dumpCFGTimestamps[1] = GetTimeBase(); + MPI_Barrier(world); // timestamp barrier + dumpCFGTimestamps[1] = GetTimeBase(); #endif performEstimate = 0; write_header(nheader); // mpifo now points to end of header info #ifdef LMP_USER_IO_TIMER - MPI_Barrier(world); // timestamp barrier - dumpCFGTimestamps[2] = GetTimeBase(); + MPI_Barrier(world); // timestamp barrier + dumpCFGTimestamps[2] = GetTimeBase(); #endif // now actually write the data @@ -235,20 +235,20 @@ void DumpCFGMPIIO::write() write_data(nme,buf); #ifdef LMP_USER_IO_TIMER - MPI_Barrier(world); // timestamp barrier - dumpCFGTimestamps[3] = GetTimeBase(); + MPI_Barrier(world); // timestamp barrier + dumpCFGTimestamps[3] = GetTimeBase(); #endif if (multifile) MPI_File_close(&mpifh); if (multifile) delete [] filecurrent; #ifdef LMP_USER_IO_TIMER - MPI_Barrier(world); // timestamp barrier - dumpCFGTimestamps[4] = GetTimeBase(); - if (me == 0) { - endTimeBase = GetTimeBase(); - printf("total dump cycles: %ld - estimates and setup: %ld openfile: %ld write header: %ld write data: %ld close file: %ld\n",(long) (endTimeBase-startTimeBase),(long) (dumpCFGTimestamps[0]-startTimeBase),(long) (dumpCFGTimestamps[1]-dumpCFGTimestamps[0]),(long) (dumpCFGTimestamps[2]-dumpCFGTimestamps[1]),(long) (dumpCFGTimestamps[3]-dumpCFGTimestamps[2]),(long) (dumpCFGTimestamps[4]-dumpCFGTimestamps[3])); - } + MPI_Barrier(world); // timestamp barrier + dumpCFGTimestamps[4] = GetTimeBase(); + if (me == 0) { + endTimeBase = GetTimeBase(); + printf("total dump cycles: %ld - estimates and setup: %ld openfile: %ld write header: %ld write data: %ld close file: %ld\n",(long) (endTimeBase-startTimeBase),(long) (dumpCFGTimestamps[0]-startTimeBase),(long) (dumpCFGTimestamps[1]-dumpCFGTimestamps[0]),(long) (dumpCFGTimestamps[2]-dumpCFGTimestamps[1]),(long) (dumpCFGTimestamps[3]-dumpCFGTimestamps[2]),(long) (dumpCFGTimestamps[4]-dumpCFGTimestamps[3])); + } #endif } @@ -401,10 +401,10 @@ int DumpCFGMPIIO::convert_string_omp(int n, double *mybuf) for (int j = 0; j < size_one; j++) { double unwrap_coord; if (j == 0) { - //offset += sprintf(&sbuf[offset],"%f \n",mybuf[m]); + //offset += sprintf(&sbuf[offset],"%f \n",mybuf[m]); mpifhStringCountPerThread[tid] += sprintf(&(mpifh_buffer_line_per_thread[tid][mpifhStringCountPerThread[tid]]),"%f \n",mybuf[bufOffset[tid]+m]); } else if (j == 1) { - // offset += sprintf(&sbuf[offset],"%s \n",typenames[(int) mybuf[m]]); + // offset += sprintf(&sbuf[offset],"%s \n",typenames[(int) mybuf[m]]); mpifhStringCountPerThread[tid] += sprintf(&(mpifh_buffer_line_per_thread[tid][mpifhStringCountPerThread[tid]]),"%s \n",typenames[(int) mybuf[bufOffset[tid]+m]]); } else if (j >= 2 && j <= 4) { unwrap_coord = (mybuf[bufOffset[tid]+m] - 0.5)/UNWRAPEXPAND + 0.5; diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index 5408db650b..43e9a9c874 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -79,7 +79,7 @@ void FixQEqDynamic::init() if (tolerance < 1e-4) if (comm->me == 0) error->warning(FLERR,"Fix qeq/dynamic tolerance may be too small" - " for damped dynamics"); + " for damped dynamics"); if (strstr(update->integrate_style,"respa")) nlevels_respa = ((Respa *) update->integrate)->nlevels; @@ -161,7 +161,7 @@ void FixQEqDynamic::pre_force(int vflag) if (iloop == maxiter) { char str[128]; sprintf(str,"Charges did not converge at step " BIGINT_FORMAT - ": %lg",update->ntimestep,enegchk); + ": %lg",update->ntimestep,enegchk); error->warning(FLERR,str); } } @@ -211,7 +211,7 @@ double FixQEqDynamic::compute_eneg() for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; - j &= NEIGHMASK; + j &= NEIGHMASK; delr[0] = x[i][0] - x[j][0]; delr[1] = x[i][1] - x[j][1]; @@ -221,9 +221,9 @@ double FixQEqDynamic::compute_eneg() if (rsq > cutoff_sq) continue; r = sqrt(rsq); - rinv = 1.0/r; - qf[i] += q[j] * rinv; - qf[j] += q[i] * rinv; + rinv = 1.0/r; + qf[i] += q[j] * rinv; + qf[j] += q[i] * rinv; } } } diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index 2404ae536d..763a39e82e 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -92,7 +92,7 @@ void FixQEqFire::init() if (tolerance < 1e-4) if (comm->me == 0) error->warning(FLERR,"Fix qeq/fire tolerance may be too small" - " for damped fires"); + " for damped fires"); if (strstr(update->integrate_style,"respa")) nlevels_respa = ((Respa *) update->integrate)->nlevels; @@ -152,7 +152,7 @@ void FixQEqFire::pre_force(int vflag) for (ii = 0; ii < inum; ii++) { i = ilist[ii]; - qf[i] -= enegtot; // Enforce adiabatic + qf[i] -= enegtot; // Enforce adiabatic } // FIRE minimization algorithm @@ -192,7 +192,7 @@ void FixQEqFire::pre_force(int vflag) alpha = ALPHA0; for (ii = 0; ii < inum; ii++) { i = ilist[ii]; - qv[i] = 0.0; + qv[i] = 0.0; } } @@ -225,7 +225,7 @@ void FixQEqFire::pre_force(int vflag) if (iloop == maxiter) { char str[128]; sprintf(str,"Charges did not converge at step " BIGINT_FORMAT - ": %lg",update->ntimestep,enegchk); + ": %lg",update->ntimestep,enegchk); error->warning(FLERR,str); } } @@ -275,7 +275,7 @@ double FixQEqFire::compute_eneg() for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; - j &= NEIGHMASK; + j &= NEIGHMASK; delr[0] = x[i][0] - x[j][0]; delr[1] = x[i][1] - x[j][1]; @@ -285,9 +285,9 @@ double FixQEqFire::compute_eneg() if (rsq > cutoff_sq) continue; r = sqrt(rsq); - rinv = 1.0/r; - qf[i] += q[j] * rinv; - qf[j] += q[i] * rinv; + rinv = 1.0/r; + qf[i] += q[j] * rinv; + qf[j] += q[i] * rinv; } } } diff --git a/src/QEQ/fix_qeq_point.cpp b/src/QEQ/fix_qeq_point.cpp index 63d20ad911..906f737991 100644 --- a/src/QEQ/fix_qeq_point.cpp +++ b/src/QEQ/fix_qeq_point.cpp @@ -79,8 +79,8 @@ void FixQEqPoint::pre_force(int vflag) reallocate_matrix(); init_matvec(); - matvecs = CG(b_s, s); // CG on s - parallel - matvecs += CG(b_t, t); // CG on t - parallel + matvecs = CG(b_s, s); // CG on s - parallel + matvecs += CG(b_t, t); // CG on t - parallel calculate_Q(); if (force->kspace) force->kspace->qsum_qsq(); @@ -143,16 +143,16 @@ void FixQEqPoint::compute_H() for( jj = 0; jj < jnum; jj++ ) { j = jlist[jj]; - j &= NEIGHMASK; + j &= NEIGHMASK; dx = x[j][0] - x[i][0]; dy = x[j][1] - x[i][1]; dz = x[j][2] - x[i][2]; r_sqr = dx*dx + dy*dy + dz*dz; - if (r_sqr <= cutoff_sq) { + if (r_sqr <= cutoff_sq) { H.jlist[m_fill] = j; - r = sqrt(r_sqr); + r = sqrt(r_sqr); H.val[m_fill] = 0.5/r; m_fill++; } diff --git a/src/QEQ/fix_qeq_shielded.cpp b/src/QEQ/fix_qeq_shielded.cpp index a5e0324d69..e23384b1c9 100644 --- a/src/QEQ/fix_qeq_shielded.cpp +++ b/src/QEQ/fix_qeq_shielded.cpp @@ -123,8 +123,8 @@ void FixQEqShielded::pre_force(int vflag) reallocate_matrix(); init_matvec(); - matvecs = CG(b_s, s); // CG on s - parallel - matvecs += CG(b_t, t); // CG on t - parallel + matvecs = CG(b_s, s); // CG on s - parallel + matvecs += CG(b_t, t); // CG on t - parallel calculate_Q(); if (force->kspace) force->kspace->qsum_qsq(); @@ -189,16 +189,16 @@ void FixQEqShielded::compute_H() for( jj = 0; jj < jnum; jj++ ) { j = jlist[jj]; - j &= NEIGHMASK; + j &= NEIGHMASK; dx = x[j][0] - x[i][0]; dy = x[j][1] - x[i][1]; dz = x[j][2] - x[i][2]; r_sqr = dx*dx + dy*dy + dz*dz; - if (r_sqr <= cutoff_sq) { + if (r_sqr <= cutoff_sq) { H.jlist[m_fill] = j; - r = sqrt(r_sqr); + r = sqrt(r_sqr); H.val[m_fill] = 0.5 * calculate_H( r, shld[type[i]][type[j]] ); m_fill++; } diff --git a/src/QEQ/fix_qeq_slater.cpp b/src/QEQ/fix_qeq_slater.cpp index 44e1a0750b..544b9f037a 100644 --- a/src/QEQ/fix_qeq_slater.cpp +++ b/src/QEQ/fix_qeq_slater.cpp @@ -101,7 +101,7 @@ void FixQEqSlater::extract_streitz() if (chi == NULL || eta == NULL || gamma == NULL || zeta == NULL || zcore == NULL) error->all(FLERR, - "Fix qeq/slater could not extract params from pair coul/streitz"); + "Fix qeq/slater could not extract params from pair coul/streitz"); } @@ -120,8 +120,8 @@ void FixQEqSlater::pre_force(int vflag) reallocate_matrix(); init_matvec(); - matvecs = CG(b_s, s); // CG on s - parallel - matvecs += CG(b_t, t); // CG on t - parallel + matvecs = CG(b_s, s); // CG on s - parallel + matvecs += CG(b_t, t); // CG on t - parallel calculate_Q(); if (force->kspace) force->kspace->qsum_qsq(); @@ -223,7 +223,7 @@ void FixQEqSlater::compute_H() /* ---------------------------------------------------------------------- */ double FixQEqSlater::calculate_H(double zei, double zej, double zj, - double r, double &zjtmp) + double r, double &zjtmp) { double rinv = 1.0/r; @@ -276,7 +276,7 @@ double FixQEqSlater::calculate_H(double zei, double zej, double zj, /* ---------------------------------------------------------------------- */ double FixQEqSlater::calculate_H_wolf(double zei, double zej, double zj, - double r, double &zjtmp) + double r, double &zjtmp) { double rinv = 1.0/r; @@ -321,7 +321,7 @@ double FixQEqSlater::calculate_H_wolf(double zei, double zej, double zj, if (zei == zej) { eshift = -exp2zirsh*(rcinv + zei*(sm1 + sm2*zei*rc + sm3*zei2*rc*rc)); ci_fifj = -exp2zir*(rinv + zei*(sm1 + sm2*zei*r + sm3*zei2*r*r)) - - eshift - (r-rc)*fshift; + - eshift - (r-rc)*fshift; } else { e1 = zei*zej4/((zei+zej)*(zei+zej)*(zei-zej)*(zei-zej)); e2 = zej*zei4/((zei+zej)*(zei+zej)*(zej-zei)*(zej-zei)); @@ -332,7 +332,7 @@ double FixQEqSlater::calculate_H_wolf(double zei, double zej, double zj, eshift = -exp2zirsh*(e1+e3/rc) - exp2zjrsh*(e2+e4/rc); ci_fifj = -exp2zir*(e1+e3/r) - exp2zjr*(e2+e4/r) - - eshift - (r-rc)*fshift; + - eshift - (r-rc)*fshift; } etmp1 = erfcr/r - erfcrc/rc; diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index 33a4b441fd..630c89fe93 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -440,8 +440,8 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) : force->numeric(FLERR,arg[iarg+3]); p_flag[0] = p_flag[1] = p_flag[2] = 1; if (dimension == 2) { - p_start[2] = p_stop[2] = p_period[2] = 0.0; - p_flag[2] = 0; + p_start[2] = p_stop[2] = p_period[2] = 0.0; + p_flag[2] = 0; } iarg += 4; @@ -457,8 +457,8 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) : force->numeric(FLERR,arg[iarg+3]); p_flag[0] = p_flag[1] = p_flag[2] = 1; if (dimension == 2) { - p_start[2] = p_stop[2] = p_period[2] = 0.0; - p_flag[2] = 0; + p_start[2] = p_stop[2] = p_period[2] = 0.0; + p_flag[2] = 0; } iarg += 4; diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index e6083f6493..6eb2a2cc23 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -267,7 +267,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : if (iarg+4 > narg) error->all(FLERR,"Illegal fix rigid/small command"); if (strcmp(style,"rigid/npt/small") != 0 && strcmp(style,"rigid/nph/small") != 0) - error->all(FLERR,"Illegal fix rigid/small command"); + error->all(FLERR,"Illegal fix rigid/small command"); pcouple = XYZ; p_start[0] = p_start[1] = p_start[2] = force->numeric(FLERR,arg[iarg+1]); p_stop[0] = p_stop[1] = p_stop[2] = force->numeric(FLERR,arg[iarg+2]); @@ -275,8 +275,8 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : force->numeric(FLERR,arg[iarg+3]); p_flag[0] = p_flag[1] = p_flag[2] = 1; if (domain->dimension == 2) { - p_start[2] = p_stop[2] = p_period[2] = 0.0; - p_flag[2] = 0; + p_start[2] = p_stop[2] = p_period[2] = 0.0; + p_flag[2] = 0; } iarg += 4; @@ -284,15 +284,15 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : if (iarg+4 > narg) error->all(FLERR,"Illegal fix rigid/small command"); if (strcmp(style,"rigid/npt/small") != 0 && strcmp(style,"rigid/nph/small") != 0) - error->all(FLERR,"Illegal fix rigid/small command"); + error->all(FLERR,"Illegal fix rigid/small command"); p_start[0] = p_start[1] = p_start[2] = force->numeric(FLERR,arg[iarg+1]); p_stop[0] = p_stop[1] = p_stop[2] = force->numeric(FLERR,arg[iarg+2]); p_period[0] = p_period[1] = p_period[2] = force->numeric(FLERR,arg[iarg+3]); p_flag[0] = p_flag[1] = p_flag[2] = 1; if (domain->dimension == 2) { - p_start[2] = p_stop[2] = p_period[2] = 0.0; - p_flag[2] = 0; + p_start[2] = p_stop[2] = p_period[2] = 0.0; + p_flag[2] = 0; } iarg += 4; diff --git a/src/SNAP/compute_sna_atom.cpp b/src/SNAP/compute_sna_atom.cpp index 5341d16efa..75b08f08bf 100644 --- a/src/SNAP/compute_sna_atom.cpp +++ b/src/SNAP/compute_sna_atom.cpp @@ -87,29 +87,29 @@ ComputeSNAAtom::ComputeSNAAtom(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"diagonal") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute sna/atom command"); + error->all(FLERR,"Illegal compute sna/atom command"); diagonalstyle = atoi(arg[iarg+1]); if (diagonalstyle < 0 || diagonalstyle > 3) - error->all(FLERR,"Illegal compute sna/atom command"); + error->all(FLERR,"Illegal compute sna/atom command"); iarg += 2; } else if (strcmp(arg[iarg],"rmin0") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute sna/atom command"); + error->all(FLERR,"Illegal compute sna/atom command"); rmin0 = atof(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"switchflag") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute sna/atom command"); + error->all(FLERR,"Illegal compute sna/atom command"); switchflag = atoi(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"bzeroflag") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute sna/atom command"); + error->all(FLERR,"Illegal compute sna/atom command"); bzeroflag = atoi(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"quadraticflag") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute sna/atom command"); + error->all(FLERR,"Illegal compute sna/atom command"); quadraticflag = atoi(arg[iarg+1]); iarg += 2; } else error->all(FLERR,"Illegal compute sna/atom command"); @@ -246,23 +246,23 @@ void ComputeSNAAtom::compute_peratom() int ninside = 0; for (int jj = 0; jj < jnum; jj++) { - int j = jlist[jj]; - j &= NEIGHMASK; - - const double delx = xtmp - x[j][0]; - const double dely = ytmp - x[j][1]; - const double delz = ztmp - x[j][2]; - const double rsq = delx*delx + dely*dely + delz*delz; - int jtype = type[j]; - if (rsq < cutsq[itype][jtype] && rsq>1e-20) { - snaptr[tid]->rij[ninside][0] = delx; - snaptr[tid]->rij[ninside][1] = dely; - snaptr[tid]->rij[ninside][2] = delz; - snaptr[tid]->inside[ninside] = j; - snaptr[tid]->wj[ninside] = wjelem[jtype]; - snaptr[tid]->rcutij[ninside] = (radi+radelem[jtype])*rcutfac; - ninside++; - } + int j = jlist[jj]; + j &= NEIGHMASK; + + const double delx = xtmp - x[j][0]; + const double dely = ytmp - x[j][1]; + const double delz = ztmp - x[j][2]; + const double rsq = delx*delx + dely*dely + delz*delz; + int jtype = type[j]; + if (rsq < cutsq[itype][jtype] && rsq>1e-20) { + snaptr[tid]->rij[ninside][0] = delx; + snaptr[tid]->rij[ninside][1] = dely; + snaptr[tid]->rij[ninside][2] = delz; + snaptr[tid]->inside[ninside] = j; + snaptr[tid]->wj[ninside] = wjelem[jtype]; + snaptr[tid]->rcutij[ninside] = (radi+radelem[jtype])*rcutfac; + ninside++; + } } snaptr[tid]->compute_ui(ninside); @@ -270,7 +270,7 @@ void ComputeSNAAtom::compute_peratom() snaptr[tid]->compute_bi(); snaptr[tid]->copy_bi2bvec(); for (int icoeff = 0; icoeff < ncoeff; icoeff++) - sna[i][icoeff] = snaptr[tid]->bvec[icoeff]; + sna[i][icoeff] = snaptr[tid]->bvec[icoeff]; if (quadraticflag) { int ncount = ncoeff; for (int icoeff = 0; icoeff < ncoeff; icoeff++) { @@ -284,7 +284,7 @@ void ComputeSNAAtom::compute_peratom() } } else { for (int icoeff = 0; icoeff < size_peratom_cols; icoeff++) - sna[i][icoeff] = 0.0; + sna[i][icoeff] = 0.0; } } } diff --git a/src/SNAP/compute_snad_atom.cpp b/src/SNAP/compute_snad_atom.cpp index c2ac5f5afd..0f522edf82 100644 --- a/src/SNAP/compute_snad_atom.cpp +++ b/src/SNAP/compute_snad_atom.cpp @@ -85,10 +85,10 @@ ComputeSNADAtom::ComputeSNADAtom(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"diagonal") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute snad/atom command"); + error->all(FLERR,"Illegal compute snad/atom command"); diagonalstyle = atof(arg[iarg+1]); if (diagonalstyle < 0 || diagonalstyle > 3) - error->all(FLERR,"Illegal compute snad/atom command"); + error->all(FLERR,"Illegal compute snad/atom command"); iarg += 2; } else if (strcmp(arg[iarg],"rmin0") == 0) { if (iarg+2 > narg) @@ -97,12 +97,12 @@ ComputeSNADAtom::ComputeSNADAtom(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"switchflag") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute snad/atom command"); + error->all(FLERR,"Illegal compute snad/atom command"); switchflag = atoi(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"quadraticflag") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute snad/atom command"); + error->all(FLERR,"Illegal compute snad/atom command"); quadraticflag = atoi(arg[iarg+1]); iarg += 2; } else error->all(FLERR,"Illegal compute snad/atom command"); @@ -205,7 +205,7 @@ void ComputeSNADAtom::compute_peratom() memory->destroy(snad); nmax = atom->nmax; memory->create(snad,nmax,size_peratom_cols, - "snad/atom:snad"); + "snad/atom:snad"); array_atom = snad; } @@ -263,23 +263,23 @@ void ComputeSNADAtom::compute_peratom() int ninside = 0; for (int jj = 0; jj < jnum; jj++) { - int j = jlist[jj]; - j &= NEIGHMASK; + int j = jlist[jj]; + j &= NEIGHMASK; - const double delx = x[j][0] - xtmp; - const double dely = x[j][1] - ytmp; - const double delz = x[j][2] - ztmp; - const double rsq = delx*delx + dely*dely + delz*delz; + const double delx = x[j][0] - xtmp; + const double dely = x[j][1] - ytmp; + const double delz = x[j][2] - ztmp; + const double rsq = delx*delx + dely*dely + delz*delz; int jtype = type[j]; - if (rsq < cutsq[itype][jtype]&&rsq>1e-20) { - snaptr[tid]->rij[ninside][0] = delx; - snaptr[tid]->rij[ninside][1] = dely; - snaptr[tid]->rij[ninside][2] = delz; - snaptr[tid]->inside[ninside] = j; - snaptr[tid]->wj[ninside] = wjelem[jtype]; - snaptr[tid]->rcutij[ninside] = (radi+radelem[jtype])*rcutfac; - ninside++; - } + if (rsq < cutsq[itype][jtype]&&rsq>1e-20) { + snaptr[tid]->rij[ninside][0] = delx; + snaptr[tid]->rij[ninside][1] = dely; + snaptr[tid]->rij[ninside][2] = delz; + snaptr[tid]->inside[ninside] = j; + snaptr[tid]->wj[ninside] = wjelem[jtype]; + snaptr[tid]->rcutij[ninside] = (radi+radelem[jtype])*rcutfac; + ninside++; + } } snaptr[tid]->compute_ui(ninside); @@ -290,26 +290,26 @@ void ComputeSNADAtom::compute_peratom() } for (int jj = 0; jj < ninside; jj++) { - const int j = snaptr[tid]->inside[jj]; - snaptr[tid]->compute_duidrj(snaptr[tid]->rij[jj], - snaptr[tid]->wj[jj], - snaptr[tid]->rcutij[jj]); - snaptr[tid]->compute_dbidrj(); - snaptr[tid]->copy_dbi2dbvec(); - - // Accumulate -dBi/dRi, -dBi/dRj - - double *snadi = snad[i]+typeoffset; - double *snadj = snad[j]+typeoffset; - - for (int icoeff = 0; icoeff < ncoeff; icoeff++) { - snadi[icoeff] += snaptr[tid]->dbvec[icoeff][0]; - snadi[icoeff+ncoeff] += snaptr[tid]->dbvec[icoeff][1]; - snadi[icoeff+twoncoeff] += snaptr[tid]->dbvec[icoeff][2]; - snadj[icoeff] -= snaptr[tid]->dbvec[icoeff][0]; - snadj[icoeff+ncoeff] -= snaptr[tid]->dbvec[icoeff][1]; - snadj[icoeff+twoncoeff] -= snaptr[tid]->dbvec[icoeff][2]; - } + const int j = snaptr[tid]->inside[jj]; + snaptr[tid]->compute_duidrj(snaptr[tid]->rij[jj], + snaptr[tid]->wj[jj], + snaptr[tid]->rcutij[jj]); + snaptr[tid]->compute_dbidrj(); + snaptr[tid]->copy_dbi2dbvec(); + + // Accumulate -dBi/dRi, -dBi/dRj + + double *snadi = snad[i]+typeoffset; + double *snadj = snad[j]+typeoffset; + + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { + snadi[icoeff] += snaptr[tid]->dbvec[icoeff][0]; + snadi[icoeff+ncoeff] += snaptr[tid]->dbvec[icoeff][1]; + snadi[icoeff+twoncoeff] += snaptr[tid]->dbvec[icoeff][2]; + snadj[icoeff] -= snaptr[tid]->dbvec[icoeff][0]; + snadj[icoeff+ncoeff] -= snaptr[tid]->dbvec[icoeff][1]; + snadj[icoeff+twoncoeff] -= snaptr[tid]->dbvec[icoeff][2]; + } if (quadraticflag) { double *snadi = snad[i]+quadraticoffset; diff --git a/src/SNAP/compute_snav_atom.cpp b/src/SNAP/compute_snav_atom.cpp index 3b5383ddf4..f284ddab0b 100644 --- a/src/SNAP/compute_snav_atom.cpp +++ b/src/SNAP/compute_snav_atom.cpp @@ -81,24 +81,24 @@ ComputeSNAVAtom::ComputeSNAVAtom(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"diagonal") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute snav/atom command"); + error->all(FLERR,"Illegal compute snav/atom command"); diagonalstyle = atof(arg[iarg+1]); if (diagonalstyle < 0 || diagonalstyle > 3) - error->all(FLERR,"Illegal compute snav/atom command"); + error->all(FLERR,"Illegal compute snav/atom command"); iarg += 2; } else if (strcmp(arg[iarg],"rmin0") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute snav/atom command"); + error->all(FLERR,"Illegal compute snav/atom command"); rmin0 = atof(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"switchflag") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute snav/atom command"); + error->all(FLERR,"Illegal compute snav/atom command"); switchflag = atoi(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"quadraticflag") == 0) { if (iarg+2 > narg) - error->all(FLERR,"Illegal compute snav/atom command"); + error->all(FLERR,"Illegal compute snav/atom command"); quadraticflag = atoi(arg[iarg+1]); iarg += 2; } else error->all(FLERR,"Illegal compute snav/atom command"); @@ -208,7 +208,7 @@ void ComputeSNAVAtom::compute_peratom() memory->destroy(snav); nmax = atom->nmax; memory->create(snav,nmax,size_peratom_cols, - "snav/atom:snav"); + "snav/atom:snav"); array_atom = snav; } @@ -257,7 +257,7 @@ void ComputeSNAVAtom::compute_peratom() // insure rij, inside, and typej are of size jnum - snaptr[tid]->grow_rij(jnum); + snaptr[tid]->grow_rij(jnum); // rij[][3] = displacements between atom I and those neighbors // inside = indices of neighbors of I within cutoff @@ -266,23 +266,23 @@ void ComputeSNAVAtom::compute_peratom() int ninside = 0; for (int jj = 0; jj < jnum; jj++) { - int j = jlist[jj]; - j &= NEIGHMASK; - - const double delx = x[j][0] - xtmp; - const double dely = x[j][1] - ytmp; - const double delz = x[j][2] - ztmp; - const double rsq = delx*delx + dely*dely + delz*delz; - int jtype = type[j]; - if (rsq < cutsq[itype][jtype]&&rsq>1e-20) { - snaptr[tid]->rij[ninside][0] = delx; - snaptr[tid]->rij[ninside][1] = dely; - snaptr[tid]->rij[ninside][2] = delz; - snaptr[tid]->inside[ninside] = j; - snaptr[tid]->wj[ninside] = wjelem[jtype]; - snaptr[tid]->rcutij[ninside] = (radi+radelem[jtype])*rcutfac; - ninside++; - } + int j = jlist[jj]; + j &= NEIGHMASK; + + const double delx = x[j][0] - xtmp; + const double dely = x[j][1] - ytmp; + const double delz = x[j][2] - ztmp; + const double rsq = delx*delx + dely*dely + delz*delz; + int jtype = type[j]; + if (rsq < cutsq[itype][jtype]&&rsq>1e-20) { + snaptr[tid]->rij[ninside][0] = delx; + snaptr[tid]->rij[ninside][1] = dely; + snaptr[tid]->rij[ninside][2] = delz; + snaptr[tid]->inside[ninside] = j; + snaptr[tid]->wj[ninside] = wjelem[jtype]; + snaptr[tid]->rcutij[ninside] = (radi+radelem[jtype])*rcutfac; + ninside++; + } } snaptr[tid]->compute_ui(ninside); @@ -293,33 +293,33 @@ void ComputeSNAVAtom::compute_peratom() } for (int jj = 0; jj < ninside; jj++) { - const int j = snaptr[tid]->inside[jj]; - - snaptr[tid]->compute_duidrj(snaptr[tid]->rij[jj], - snaptr[tid]->wj[jj], - snaptr[tid]->rcutij[jj]); - snaptr[tid]->compute_dbidrj(); - snaptr[tid]->copy_dbi2dbvec(); - - // Accumulate -dBi/dRi*Ri, -dBi/dRj*Rj - - double *snavi = snav[i]+typeoffset; - double *snavj = snav[j]+typeoffset; - - for (int icoeff = 0; icoeff < ncoeff; icoeff++) { - snavi[icoeff] += snaptr[tid]->dbvec[icoeff][0]*xtmp; - snavi[icoeff+ncoeff] += snaptr[tid]->dbvec[icoeff][1]*ytmp; - snavi[icoeff+twoncoeff] += snaptr[tid]->dbvec[icoeff][2]*ztmp; - snavi[icoeff+threencoeff] += snaptr[tid]->dbvec[icoeff][1]*ztmp; - snavi[icoeff+fourncoeff] += snaptr[tid]->dbvec[icoeff][0]*ztmp; - snavi[icoeff+fivencoeff] += snaptr[tid]->dbvec[icoeff][0]*ytmp; - snavj[icoeff] -= snaptr[tid]->dbvec[icoeff][0]*x[j][0]; - snavj[icoeff+ncoeff] -= snaptr[tid]->dbvec[icoeff][1]*x[j][1]; - snavj[icoeff+twoncoeff] -= snaptr[tid]->dbvec[icoeff][2]*x[j][2]; - snavj[icoeff+threencoeff] -= snaptr[tid]->dbvec[icoeff][1]*x[j][2]; - snavj[icoeff+fourncoeff] -= snaptr[tid]->dbvec[icoeff][0]*x[j][2]; - snavj[icoeff+fivencoeff] -= snaptr[tid]->dbvec[icoeff][0]*x[j][1]; - } + const int j = snaptr[tid]->inside[jj]; + + snaptr[tid]->compute_duidrj(snaptr[tid]->rij[jj], + snaptr[tid]->wj[jj], + snaptr[tid]->rcutij[jj]); + snaptr[tid]->compute_dbidrj(); + snaptr[tid]->copy_dbi2dbvec(); + + // Accumulate -dBi/dRi*Ri, -dBi/dRj*Rj + + double *snavi = snav[i]+typeoffset; + double *snavj = snav[j]+typeoffset; + + for (int icoeff = 0; icoeff < ncoeff; icoeff++) { + snavi[icoeff] += snaptr[tid]->dbvec[icoeff][0]*xtmp; + snavi[icoeff+ncoeff] += snaptr[tid]->dbvec[icoeff][1]*ytmp; + snavi[icoeff+twoncoeff] += snaptr[tid]->dbvec[icoeff][2]*ztmp; + snavi[icoeff+threencoeff] += snaptr[tid]->dbvec[icoeff][1]*ztmp; + snavi[icoeff+fourncoeff] += snaptr[tid]->dbvec[icoeff][0]*ztmp; + snavi[icoeff+fivencoeff] += snaptr[tid]->dbvec[icoeff][0]*ytmp; + snavj[icoeff] -= snaptr[tid]->dbvec[icoeff][0]*x[j][0]; + snavj[icoeff+ncoeff] -= snaptr[tid]->dbvec[icoeff][1]*x[j][1]; + snavj[icoeff+twoncoeff] -= snaptr[tid]->dbvec[icoeff][2]*x[j][2]; + snavj[icoeff+threencoeff] -= snaptr[tid]->dbvec[icoeff][1]*x[j][2]; + snavj[icoeff+fourncoeff] -= snaptr[tid]->dbvec[icoeff][0]*x[j][2]; + snavj[icoeff+fivencoeff] -= snaptr[tid]->dbvec[icoeff][0]*x[j][1]; + } if (quadraticflag) { double *snavi = snav[i]+quadraticoffset; diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index e8e57a72a2..3de5d0c6c8 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -132,9 +132,9 @@ PairSNAP::~PairSNAP() time[i] = 0; timeave[i] = 0; for (int tid = 0; tid<nthreads; tid++) { - if (sna[tid]->timers[i]>time[i]) - time[i] = sna[tid]->timers[i]; - timeave[i] += sna[tid]->timers[i]; + if (sna[tid]->timers[i]>time[i]) + time[i] = sna[tid]->timers[i]; + timeave[i] += sna[tid]->timers[i]; } timeave[i] /= nthreads; } @@ -224,13 +224,13 @@ void PairSNAP::compute_regular(int eflag, int vflag) int jelem = map[jtype]; if (rsq < cutsq[itype][jtype]&&rsq>1e-20) { - snaptr->rij[ninside][0] = delx; - snaptr->rij[ninside][1] = dely; - snaptr->rij[ninside][2] = delz; - snaptr->inside[ninside] = j; - snaptr->wj[ninside] = wjelem[jelem]; - snaptr->rcutij[ninside] = (radi + radelem[jelem])*rcutfac; - ninside++; + snaptr->rij[ninside][0] = delx; + snaptr->rij[ninside][1] = dely; + snaptr->rij[ninside][2] = delz; + snaptr->inside[ninside] = j; + snaptr->wj[ninside] = wjelem[jelem]; + snaptr->rcutij[ninside] = (radi + radelem[jelem])*rcutfac; + ninside++; } } @@ -252,7 +252,7 @@ void PairSNAP::compute_regular(int eflag, int vflag) for (int jj = 0; jj < ninside; jj++) { int j = snaptr->inside[jj]; snaptr->compute_duidrj(snaptr->rij[jj], - snaptr->wj[jj],snaptr->rcutij[jj]); + snaptr->wj[jj],snaptr->rcutij[jj]); snaptr->compute_dbidrj(); snaptr->copy_dbi2dbvec(); @@ -264,10 +264,10 @@ void PairSNAP::compute_regular(int eflag, int vflag) // linear contributions for (int k = 1; k <= ncoeff; k++) { - double bgb = coeffi[k]; - fij[0] += bgb*snaptr->dbvec[k-1][0]; - fij[1] += bgb*snaptr->dbvec[k-1][1]; - fij[2] += bgb*snaptr->dbvec[k-1][2]; + double bgb = coeffi[k]; + fij[0] += bgb*snaptr->dbvec[k-1][0]; + fij[1] += bgb*snaptr->dbvec[k-1][1]; + fij[2] += bgb*snaptr->dbvec[k-1][2]; } // quadratic contributions @@ -305,9 +305,9 @@ void PairSNAP::compute_regular(int eflag, int vflag) if (vflag) ev_tally_xyz(i,j,nlocal,newton_pair,0.0,0.0, - fij[0],fij[1],fij[2], - -snaptr->rij[jj][0],-snaptr->rij[jj][1], - -snaptr->rij[jj][2]); + fij[0],fij[1],fij[2], + -snaptr->rij[jj][0],-snaptr->rij[jj][1], + -snaptr->rij[jj][2]); } // tally energy contribution @@ -532,8 +532,8 @@ void PairSNAP::compute_optimized(int eflag, int vflag) i = i_pairs[iijj][0]; if (iold != i) { set_sna_to_shared(tid,i_pairs[iijj][3]); - ielem = map[type[i]]; - } + ielem = map[type[i]]; + } iold = i; } else { i = pairs[iijj][0]; @@ -543,8 +543,8 @@ void PairSNAP::compute_optimized(int eflag, int vflag) const double ytmp = x[i][1]; const double ztmp = x[i][2]; const int itype = type[i]; - ielem = map[itype]; - const double radi = radelem[ielem]; + ielem = map[itype]; + const double radi = radelem[ielem]; if (i < nlocal) { jlist = firstneigh[i]; @@ -573,7 +573,7 @@ void PairSNAP::compute_optimized(int eflag, int vflag) delz = x[j][2] - ztmp; rsq = delx*delx + dely*dely + delz*delz; jtype = type[j]; - int jelem = map[jtype]; + int jelem = map[jtype]; if (rsq < cutsq[itype][jtype]&&rsq>1e-20) { //unitialised sna[tid]->rij[ninside][0] = delx; @@ -582,7 +582,7 @@ void PairSNAP::compute_optimized(int eflag, int vflag) sna[tid]->inside[ninside] = j; sna[tid]->wj[ninside] = wjelem[jelem]; sna[tid]->rcutij[ninside] = (radi + radelem[jelem])*rcutfac; - ninside++; + ninside++; // update index list with inside index pairs[iijj + (jj - pairs[iijj][1])][2] = @@ -613,7 +613,7 @@ void PairSNAP::compute_optimized(int eflag, int vflag) jj = pairs[iijj][2]; int j = sna[tid]->inside[jj]; sna[tid]->compute_duidrj(sna[tid]->rij[jj], - sna[tid]->wj[jj],sna[tid]->rcutij[jj]); + sna[tid]->wj[jj],sna[tid]->rcutij[jj]); sna[tid]->compute_dbidrj(); sna[tid]->copy_dbi2dbvec(); @@ -625,10 +625,10 @@ void PairSNAP::compute_optimized(int eflag, int vflag) // linear contributions for (k = 1; k <= ncoeff; k++) { - double bgb = coeffi[k]; - fij[0] += bgb*sna[tid]->dbvec[k-1][0]; - fij[1] += bgb*sna[tid]->dbvec[k-1][1]; - fij[2] += bgb*sna[tid]->dbvec[k-1][2]; + double bgb = coeffi[k]; + fij[0] += bgb*sna[tid]->dbvec[k-1][0]; + fij[1] += bgb*sna[tid]->dbvec[k-1][1]; + fij[2] += bgb*sna[tid]->dbvec[k-1][2]; } // quadratic contributions @@ -681,7 +681,7 @@ void PairSNAP::compute_optimized(int eflag, int vflag) // if atom has no pairs, eatom=0, which is wrong if (eflag&&pairs[iijj][1] == 0) { - evdwl = coeffi[0]; + evdwl = coeffi[0]; if (!quadraticflag) { sna[tid]->compute_bi(); @@ -1184,7 +1184,7 @@ void PairSNAP::build_per_atom_arrays() const double delz = atom->x[j][2] - ztmp; const double rsq = delx*delx + dely*dely + delz*delz; int jtype = atom->type[j]; - int jelem = map[jtype]; + int jelem = map[jtype]; i_pairs[i_numpairs][0] = i; i_pairs[i_numpairs][1] = jj; @@ -1350,40 +1350,40 @@ void PairSNAP::settings(int narg, char **arg) if (strcmp(arg[i],"loadbalance")==0) { do_load_balance = force->inumeric(FLERR,arg[++i]); if (do_load_balance) { - double mincutoff = extra_cutoff() + - rcutmax + neighbor->skin; - if (comm->cutghostuser < mincutoff) { - char buffer[255]; + double mincutoff = extra_cutoff() + + rcutmax + neighbor->skin; + if (comm->cutghostuser < mincutoff) { + char buffer[255]; - //apparently mincutoff is 0 after sprintf command ????? + //apparently mincutoff is 0 after sprintf command ????? - double tmp = mincutoff + 0.1; - sprintf(buffer, "Communication cutoff is too small " - "for SNAP micro load balancing, increased to %lf", - mincutoff+0.1); - if (comm->me==0) - error->warning(FLERR,buffer); + double tmp = mincutoff + 0.1; + sprintf(buffer, "Communication cutoff is too small " + "for SNAP micro load balancing, increased to %lf", + mincutoff+0.1); + if (comm->me==0) + error->warning(FLERR,buffer); - comm->cutghostuser = tmp; + comm->cutghostuser = tmp; - } + } } continue; } if (strcmp(arg[i],"schedule")==0) { i++; if (strcmp(arg[i],"static")==0) - schedule_user = 1; + schedule_user = 1; if (strcmp(arg[i],"dynamic")==0) - schedule_user = 2; + schedule_user = 2; if (strcmp(arg[i],"guided")==0) - schedule_user = 3; + schedule_user = 3; if (strcmp(arg[i],"auto")==0) - schedule_user = 4; + schedule_user = 4; if (strcmp(arg[i],"determine")==0) - schedule_user = 5; + schedule_user = 5; if (schedule_user == 0) - error->all(FLERR,"Illegal pair_style command"); + error->all(FLERR,"Illegal pair_style command"); continue; } error->all(FLERR,"Illegal pair_style command"); @@ -1403,9 +1403,9 @@ void PairSNAP::settings(int narg, char **arg) if (!use_optimized) if (nthreads > 1 || - use_shared_arrays || - do_load_balance || - schedule_user) + use_shared_arrays || + do_load_balance || + schedule_user) error->all(FLERR,"Illegal pair_style command"); } @@ -1484,7 +1484,7 @@ void PairSNAP::coeff(int narg, char **arg) int jelem; for (jelem = 0; jelem < nelements; jelem++) if (strcmp(elemname,elements[jelem]) == 0) - break; + break; if (jelem < nelements) map[i] = jelem; @@ -1523,7 +1523,7 @@ void PairSNAP::coeff(int narg, char **arg) int tid = omp_get_thread_num(); sna[tid] = new SNA(lmp,rfac0,twojmax, diagonalstyle,use_shared_arrays, - rmin0,switchflag,bzeroflag); + rmin0,switchflag,bzeroflag); if (!use_shared_arrays) sna[tid]->grow_rij(nmax); } @@ -1575,7 +1575,7 @@ double PairSNAP::init_one(int i, int j) { if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); return (radelem[map[i]] + - radelem[map[j]])*rcutfac; + radelem[map[j]])*rcutfac; } /* ---------------------------------------------------------------------- */ @@ -1650,8 +1650,8 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) if (comm->me == 0) { ptr = fgets(line,MAXLINE,fpcoeff); if (ptr == NULL) { - eof = 1; - fclose(fpcoeff); + eof = 1; + fclose(fpcoeff); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -1682,8 +1682,8 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) if (strcmp(elemtmp,elements[ielem]) == 0) break; if (ielem == nelements) { if (comm->me == 0) - for (int icoeff = 0; icoeff < ncoeffall; icoeff++) - ptr = fgets(line,MAXLINE,fpcoeff); + for (int icoeff = 0; icoeff < ncoeffall; icoeff++) + ptr = fgets(line,MAXLINE,fpcoeff); continue; } @@ -1691,8 +1691,8 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) if (found[ielem]) { if (comm->me == 0) - for (int icoeff = 0; icoeff < ncoeffall; icoeff++) - ptr = fgets(line,MAXLINE,fpcoeff); + for (int icoeff = 0; icoeff < ncoeffall; icoeff++) + ptr = fgets(line,MAXLINE,fpcoeff); continue; } @@ -1703,29 +1703,29 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) if (comm->me == 0) { if (screen) fprintf(screen,"SNAP Element = %s, Radius %g, Weight %g \n", - elements[ielem], radelem[ielem], wjelem[ielem]); + elements[ielem], radelem[ielem], wjelem[ielem]); if (logfile) fprintf(logfile,"SNAP Element = %s, Radius %g, Weight %g \n", - elements[ielem], radelem[ielem], wjelem[ielem]); + elements[ielem], radelem[ielem], wjelem[ielem]); } for (int icoeff = 0; icoeff < ncoeffall; icoeff++) { if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fpcoeff); - if (ptr == NULL) { - eof = 1; - fclose(fpcoeff); - } else n = strlen(line) + 1; + ptr = fgets(line,MAXLINE,fpcoeff); + if (ptr == NULL) { + eof = 1; + fclose(fpcoeff); + } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); if (eof) - error->all(FLERR,"Incorrect format in SNAP coefficient file"); + error->all(FLERR,"Incorrect format in SNAP coefficient file"); MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); nwords = atom->count_words(line); if (nwords != 1) - error->all(FLERR,"Incorrect format in SNAP coefficient file"); + error->all(FLERR,"Incorrect format in SNAP coefficient file"); iword = 0; words[iword] = strtok(line,"' \t\n\r\f"); diff --git a/src/SNAP/sna.cpp b/src/SNAP/sna.cpp index 2c20e78b71..21470876d4 100644 --- a/src/SNAP/sna.cpp +++ b/src/SNAP/sna.cpp @@ -268,12 +268,12 @@ void SNA::build_indexlist() for(int j1 = 0; j1 <= twojmax; j1++) for(int j2 = 0; j2 <= j1; j2++) for(int j = abs(j1 - j2); j <= MIN(twojmax, j1 + j2); j += 2) - if (j >= j1) { - idxj[idxj_count].j1 = j1; - idxj[idxj_count].j2 = j2; - idxj[idxj_count].j = j; - idxj_count++; - } + if (j >= j1) { + idxj[idxj_count].j1 = j1; + idxj[idxj_count].j2 = j2; + idxj[idxj_count].j = j; + idxj_count++; + } } } @@ -414,38 +414,38 @@ void SNA::compute_zi() for(int j1 = 0; j1 <= twojmax; j1++) for(int j2 = 0; j2 <= j1; j2++) { for(int j = j1 - j2; j <= MIN(twojmax, j1 + j2); j += 2) { - double sumb1_r, sumb1_i; - int ma2, mb2; - for(int mb = 0; 2*mb <= j; mb++) - for(int ma = 0; ma <= j; ma++) { - zarray_r[j1][j2][j][ma][mb] = 0.0; - zarray_i[j1][j2][j][ma][mb] = 0.0; + double sumb1_r, sumb1_i; + int ma2, mb2; + for(int mb = 0; 2*mb <= j; mb++) + for(int ma = 0; ma <= j; ma++) { + zarray_r[j1][j2][j][ma][mb] = 0.0; + zarray_i[j1][j2][j][ma][mb] = 0.0; - for(int ma1 = MAX(0, (2 * ma - j - j2 + j1) / 2); - ma1 <= MIN(j1, (2 * ma - j + j2 + j1) / 2); ma1++) { - sumb1_r = 0.0; - sumb1_i = 0.0; + for(int ma1 = MAX(0, (2 * ma - j - j2 + j1) / 2); + ma1 <= MIN(j1, (2 * ma - j + j2 + j1) / 2); ma1++) { + sumb1_r = 0.0; + sumb1_i = 0.0; - ma2 = (2 * ma - j - (2 * ma1 - j1) + j2) / 2; + ma2 = (2 * ma - j - (2 * ma1 - j1) + j2) / 2; - for(int mb1 = MAX(0, (2 * mb - j - j2 + j1) / 2); + for(int mb1 = MAX(0, (2 * mb - j - j2 + j1) / 2); mb1 <= MIN(j1, (2 * mb - j + j2 + j1) / 2); mb1++) { - mb2 = (2 * mb - j - (2 * mb1 - j1) + j2) / 2; - sumb1_r += cgarray[j1][j2][j][mb1][mb2] * - (uarraytot_r[j1][ma1][mb1] * uarraytot_r[j2][ma2][mb2] - - uarraytot_i[j1][ma1][mb1] * uarraytot_i[j2][ma2][mb2]); - sumb1_i += cgarray[j1][j2][j][mb1][mb2] * - (uarraytot_r[j1][ma1][mb1] * uarraytot_i[j2][ma2][mb2] + - uarraytot_i[j1][ma1][mb1] * uarraytot_r[j2][ma2][mb2]); - } // end loop over mb1 - - zarray_r[j1][j2][j][ma][mb] += - sumb1_r * cgarray[j1][j2][j][ma1][ma2]; - zarray_i[j1][j2][j][ma][mb] += - sumb1_i * cgarray[j1][j2][j][ma1][ma2]; - } // end loop over ma1 - } // end loop over ma, mb + mb2 = (2 * mb - j - (2 * mb1 - j1) + j2) / 2; + sumb1_r += cgarray[j1][j2][j][mb1][mb2] * + (uarraytot_r[j1][ma1][mb1] * uarraytot_r[j2][ma2][mb2] - + uarraytot_i[j1][ma1][mb1] * uarraytot_i[j2][ma2][mb2]); + sumb1_i += cgarray[j1][j2][j][mb1][mb2] * + (uarraytot_r[j1][ma1][mb1] * uarraytot_i[j2][ma2][mb2] + + uarraytot_i[j1][ma1][mb1] * uarraytot_r[j2][ma2][mb2]); + } // end loop over mb1 + + zarray_r[j1][j2][j][ma][mb] += + sumb1_r * cgarray[j1][j2][j][ma1][ma2]; + zarray_i[j1][j2][j][ma][mb] += + sumb1_i * cgarray[j1][j2][j][ma1][ma2]; + } // end loop over ma1 + } // end loop over ma, mb } // end loop over j } // end loop over j1, j2 @@ -506,11 +506,11 @@ void SNA::compute_zi_omp(int sub_threads) mb2 = (2 * mb - j - (2 * mb1 - j1) + j2) / 2; sumb1_r += cgarray[j1][j2][j][mb1][mb2] * - (uarraytot_r[j1][ma1][mb1] * uarraytot_r[j2][ma2][mb2] - - uarraytot_i[j1][ma1][mb1] * uarraytot_i[j2][ma2][mb2]); + (uarraytot_r[j1][ma1][mb1] * uarraytot_r[j2][ma2][mb2] - + uarraytot_i[j1][ma1][mb1] * uarraytot_i[j2][ma2][mb2]); sumb1_i += cgarray[j1][j2][j][mb1][mb2] * - (uarraytot_r[j1][ma1][mb1] * uarraytot_i[j2][ma2][mb2] + - uarraytot_i[j1][ma1][mb1] * uarraytot_r[j2][ma2][mb2]); + (uarraytot_r[j1][ma1][mb1] * uarraytot_i[j2][ma2][mb2] + + uarraytot_i[j1][ma1][mb1] * uarraytot_r[j2][ma2][mb2]); } zarray_r[j1][j2][j][ma][mb] += @@ -547,29 +547,29 @@ void SNA::compute_bi() j <= MIN(twojmax, j1 + j2); j += 2) { barray[j1][j2][j] = 0.0; - for(int mb = 0; 2*mb < j; mb++) - for(int ma = 0; ma <= j; ma++) + for(int mb = 0; 2*mb < j; mb++) + for(int ma = 0; ma <= j; ma++) barray[j1][j2][j] += uarraytot_r[j][ma][mb] * zarray_r[j1][j2][j][ma][mb] + - uarraytot_i[j][ma][mb] * zarray_i[j1][j2][j][ma][mb]; - - // For j even, special treatment for middle column - - if (j%2 == 0) { - int mb = j/2; - for(int ma = 0; ma < mb; ma++) - barray[j1][j2][j] += - uarraytot_r[j][ma][mb] * zarray_r[j1][j2][j][ma][mb] + - uarraytot_i[j][ma][mb] * zarray_i[j1][j2][j][ma][mb]; - int ma = mb; - barray[j1][j2][j] += - (uarraytot_r[j][ma][mb] * zarray_r[j1][j2][j][ma][mb] + - uarraytot_i[j][ma][mb] * zarray_i[j1][j2][j][ma][mb])*0.5; - } + uarraytot_i[j][ma][mb] * zarray_i[j1][j2][j][ma][mb]; + + // For j even, special treatment for middle column + + if (j%2 == 0) { + int mb = j/2; + for(int ma = 0; ma < mb; ma++) + barray[j1][j2][j] += + uarraytot_r[j][ma][mb] * zarray_r[j1][j2][j][ma][mb] + + uarraytot_i[j][ma][mb] * zarray_i[j1][j2][j][ma][mb]; + int ma = mb; + barray[j1][j2][j] += + (uarraytot_r[j][ma][mb] * zarray_r[j1][j2][j][ma][mb] + + uarraytot_i[j][ma][mb] * zarray_i[j1][j2][j][ma][mb])*0.5; + } barray[j1][j2][j] *= 2.0; - if (bzero_flag) - barray[j1][j2][j] -= bzero[j]; + if (bzero_flag) + barray[j1][j2][j] -= bzero[j]; } } @@ -614,10 +614,10 @@ void SNA::copy_bi2bvec() for(j2 = 0; j2 <= j1; j2++) for(j = abs(j1 - j2); j <= MIN(twojmax, j1 + j2); j += 2) - if (j >= j1) { - bvec[ncount] = barray[j1][j2][j]; - ncount++; - } + if (j >= j1) { + bvec[ncount] = barray[j1][j2][j]; + ncount++; + } } } @@ -874,12 +874,12 @@ void SNA::compute_dbidrj() dudr_r = duarray_r[j][ma][mb]; dudr_i = duarray_i[j][ma][mb]; - jjjmambzarray_r = jjjzarray_r[ma][mb]; - jjjmambzarray_i = jjjzarray_i[ma][mb]; + jjjmambzarray_r = jjjzarray_r[ma][mb]; + jjjmambzarray_i = jjjzarray_i[ma][mb]; for(int k = 0; k < 3; k++) sumzdu_r[k] += dudr_r[k] * jjjmambzarray_r + - dudr_i[k] * jjjmambzarray_i; + dudr_i[k] * jjjmambzarray_i; } //end loop over ma mb @@ -889,13 +889,13 @@ void SNA::compute_dbidrj() int mb = j/2; for(int ma = 0; ma < mb; ma++) { dudr_r = duarray_r[j][ma][mb]; - dudr_i = duarray_i[j][ma][mb]; - jjjmambzarray_r = jjjzarray_r[ma][mb]; - jjjmambzarray_i = jjjzarray_i[ma][mb]; + dudr_i = duarray_i[j][ma][mb]; + jjjmambzarray_r = jjjzarray_r[ma][mb]; + jjjmambzarray_i = jjjzarray_i[ma][mb]; for(int k = 0; k < 3; k++) sumzdu_r[k] += dudr_r[k] * jjjmambzarray_r + - dudr_i[k] * jjjmambzarray_i; + dudr_i[k] * jjjmambzarray_i; } int ma = mb; dudr_r = duarray_r[j][ma][mb]; @@ -903,9 +903,9 @@ void SNA::compute_dbidrj() jjjmambzarray_r = jjjzarray_r[ma][mb]; jjjmambzarray_i = jjjzarray_i[ma][mb]; for(int k = 0; k < 3; k++) - sumzdu_r[k] += - (dudr_r[k] * jjjmambzarray_r + - dudr_i[k] * jjjmambzarray_i)*0.5; + sumzdu_r[k] += + (dudr_r[k] * jjjmambzarray_r + + dudr_i[k] * jjjmambzarray_i)*0.5; } // end if jeven for(int k = 0; k < 3; k++) @@ -933,12 +933,12 @@ void SNA::compute_dbidrj() dudr_r = duarray_r[j1][ma1][mb1]; dudr_i = duarray_i[j1][ma1][mb1]; - jjjmambzarray_r = jjjzarray_r[ma1][mb1]; - jjjmambzarray_i = jjjzarray_i[ma1][mb1]; + jjjmambzarray_r = jjjzarray_r[ma1][mb1]; + jjjmambzarray_i = jjjzarray_i[ma1][mb1]; for(int k = 0; k < 3; k++) sumzdu_r[k] += dudr_r[k] * jjjmambzarray_r + - dudr_i[k] * jjjmambzarray_i; + dudr_i[k] * jjjmambzarray_i; } //end loop over ma1 mb1 @@ -948,13 +948,13 @@ void SNA::compute_dbidrj() int mb1 = j1/2; for(int ma1 = 0; ma1 < mb1; ma1++) { dudr_r = duarray_r[j1][ma1][mb1]; - dudr_i = duarray_i[j1][ma1][mb1]; - jjjmambzarray_r = jjjzarray_r[ma1][mb1]; - jjjmambzarray_i = jjjzarray_i[ma1][mb1]; + dudr_i = duarray_i[j1][ma1][mb1]; + jjjmambzarray_r = jjjzarray_r[ma1][mb1]; + jjjmambzarray_i = jjjzarray_i[ma1][mb1]; for(int k = 0; k < 3; k++) sumzdu_r[k] += dudr_r[k] * jjjmambzarray_r + - dudr_i[k] * jjjmambzarray_i; + dudr_i[k] * jjjmambzarray_i; } int ma1 = mb1; dudr_r = duarray_r[j1][ma1][mb1]; @@ -962,9 +962,9 @@ void SNA::compute_dbidrj() jjjmambzarray_r = jjjzarray_r[ma1][mb1]; jjjmambzarray_i = jjjzarray_i[ma1][mb1]; for(int k = 0; k < 3; k++) - sumzdu_r[k] += - (dudr_r[k] * jjjmambzarray_r + - dudr_i[k] * jjjmambzarray_i)*0.5; + sumzdu_r[k] += + (dudr_r[k] * jjjmambzarray_r + + dudr_i[k] * jjjmambzarray_i)*0.5; } // end if j1even for(int k = 0; k < 3; k++) @@ -992,12 +992,12 @@ void SNA::compute_dbidrj() dudr_r = duarray_r[j2][ma2][mb2]; dudr_i = duarray_i[j2][ma2][mb2]; - jjjmambzarray_r = jjjzarray_r[ma2][mb2]; - jjjmambzarray_i = jjjzarray_i[ma2][mb2]; + jjjmambzarray_r = jjjzarray_r[ma2][mb2]; + jjjmambzarray_i = jjjzarray_i[ma2][mb2]; for(int k = 0; k < 3; k++) sumzdu_r[k] += dudr_r[k] * jjjmambzarray_r + - dudr_i[k] * jjjmambzarray_i; + dudr_i[k] * jjjmambzarray_i; } //end loop over ma2 mb2 @@ -1007,13 +1007,13 @@ void SNA::compute_dbidrj() int mb2 = j2/2; for(int ma2 = 0; ma2 < mb2; ma2++) { dudr_r = duarray_r[j2][ma2][mb2]; - dudr_i = duarray_i[j2][ma2][mb2]; - jjjmambzarray_r = jjjzarray_r[ma2][mb2]; - jjjmambzarray_i = jjjzarray_i[ma2][mb2]; + dudr_i = duarray_i[j2][ma2][mb2]; + jjjmambzarray_r = jjjzarray_r[ma2][mb2]; + jjjmambzarray_i = jjjzarray_i[ma2][mb2]; for(int k = 0; k < 3; k++) sumzdu_r[k] += dudr_r[k] * jjjmambzarray_r + - dudr_i[k] * jjjmambzarray_i; + dudr_i[k] * jjjmambzarray_i; } int ma2 = mb2; dudr_r = duarray_r[j2][ma2][mb2]; @@ -1021,9 +1021,9 @@ void SNA::compute_dbidrj() jjjmambzarray_r = jjjzarray_r[ma2][mb2]; jjjmambzarray_i = jjjzarray_i[ma2][mb2]; for(int k = 0; k < 3; k++) - sumzdu_r[k] += - (dudr_r[k] * jjjmambzarray_r + - dudr_i[k] * jjjmambzarray_i)*0.5; + sumzdu_r[k] += + (dudr_r[k] * jjjmambzarray_r + + dudr_i[k] * jjjmambzarray_i)*0.5; } // end if j2even for(int k = 0; k < 3; k++) @@ -1078,12 +1078,12 @@ void SNA::copy_dbi2dbvec() for(j2 = 0; j2 <= j1; j2++) for(j = abs(j1 - j2); j <= MIN(twojmax, j1 + j2); j += 2) - if (j >= j1) { - dbvec[ncount][0] = dbarray[j1][j2][j][0]; - dbvec[ncount][1] = dbarray[j1][j2][j][1]; - dbvec[ncount][2] = dbarray[j1][j2][j][2]; - ncount++; - } + if (j >= j1) { + dbvec[ncount][0] = dbarray[j1][j2][j][0]; + dbvec[ncount][1] = dbarray[j1][j2][j][1]; + dbvec[ncount][2] = dbarray[j1][j2][j][2]; + ncount++; + } } } } @@ -1187,25 +1187,25 @@ void SNA::compute_uarray(double x, double y, double z, uarray_i[j][0][mb] = 0.0; for (int ma = 0; ma < j; ma++) { - rootpq = rootpqarray[j - ma][j - mb]; + rootpq = rootpqarray[j - ma][j - mb]; uarray_r[j][ma][mb] += rootpq * (a_r * uarray_r[j - 1][ma][mb] + - a_i * uarray_i[j - 1][ma][mb]); + a_i * uarray_i[j - 1][ma][mb]); uarray_i[j][ma][mb] += rootpq * (a_r * uarray_i[j - 1][ma][mb] - - a_i * uarray_r[j - 1][ma][mb]); + a_i * uarray_r[j - 1][ma][mb]); - rootpq = rootpqarray[ma + 1][j - mb]; + rootpq = rootpqarray[ma + 1][j - mb]; uarray_r[j][ma + 1][mb] = -rootpq * (b_r * uarray_r[j - 1][ma][mb] + - b_i * uarray_i[j - 1][ma][mb]); + b_i * uarray_i[j - 1][ma][mb]); uarray_i[j][ma + 1][mb] = -rootpq * (b_r * uarray_i[j - 1][ma][mb] - - b_i * uarray_r[j - 1][ma][mb]); + b_i * uarray_r[j - 1][ma][mb]); } } @@ -1217,14 +1217,14 @@ void SNA::compute_uarray(double x, double y, double z, mbpar = -mbpar; int mapar = -mbpar; for (int ma = 0; ma <= j; ma++) { - mapar = -mapar; - if (mapar == 1) { - uarray_r[j][j-ma][j-mb] = uarray_r[j][ma][mb]; - uarray_i[j][j-ma][j-mb] = -uarray_i[j][ma][mb]; - } else { - uarray_r[j][j-ma][j-mb] = -uarray_r[j][ma][mb]; - uarray_i[j][j-ma][j-mb] = uarray_i[j][ma][mb]; - } + mapar = -mapar; + if (mapar == 1) { + uarray_r[j][j-ma][j-mb] = uarray_r[j][ma][mb]; + uarray_i[j][j-ma][j-mb] = -uarray_i[j][ma][mb]; + } else { + uarray_r[j][j-ma][j-mb] = -uarray_r[j][ma][mb]; + uarray_i[j][j-ma][j-mb] = uarray_i[j][ma][mb]; + } } } } @@ -1259,25 +1259,25 @@ void SNA::compute_uarray_omp(double x, double y, double z, uarray_i[j][0][mb] = 0.0; for (int ma = 0; ma < j; ma++) { - rootpq = rootpqarray[j - ma][j - mb]; + rootpq = rootpqarray[j - ma][j - mb]; uarray_r[j][ma][mb] += - rootpq * + rootpq * (a_r * uarray_r[j - 1][ma][mb] + - a_i * uarray_i[j - 1][ma][mb]); + a_i * uarray_i[j - 1][ma][mb]); uarray_i[j][ma][mb] += - rootpq * + rootpq * (a_r * uarray_i[j - 1][ma][mb] - - a_i * uarray_r[j - 1][ma][mb]); + a_i * uarray_r[j - 1][ma][mb]); - rootpq = rootpqarray[ma + 1][j - mb]; + rootpq = rootpqarray[ma + 1][j - mb]; uarray_r[j][ma + 1][mb] = - -rootpq * + -rootpq * (b_r * uarray_r[j - 1][ma][mb] + - b_i * uarray_i[j - 1][ma][mb]); + b_i * uarray_i[j - 1][ma][mb]); uarray_i[j][ma + 1][mb] = - -rootpq * + -rootpq * (b_r * uarray_i[j - 1][ma][mb] - - b_i * uarray_r[j - 1][ma][mb]); + b_i * uarray_r[j - 1][ma][mb]); } } @@ -1291,23 +1291,23 @@ void SNA::compute_uarray_omp(double x, double y, double z, for (int ma = 0; ma < j; ma++) { rootpq = rootpqarray[j - ma][mb]; uarray_r[j][ma][mb] += - rootpq * + rootpq * (b_r * uarray_r[j - 1][ma][mb - 1] - - b_i * uarray_i[j - 1][ma][mb - 1]); + b_i * uarray_i[j - 1][ma][mb - 1]); uarray_i[j][ma][mb] += - rootpq * + rootpq * (b_r * uarray_i[j - 1][ma][mb - 1] + - b_i * uarray_r[j - 1][ma][mb - 1]); + b_i * uarray_r[j - 1][ma][mb - 1]); rootpq = rootpqarray[ma + 1][mb]; uarray_r[j][ma + 1][mb] = - rootpq * + rootpq * (a_r * uarray_r[j - 1][ma][mb - 1] - - a_i * uarray_i[j - 1][ma][mb - 1]); + a_i * uarray_i[j - 1][ma][mb - 1]); uarray_i[j][ma + 1][mb] = - rootpq * + rootpq * (a_r * uarray_i[j - 1][ma][mb - 1] + - a_i * uarray_r[j - 1][ma][mb - 1]); + a_i * uarray_r[j - 1][ma][mb - 1]); } } } @@ -1319,7 +1319,7 @@ void SNA::compute_uarray_omp(double x, double y, double z, void SNA::compute_duarray(double x, double y, double z, double z0, double r, double dz0dr, - double wj, double rcut) + double wj, double rcut) { double r0inv; double a_r, a_i, b_r, b_i; @@ -1405,7 +1405,7 @@ void SNA::compute_duarray(double x, double y, double z, a_i * duarray_r[j - 1][ma][mb][k]); } - rootpq = rootpqarray[ma + 1][j - mb]; + rootpq = rootpqarray[ma + 1][j - mb]; uarray_r[j][ma + 1][mb] = -rootpq * (b_r * uarray_r[j - 1][ma][mb] + b_i * uarray_i[j - 1][ma][mb]); @@ -1433,22 +1433,22 @@ void SNA::compute_duarray(double x, double y, double z, mbpar = -mbpar; int mapar = -mbpar; for (int ma = 0; ma <= j; ma++) { - mapar = -mapar; - if (mapar == 1) { - uarray_r[j][j-ma][j-mb] = uarray_r[j][ma][mb]; - uarray_i[j][j-ma][j-mb] = -uarray_i[j][ma][mb]; - for (int k = 0; k < 3; k++) { - duarray_r[j][j-ma][j-mb][k] = duarray_r[j][ma][mb][k]; - duarray_i[j][j-ma][j-mb][k] = -duarray_i[j][ma][mb][k]; - } - } else { - uarray_r[j][j-ma][j-mb] = -uarray_r[j][ma][mb]; - uarray_i[j][j-ma][j-mb] = uarray_i[j][ma][mb]; - for (int k = 0; k < 3; k++) { - duarray_r[j][j-ma][j-mb][k] = -duarray_r[j][ma][mb][k]; - duarray_i[j][j-ma][j-mb][k] = duarray_i[j][ma][mb][k]; - } - } + mapar = -mapar; + if (mapar == 1) { + uarray_r[j][j-ma][j-mb] = uarray_r[j][ma][mb]; + uarray_i[j][j-ma][j-mb] = -uarray_i[j][ma][mb]; + for (int k = 0; k < 3; k++) { + duarray_r[j][j-ma][j-mb][k] = duarray_r[j][ma][mb][k]; + duarray_i[j][j-ma][j-mb][k] = -duarray_i[j][ma][mb][k]; + } + } else { + uarray_r[j][j-ma][j-mb] = -uarray_r[j][ma][mb]; + uarray_i[j][j-ma][j-mb] = uarray_i[j][ma][mb]; + for (int k = 0; k < 3; k++) { + duarray_r[j][j-ma][j-mb][k] = -duarray_r[j][ma][mb][k]; + duarray_i[j][j-ma][j-mb][k] = duarray_i[j][ma][mb][k]; + } + } } } } @@ -1794,36 +1794,36 @@ void SNA::init_clebsch_gordan() if(m < 0 || m > j) continue; - sum = 0.0; - - for (int z = MAX(0, MAX(-(j - j2 + aa2) - / 2, -(j - j1 - bb2) / 2)); - z <= MIN((j1 + j2 - j) / 2, - MIN((j1 - aa2) / 2, (j2 + bb2) / 2)); - z++) { - ifac = z % 2 ? -1 : 1; - sum += ifac / - (factorial(z) * - factorial((j1 + j2 - j) / 2 - z) * - factorial((j1 - aa2) / 2 - z) * - factorial((j2 + bb2) / 2 - z) * - factorial((j - j2 + aa2) / 2 + z) * - factorial((j - j1 - bb2) / 2 + z)); - } - - cc2 = 2 * m - j; - dcg = deltacg(j1, j2, j); - sfaccg = sqrt(factorial((j1 + aa2) / 2) * - factorial((j1 - aa2) / 2) * - factorial((j2 + bb2) / 2) * - factorial((j2 - bb2) / 2) * - factorial((j + cc2) / 2) * - factorial((j - cc2) / 2) * - (j + 1)); - - cgarray[j1][j2][j][m1][m2] = sum * dcg * sfaccg; - } - } + sum = 0.0; + + for (int z = MAX(0, MAX(-(j - j2 + aa2) + / 2, -(j - j1 - bb2) / 2)); + z <= MIN((j1 + j2 - j) / 2, + MIN((j1 - aa2) / 2, (j2 + bb2) / 2)); + z++) { + ifac = z % 2 ? -1 : 1; + sum += ifac / + (factorial(z) * + factorial((j1 + j2 - j) / 2 - z) * + factorial((j1 - aa2) / 2 - z) * + factorial((j2 + bb2) / 2 - z) * + factorial((j - j2 + aa2) / 2 + z) * + factorial((j - j1 - bb2) / 2 + z)); + } + + cc2 = 2 * m - j; + dcg = deltacg(j1, j2, j); + sfaccg = sqrt(factorial((j1 + aa2) / 2) * + factorial((j1 - aa2) / 2) * + factorial((j2 + bb2) / 2) * + factorial((j2 - bb2) / 2) * + factorial((j + cc2) / 2) * + factorial((j - cc2) / 2) * + (j + 1)); + + cgarray[j1][j2][j][m1][m2] = sum * dcg * sfaccg; + } + } } /* ---------------------------------------------------------------------- diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index 7e43901dc9..c1c83ce59a 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -1037,8 +1037,8 @@ void FixSRD::reset_velocities() for (i = 0; i < nbins; i++){ if (vbin[i].owner) { if (vbin[i].n > 1) { - srd_bin_temp += vbin[i].value[0]/(vbin[i].n-dof_temp); - srd_bin_count++; + srd_bin_temp += vbin[i].value[0]/(vbin[i].n-dof_temp); + srd_bin_count++; } } } @@ -1348,16 +1348,16 @@ void FixSRD::collisions_single() "inside big particle " TAGINT_FORMAT " on step " BIGINT_FORMAT " bounce %d", atom->tag[i],atom->tag[j],update->ntimestep,ibounce+1); - if (insideflag == INSIDE_ERROR) error->one(FLERR,str); - error->warning(FLERR,str); - } else{ + if (insideflag == INSIDE_ERROR) error->one(FLERR,str); + error->warning(FLERR,str); + } else{ sprintf(str, "SRD particle " TAGINT_FORMAT " started " "inside wall %d on step " BIGINT_FORMAT " bounce %d", atom->tag[i],j,update->ntimestep,ibounce+1); - if (insideflag == INSIDE_ERROR) error->one(FLERR,str); - error->warning(FLERR,str); - } + if (insideflag == INSIDE_ERROR) error->one(FLERR,str); + error->warning(FLERR,str); + } } break; } @@ -1507,16 +1507,16 @@ void FixSRD::collisions_multi() "inside big particle " TAGINT_FORMAT " on step " BIGINT_FORMAT " bounce %d", atom->tag[i],atom->tag[j],update->ntimestep,ibounce+1); - if (insideflag == INSIDE_ERROR) error->one(FLERR,str); - error->warning(FLERR,str); - } else{ + if (insideflag == INSIDE_ERROR) error->one(FLERR,str); + error->warning(FLERR,str); + } else{ sprintf(str, "SRD particle " TAGINT_FORMAT " started " "inside wall %d on step " BIGINT_FORMAT " bounce %d", atom->tag[i],j,update->ntimestep,ibounce+1); - if (insideflag == INSIDE_ERROR) error->one(FLERR,str); - error->warning(FLERR,str); - } + if (insideflag == INSIDE_ERROR) error->one(FLERR,str); + error->warning(FLERR,str); + } } t_first = 0.0; break; diff --git a/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp b/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp index c0ed980023..9d10fe1614 100644 --- a/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp +++ b/src/USER-CGDNA/pair_oxdna2_coaxstk.cpp @@ -234,8 +234,8 @@ void PairOxdna2Coaxstk::compute(int eflag, int vflag) theta1p = 2 * MY_PI - theta1; f4f6t1 = F4(theta1, a_cxst1[atype][btype], theta_cxst1_0[atype][btype], dtheta_cxst1_ast[atype][btype], - b_cxst1[atype][btype], dtheta_cxst1_c[atype][btype]) + - F6(theta1, AA_cxst1[atype][btype], BB_cxst1[atype][btype]); + b_cxst1[atype][btype], dtheta_cxst1_c[atype][btype]) + + F6(theta1, AA_cxst1[atype][btype], BB_cxst1[atype][btype]); // early rejection criterium if (f4f6t1) { @@ -296,8 +296,8 @@ void PairOxdna2Coaxstk::compute(int eflag, int vflag) rsint = 1.0/sin(theta1); df4f6t1 = DF4(theta1, a_cxst1[atype][btype], theta_cxst1_0[atype][btype], dtheta_cxst1_ast[atype][btype], - b_cxst1[atype][btype], dtheta_cxst1_c[atype][btype])*rsint + - DF6(theta1, AA_cxst1[atype][btype], BB_cxst1[atype][btype])*rsint; + b_cxst1[atype][btype], dtheta_cxst1_c[atype][btype])*rsint + + DF6(theta1, AA_cxst1[atype][btype], BB_cxst1[atype][btype])*rsint; df4t4 = DF4(theta4, a_cxst4[atype][btype], theta_cxst4_0[atype][btype], dtheta_cxst4_ast[atype][btype], b_cxst4[atype][btype], dtheta_cxst4_c[atype][btype])/sin(theta4); @@ -874,8 +874,8 @@ void PairOxdna2Coaxstk::read_restart(FILE *fp) fread(&b_cxst6[i][j],sizeof(double),1,fp); fread(&dtheta_cxst6_c[i][j],sizeof(double),1,fp); - fread(&AA_cxst1[i][j],sizeof(double),1,fp); - fread(&BB_cxst1[i][j],sizeof(double),1,fp); + fread(&AA_cxst1[i][j],sizeof(double),1,fp); + fread(&BB_cxst1[i][j],sizeof(double),1,fp); } @@ -895,7 +895,7 @@ void PairOxdna2Coaxstk::read_restart(FILE *fp) MPI_Bcast(&b_cxst1[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&dtheta_cxst1_c[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&a_cxst4[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&a_cxst4[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&theta_cxst4_0[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&dtheta_cxst4_ast[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&b_cxst4[i][j],1,MPI_DOUBLE,0,world); @@ -962,7 +962,7 @@ void PairOxdna2Coaxstk::write_data(FILE *fp) %g %g %g %g %g\ %g %g %g %g %g\ %g %g %g %g %g\ - %g %g\ + %g %g\ \n",i, k_cxst[i][i],cut_cxst_0[i][i],cut_cxst_c[i][i],cut_cxst_lo[i][i],cut_cxst_hi[i][i], cut_cxst_lc[i][i],cut_cxst_hc[i][i],b_cxst_lo[i][i],b_cxst_hi[i][i], @@ -970,7 +970,7 @@ void PairOxdna2Coaxstk::write_data(FILE *fp) a_cxst4[i][i],theta_cxst4_0[i][i],dtheta_cxst4_ast[i][i],b_cxst4[i][i],dtheta_cxst4_c[i][i], a_cxst5[i][i],theta_cxst5_0[i][i],dtheta_cxst5_ast[i][i],b_cxst5[i][i],dtheta_cxst5_c[i][i], a_cxst6[i][i],theta_cxst6_0[i][i],dtheta_cxst6_ast[i][i],b_cxst6[i][i],dtheta_cxst6_c[i][i], - AA_cxst1[i][i],BB_cxst1[i][i]); + AA_cxst1[i][i],BB_cxst1[i][i]); } /* ---------------------------------------------------------------------- @@ -988,7 +988,7 @@ void PairOxdna2Coaxstk::write_data_all(FILE *fp) %g %g %g %g %g\ %g %g %g %g %g\ %g %g %g %g %g\ - %g %g\ + %g %g\ \n",i,j, k_cxst[i][j],cut_cxst_0[i][j],cut_cxst_c[i][j],cut_cxst_lo[i][j],cut_cxst_hi[i][j], cut_cxst_lc[i][j],cut_cxst_hc[i][j],b_cxst_lo[i][j],b_cxst_hi[i][j], @@ -996,7 +996,7 @@ void PairOxdna2Coaxstk::write_data_all(FILE *fp) a_cxst4[i][j],theta_cxst4_0[i][j],dtheta_cxst4_ast[i][j],b_cxst4[i][j],dtheta_cxst4_c[i][j], a_cxst5[i][j],theta_cxst5_0[i][j],dtheta_cxst5_ast[i][j],b_cxst5[i][j],dtheta_cxst5_c[i][j], a_cxst6[i][j],theta_cxst6_0[i][j],dtheta_cxst6_ast[i][j],b_cxst6[i][j],dtheta_cxst6_c[i][j], - AA_cxst1[i][j],BB_cxst1[i][j]); + AA_cxst1[i][j],BB_cxst1[i][j]); } diff --git a/src/USER-CGDNA/pair_oxdna2_dh.cpp b/src/USER-CGDNA/pair_oxdna2_dh.cpp index ea91dad0a0..73072f4c0e 100644 --- a/src/USER-CGDNA/pair_oxdna2_dh.cpp +++ b/src/USER-CGDNA/pair_oxdna2_dh.cpp @@ -163,20 +163,20 @@ void PairOxdna2Dh::compute(int eflag, int vflag) if (rsq <= cutsq_dh_c[atype][btype]) { - r = sqrt(rsq); - rinv = 1.0/r; + r = sqrt(rsq); + rinv = 1.0/r; - if (r <= cut_dh_ast[atype][btype]) { + if (r <= cut_dh_ast[atype][btype]) { - fpair = qeff_dh_pf[atype][btype] * exp(-kappa_dh[atype][btype] * r) * - (kappa_dh[atype][btype] + rinv) * rinv * rinv; + fpair = qeff_dh_pf[atype][btype] * exp(-kappa_dh[atype][btype] * r) * + (kappa_dh[atype][btype] + rinv) * rinv * rinv; - if (eflag) { - evdwl = qeff_dh_pf[atype][btype] * exp(-kappa_dh[atype][btype]*r) * rinv; - } + if (eflag) { + evdwl = qeff_dh_pf[atype][btype] * exp(-kappa_dh[atype][btype]*r) * rinv; + } - } - else { + } + else { fpair = 2.0 * b_dh[atype][btype] * (cut_dh_c[atype][btype] - r) * rinv; @@ -184,50 +184,50 @@ void PairOxdna2Dh::compute(int eflag, int vflag) evdwl = b_dh[atype][btype] * (r - cut_dh_c[atype][btype]) * (r - cut_dh_c[atype][btype]); } - } + } // knock out nearest-neighbour interaction between adjacent backbone sites fpair *= factor_lj; evdwl *= factor_lj; - delf[0] = delr[0] * fpair; - delf[1] = delr[1] * fpair; - delf[2] = delr[2] * fpair; + delf[0] = delr[0] * fpair; + delf[1] = delr[1] * fpair; + delf[2] = delr[2] * fpair; - // apply force and torque to each of 2 atoms + // apply force and torque to each of 2 atoms - if (newton_pair || a < nlocal) { + if (newton_pair || a < nlocal) { - f[a][0] += delf[0]; - f[a][1] += delf[1]; - f[a][2] += delf[2]; + f[a][0] += delf[0]; + f[a][1] += delf[1]; + f[a][2] += delf[2]; - MathExtra::cross3(ra_cs,delf,delta); + MathExtra::cross3(ra_cs,delf,delta); - torque[a][0] += delta[0]; - torque[a][1] += delta[1]; - torque[a][2] += delta[2]; + torque[a][0] += delta[0]; + torque[a][1] += delta[1]; + torque[a][2] += delta[2]; - } + } - if (newton_pair || b < nlocal) { + if (newton_pair || b < nlocal) { - f[b][0] -= delf[0]; - f[b][1] -= delf[1]; - f[b][2] -= delf[2]; + f[b][0] -= delf[0]; + f[b][1] -= delf[1]; + f[b][2] -= delf[2]; - MathExtra::cross3(rb_cs,delf,deltb); + MathExtra::cross3(rb_cs,delf,deltb); - torque[b][0] -= deltb[0]; - torque[b][1] -= deltb[1]; - torque[b][2] -= deltb[2]; + torque[b][0] -= deltb[0]; + torque[b][1] -= deltb[1]; + torque[b][2] -= deltb[2]; - } + } - // increment energy and virial + // increment energy and virial - if (evflag) ev_tally(a,b,nlocal,newton_pair, - evdwl,0.0,fpair,delr[0],delr[1],delr[2]); + if (evflag) ev_tally(a,b,nlocal,newton_pair, + evdwl,0.0,fpair,delr[0],delr[1],delr[2]); } } @@ -302,7 +302,7 @@ void PairOxdna2Dh::coeff(int narg, char **arg) The numerical factor is the Debye length in s.u. lambda(T = 300 K = 0.1) = sqrt(eps_0 * eps_r * k_B * T/(2 * N_A * e^2 * 1000 mol/m^3)) - * 1/oxDNA_energy_unit + * 1/oxDNA_energy_unit (see B. Snodin et al., J. Chem. Phys. 142, 234901 (2015).) We use @@ -324,7 +324,7 @@ void PairOxdna2Dh::coeff(int narg, char **arg) NOTE: The numerical factor is qeff_dh_pf = e^2/(4 * pi * eps_0 * eps_r) - * 1/(oxDNA_energy_unit * oxDNA_length_unit) + * 1/(oxDNA_energy_unit * oxDNA_length_unit) (see B. Snodin et al., J. Chem. Phys. 142, 234901 (2015).) In addition to the above units we use @@ -515,10 +515,10 @@ void PairOxdna2Dh::write_data(FILE *fp) for (int i = 1; i <= atom->ntypes; i++) fprintf(fp,"%d\ %g %g\ - %g %g %g\ + %g %g %g\ \n",i, kappa_dh[i][i],qeff_dh_pf[i][i], - b_dh[i][i],cut_dh_ast[i][i],cut_dh_c[i][i]); + b_dh[i][i],cut_dh_ast[i][i],cut_dh_c[i][i]); } /* ---------------------------------------------------------------------- @@ -531,10 +531,10 @@ void PairOxdna2Dh::write_data_all(FILE *fp) for (int j = i; j <= atom->ntypes; j++) fprintf(fp,"%d %d\ %g %g\ - %g %g %g\ + %g %g %g\ \n",i,j, kappa_dh[i][j],qeff_dh_pf[i][j], - b_dh[i][j],cut_dh_ast[i][j],cut_dh_c[i][j]); + b_dh[i][j],cut_dh_ast[i][j],cut_dh_c[i][j]); } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-COLVARS/fix_colvars.cpp b/src/USER-COLVARS/fix_colvars.cpp index 956ba6498a..84b3ee07d6 100644 --- a/src/USER-COLVARS/fix_colvars.cpp +++ b/src/USER-COLVARS/fix_colvars.cpp @@ -549,9 +549,9 @@ void FixColvars::setup(int vflag) } else { m[i] = atom->mass[type[k]]; } - if (atom->q_flag) { - q[i] = atom->q[k]; - } + if (atom->q_flag) { + q[i] = atom->q[k]; + } } } @@ -616,7 +616,7 @@ void FixColvars::setup(int vflag) comm_buf[nme].m = atom->mass[type[k]]; } - if (atom->q_flag) { + if (atom->q_flag) { comm_buf[nme].q = atom->q[k]; } diff --git a/src/USER-DIFFRACTION/compute_xrd.cpp b/src/USER-DIFFRACTION/compute_xrd.cpp index f56409f57c..380629ffb9 100644 --- a/src/USER-DIFFRACTION/compute_xrd.cpp +++ b/src/USER-DIFFRACTION/compute_xrd.cpp @@ -216,10 +216,10 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) : K[2] = k * dK[2]; dinv2 = (K[0] * K[0] + K[1] * K[1] + K[2] * K[2]); if (4 >= dinv2 * lambda * lambda ) { - ang = asin(lambda * sqrt(dinv2) * 0.5); + ang = asin(lambda * sqrt(dinv2) * 0.5); if ((ang <= Max2Theta) && (ang >= Min2Theta)) { nRows++; - } + } } } } diff --git a/src/USER-H5MD/dump_h5md.cpp b/src/USER-H5MD/dump_h5md.cpp index 7456d6fa44..4e85b5c8b6 100644 --- a/src/USER-H5MD/dump_h5md.cpp +++ b/src/USER-H5MD/dump_h5md.cpp @@ -125,7 +125,7 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) size_one+=1; } else if (strcmp(arg[iarg], "charge")==0) { if (!atom->q_flag) - error->all(FLERR, "Requesting non-allocated quantity q in dump_h5md"); + error->all(FLERR, "Requesting non-allocated quantity q in dump_h5md"); every_charge = default_every; iarg+=1; n_parsed = element_args(narg-iarg, &arg[iarg], &every_charge); @@ -137,10 +137,10 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) error->all(FLERR, "Invalid number of arguments in dump h5md"); } if (box_is_set||create_group_is_set) - error->all(FLERR, "Cannot set file_from in dump h5md after box or create_group"); + error->all(FLERR, "Cannot set file_from in dump h5md after box or create_group"); int idump; for (idump = 0; idump < output->ndump; idump++) - if (strcmp(arg[iarg+1],output->dump[idump]->id) == 0) break; + if (strcmp(arg[iarg+1],output->dump[idump]->id) == 0) break; if (idump == output->ndump) error->all(FLERR,"Cound not find dump_modify ID"); datafile_from_dump = idump; do_box=false; @@ -152,11 +152,11 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) } box_is_set = true; if (strcmp(arg[iarg+1], "yes")==0) - do_box=true; + do_box=true; else if (strcmp(arg[iarg+1], "no")==0) - do_box=false; + do_box=false; else - error->all(FLERR, "Illegal dump h5md command"); + error->all(FLERR, "Illegal dump h5md command"); iarg+=2; } else if (strcmp(arg[iarg], "create_group")==0) { if (iarg+1>=narg) { @@ -164,22 +164,22 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) } create_group_is_set = true; if (strcmp(arg[iarg+1], "yes")==0) - create_group=true; + create_group=true; else if (strcmp(arg[iarg+1], "no")==0) { - create_group=false; + create_group=false; } else - error->all(FLERR, "Illegal dump h5md command"); + error->all(FLERR, "Illegal dump h5md command"); iarg+=2; } else if (strcmp(arg[iarg], "author")==0) { if (iarg+1>=narg) { error->all(FLERR, "Invalid number of arguments in dump h5md"); } if (author_name==NULL) { - author_name = new char[strlen(arg[iarg])+1]; - strcpy(author_name, arg[iarg+1]); + author_name = new char[strlen(arg[iarg])+1]; + strcpy(author_name, arg[iarg+1]); } else { - error->all(FLERR, "Illegal dump h5md command: author argument repeated"); + error->all(FLERR, "Illegal dump h5md command: author argument repeated"); } iarg+=2; } else { @@ -218,7 +218,7 @@ DumpH5MD::~DumpH5MD() if (me==0) { h5md_close_element(particles_data.position); if (do_box) - h5md_close_element(particles_data.box_edges); + h5md_close_element(particles_data.box_edges); } } if (every_image>=0) { @@ -272,36 +272,36 @@ void DumpH5MD::openfile() if (me == 0) { if (datafile_from_dump<0) { if (author_name==NULL) { - datafile = h5md_create_file(filename, "N/A", NULL, "lammps", LAMMPS_VERSION); + datafile = h5md_create_file(filename, "N/A", NULL, "lammps", LAMMPS_VERSION); } else { - datafile = h5md_create_file(filename, author_name, NULL, "lammps", LAMMPS_VERSION); + datafile = h5md_create_file(filename, author_name, NULL, "lammps", LAMMPS_VERSION); } group_name_length = strlen(group->names[igroup])+1; group_name = new char[group_name_length]; strcpy(group_name, group->names[igroup]); if (create_group) { - particles_data = h5md_create_particles_group(datafile, group_name); + particles_data = h5md_create_particles_group(datafile, group_name); } else { - particles_data.group = h5md_open_particles_group(datafile.particles, group_name); + particles_data.group = h5md_open_particles_group(datafile.particles, group_name); } delete [] group_name; dims[0] = natoms; dims[1] = domain->dimension; if (every_position>0) { - particles_data.position = h5md_create_time_data(particles_data.group, "position", 2, dims, H5T_NATIVE_DOUBLE, NULL); - h5md_create_box(&particles_data, dims[1], boundary, true, NULL, &particles_data.position); + particles_data.position = h5md_create_time_data(particles_data.group, "position", 2, dims, H5T_NATIVE_DOUBLE, NULL); + h5md_create_box(&particles_data, dims[1], boundary, true, NULL, &particles_data.position); } if (every_image>0) - particles_data.image = h5md_create_time_data(particles_data.group, "image", 2, dims, H5T_NATIVE_INT, &particles_data.position); + particles_data.image = h5md_create_time_data(particles_data.group, "image", 2, dims, H5T_NATIVE_INT, &particles_data.position); if (every_velocity>0) - particles_data.velocity = h5md_create_time_data(particles_data.group, "velocity", 2, dims, H5T_NATIVE_DOUBLE, NULL); + particles_data.velocity = h5md_create_time_data(particles_data.group, "velocity", 2, dims, H5T_NATIVE_DOUBLE, NULL); if (every_force>0) - particles_data.force = h5md_create_time_data(particles_data.group, "force", 2, dims, H5T_NATIVE_DOUBLE, NULL); + particles_data.force = h5md_create_time_data(particles_data.group, "force", 2, dims, H5T_NATIVE_DOUBLE, NULL); if (every_species>0) - particles_data.species = h5md_create_time_data(particles_data.group, "species", 1, dims, H5T_NATIVE_INT, NULL); + particles_data.species = h5md_create_time_data(particles_data.group, "species", 1, dims, H5T_NATIVE_INT, NULL); if (every_charge>0) { - particles_data.charge = h5md_create_time_data(particles_data.group, "charge", 1, dims, H5T_NATIVE_DOUBLE, NULL); - h5md_write_string_attribute(particles_data.group, "charge", "type", "effective"); + particles_data.charge = h5md_create_time_data(particles_data.group, "charge", 1, dims, H5T_NATIVE_DOUBLE, NULL); + h5md_write_string_attribute(particles_data.group, "charge", "type", "effective"); } } else { DumpH5MD* other_dump; @@ -311,27 +311,27 @@ void DumpH5MD::openfile() group_name = new char[group_name_length]; strcpy(group_name, group->names[igroup]); if (create_group) { - particles_data = h5md_create_particles_group(datafile, group_name); + particles_data = h5md_create_particles_group(datafile, group_name); } else { - particles_data = other_dump->particles_data; + particles_data = other_dump->particles_data; } dims[0] = natoms; dims[1] = domain->dimension; if (every_position>0) { - particles_data.position = h5md_create_time_data(particles_data.group, "position", 2, dims, H5T_NATIVE_DOUBLE, NULL); - h5md_create_box(&particles_data, dims[1], boundary, true, NULL, &particles_data.position); + particles_data.position = h5md_create_time_data(particles_data.group, "position", 2, dims, H5T_NATIVE_DOUBLE, NULL); + h5md_create_box(&particles_data, dims[1], boundary, true, NULL, &particles_data.position); } if (every_image>0) - particles_data.image = h5md_create_time_data(particles_data.group, "image", 2, dims, H5T_NATIVE_INT, &particles_data.position); + particles_data.image = h5md_create_time_data(particles_data.group, "image", 2, dims, H5T_NATIVE_INT, &particles_data.position); if (every_velocity>0) - particles_data.velocity = h5md_create_time_data(particles_data.group, "velocity", 2, dims, H5T_NATIVE_DOUBLE, NULL); + particles_data.velocity = h5md_create_time_data(particles_data.group, "velocity", 2, dims, H5T_NATIVE_DOUBLE, NULL); if (every_force>0) - particles_data.force = h5md_create_time_data(particles_data.group, "force", 2, dims, H5T_NATIVE_DOUBLE, NULL); + particles_data.force = h5md_create_time_data(particles_data.group, "force", 2, dims, H5T_NATIVE_DOUBLE, NULL); if (every_species>0) - particles_data.species = h5md_create_time_data(particles_data.group, "species", 1, dims, H5T_NATIVE_INT, NULL); + particles_data.species = h5md_create_time_data(particles_data.group, "species", 1, dims, H5T_NATIVE_INT, NULL); if (every_charge>0) { - particles_data.charge = h5md_create_time_data(particles_data.group, "charge", 1, dims, H5T_NATIVE_DOUBLE, NULL); - h5md_write_string_attribute(particles_data.group, "charge", "type", "effective"); + particles_data.charge = h5md_create_time_data(particles_data.group, "charge", 1, dims, H5T_NATIVE_DOUBLE, NULL); + h5md_write_string_attribute(particles_data.group, "charge", "type", "effective"); } } @@ -376,38 +376,38 @@ void DumpH5MD::pack(tagint *ids) for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { if (every_position>=0) { - int ix = (image[i] & IMGMASK) - IMGMAX; - int iy = (image[i] >> IMGBITS & IMGMASK) - IMGMAX; - int iz = (image[i] >> IMG2BITS) - IMGMAX; - if (unwrap_flag == 1) { - buf[m++] = (x[i][0] + ix * xprd); - buf[m++] = (x[i][1] + iy * yprd); - if (dim>2) buf[m++] = (x[i][2] + iz * zprd); - } else { - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - if (dim>2) buf[m++] = x[i][2]; - } - if (every_image>=0) { - buf[m++] = ix; - buf[m++] = iy; - if (dim>2) buf[m++] = iz; - } + int ix = (image[i] & IMGMASK) - IMGMAX; + int iy = (image[i] >> IMGBITS & IMGMASK) - IMGMAX; + int iz = (image[i] >> IMG2BITS) - IMGMAX; + if (unwrap_flag == 1) { + buf[m++] = (x[i][0] + ix * xprd); + buf[m++] = (x[i][1] + iy * yprd); + if (dim>2) buf[m++] = (x[i][2] + iz * zprd); + } else { + buf[m++] = x[i][0]; + buf[m++] = x[i][1]; + if (dim>2) buf[m++] = x[i][2]; + } + if (every_image>=0) { + buf[m++] = ix; + buf[m++] = iy; + if (dim>2) buf[m++] = iz; + } } if (every_velocity>=0) { - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - if (dim>2) buf[m++] = v[i][2]; + buf[m++] = v[i][0]; + buf[m++] = v[i][1]; + if (dim>2) buf[m++] = v[i][2]; } if (every_force>=0) { - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - if (dim>2) buf[m++] = f[i][2]; + buf[m++] = f[i][0]; + buf[m++] = f[i][1]; + if (dim>2) buf[m++] = f[i][2]; } if (every_species>=0) - buf[m++] = species[i]; + buf[m++] = species[i]; if (every_charge>=0) - buf[m++] = q[i]; + buf[m++] = q[i]; ids[n++] = tag[i]; } } @@ -429,20 +429,20 @@ void DumpH5MD::write_data(int n, double *mybuf) for (int i = 0; i < n; i++) { if (every_position>=0) { for (int j=0; j<dim; j++) { - dump_position[k++] = mybuf[m++]; + dump_position[k++] = mybuf[m++]; } if (every_image>=0) - for (int j=0; j<dim; j++) { - dump_image[k_image++] = mybuf[m++]; - } + for (int j=0; j<dim; j++) { + dump_image[k_image++] = mybuf[m++]; + } } if (every_velocity>=0) for (int j=0; j<dim; j++) { - dump_velocity[k_velocity++] = mybuf[m++]; + dump_velocity[k_velocity++] = mybuf[m++]; } if (every_force>=0) for (int j=0; j<dim; j++) { - dump_force[k_force++] = mybuf[m++]; + dump_force[k_force++] = mybuf[m++]; } if (every_species>=0) dump_species[k_species++] = mybuf[m++]; @@ -494,7 +494,7 @@ void DumpH5MD::write_frame() h5md_append(particles_data.position, dump_position, local_step, local_time); h5md_append(particles_data.box_edges, edges, local_step, local_time); if (every_image>0) - h5md_append(particles_data.image, dump_image, local_step, local_time); + h5md_append(particles_data.image, dump_image, local_step, local_time); } } else { if (do_box) h5md_append(particles_data.box_edges, edges, local_step, local_time); diff --git a/src/USER-INTEL/dihedral_fourier_intel.cpp b/src/USER-INTEL/dihedral_fourier_intel.cpp index 772ea5b02f..17a33b6f65 100644 --- a/src/USER-INTEL/dihedral_fourier_intel.cpp +++ b/src/USER-INTEL/dihedral_fourier_intel.cpp @@ -70,8 +70,8 @@ void DihedralFourierIntel::compute(int eflag, int vflag) template <class flt_t, class acc_t> void DihedralFourierIntel::compute(int eflag, int vflag, - IntelBuffers<flt_t,acc_t> *buffers, - const ForceConst<flt_t> &fc) + IntelBuffers<flt_t,acc_t> *buffers, + const ForceConst<flt_t> &fc) { if (eflag || vflag) { ev_setup(eflag,vflag); @@ -99,8 +99,8 @@ void DihedralFourierIntel::compute(int eflag, int vflag, template <int EFLAG, int VFLAG, int NEWTON_BOND, class flt_t, class acc_t> void DihedralFourierIntel::eval(const int vflag, - IntelBuffers<flt_t,acc_t> *buffers, - const ForceConst<flt_t> &fc) + IntelBuffers<flt_t,acc_t> *buffers, + const ForceConst<flt_t> &fc) { const int inum = neighbor->ndihedrallist; @@ -238,30 +238,30 @@ void DihedralFourierIntel::eval(const int vflag, if (EFLAG) deng = (flt_t)0.0; for (int j = 0; j < nterms[type]; j++) { - const flt_t tcos_shift = fc.bp[j][type].cos_shift; - const flt_t tsin_shift = fc.bp[j][type].sin_shift; - const flt_t tk = fc.bp[j][type].k; - const int m = fc.bp[j][type].multiplicity; - - flt_t p = (flt_t)1.0; - flt_t ddf1, df1; - ddf1 = df1 = (flt_t)0.0; - - for (int i = 0; i < m; i++) { - ddf1 = p*c - df1*s; - df1 = p*s + df1*c; - p = ddf1; - } - - p = p*tcos_shift + df1*tsin_shift; - df1 = df1*tcos_shift - ddf1*tsin_shift; - df1 *= -m; - p += (flt_t)1.0; - - if (m == 0) { - p = (flt_t)1.0 + tcos_shift; - df1 = (flt_t)0.0; - } + const flt_t tcos_shift = fc.bp[j][type].cos_shift; + const flt_t tsin_shift = fc.bp[j][type].sin_shift; + const flt_t tk = fc.bp[j][type].k; + const int m = fc.bp[j][type].multiplicity; + + flt_t p = (flt_t)1.0; + flt_t ddf1, df1; + ddf1 = df1 = (flt_t)0.0; + + for (int i = 0; i < m; i++) { + ddf1 = p*c - df1*s; + df1 = p*s + df1*c; + p = ddf1; + } + + p = p*tcos_shift + df1*tsin_shift; + df1 = df1*tcos_shift - ddf1*tsin_shift; + df1 *= -m; + p += (flt_t)1.0; + + if (m == 0) { + p = (flt_t)1.0 + tcos_shift; + df1 = (flt_t)0.0; + } if (EFLAG) deng += tk * p; df -= tk * df1; @@ -401,7 +401,7 @@ void DihedralFourierIntel::init_style() template <class flt_t, class acc_t> void DihedralFourierIntel::pack_force_const(ForceConst<flt_t> &fc, - IntelBuffers<flt_t,acc_t> *buffers) + IntelBuffers<flt_t,acc_t> *buffers) { const int bp1 = atom->ndihedraltypes + 1; fc.set_ntypes(bp1, setflag, nterms, memory); @@ -410,9 +410,9 @@ void DihedralFourierIntel::pack_force_const(ForceConst<flt_t> &fc, if (setflag[i]) { for (int j = 0; j < nterms[i]; j++) { fc.bp[j][i].cos_shift = cos_shift[i][j]; - fc.bp[j][i].sin_shift = sin_shift[i][j]; - fc.bp[j][i].k = k[i][j]; - fc.bp[j][i].multiplicity = multiplicity[i][j]; + fc.bp[j][i].sin_shift = sin_shift[i][j]; + fc.bp[j][i].k = k[i][j]; + fc.bp[j][i].multiplicity = multiplicity[i][j]; } } } @@ -423,8 +423,8 @@ void DihedralFourierIntel::pack_force_const(ForceConst<flt_t> &fc, template <class flt_t> void DihedralFourierIntel::ForceConst<flt_t>::set_ntypes(const int nbondtypes, int *setflag, - int *nterms, - Memory *memory) { + int *nterms, + Memory *memory) { if (nbondtypes != _nbondtypes) { if (_nbondtypes > 0) _memory->destroy(bp); diff --git a/src/USER-INTEL/dihedral_fourier_intel.h b/src/USER-INTEL/dihedral_fourier_intel.h index cb83b8167c..26007f4118 100644 --- a/src/USER-INTEL/dihedral_fourier_intel.h +++ b/src/USER-INTEL/dihedral_fourier_intel.h @@ -66,7 +66,7 @@ class DihedralFourierIntel : public DihedralFourier { ~ForceConst() { set_ntypes(0, NULL, NULL, NULL); } void set_ntypes(const int nbondtypes, int *setflag, int *nterms, - Memory *memory); + Memory *memory); private: int _nbondtypes, _maxnterms; diff --git a/src/USER-INTEL/fix_intel.cpp b/src/USER-INTEL/fix_intel.cpp index cac5e0b49c..d05e059578 100644 --- a/src/USER-INTEL/fix_intel.cpp +++ b/src/USER-INTEL/fix_intel.cpp @@ -755,7 +755,7 @@ void FixIntel::add_oresults(const ft * _noalias const f_in, double * _noalias const lmp_eatom = force->pair->eatom + out_offset; #if defined(LMP_SIMD_COMPILER) #pragma vector aligned - #pragma ivdep + #pragma ivdep #endif for (int i = ifrom; i < ito; i++) { f[i].x += f_in[ii].x; @@ -770,7 +770,7 @@ void FixIntel::add_oresults(const ft * _noalias const f_in, } else { #if defined(LMP_SIMD_COMPILER) #pragma vector aligned - #pragma ivdep + #pragma ivdep #endif for (int i = ifrom; i < ito; i++) { f[i].x += f_in[ii].x; @@ -787,7 +787,7 @@ void FixIntel::add_oresults(const ft * _noalias const f_in, double * _noalias const lmp_eatom = force->pair->eatom + out_offset; #if defined(LMP_SIMD_COMPILER) #pragma vector aligned - #pragma ivdep + #pragma ivdep #endif for (int i = ifrom; i < ito; i++) { f[i].x += f_in[i].x; @@ -798,7 +798,7 @@ void FixIntel::add_oresults(const ft * _noalias const f_in, } else { #if defined(LMP_SIMD_COMPILER) #pragma vector aligned - #pragma ivdep + #pragma ivdep #endif for (int i = ifrom; i < ito; i++) { f[i].x += f_in[i].x; diff --git a/src/USER-INTEL/intel_buffers.cpp b/src/USER-INTEL/intel_buffers.cpp index ac208f5a0c..1ef078821e 100644 --- a/src/USER-INTEL/intel_buffers.cpp +++ b/src/USER-INTEL/intel_buffers.cpp @@ -532,7 +532,7 @@ void IntelBuffers<flt_t, acc_t>::grow_ncache(const int off_flag, lmp->memory->create(_ncachetag, tsize, "_ncachetag"); } int *ncachetag = _ncachetag; - #pragma offload_transfer target(mic:_cop) \ + #pragma offload_transfer target(mic:_cop) \ nocopy(ncachetag:length(tsize) alloc_if(1) free_if(0)) _off_ncache = 1; } @@ -570,7 +570,7 @@ void IntelBuffers<flt_t, acc_t>::fdotr_reduce(const int nall, template <class flt_t, class acc_t> void IntelBuffers<flt_t, acc_t>::set_ntypes(const int ntypes, - const int use_ghost_cut) + const int use_ghost_cut) { if (ntypes != _ntypes) { if (_ntypes > 0) { @@ -582,7 +582,7 @@ void IntelBuffers<flt_t, acc_t>::set_ntypes(const int ntypes, } flt_t * cutneighghostsqo; if (_cutneighghostsq && _off_threads > 0 && cutneighghostsqo != 0) { - cutneighghostsqo = _cutneighghostsq[0]; + cutneighghostsqo = _cutneighghostsq[0]; #pragma offload_transfer target(mic:_cop) \ nocopy(cutneighghostsqo:alloc_if(0) free_if(1)) } @@ -593,8 +593,8 @@ void IntelBuffers<flt_t, acc_t>::set_ntypes(const int ntypes, if (ntypes > 0) { lmp->memory->create(_cutneighsq, ntypes, ntypes, "_cutneighsq"); if (use_ghost_cut) - lmp->memory->create(_cutneighghostsq, ntypes, ntypes, - "_cutneighghostsq"); + lmp->memory->create(_cutneighghostsq, ntypes, ntypes, + "_cutneighghostsq"); #ifdef _LMP_INTEL_OFFLOAD flt_t * cutneighsqo = _cutneighsq[0]; const int ntypes2 = ntypes * ntypes; diff --git a/src/USER-INTEL/intel_intrinsics_airebo.h b/src/USER-INTEL/intel_intrinsics_airebo.h index 35c5cb7a43..f17fd69856 100644 --- a/src/USER-INTEL/intel_intrinsics_airebo.h +++ b/src/USER-INTEL/intel_intrinsics_airebo.h @@ -61,59 +61,59 @@ namespace mm512 { #ifndef FVEC_FIRST_PASS VEC_INLINE static inline __m512i _mm512_mask_expand_epi32(__m512i src, - __mmask16 k, - __m512i a) { + __mmask16 k, + __m512i a) { int buf[16] __attribute__((aligned(64))); _mm512_store_epi32(buf, a); return _mm512_mask_loadunpacklo_epi32(src, k, buf); } VEC_INLINE static inline __m512i _mm512_maskz_expand_epi32(__mmask16 k, - __m512i a) { + __m512i a) { int buf[16] __attribute__((aligned(64))); _mm512_store_epi32(buf, a); return _mm512_mask_loadunpacklo_epi32(_mm512_setzero_epi32(), k, buf); } VEC_INLINE static inline __m512i _mm512_mask_compress_epi32(__m512i src, - __mmask16 k, - __m512i a) { + __mmask16 k, + __m512i a) { int buf[16] __attribute__((aligned(64))); _mm512_store_epi32(buf, src); _mm512_mask_packstorelo_epi32(buf, k, a); return _mm512_load_epi32(buf); } VEC_INLINE static inline __m512i _mm512_maskz_compress_epi32(__mmask16 k, - __m512i a) { + __m512i a) { int buf[16] __attribute__((aligned(64))) = {0}; _mm512_mask_packstorelo_epi32(buf, k, a); return _mm512_load_epi32(buf); } VEC_INLINE static inline void _mm512_mask_compressstoreu_epi32(int * dest, - __mmask16 mask, - __m512i src) { + __mmask16 mask, + __m512i src) { _mm512_mask_packstorelo_epi32(dest, mask, src); _mm512_mask_packstorehi_epi32(dest + 16, mask, src); } VEC_INLINE static inline __m512i _mm512_mask_loadu_epi32(__m512i src, - __mmask16 k, - const int * mem_addr) { + __mmask16 k, + const int * mem_addr) { assert((k & (k + 1)) == 0); __m512i ret = _mm512_mask_loadunpacklo_epi32(src, k, mem_addr); ret = _mm512_mask_loadunpackhi_epi32(ret, k, mem_addr + 16); return ret; } VEC_INLINE static inline __m512i _mm512_maskz_loadu_epi32(__mmask16 k, - const int * mem_addr) { + const int * mem_addr) { assert((k & (k + 1)) == 0); __m512i ret = _mm512_mask_loadunpacklo_epi32(_mm512_setzero_epi32(), k, - mem_addr); + mem_addr); ret = _mm512_mask_loadunpackhi_epi32(ret, k, mem_addr + 16); return ret; } VEC_INLINE static inline void _mm512_mask_storeu_epi32(int * dest, - __mmask16 mask, - __m512i src) { + __mmask16 mask, + __m512i src) { assert((mask & (mask + 1)) == 0); _mm512_mask_packstorelo_epi32(dest, mask, src); _mm512_mask_packstorehi_epi32(dest + 16, mask, src); @@ -131,7 +131,7 @@ VEC_INLINE static inline FVEC_VEC_T FVEC_SUFFIX(_mm512_maskz_expand_) FVEC_SCAL_T buf[FVEC_LEN] __attribute__((aligned(64))); FVEC_SUFFIX(_mm512_store_)(buf, a); return FVEC_SUFFIX(_mm512_mask_loadunpacklo_)(FVEC_SUFFIX(_mm512_setzero_)(), - k, buf); + k, buf); } VEC_INLINE static inline FVEC_VEC_T FVEC_SUFFIX(_mm512_mask_compress_) (FVEC_VEC_T src, __mmask16 k, FVEC_VEC_T a) { @@ -182,24 +182,24 @@ public: return _mm512_kortestz(a.val_, b.val_); } VEC_INLINE static BVEC_NAME masku_compress(const BVEC_NAME &mask, - const BVEC_NAME &a) { + const BVEC_NAME &a) { const __m512i c_i1 = _mm512_set1_epi32(1); __m512i a_int_vec = _mm512_mask_blend_epi32(a.val_, _mm512_setzero_epi32(), - c_i1); + c_i1); __m512i compressed = _mm512_mask_compress_epi32(_mm512_undefined_epi32(), - mask.val_, a_int_vec); + mask.val_, a_int_vec); return _mm512_cmpeq_epi32_mask(compressed, c_i1); } VEC_INLINE static BVEC_NAME mask_expand(const BVEC_NAME &src, - const BVEC_NAME &mask, - const BVEC_NAME &a) { + const BVEC_NAME &mask, + const BVEC_NAME &a) { const __m512i c_i1 = _mm512_set1_epi32(1); __m512i a_int_vec = _mm512_mask_blend_epi32(a.val_, _mm512_setzero_epi32(), - c_i1); + c_i1); __m512i src_int_vec = _mm512_mask_blend_epi32(src.val_, - _mm512_setzero_epi32(), c_i1); + _mm512_setzero_epi32(), c_i1); __m512i compressed = _mm512_mask_expand_epi32(src_int_vec, mask.val_, - a_int_vec); + a_int_vec); return _mm512_cmpeq_epi32_mask(compressed, c_i1); } VEC_INLINE static BVEC_NAME full() { @@ -254,29 +254,29 @@ public: VEC_INLINE IVEC_NAME() {} #define IVEC_MASK_BINFN_B(the_name) \ - VEC_INLINE static BVEC_NAME the_name(const IVEC_NAME &a, \ - const IVEC_NAME &b) { \ + VEC_INLINE static BVEC_NAME the_name(const IVEC_NAME &a, \ + const IVEC_NAME &b) { \ return _mm512_##the_name##_epi32_mask(a.val_, b.val_); \ - } \ - VEC_INLINE static BVEC_NAME mask_##the_name( \ - const BVEC_NAME &mask, \ - const IVEC_NAME &a, \ - const IVEC_NAME &b \ - ) { \ - return _mm512_mask_##the_name##_epi32_mask( \ - mask.val_, a.val_, b.val_); \ + } \ + VEC_INLINE static BVEC_NAME mask_##the_name( \ + const BVEC_NAME &mask, \ + const IVEC_NAME &a, \ + const IVEC_NAME &b \ + ) { \ + return _mm512_mask_##the_name##_epi32_mask( \ + mask.val_, a.val_, b.val_); \ } IVEC_MASK_BINFN_B(cmpeq) IVEC_MASK_BINFN_B(cmplt) IVEC_MASK_BINFN_B(cmpneq) IVEC_MASK_BINFN_B(cmpgt) - #define IVEC_MASK_BINFN_I(the_name) \ - VEC_INLINE static IVEC_NAME mask_##the_name( \ + #define IVEC_MASK_BINFN_I(the_name) \ + VEC_INLINE static IVEC_NAME mask_##the_name( \ const IVEC_NAME &src, const BVEC_NAME &mask, \ const IVEC_NAME &a, const IVEC_NAME &b \ ) { \ - return _mm512_mask_##the_name##_epi32( \ + return _mm512_mask_##the_name##_epi32( \ src.val_, mask.val_, a.val_, b.val_); \ } IVEC_MASK_BINFN_I(add) @@ -287,8 +287,8 @@ public: } #define IVEC_BINFN_I(the_name) \ - VEC_INLINE static IVEC_NAME the_name(const IVEC_NAME &a, \ - const IVEC_NAME &b) { \ + VEC_INLINE static IVEC_NAME the_name(const IVEC_NAME &a, \ + const IVEC_NAME &b) { \ return _mm512_##the_name##_epi32(a.val_, b.val_); \ } IVEC_BINFN_I(mullo) @@ -407,7 +407,7 @@ public: #define FVEC_MASK_BINFN_B(the_name) \ VEC_INLINE static BVEC_NAME the_name(const FVEC_NAME &a, \ - const FVEC_NAME &b) { \ + const FVEC_NAME &b) { \ return FVEC_SUFFIX_MASK(_mm512_##the_name##_)(a.val_, b.val_); \ } \ VEC_INLINE static BVEC_NAME mask_##the_name( \ @@ -481,7 +481,7 @@ public: const BVEC_NAME &a, const FVEC_NAME &b ) { return FVEC_SUFFIX(_mm512_mask_compress_)(FVEC_SUFFIX(_mm512_undefined_)(), - a.val_, b.val_); + a.val_, b.val_); } VEC_INLINE static FVEC_NAME set1(const FVEC_SCAL_T &a) { @@ -498,7 +498,7 @@ public: return FVEC_SUFFIX(_mm512_load_)(mem); } VEC_INLINE static void mask_storeu(const BVEC_NAME &mask, FVEC_SCAL_T * dest, - const FVEC_NAME &a) { + const FVEC_NAME &a) { FVEC_SUFFIX(_mm512_mask_storeu_)(dest, mask.val_, a.val_); } VEC_INLINE static void store(FVEC_SCAL_T * dest, const FVEC_NAME &a) { @@ -506,8 +506,8 @@ public: } VEC_INLINE static FVEC_NAME gather(const IVEC_NAME &idx, - const FVEC_SCAL_T * mem, - const int scale) { + const FVEC_SCAL_T * mem, + const int scale) { assert(scale == sizeof(FVEC_SCAL_T)); # if FVEC_LEN==8 return FVEC_SUFFIX(_mm512_i32logather_)(idx.val_, mem, sizeof(FVEC_SCAL_T)); @@ -530,22 +530,22 @@ public: } VEC_INLINE static void gather_3_adjacent(const IVEC_NAME &idx, - const FVEC_SCAL_T * mem, - const int scale, - FVEC_NAME * out_0, - FVEC_NAME * out_1, - FVEC_NAME * out_2) { + const FVEC_SCAL_T * mem, + const int scale, + FVEC_NAME * out_0, + FVEC_NAME * out_1, + FVEC_NAME * out_2) { assert(scale == sizeof(FVEC_SCAL_T)); *out_0 = FVEC_NAME::gather(idx, mem + 0, scale); *out_1 = FVEC_NAME::gather(idx, mem + 1, scale); *out_2 = FVEC_NAME::gather(idx, mem + 2, scale); } VEC_INLINE static void gather_4_adjacent(const IVEC_NAME &idx, - const FVEC_SCAL_T * mem, - const int scale, FVEC_NAME * out_0, - FVEC_NAME * out_1, - FVEC_NAME * out_2, - FVEC_NAME * out_3) { + const FVEC_SCAL_T * mem, + const int scale, FVEC_NAME * out_0, + FVEC_NAME * out_1, + FVEC_NAME * out_2, + FVEC_NAME * out_3) { assert(scale == sizeof(FVEC_SCAL_T)); *out_0 = FVEC_NAME::gather(idx, mem + 0, scale); *out_1 = FVEC_NAME::gather(idx, mem + 1, scale); @@ -554,7 +554,7 @@ public: } VEC_INLINE static FVEC_SCAL_T mask_reduce_add(const BVEC_NAME &mask, - const FVEC_NAME &a) { + const FVEC_NAME &a) { return FVEC_SUFFIX(_mm512_mask_reduce_add_)(mask.val_, a.val_); } VEC_INLINE static FVEC_SCAL_T reduce_add(const FVEC_NAME &a) { @@ -609,7 +609,7 @@ public: assert(scale == sizeof(FVEC_SCAL_T)); # if FVEC_LEN==8 return FVEC_SUFFIX(_mm512_mask_i32logather_)(src.val_, mask.val_, idx.val_, - mem, sizeof(FVEC_SCAL_T)); + mem, sizeof(FVEC_SCAL_T)); # else return FVEC_SUFFIX(_mm512_mask_i32gather_)(src.val_, mask.val_, idx.val_, mem, sizeof(FVEC_SCAL_T)); @@ -622,10 +622,10 @@ public: assert(scale == sizeof(FVEC_SCAL_T)); # if FVEC_LEN==8 FVEC_SUFFIX(_mm512_mask_i32loscatter_)(mem, mask.val_, idx.val_, a.val_, - sizeof(FVEC_SCAL_T)); + sizeof(FVEC_SCAL_T)); # else FVEC_SUFFIX(_mm512_mask_i32scatter_)(mem, mask.val_, idx.val_, a.val_, - sizeof(FVEC_SCAL_T)); + sizeof(FVEC_SCAL_T)); # endif } @@ -637,7 +637,7 @@ public: VEC_INLINE static void gather_prefetch0(const IVEC_NAME &a, void * mem) { _mm512_mask_prefetch_i32gather_ps(a.val_, BVEC_NAME::full().val_, mem, - sizeof(FVEC_SCAL_T), _MM_HINT_T0); + sizeof(FVEC_SCAL_T), _MM_HINT_T0); } }; @@ -666,10 +666,10 @@ public: ) { assert(scale == sizeof(double)); __m512d lo = _mm512_mask_i32logather_pd(src.lo_, mask.val_, idx.val_, mem, - sizeof(double)); + sizeof(double)); __m512d hi = _mm512_mask_i32logather_pd(src.hi_, get_bvec_hi(mask.val_), - get_ivec_hi(idx.val_), mem, - sizeof(double)); + get_ivec_hi(idx.val_), mem, + sizeof(double)); return avec16pd(lo, hi); } VEC_INLINE static void mask_i32loscatter( @@ -678,9 +678,9 @@ public: ) { assert(scale == sizeof(double)); _mm512_mask_i32loscatter_pd(mem, mask.val_, idx.val_, a.lo_, - sizeof(double)); + sizeof(double)); _mm512_mask_i32loscatter_pd(mem, get_bvec_hi(mask.val_), - get_ivec_hi(idx.val_), a.hi_, sizeof(double)); + get_ivec_hi(idx.val_), a.hi_, sizeof(double)); } #define AVEC2_BINOP(the_sym, the_name) \ @@ -693,7 +693,7 @@ public: VEC_INLINE static void gather_prefetch0(const IVEC_NAME &a, void * mem) { _mm512_mask_prefetch_i32gather_ps(a.val_, BVEC_NAME::full().val_, mem, - sizeof(double), _MM_HINT_T0); + sizeof(double), _MM_HINT_T0); } }; #endif @@ -809,17 +809,17 @@ VEC_INLINE inline __m256i _cm256_and_si256(const __m256i &a, const __m256i &b) { } VEC_INLINE inline __m256i _cm256_andnot_si256(const __m256i &a, - const __m256i &b) { + const __m256i &b) { IVEC_EM_BIN(_mm_andnot_si128) } VEC_INLINE inline __m256i _cm256_cmpeq_epi32(const __m256i &a, - const __m256i &b) { + const __m256i &b) { IVEC_EM_BIN(_mm_cmpeq_epi32) } VEC_INLINE inline __m256i _cm256_cmpgt_epi32(const __m256i &a, - const __m256i &b) { + const __m256i &b) { IVEC_EM_BIN(_mm_cmpgt_epi32) } @@ -838,13 +838,13 @@ VEC_INLINE inline __m256i _cm256_cvtepu8_epi32(const __m128i &a) { int dest[8] __attribute__((aligned(32))); \ _mm256_store_si256((__m256i*)buf_a, a); \ _mm256_store_si256((__m256i*)buf_b, b); \ - for (int i = 0; i < 8; i++) { \ - dest[i] = op; \ - } \ + for (int i = 0; i < 8; i++) { \ + dest[i] = op; \ + } \ return _mm256_load_si256((__m256i*) dest); VEC_INLINE inline __m256i _cm256_permutevar8x32_epi32(const __m256i &a, - const __m256i &b) { + const __m256i &b) { IVEC_EM_SCAL(buf_a[buf_b[i]]) } @@ -858,9 +858,9 @@ VEC_INLINE inline __m256i _cm256_srlv_epi32(__m256i a, __m256i b) { VEC_INLINE inline __m256 _cm256_permutevar8x32_ps(const __m256 &a, - const __m256i &b) { + const __m256i &b) { return _mm256_castsi256_ps(_cm256_permutevar8x32_epi32(_mm256_castps_si256(a), - b)); + b)); } VEC_INLINE inline __m128i _cm_maskload_epi32(int const * mem, __m128i mask) { @@ -878,10 +878,10 @@ VEC_INLINE inline __m256i _cm256_maskload_epi32(int const * mem, __m256i mask) { VEC_INLINE inline __m256i _cm256_mask_i32gather_epi32(__m256i src, - int const * base_addr, - __m256i index, - __m256i mask, - const int scale) { + int const * base_addr, + __m256i index, + __m256i mask, + const int scale) { assert(scale == sizeof(int)); int buf_index[8] __attribute__((aligned(32))); int buf_mask[8] __attribute__((aligned(32))); @@ -896,18 +896,18 @@ VEC_INLINE inline __m256i _cm256_mask_i32gather_epi32(__m256i src, } VEC_INLINE inline __m256 _cm256_mask_i32gather_ps(__m256 src, - float const * base_addr, - __m256i index, __m256 mask, - const int scale) { + float const * base_addr, + __m256i index, __m256 mask, + const int scale) { return _mm256_castsi256_ps(_cm256_mask_i32gather_epi32( _mm256_castps_si256(src), (const int *) base_addr, index, _mm256_castps_si256(mask), scale)); } VEC_INLINE inline __m256d _cm256_mask_i32gather_pd(__m256d src, - double const * base_addr, - __m128i index, __m256d mask, - const int scale) { + double const * base_addr, + __m128i index, __m256d mask, + const int scale) { assert(scale == sizeof(double)); int buf_index[4] __attribute__((aligned(32))); int buf_mask[8] __attribute__((aligned(32))); @@ -922,8 +922,8 @@ VEC_INLINE inline __m256d _cm256_mask_i32gather_pd(__m256d src, } VEC_INLINE inline __m256i _cm256_i32gather_epi32(int const * base_addr, - __m256i index, - const int scale) { + __m256i index, + const int scale) { assert(scale == sizeof(int)); int buf_index[8] __attribute__((aligned(32))); int dest[8] __attribute__((aligned(32))); @@ -935,13 +935,13 @@ VEC_INLINE inline __m256i _cm256_i32gather_epi32(int const * base_addr, } VEC_INLINE inline __m256 _cm256_i32gather_ps(float const * base_addr, - __m256i index, const int scale) { + __m256i index, const int scale) { return _mm256_castsi256_ps(_cm256_i32gather_epi32((const int *) base_addr, - index, scale)); + index, scale)); } VEC_INLINE inline __m256d _cm256_i32gather_pd(double const * base_addr, - __m128i index, const int scale) { + __m128i index, const int scale) { assert(scale == sizeof(double)); int buf_index[4] __attribute__((aligned(32))); double dest[4] __attribute__((aligned(32))); @@ -1008,7 +1008,7 @@ VEC_INLINE inline uint64_t _cext_u64(uint64_t tmp, uint64_t mask) { VEC_INLINE inline __m256 _mm256_compress_ps(__m256 mask, __m256 a) { # ifdef __AVX2__ uint64_t expanded_mask = _pdep_u64(_mm256_movemask_ps(mask), - 0x0101010101010101); + 0x0101010101010101); // unpack each bit to a byte expanded_mask *= 0xFF; // mask |= mask<<1 | mask<<2 | ... | mask<<7; // the identity shuffle for vpermps, packed to one index per byte @@ -1037,7 +1037,7 @@ VEC_INLINE inline __m256 _mm256_compress_ps(__m256 mask, __m256 a) { VEC_INLINE inline __m256 _mm256_expand_ps(__m256 mask, __m256 a) { # ifdef __AVX2__ uint64_t expanded_mask = _pdep_u64(_mm256_movemask_ps(mask), - 0x0101010101010101); + 0x0101010101010101); expanded_mask *= 0xFF; const uint64_t identity_indices = 0x0706050403020100; uint64_t wanted_indices = _pdep_u64(identity_indices, expanded_mask); @@ -1062,7 +1062,7 @@ VEC_INLINE inline __m256 _mm256_expand_ps(__m256 mask, __m256 a) { VEC_INLINE inline __m256d _mm256_compress_pd(__m256d mask, __m256d a) { return _mm256_castps_pd(_mm256_compress_ps(_mm256_castpd_ps(mask), - _mm256_castpd_ps(a))); + _mm256_castpd_ps(a))); } VEC_INLINE inline __m256d _mm256_expand_pd(__m256d mask, __m256d a) { return _mm256_castps_pd(_mm256_expand_ps(_mm256_castpd_ps(mask), @@ -1084,7 +1084,7 @@ class BVEC_NAME { FVEC_MASK_T val_; VEC_INLINE BVEC_NAME(const FVEC_MASK_T &v) : val_(v) {} VEC_INLINE BVEC_NAME(const __m256i &v) : val_(FVEC_SUFFIX(_mm256_castsi256_) - (v)) {} + (v)) {} public: VEC_INLINE BVEC_NAME() {} VEC_INLINE static BVEC_NAME kand(const BVEC_NAME &a, const BVEC_NAME &b) { @@ -1094,16 +1094,16 @@ public: return FVEC_SUFFIX(_mm256_andnot_)(a.val_, b.val_); } VEC_INLINE static BVEC_NAME masku_compress(const BVEC_NAME &mask, - const BVEC_NAME &a) { + const BVEC_NAME &a) { return FVEC_SUFFIX(_mm256_compress_)(mask.val_, a.val_); } VEC_INLINE static BVEC_NAME mask_expand(const BVEC_NAME &src, - const BVEC_NAME &mask, - const BVEC_NAME &a) { + const BVEC_NAME &mask, + const BVEC_NAME &a) { FVEC_MASK_T ret = FVEC_SUFFIX(_mm256_expand_)(mask.val_, a.val_); ret = FVEC_SUFFIX(_mm256_and_)(mask.val_, ret); ret = FVEC_SUFFIX(_mm256_or_)(ret, FVEC_SUFFIX(_mm256_andnot_) - (mask.val_, src.val_)); + (mask.val_, src.val_)); return ret; } VEC_INLINE static BVEC_NAME full() { @@ -1210,7 +1210,7 @@ public: #define IVEC_MASK_BINFN_B(the_name) \ VEC_INLINE static BVEC_NAME the_name(const IVEC_NAME &a, \ - const IVEC_NAME &b) { \ + const IVEC_NAME &b) { \ return _mm256_##the_name##_epi32(a.val_, b.val_); \ } \ VEC_INLINE static BVEC_NAME mask_##the_name( \ @@ -1253,15 +1253,15 @@ public: const IVEC_NAME &a, const IVEC_NAME &b \ ) { \ IVEC_NAME ret = _mm256_##the_name##_epi32( \ - a.val_, b.val_); \ - return mask_blend(mask, src, ret); \ + a.val_, b.val_); \ + return mask_blend(mask, src, ret); \ } IVEC_MASK_BINFN_I(add) #undef IVEC_MASK_BINFN_I #define IVEC_BINFN_I(the_name) \ VEC_INLINE static IVEC_NAME the_name(const IVEC_NAME &a, \ - const IVEC_NAME &b) { \ + const IVEC_NAME &b) { \ return _mm256_##the_name##_epi32(a.val_, b.val_); \ } IVEC_BINFN_I(mullo) @@ -1272,7 +1272,7 @@ public: } VEC_INLINE static IVEC_NAME masku_compress(const BVEC_NAME &mask, - const IVEC_NAME &b) { + const IVEC_NAME &b) { return to(FVEC_SUFFIX(_mm256_compress_)(mask.val_, from(b.val_))); } VEC_INLINE static IVEC_NAME mask_expand( @@ -1281,7 +1281,7 @@ public: FVEC_VEC_T ret = FVEC_SUFFIX(_mm256_expand_)(mask.val_, from(b.val_)); ret = FVEC_SUFFIX(_mm256_and_)(mask.val_, ret); ret = FVEC_SUFFIX(_mm256_or_)(ret, FVEC_SUFFIX(_mm256_andnot_) - (mask.val_, from(src.val_))); + (mask.val_, from(src.val_))); return to(ret); } @@ -1311,7 +1311,7 @@ public: } VEC_INLINE static IVEC_NAME maskz_loadu(const BVEC_NAME &mask, - const int * src) { + const int * src) { FVEC_VEC_T mask_val = mask.val_; # if FVEC_LEN==4 # ifdef __AVX2__ @@ -1349,11 +1349,11 @@ public: ) { assert(scale == sizeof(int)); return _mm256_mask_i32gather_epi32(src.val_, mem, idx.val_, to(mask.val_), - sizeof(int)); + sizeof(int)); } VEC_INLINE static void mask_compressstore(const BVEC_NAME &mask, int * dest, - const IVEC_NAME &src) { + const IVEC_NAME &src) { int buf[8] __attribute__((aligned(64))); const int stride = FVEC_LEN==4 ? 2 : 1; _mm256_store_si256((__m256i*)buf, src.val_); @@ -1403,18 +1403,18 @@ public: return data[i]; } - #define FVEC_MASK_BINFN_B(the_name, the_imm) \ - VEC_INLINE static BVEC_NAME the_name(const FVEC_NAME &a, \ - const FVEC_NAME &b) { \ + #define FVEC_MASK_BINFN_B(the_name, the_imm) \ + VEC_INLINE static BVEC_NAME the_name(const FVEC_NAME &a, \ + const FVEC_NAME &b) { \ return FVEC_SUFFIX(_mm256_cmp_)(a.val_, b.val_, the_imm); \ - } \ + } \ VEC_INLINE static BVEC_NAME mask_##the_name( \ const BVEC_NAME &mask, \ const FVEC_NAME &a, const FVEC_NAME &b \ ) { \ BVEC_NAME ret = FVEC_SUFFIX(_mm256_cmp_)( \ a.val_, b.val_, the_imm); \ - return mask & ret; \ + return mask & ret; \ } FVEC_MASK_BINFN_B(cmple, _CMP_LE_OS) FVEC_MASK_BINFN_B(cmplt, _CMP_LT_OS) @@ -1434,15 +1434,15 @@ public: const unsigned long long abs_mask = 0x7FFFFFFFFFFFFFFF; const unsigned long long abs_full[8] = {abs_mask, abs_mask, abs_mask, abs_mask, abs_mask, abs_mask, abs_mask, - abs_mask}; + abs_mask}; return _mm256_and_pd(_mm256_load_pd((double*)abs_full), a); } VEC_INLINE static __m256 _mm256_abs_ps(__m256 a) { const unsigned long long abs_mask = 0x7FFFFFFF; const unsigned long long abs_full[16] = {abs_mask, abs_mask, abs_mask, abs_mask, abs_mask, abs_mask, abs_mask, - abs_mask, abs_mask, abs_mask, abs_mask, abs_mask, abs_mask, - abs_mask, abs_mask, abs_mask}; + abs_mask, abs_mask, abs_mask, abs_mask, abs_mask, abs_mask, + abs_mask, abs_mask, abs_mask}; return _mm256_and_ps(_mm256_load_ps((float*)abs_full), a); } @@ -1468,8 +1468,8 @@ public: const FVEC_NAME &a \ ) { \ FVEC_NAME ret = FVEC_SUFFIX(_mm256_##the_name##_)( \ - a.val_); \ - return mask_blend(mask, src, ret); \ + a.val_); \ + return mask_blend(mask, src, ret); \ } FVEC_MASK_UNFN_F(cos) FVEC_MASK_UNFN_F(recip) @@ -1478,15 +1478,15 @@ public: #define FVEC_BINFN_F(the_name) \ VEC_INLINE static FVEC_NAME the_name(const FVEC_NAME &a, \ - const FVEC_NAME &b) { \ - return FVEC_SUFFIX(_mm256_##the_name##_)(a.val_, b.val_); \ + const FVEC_NAME &b) { \ + return FVEC_SUFFIX(_mm256_##the_name##_)(a.val_, b.val_); \ } FVEC_BINFN_F(max) FVEC_BINFN_F(min) #undef FVEC_BINFN_F #define FVEC_MASK_BINFN_F(the_name) \ - VEC_INLINE static FVEC_NAME mask_##the_name( \ + VEC_INLINE static FVEC_NAME mask_##the_name( \ const FVEC_NAME &src, const BVEC_NAME &mask, \ const FVEC_NAME &a, const FVEC_NAME &b \ ) { \ @@ -1633,11 +1633,11 @@ public: # endif } VEC_INLINE static void gather_3_adjacent(const IVEC_NAME &idx, - const FVEC_SCAL_T * mem, - const int scale, - FVEC_NAME * out_0, - FVEC_NAME * out_1, - FVEC_NAME * out_2) { + const FVEC_SCAL_T * mem, + const int scale, + FVEC_NAME * out_0, + FVEC_NAME * out_1, + FVEC_NAME * out_2) { assert(scale == sizeof(FVEC_SCAL_T)); FVEC_NAME tmp_3; gather_4_adjacent(idx, mem, scale, out_0, out_1, out_2, &tmp_3); @@ -1663,7 +1663,7 @@ public: return FVEC_SUFFIX(_mm256_reduce_add_)(a.val_); } VEC_INLINE static FVEC_SCAL_T mask_reduce_add(const BVEC_NAME &mask, - const FVEC_NAME &a) { + const FVEC_NAME &a) { return reduce_add(FVEC_SUFFIX(_mm256_and_)(mask.val_, a.val_)); } @@ -1800,9 +1800,9 @@ public: __m256d hi_mask = _mm256_castps_pd(_mm256_permutevar8x32_ps(mask.val_, _mm256_load_si256((__m256i*) hi_shuffle))); __m256d lo = _mm256_mask_i32gather_pd(src.lo_, mem, get_si_lo(idx.val_), - lo_mask, sizeof(double)); + lo_mask, sizeof(double)); __m256d hi = _mm256_mask_i32gather_pd(src.hi_, mem, get_si_hi(idx.val_), - hi_mask, sizeof(double)); + hi_mask, sizeof(double)); # endif return avec8pd(lo, hi); } @@ -1912,7 +1912,7 @@ public: return mask.val_ ? a.val_ : false; } VEC_INLINE static bvec mask_expand(const bvec &src, const bvec &mask, - const bvec &a) { + const bvec &a) { return mask.val_ ? a.val_ : src.val_; } VEC_INLINE static bvec full() { @@ -2038,14 +2038,14 @@ public: VEC_INLINE static ivec mask_gather( const ivec &src, const bvec &mask, const ivec &idx, const int * mem, - const int scale + const int scale ) { return mask.val_ ? *reinterpret_cast<const int *> (reinterpret_cast<const char*>(mem) + scale * idx.val_) : src.val_; } VEC_INLINE static void mask_i32scatter( int * mem, const bvec &mask, const ivec &idx, const ivec &a, - const int scale + const int scale ) { if (mask.val_) *reinterpret_cast<int *>(reinterpret_cast<char*>(mem) + scale * idx.val_) = a.val_; @@ -2176,7 +2176,7 @@ public: return *mem; } VEC_INLINE static void mask_storeu(const bvec &mask, flt_t * dest, - const fvec &a) { + const fvec &a) { if (mask.val_) *dest = a.val_; } VEC_INLINE static void store(flt_t * dest, const fvec &a) { @@ -2184,7 +2184,7 @@ public: } VEC_INLINE static fvec gather(const ivec &idx, const flt_t * mem, - const int scale) { + const int scale) { return *reinterpret_cast<const flt_t*>(reinterpret_cast<const char*>(mem) + scale * idx.val_); } @@ -2197,17 +2197,17 @@ public: } VEC_INLINE static void gather_3_adjacent(const ivec &idx, const flt_t * mem, - const int scale, fvec * out_0, - fvec * out_1, fvec * out_2) { + const int scale, fvec * out_0, + fvec * out_1, fvec * out_2) { assert(scale == sizeof(flt_t)); *out_0 = gather(idx, mem + 0, scale); *out_1 = gather(idx, mem + 1, scale); *out_2 = gather(idx, mem + 2, scale); } VEC_INLINE static void gather_4_adjacent(const ivec &idx, const flt_t * mem, - const int scale, fvec * out_0, - fvec * out_1, fvec * out_2, - fvec * out_3) { + const int scale, fvec * out_0, + fvec * out_1, fvec * out_2, + fvec * out_3) { assert(scale == sizeof(flt_t)); *out_0 = gather(idx, mem + 0, scale); *out_1 = gather(idx, mem + 1, scale); @@ -2255,16 +2255,16 @@ public: return 1337.1337; } VEC_INLINE static avec mask_gather(const avec &src, const bvec &mask, - const ivec &idx, const acc_t * mem, - const int scale) { + const ivec &idx, const acc_t * mem, + const int scale) { return mask.val_ ? *reinterpret_cast<const acc_t*> (reinterpret_cast<const char*>(mem) + scale * idx.val_) : src.val_; } VEC_INLINE static void mask_i32loscatter(acc_t * mem, const bvec &mask, - const ivec &idx, const avec &a, - const int scale) { + const ivec &idx, const avec &a, + const int scale) { if (mask.val_) *reinterpret_cast<acc_t*>(reinterpret_cast<char*>(mem) + - idx.val_ * scale) = a.val_; + idx.val_ * scale) = a.val_; } #define AVEC_BINOP(the_sym, the_name) \ diff --git a/src/USER-INTEL/intel_preprocess.h b/src/USER-INTEL/intel_preprocess.h index 068f61023e..29cc45f755 100644 --- a/src/USER-INTEL/intel_preprocess.h +++ b/src/USER-INTEL/intel_preprocess.h @@ -211,8 +211,8 @@ enum {TIME_PACK, TIME_HOST_NEIGHBOR, TIME_HOST_PAIR, TIME_OFFLOAD_NEIGHBOR, datasize); \ } -#define IP_PRE_omp_range_vec(ifrom, ito, tid, inum, nthreads, \ - vecsize) \ +#define IP_PRE_omp_range_vec(ifrom, ito, tid, inum, nthreads, \ + vecsize) \ { \ int idelta = static_cast<int>(ceil(static_cast<float>(inum) \ /vecsize/nthreads)); \ @@ -226,8 +226,8 @@ enum {TIME_PACK, TIME_HOST_NEIGHBOR, TIME_HOST_PAIR, TIME_OFFLOAD_NEIGHBOR, nthreads, vecsize) \ { \ tid = omp_get_thread_num(); \ - IP_PRE_omp_range_vec(ifrom, ito, tid, inum, nthreads, \ - vecsize); \ + IP_PRE_omp_range_vec(ifrom, ito, tid, inum, nthreads, \ + vecsize); \ } #define IP_PRE_omp_stride_id_vec(ifrom, ip, ito, tid, inum, \ @@ -242,12 +242,12 @@ enum {TIME_PACK, TIME_HOST_NEIGHBOR, TIME_HOST_PAIR, TIME_OFFLOAD_NEIGHBOR, int nd = nthr / INTEL_HTHREADS; \ int td = tid / INTEL_HTHREADS; \ int tm = tid % INTEL_HTHREADS; \ - IP_PRE_omp_range_vec(ifrom, ito, td, inum, nd, vecsize); \ + IP_PRE_omp_range_vec(ifrom, ito, td, inum, nd, vecsize); \ ifrom += tm * vecsize; \ ip = INTEL_HTHREADS * vecsize; \ } else { \ - IP_PRE_omp_range_vec(ifrom, ito, tid, inum, nthr, \ - vecsize); \ + IP_PRE_omp_range_vec(ifrom, ito, tid, inum, nthr, \ + vecsize); \ ip = vecsize; \ } \ } @@ -301,10 +301,10 @@ enum {TIME_PACK, TIME_HOST_NEIGHBOR, TIME_HOST_PAIR, TIME_OFFLOAD_NEIGHBOR, #define IP_PRE_omp_stride_id_vec(ifrom, ip, ito, tid, inum, \ nthr, vecsize) \ { \ - tid = 0; \ - ifrom = 0; \ - ip = 1; \ - ito = inum; \ + tid = 0; \ + ifrom = 0; \ + ip = 1; \ + ito = inum; \ } #endif diff --git a/src/USER-INTEL/nbin_intel.cpp b/src/USER-INTEL/nbin_intel.cpp index 9a1dae36ca..e071b141fe 100644 --- a/src/USER-INTEL/nbin_intel.cpp +++ b/src/USER-INTEL/nbin_intel.cpp @@ -212,8 +212,8 @@ void NBinIntel::bin_atoms(IntelBuffers<flt_t,acc_t> * buffers) { for (i = nall-1; i >= nlocal; i--) { if (mask[i] & bitmask) { ibin = coord2bin(atom->x[i]); - // Only necessary to store when neighboring ghost - atombin[i] = ibin; + // Only necessary to store when neighboring ghost + atombin[i] = ibin; bins[i] = binhead[ibin]; binhead[ibin] = i; } diff --git a/src/USER-INTEL/npair_full_bin_ghost_intel.cpp b/src/USER-INTEL/npair_full_bin_ghost_intel.cpp index a814891f25..574855e468 100644 --- a/src/USER-INTEL/npair_full_bin_ghost_intel.cpp +++ b/src/USER-INTEL/npair_full_bin_ghost_intel.cpp @@ -68,7 +68,7 @@ void NPairFullBinGhostIntel::build(NeighList *list) template<class flt_t, class acc_t> void NPairFullBinGhostIntel::fbi(NeighList * list, - IntelBuffers<flt_t,acc_t> * buffers) + IntelBuffers<flt_t,acc_t> * buffers) { const int nlocal = atom->nlocal; const int nall = atom->nlocal + atom->nghost; @@ -87,12 +87,12 @@ void NPairFullBinGhostIntel::fbi(NeighList * list, // only uses offload_end_neighbor to check whether we are doing offloading // at all, no need to correct this later buffers->grow_list(list, nall, comm->nthreads, off_end, - _fix->nbor_pack_width()); + _fix->nbor_pack_width()); int need_ic = 0; if (atom->molecular) dminimum_image_check(need_ic, neighbor->cutneighmax, neighbor->cutneighmax, - neighbor->cutneighmax); + neighbor->cutneighmax); if (need_ic) { fbi<flt_t,acc_t,1>(1, list, buffers, 0, off_end); @@ -107,8 +107,8 @@ void NPairFullBinGhostIntel::fbi(NeighList * list, template<class flt_t, class acc_t, int need_ic> void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, - IntelBuffers<flt_t,acc_t> * buffers, - const int pstart, const int pend) { + IntelBuffers<flt_t,acc_t> * buffers, + const int pstart, const int pend) { if (pend-pstart == 0) return; const int nall = atom->nlocal + atom->nghost; @@ -164,7 +164,7 @@ void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, else moltemplate = 0; if (moltemplate) error->all(FLERR, - "Can't use moltemplate with npair style full/bin/ghost/intel."); + "Can't use moltemplate with npair style full/bin/ghost/intel."); int tnum; int *overflow; @@ -316,38 +316,38 @@ void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, if (ibin != oldbin) { oldbin = ibin; ncount = 0; - if (i < nlocal) { - for (int k = 0; k < nstencilp; k++) { - const int bstart = binhead[ibin + binstart[k]]; - const int bend = binhead[ibin + binend[k]]; + if (i < nlocal) { + for (int k = 0; k < nstencilp; k++) { + const int bstart = binhead[ibin + binstart[k]]; + const int bend = binhead[ibin + binend[k]]; #if defined(LMP_SIMD_COMPILER) #pragma simd #endif for (int jj = bstart; jj < bend; jj++) tj[ncount++] = binpacked[jj]; - } - } else { - const int zbin = ibin / mbinyx; - const int zrem = ibin % mbinyx; - const int ybin = zrem / mbinx; - const int xbin = zrem % mbinx; - for (int k = 0; k < nstencil; k++) { - const int xbin2 = xbin + stencilxyz[3 * k + 0]; - const int ybin2 = ybin + stencilxyz[3 * k + 1]; - const int zbin2 = zbin + stencilxyz[3 * k + 2]; - if (xbin2 < 0 || xbin2 >= mbinx || + } + } else { + const int zbin = ibin / mbinyx; + const int zrem = ibin % mbinyx; + const int ybin = zrem / mbinx; + const int xbin = zrem % mbinx; + for (int k = 0; k < nstencil; k++) { + const int xbin2 = xbin + stencilxyz[3 * k + 0]; + const int ybin2 = ybin + stencilxyz[3 * k + 1]; + const int zbin2 = zbin + stencilxyz[3 * k + 2]; + if (xbin2 < 0 || xbin2 >= mbinx || ybin2 < 0 || ybin2 >= mbiny || zbin2 < 0 || zbin2 >= mbinz) continue; - const int bstart = binhead[ibin + stencil[k]]; - const int bend = binhead[ibin + stencil[k] + 1]; + const int bstart = binhead[ibin + stencil[k]]; + const int bend = binhead[ibin + stencil[k] + 1]; #if defined(LMP_SIMD_COMPILER) #pragma simd #endif for (int jj = bstart; jj < bend; jj++) tj[ncount++] = binpacked[jj]; - } - } // if i < nlocal + } + } // if i < nlocal #if defined(LMP_SIMD_COMPILER) #pragma vector aligned #pragma simd @@ -358,20 +358,20 @@ void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, ty[u] = x[j].y; tz[u] = x[j].z; tjtype[u] = x[j].w; - ttag[u] = tag[j]; + ttag[u] = tag[j]; } - } // if ibin != oldbin + } // if ibin != oldbin // ---------------------- Loop over other bins int n = maxnbors; int n2 = n * 2; - int *neighptr2 = neighptr; - const flt_t * _noalias cutsq; - if (i < nlocal) cutsq = cutneighsq; - else cutsq = cutneighghostsq; + int *neighptr2 = neighptr; + const flt_t * _noalias cutsq; + if (i < nlocal) cutsq = cutneighsq; + else cutsq = cutneighghostsq; - const int icp = i; + const int icp = i; #if defined(LMP_SIMD_COMPILER) #pragma vector aligned @@ -381,41 +381,41 @@ void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, int addme = 1; int j = tj[u]; - if (i == j) addme = 0; + if (i == j) addme = 0; // Cutoff Check const flt_t delx = xtmp - tx[u]; const flt_t dely = ytmp - ty[u]; const flt_t delz = ztmp - tz[u]; const int jtype = tjtype[u]; - const int jtag = ttag[u]; + const int jtag = ttag[u]; const flt_t rsq = delx * delx + dely * dely + delz * delz; if (rsq > cutsq[ioffset + jtype]) addme = 0; if (need_ic && icp < nlocal) { int no_special; - ominimum_image_check(no_special, delx, dely, delz); + ominimum_image_check(no_special, delx, dely, delz); if (no_special) j = -j - 1; } - int flist = 0; - if (itag > jtag) { - if (((itag+jtag) & 1) == 0) flist = 1; - } else if (itag < jtag) { - if (((itag+jtag) & 1) == 1) flist = 1; - } else { - if (tz[u] < ztmp) flist = 1; - else if (tz[u] == ztmp && ty[u] < ytmp) flist = 1; - else if (tz[u] == ztmp && ty[u] == ytmp && tx[u] < xtmp) - flist = 1; - } - if (addme) { - if (flist) - neighptr2[n2++] = j; - else - neighptr[n++] = j; - } + int flist = 0; + if (itag > jtag) { + if (((itag+jtag) & 1) == 0) flist = 1; + } else if (itag < jtag) { + if (((itag+jtag) & 1) == 1) flist = 1; + } else { + if (tz[u] < ztmp) flist = 1; + else if (tz[u] == ztmp && ty[u] < ytmp) flist = 1; + else if (tz[u] == ztmp && ty[u] == ytmp && tx[u] < xtmp) + flist = 1; + } + if (addme) { + if (flist) + neighptr2[n2++] = j; + else + neighptr[n++] = j; + } } // for u #ifndef _LMP_INTEL_OFFLOAD @@ -431,45 +431,45 @@ void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, if (exclusion(i,pj,itype,jtype,mask,molecule)) continue; neighptr[n++] = j; } - alln = n2; - n2 = maxnbors * 2; - for (int u = n2; u < alln; u++) { - const int j = neighptr[u]; - int pj = j; - if (need_ic) - if (pj < 0) pj = -j - 1; - const int jtype = x[pj].w; - if (exclusion(i,pj,itype,jtype,mask,molecule)) continue; - neighptr[n2++] = j; - } + alln = n2; + n2 = maxnbors * 2; + for (int u = n2; u < alln; u++) { + const int j = neighptr[u]; + int pj = j; + if (need_ic) + if (pj < 0) pj = -j - 1; + const int jtype = x[pj].w; + if (exclusion(i,pj,itype,jtype,mask,molecule)) continue; + neighptr[n2++] = j; + } } #endif int ns = n - maxnbors; - int alln = n; - atombin[i] = ns; - n = 0; - for (int u = maxnbors; u < alln; u++) + int alln = n; + atombin[i] = ns; + n = 0; + for (int u = maxnbors; u < alln; u++) neighptr[n++] = neighptr[u]; - ns += n2 - maxnbors * 2; - for (int u = maxnbors * 2; u < n2; u++) + ns += n2 - maxnbors * 2; + for (int u = maxnbors * 2; u < n2; u++) neighptr[n++] = neighptr[u]; - if (ns > maxnbors) *overflow = 1; + if (ns > maxnbors) *overflow = 1; ilist[i] = i; cnumneigh[i] = ct; numneigh[i] = ns; - ct += ns; - const int alignb = (INTEL_DATA_ALIGN / sizeof(int)); - const int edge = ct & (alignb - 1); - if (edge) ct += alignb - edge; - neighptr = firstneigh + ct; - if (ct + obound > list_size) { - if (i < ito - 1) { - *overflow = 1; - ct = (ifrom + tid * 2) * maxnbors; - } - } + ct += ns; + const int alignb = (INTEL_DATA_ALIGN / sizeof(int)); + const int edge = ct & (alignb - 1); + if (edge) ct += alignb - edge; + neighptr = firstneigh + ct; + if (ct + obound > list_size) { + if (i < ito - 1) { + *overflow = 1; + ct = (ifrom + tid * 2) * maxnbors; + } + } } if (*overflow == 1) @@ -492,10 +492,10 @@ void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, } } - overflow[LMP_LOCAL_MIN] = 0; - overflow[LMP_LOCAL_MAX] = nlocal - 1; - overflow[LMP_GHOST_MIN] = nlocal; - overflow[LMP_GHOST_MAX] = e_nall - 1; + overflow[LMP_LOCAL_MIN] = 0; + overflow[LMP_LOCAL_MAX] = nlocal - 1; + overflow[LMP_GHOST_MIN] = nlocal; + overflow[LMP_GHOST_MAX] = e_nall - 1; int nghost = overflow[LMP_GHOST_MAX] + 1 - overflow[LMP_GHOST_MIN]; if (nghost < 0) nghost = 0; @@ -510,8 +510,8 @@ void NPairFullBinGhostIntel::fbi(const int offload, NeighList * list, #endif if (molecular) { - int ito_m = ito; - if (ito >= nlocal) ito_m = nlocal; + int ito_m = ito; + if (ito >= nlocal) ito_m = nlocal; for (int i = ifrom; i < ito_m; ++i) { int * _noalias jlist = firstneigh + cnumneigh[i]; const int jnum = numneigh[i]; diff --git a/src/USER-INTEL/npair_full_bin_ghost_intel.h b/src/USER-INTEL/npair_full_bin_ghost_intel.h index 1571539505..94e6fc3928 100644 --- a/src/USER-INTEL/npair_full_bin_ghost_intel.h +++ b/src/USER-INTEL/npair_full_bin_ghost_intel.h @@ -41,7 +41,7 @@ class NPairFullBinGhostIntel : public NPairIntel { void fbi(NeighList * list, IntelBuffers<flt_t,acc_t> * buffers); template<class flt_t, class acc_t, int need_ic> void fbi(const int offload, NeighList * list, - IntelBuffers<flt_t,acc_t> * buffers, + IntelBuffers<flt_t,acc_t> * buffers, const int astart, const int aend); }; diff --git a/src/USER-INTEL/npair_intel.cpp b/src/USER-INTEL/npair_intel.cpp index 234557c941..d3d2745aee 100644 --- a/src/USER-INTEL/npair_intel.cpp +++ b/src/USER-INTEL/npair_intel.cpp @@ -292,7 +292,7 @@ void NPairIntel::bin_newton(const int offload, NeighList *list, ty[u] = x[j].y; tz[u] = x[j].z; tjtype[u] = x[j].w; - if (THREE) ttag[u] = tag[j]; + if (THREE) ttag[u] = tag[j]; } if (FULL == 0 || TRI == 1) { @@ -440,9 +440,9 @@ void NPairIntel::bin_newton(const int offload, NeighList *list, const int jtag = ttag[u]; int flist = 0; if (itag > jtag) { - if (((itag+jtag) & 1) == 0) flist = 1; + if (((itag+jtag) & 1) == 0) flist = 1; } else if (itag < jtag) { - if (((itag+jtag) & 1) == 1) flist = 1; + if (((itag+jtag) & 1) == 1) flist = 1; } else { if (tz[u] < ztmp) flist = 1; else if (tz[u] == ztmp && ty[u] < ytmp) flist = 1; diff --git a/src/USER-INTEL/pair_airebo_intel.cpp b/src/USER-INTEL/pair_airebo_intel.cpp index b35d0210a7..0499d2ad62 100644 --- a/src/USER-INTEL/pair_airebo_intel.cpp +++ b/src/USER-INTEL/pair_airebo_intel.cpp @@ -233,18 +233,18 @@ PairAIREBOIntelParam<flt_t,acc_t> PairAIREBOIntel::get_param() #define A(a) \ for (int i = 0; i < sizeof(this->a)/sizeof(double); i++) { \ - reinterpret_cast<flt_t*>(&fc.a)[i] = \ - reinterpret_cast<double*>(&this->a)[i]; \ + reinterpret_cast<flt_t*>(&fc.a)[i] = \ + reinterpret_cast<double*>(&this->a)[i]; \ } -#define A0(a) \ - for (int i = 0; i < sizeof(fc.a)/sizeof(flt_t); i++) { \ - reinterpret_cast<flt_t*>(&fc.a)[i] = \ - reinterpret_cast<double*>(this->a[0])[i]; \ +#define A0(a) \ + for (int i = 0; i < sizeof(fc.a)/sizeof(flt_t); i++) { \ + reinterpret_cast<flt_t*>(&fc.a)[i] = \ + reinterpret_cast<double*>(this->a[0])[i]; \ } -#define B(a) \ - for (int i = 0; i < sizeof(this->a)/sizeof(double); i++) { \ - reinterpret_cast<acc_t*>(&fc.a)[i] = \ - reinterpret_cast<double*>(&this->a)[i]; \ +#define B(a) \ + for (int i = 0; i < sizeof(this->a)/sizeof(double); i++) { \ + reinterpret_cast<acc_t*>(&fc.a)[i] = \ + reinterpret_cast<double*>(&this->a)[i]; \ } A(cutlj) A(cutljrebosq) A(cut3rebo) A(sigmin); @@ -265,11 +265,11 @@ PairAIREBOIntelParam<flt_t,acc_t> PairAIREBOIntel::get_param() for (int i = 0; i < 5; i++) fc.gDom[i] = fc.gCdom[i]; for (int i = 0; i < 4; i++) fc.gDom[5+i] = fc.gHdom[i]; for (int i = 0; i < 4; i++) for (int j = 0; j < 6; j++) - fc.gVal[6*i+j] = fc.gC1[i][j]; + fc.gVal[6*i+j] = fc.gC1[i][j]; for (int i = 0; i < 4; i++) for (int j = 0; j < 6; j++) - fc.gVal[4*6+6*i+j] = fc.gC2[i][j]; + fc.gVal[4*6+6*i+j] = fc.gC2[i][j]; for (int i = 0; i < 3; i++) for (int j = 0; j < 6; j++) - fc.gVal[8*6+6*i+j] = fc.gH[i][j]; + fc.gVal[8*6+6*i+j] = fc.gH[i][j]; return fc; } @@ -408,8 +408,8 @@ void PairAIREBOIntel::eval( int x_size, q_size, f_stride, ev_size, separate_flag; IP_PRE_get_transfern(ago, 1 /*NEWTON_PAIR*/, EFLAG, vflag, - buffers, offload, fix, separate_flag, - x_size, q_size, ev_size, f_stride); + buffers, offload, fix, separate_flag, + x_size, q_size, ev_size, f_stride); int tc; FORCE_T * _noalias f_start; @@ -469,7 +469,7 @@ void PairAIREBOIntel::eval( #endif IP_PRE_repack_for_offload(1 /*NEWTON_PAIR*/, separate_flag, nlocal, nall, - f_stride, x, 0/*q*/); + f_stride, x, 0/*q*/); acc_t oevdwl, oecoul, ov0, ov1, ov2, ov3, ov4, ov5; if (EVFLAG) { @@ -480,7 +480,7 @@ void PairAIREBOIntel::eval( // loop over neighbors of my atoms #if defined(_OPENMP) #pragma omp parallel \ - shared(f_start,f_stride,nlocal,nall,minlocal) \ + shared(f_start,f_stride,nlocal,nall,minlocal) \ reduction(+:oevdwl,oecoul,ov0,ov1,ov2,ov3,ov4,ov5) #endif { @@ -740,7 +740,7 @@ inline flt_t gSpline(KernelArgsAIREBOT<flt_t,acc_t> * ka, int itype, flt_t cos, template<typename flt_t> inline flt_t eval_poly_bi(int n, flt_t * coeffs, flt_t x, flt_t y, - flt_t * deriv) { + flt_t * deriv) { flt_t dy; flt_t vy = eval_poly_lin(n, &coeffs[n * (n - 1)], y, &dy); flt_t result = vy; @@ -759,7 +759,7 @@ inline flt_t eval_poly_bi(int n, flt_t * coeffs, flt_t x, flt_t y, template<typename flt_t> inline flt_t eval_poly_tri(int n, flt_t * coeffs, flt_t x, flt_t y, flt_t z, - flt_t * deriv) { + flt_t * deriv) { flt_t dyz[2]; flt_t vyz = eval_poly_bi(n, &coeffs[n * n * (n - 1)], y, z, &dyz[0]); flt_t result = vyz; @@ -781,7 +781,7 @@ inline flt_t eval_poly_tri(int n, flt_t * coeffs, flt_t x, flt_t y, flt_t z, template<typename flt_t, typename acc_t> inline flt_t PijSpline(KernelArgsAIREBOT<flt_t,acc_t> * ka, int itype, - int jtype, flt_t NC, flt_t NH, flt_t * dN) { + int jtype, flt_t NC, flt_t NH, flt_t * dN) { dN[0] = 0.0; dN[1] = 0.0; if (itype == HYDROGEN) return 0; @@ -814,7 +814,7 @@ inline flt_t TijSpline(KernelArgsAIREBOT<flt_t,acc_t> * ka, flt_t Nij, int nji = floor(Nji); int nijconj = floor(Nijconj); if (fabs(Nij - nij) < TOL && fabs(Nji - nji) < - TOL && fabs(Nijconj - nijconj) < TOL) { + TOL && fabs(Nijconj - nijconj) < TOL) { dN3[0] = ka->params.Tdfdx[nij][nji][nijconj]; dN3[1] = ka->params.Tdfdy[nij][nji][nijconj]; dN3[2] = ka->params.Tdfdz[nij][nji][nijconj]; @@ -835,11 +835,11 @@ inline flt_t piRCSpline(KernelArgsAIREBOT<flt_t,acc_t> * ka, int itype, /* const int CC = 0; */ int select = itype + jtype; #define piRCSelect(a, b, c) (select == HH ? ka->params.a : select == CH ? \ - ka->params.b : ka->params.c) + ka->params.b : ka->params.c) flt_t * piIJdom = &piRCSelect(piHHdom, piCHdom, piCCdom)[0][0]; if (select == HH) { if (Nij < piIJdom[0] || Nij > piIJdom[1] || Nji < piIJdom[2] || - Nji > piIJdom[3] || Nijconj < piIJdom[4] || Nijconj > piIJdom[5]) { + Nji > piIJdom[3] || Nijconj < piIJdom[4] || Nijconj > piIJdom[5]) { Nij = 0; Nji = 0; Nijconj = 0; @@ -852,7 +852,7 @@ inline flt_t piRCSpline(KernelArgsAIREBOT<flt_t,acc_t> * ka, int itype, int nji = floor(Nji); int nijconj = floor(Nijconj); if (fabs(Nij - nij) < TOL && fabs(Nji - nji) < - TOL && fabs(Nijconj - nijconj) < TOL) { + TOL && fabs(Nijconj - nijconj) < TOL) { dN3[0] = piRCSelect(piHHdfdx, piCHdfdx, piCCdfdx)[nij][nji][nijconj]; dN3[1] = piRCSelect(piHHdfdy, piCHdfdy, piCCdfdy)[nij][nji][nijconj]; dN3[2] = piRCSelect(piHHdfdz, piCHdfdz, piCCdfdz)[nij][nji][nijconj]; @@ -922,7 +922,7 @@ inline flt_t frebo_pij(KernelArgsAIREBOT<flt_t,acc_t> * ka, int i, int j, flt_t wik = Sp(rikmag, rcminik, rcmaxik, &dwik); flt_t Nki = nC[k] + nH[k] - wik; flt_t cosjik = (rijx * rikx + rijy * riky + rijz * rikz) / - (rijmag * rikmag); + (rijmag * rikmag); cosjik = fmin_nonan<flt_t>(1, fmax_nonan<flt_t>(-1, cosjik)); flt_t dgdc, dgdN; flt_t g = gSpline(ka, itype, cosjik, Nij, &dgdc, &dgdN); @@ -1132,7 +1132,7 @@ inline flt_t frebo_sum_omega(KernelArgsAIREBOT<flt_t,acc_t> * ka, int i, int j, flt_t r34z = x[a3].z - x[a4].z; flt_t r34mag = overloaded::sqrt(r34x * r34x + r34y * r34y + r34z * r34z); flt_t cos234 = (r32x * r34x + r32y * r34y + r32z * r34z) / - (r23mag * r34mag); + (r23mag * r34mag); cos234 = fmin_nonan<flt_t>(1, fmax_nonan<flt_t>(-1, cos234)); flt_t sin234 = overloaded::sqrt(1 - cos234 * cos234); if (sin234 == 0) continue; @@ -2128,9 +2128,9 @@ void ref_lennard_jones_single_interaction(KernelArgsAIREBOT<flt_t,acc_t> * ka, flt_t r6inv = r2inv * r2inv * r2inv; vdw = r6inv * (ka->params.lj3[itype][jtype]*r6inv - - ka->params.lj4[itype][jtype]); + ka->params.lj4[itype][jtype]); dvdw = -r6inv * (ka->params.lj1[itype][jtype]*r6inv - - ka->params.lj2[itype][jtype]) / rij; + ka->params.lj2[itype][jtype]) / rij; } flt_t VLJ = vdw * slw; @@ -2165,7 +2165,7 @@ void ref_lennard_jones_single_interaction(KernelArgsAIREBOT<flt_t,acc_t> * ka, template<typename flt_t, typename acc_t> void ref_lennard_jones_single_atom(KernelArgsAIREBOT<flt_t,acc_t> * ka, int i, - int morseflag) { + int morseflag) { AtomAIREBOT<flt_t> * x = ka->x; int jj; int * neighs = ka->neigh_lmp.entries + ka->neigh_lmp.offset[i]; @@ -2320,10 +2320,10 @@ static void aut_rebo_neigh(KernelArgsAIREBOT<flt_t,acc_t> * ka) { fvec rcmin1 = fvec::set1(ka->params.rcmin[itype][1]); fvec rcmaxskinsq0 = fvec::set1( (ka->params.rcmax[itype][0] + ka->skin) * (ka->params.rcmax[itype][0] + - ka->skin)); + ka->skin)); fvec rcmaxskinsq1 = fvec::set1( (ka->params.rcmax[itype][1] + ka->skin) * (ka->params.rcmax[itype][1] + - ka->skin)); + ka->skin)); fvec nC = fvec::setzero(); fvec nH = fvec::setzero(); @@ -2356,7 +2356,7 @@ static void aut_rebo_neigh(KernelArgsAIREBOT<flt_t,acc_t> * ka) { fvec rsq = delx * delx + dely * dely + delz * delz; if (ka->rebuild_flag) { fvec rcmaxskinsq = fvec::mask_blend(jtype_mask, rcmaxskinsq0, - rcmaxskinsq1); + rcmaxskinsq1); bvec c_mask = fvec::mask_cmplt(j_mask, rsq, rcmaxskinsq); ivec::mask_compressstore(c_mask, &skin_target[n_skin], ji); n_skin += bvec::popcnt(c_mask); @@ -2393,7 +2393,7 @@ static void aut_rebo_neigh(KernelArgsAIREBOT<flt_t,acc_t> * ka) { static fvec aut_eval_poly_lin_pd_2(int n, flt_t * vals, ivec idx, fvec x, - fvec * deriv) { + fvec * deriv) { fvec c_1 = fvec::set1(1); fvec x_i = c_1; fvec x_im1 = fvec::setzero(); @@ -2413,8 +2413,8 @@ static fvec aut_eval_poly_lin_pd_2(int n, flt_t * vals, ivec idx, fvec x, } static fvec aut_mask_gSpline_pd_2(KernelArgsAIREBOT<flt_t,acc_t> * ka, - bvec active_mask, int itype, fvec cosjik, - fvec Nij, fvec *dgdc, fvec *dgdN) { + bvec active_mask, int itype, fvec cosjik, + fvec Nij, fvec *dgdc, fvec *dgdN) { int i; flt_t * gDom = NULL; int nDom = 0; @@ -2431,7 +2431,7 @@ static fvec aut_mask_gSpline_pd_2(KernelArgsAIREBOT<flt_t,acc_t> * ka, offs = ivec::set1(8 * 6); } cosjik = fvec::max(fvec::set1(gDom[0]), fvec::min(fvec::set1(gDom[nDom]), - cosjik)); + cosjik)); ivec index6 = ivec::setzero(); for (i = 0; i < nDom; i++) { bvec cosge = fvec::cmpnlt(cosjik, fvec::set1(gDom[i])); //ge @@ -2439,7 +2439,7 @@ static fvec aut_mask_gSpline_pd_2(KernelArgsAIREBOT<flt_t,acc_t> * ka, index6 = ivec::mask_blend(cosge & cosle, index6, ivec::set1(6*i)); } fvec g = aut_eval_poly_lin_pd_2(6, &ka->params.gVal[0], offs + index6, - cosjik, dgdc); + cosjik, dgdc); *dgdN = fvec::setzero(); if (itype == 0) { fvec NCmax = fvec::set1(ka->params.NCmax); @@ -2448,7 +2448,7 @@ static fvec aut_mask_gSpline_pd_2(KernelArgsAIREBOT<flt_t,acc_t> * ka, if (bvec::test_any_set(Nmask)) { fvec dg1; fvec g1 = aut_eval_poly_lin_pd_2(6, &ka->params.gVal[0], index6, cosjik, - &dg1); + &dg1); fvec dS; fvec cut = aut_Sp_deriv(Nij, NCmin, NCmax, &dS); *dgdN = fvec::mask_mul(*dgdN, Nmask, dS, g1 - g); @@ -2460,7 +2460,7 @@ static fvec aut_mask_gSpline_pd_2(KernelArgsAIREBOT<flt_t,acc_t> * ka, } static fvec aut_PijSpline(KernelArgsAIREBOT<flt_t,acc_t> * ka, int itype, - int jtype, fvec NijC, fvec NijH, fvec *dN2) { + int jtype, fvec NijC, fvec NijH, fvec *dN2) { flt_t ret[fvec::VL] __attribute__((aligned(64))); flt_t dN20[fvec::VL] __attribute__((aligned(64))); flt_t dN21[fvec::VL] __attribute__((aligned(64))); @@ -2580,10 +2580,10 @@ static fvec aut_frebo_pij_pd_2( fvec sum_dpij_dN = fvec::setzero(); fvec dN2[2]; ivec offseti = ivec::mask_gather(ivec::setzero(), bvec::full(), vi, - ka->neigh_rebo.offset, sizeof(int)); + ka->neigh_rebo.offset, sizeof(int)); int buf_len = 0; ivec knum = ivec::mask_gather(ivec::setzero(), bvec::full(), vi, - ka->neigh_rebo.num, sizeof(int)); + ka->neigh_rebo.num, sizeof(int)); ivec kk = ivec::setzero(); bvec active_mask = ivec::cmplt(kk, knum); ivec c_i1 = ivec::set1(1); @@ -2613,7 +2613,7 @@ static fvec aut_frebo_pij_pd_2( { while (bvec::test_any_set(active_mask)) { ivec k = ivec::mask_gather(ivec::setzero(), active_mask, kk + offseti, - ka->neigh_rebo.entries, sizeof(int)); + ka->neigh_rebo.entries, sizeof(int)); bvec excluded_mask = ivec::cmpeq(k, vj) & active_mask; if (bvec::test_any_set(excluded_mask)) { kk = ivec::mask_add(kk, excluded_mask, kk, c_i1); @@ -2623,35 +2623,35 @@ static fvec aut_frebo_pij_pd_2( fvec x_k, y_k, z_k; bvec ktype_mask; aut_loadatoms_vec(x, k, &x_k, &y_k, &z_k, &ktype_mask, ka->map, map_i, - c_i1); + c_i1); fvec rikx = x_i - x_k; fvec riky = y_i - y_k; fvec rikz = z_i - z_k; fvec rikmag = fvec::sqrt(rikx * rikx + riky * riky + rikz * rikz); fvec rho_k = fvec::mask_blend(ktype_mask, rho_k0, rho_k1); fvec lamdajik = c_4 * factor_itype * ( rho_k - rikmag - ( rho_j - - rijmag)); + rijmag)); fvec ex_lam = fvec::exp(lamdajik); fvec rcmax = fvec::mask_blend(ktype_mask, rcmax0, rcmax1); fvec rcmin = fvec::mask_blend(ktype_mask, rcmin0, rcmin1); fvec dwik; fvec wik = aut_Sp_deriv(rikmag, rcmin, rcmax, &dwik); fvec Nki = fvec::gather(k, nC, sizeof(flt_t)) + - fvec::gather(k, nH, sizeof(flt_t)) - wik; + fvec::gather(k, nH, sizeof(flt_t)) - wik; fvec cosjik = (rijx * rikx + rijy * riky + rijz * rikz) / - ( rijmag * rikmag); + ( rijmag * rikmag); cosjik = fvec::min(c_1, fvec::max(c_m1, cosjik)); fvec dgdc, dgdN; fvec g = aut_mask_gSpline_pd_2(ka, active_mask, itype, cosjik, Nij, - &dgdc, &dgdN); + &dgdc, &dgdN); sum_pij = fvec::mask_add(sum_pij, active_mask, sum_pij, wik * g * ex_lam); sum_dpij_dN = fvec::mask_add(sum_dpij_dN, active_mask, sum_dpij_dN, - wik * ex_lam * dgdN); + wik * ex_lam * dgdN); fvec dcutN; fvec cutN = aut_Sp_deriv(Nki, Nmin, Nmax, &dcutN); *sum_N = fvec::mask_add(*sum_N, active_mask, *sum_N, - fvec::mask_blend(ktype_mask, c_1, - fvec::setzero()) * wik * cutN); + fvec::mask_blend(ktype_mask, c_1, + fvec::setzero()) * wik * cutN); if (buf_len == BUF_CAP) goto exceed_buffer; data->rikx_buf[buf_len] = rikx; data->riky_buf[buf_len] = riky; @@ -2956,15 +2956,15 @@ static void aut_frebo_N_spline_force( } static fvec aut_frebo_pi_rc_pd(KernelArgsAIREBOT<flt_t,acc_t> * ka, int itype, - int jtype, fvec Nij, fvec Nji, fvec Nijconj, - fvec * dN3) { + int jtype, fvec Nij, fvec Nji, fvec Nijconj, + fvec * dN3) { flt_t ret[fvec::VL] __attribute__((aligned(64))); flt_t dN3ret[3][fvec::VL] __attribute__((aligned(64))); int i; for (i = 0; i < fvec::VL; i++) { flt_t dN3tmp[3]; ret[i] = frebo_pi_rc(ka, itype, jtype, fvec::at(Nij, i), fvec::at(Nji, i), - fvec::at(Nijconj, i), &dN3tmp[0]); + fvec::at(Nijconj, i), &dN3tmp[0]); dN3ret[0][i] = dN3tmp[0]; dN3ret[1][i] = dN3tmp[1]; dN3ret[2][i] = dN3tmp[2]; @@ -2976,15 +2976,15 @@ static fvec aut_frebo_pi_rc_pd(KernelArgsAIREBOT<flt_t,acc_t> * ka, int itype, } static fvec aut_frebo_Tij(KernelArgsAIREBOT<flt_t,acc_t> * ka, int itype, - int jtype, fvec Nij, fvec Nji, fvec Nijconj, - fvec * dN3) { + int jtype, fvec Nij, fvec Nji, fvec Nijconj, + fvec * dN3) { flt_t ret[fvec::VL] __attribute__((aligned(64))); flt_t dN3ret[3][fvec::VL] __attribute__((aligned(64))); int i; for (i = 0; i < fvec::VL; i++) { flt_t dN3tmp[3]; ret[i] = frebo_Tij(ka, itype, jtype, fvec::at(Nij, i), fvec::at(Nji, i), - fvec::at(Nijconj, i), &dN3tmp[0]); + fvec::at(Nijconj, i), &dN3tmp[0]); dN3ret[0][i] = dN3tmp[0]; dN3ret[1][i] = dN3tmp[1]; dN3ret[2][i] = dN3tmp[2]; @@ -3031,9 +3031,9 @@ static fvec aut_frebo_sum_omega( bvec mask_outer = fvec::cmpneq(fvec::setzero(), sin321) & mask_start; // add "continue" fvec sink2i = fvec::mask_recip(fvec::undefined(), mask_outer, - sin321 * sin321); + sin321 * sin321); fvec rik2i = fvec::mask_recip(fvec::undefined(), mask_outer, - r21mag * r21mag); + r21mag * r21mag); fvec rr = r23mag * r23mag - r21mag * r21mag; fvec r31x = r21x - r23x; fvec r31y = r21y - r23y; @@ -3042,9 +3042,9 @@ static fvec aut_frebo_sum_omega( fvec rijrik = c_2 * r23mag * r21mag; fvec r21mag2 = r21mag * r21mag; fvec dctik = fvec::mask_div(fvec::undefined(), mask_outer, r31mag2 - rr, - rijrik * r21mag2); + rijrik * r21mag2); fvec dctij = fvec::mask_div(fvec::undefined(), mask_outer, r31mag2 + rr, - rijrik * r23mag * r23mag); + rijrik * r23mag * r23mag); fvec dctjk = fvec::mask_div(fvec::undefined(), mask_outer, c_m2, rijrik); fvec dw21 = i_data->dwik_buf[buf_idx_i]; fvec w21 = i_data->wik_buf[buf_idx_i]; @@ -3057,25 +3057,25 @@ static fvec aut_frebo_sum_omega( // l == a4 == buf_idx_j ivec l = j_data->k_buf[buf_idx_j]; bvec mask_inner_0 = ivec::mask_cmpneq(mask_outer, k, l) & - j_data->mask_buf[buf_idx_j]; + j_data->mask_buf[buf_idx_j]; // add "continue" fvec r34x = j_data->rikx_buf[buf_idx_j]; fvec r34y = j_data->riky_buf[buf_idx_j]; fvec r34z = j_data->rikz_buf[buf_idx_j]; fvec r34mag = j_data->rikmag_buf[buf_idx_j]; fvec cos234 = fvec::mask_div(fvec::undefined(), mask_inner_0, - r32x * r34x + r32y * r34y + r32z * r34z, - r23mag * r34mag); + r32x * r34x + r32y * r34y + r32z * r34z, + r23mag * r34mag); cos234 = fvec::min(c_1, fvec::max(c_m1, cos234)); fvec sin234 = fvec::mask_sqrt(fvec::undefined(), mask_inner_0, - c_1 - cos234 * cos234); + c_1 - cos234 * cos234); bvec mask_inner_1 = fvec::mask_cmpneq(mask_inner_0, sin234, - fvec::setzero()); + fvec::setzero()); // add "continue" fvec sinl2i = fvec::mask_recip(fvec::undefined(), mask_inner_1, - sin234 * sin234); + sin234 * sin234); fvec rjl2i = fvec::mask_recip(fvec::undefined(), mask_inner_1, - r34mag * r34mag); + r34mag * r34mag); fvec dw34 = j_data->dwik_buf[buf_idx_j]; fvec w34 = j_data->wik_buf[buf_idx_j]; fvec rr = r23mag * r23mag - r34mag * r34mag; @@ -3086,11 +3086,11 @@ static fvec aut_frebo_sum_omega( fvec rijrjl = c_2 * r23mag * r34mag; fvec rjl2 = r34mag * r34mag; fvec dctjl = fvec::mask_div(fvec::undefined(), mask_inner_1, r242 - rr, - rijrjl * rjl2); + rijrjl * rjl2); fvec dctji = fvec::mask_div(fvec::undefined(), mask_inner_1, r242 + rr, - rijrjl * r23mag * r23mag); + rijrjl * r23mag * r23mag); fvec dctil = fvec::mask_div(fvec::undefined(), mask_inner_1, c_m2, - rijrjl); + rijrjl); fvec dtsijl; fvec tspijl = aut_Sp2_deriv(cos234, thmin, thmax, &dtsijl); dtsijl = fvec::setzero() - dtsijl; @@ -3104,22 +3104,22 @@ static fvec aut_frebo_sum_omega( fvec cross234z = r23x * r34y - r23y * r34x; fvec cwnum = cross321x * cross234x + cross321y * cross234y + cross321z * - cross234z; + cross234z; fvec cwnom = r21mag * r34mag * r23mag * r23mag * sin321 * sin234; fvec om1234 = fvec::mask_div(fvec::undefined(), mask_inner_1, cwnum, - cwnom); + cwnom); fvec cw = om1234; fvec sum_omega_contrib = (c_1 - om1234 * om1234) * w21 * w34 * - (c_1 - tspjik) * ( c_1 - tspijl); + (c_1 - tspjik) * ( c_1 - tspijl); sum_omega = fvec::mask_add(sum_omega, mask_inner_1, sum_omega, - sum_omega_contrib); + sum_omega_contrib); fvec dt1dik = rik2i - dctik * sink2i * cos321; fvec dt1djk = fvec::setzero() - dctjk * sink2i * cos321; fvec dt1djl = rjl2i - dctjl * sinl2i * cos234; fvec dt1dil = fvec::setzero() - dctil * sinl2i * cos234; fvec dt1dij = fvec::mask_div(fvec::undefined(), mask_inner_1, c_2, - r23mag * r23mag) - - dctij * sink2i * cos321 - dctji * sinl2i * cos234; + r23mag * r23mag) - + dctij * sink2i * cos321 - dctji * sinl2i * cos234; fvec dt2dikx = r23y * cross234z - r23z * cross234y; fvec dt2diky = r23z * cross234x - r23x * cross234z; @@ -3130,23 +3130,23 @@ static fvec aut_frebo_sum_omega( fvec dt2djlz = r23y * cross321x - r23x * cross321y; fvec dt2dijx = r21z * cross234y + r34y * cross321z - - ( r34z * cross321y + r21y * cross234z); + ( r34z * cross321y + r21y * cross234z); fvec dt2dijy = r21x * cross234z + r34z * cross321x - - ( r34x * cross321z + r21z * cross234x); + ( r34x * cross321z + r21z * cross234x); fvec dt2dijz = r21y * cross234x + r34x * cross321y - - ( r34y * cross321x + r21x * cross234y); + ( r34y * cross321x + r21x * cross234y); fvec aa = prefactor * c_2 * fvec::mask_div(fvec::undefined(), - mask_inner_1, cw, cwnom) * - w21 * w34 * (c_1 - tspjik) * ( c_1 - tspijl); + mask_inner_1, cw, cwnom) * + w21 * w34 * (c_1 - tspjik) * ( c_1 - tspijl); fvec aaa1 = (fvec::setzero() - prefactor) * (c_1 - om1234 * om1234) * - (c_1 - tspjik) * (c_1 - tspijl); + (c_1 - tspjik) * (c_1 - tspijl); fvec aaa2 = (fvec::setzero() - prefactor) * (c_1 - om1234 * om1234) * - w21 * w34; + w21 * w34; fvec at2 = aa * cwnum; fvec fcijpc = aaa2 * dtsjik * dctij * (c_1 - tspijl) + aaa2 * dtsijl * - dctji * (c_1 - tspjik) - dt1dij * at2; + dctji * (c_1 - tspjik) - dt1dij * at2; fvec fcikpc = aaa2 * dtsjik * dctik * (c_1 - tspijl) - dt1dik * at2; fvec fcjlpc = aaa2 * dtsijl * dctjl * (c_1 - tspjik) - dt1djl * at2; fvec fcjkpc = aaa2 * dtsjik * dctjk * (c_1 - tspijl) - dt1djk * at2; @@ -3193,8 +3193,8 @@ static fvec aut_frebo_sum_omega( F23z + F24z - F31z); fvec tmp20 = VA * (c_1 - om1234 * om1234) * (c_1 - tspjik) * - (c_1 - tspijl) * dw21 * w34 * fvec::mask_recip(fvec::undefined(), - mask_inner_1, r21mag); + (c_1 - tspijl) * dw21 * w34 * fvec::mask_recip(fvec::undefined(), + mask_inner_1, r21mag); f2x = f2x - tmp20 * r21x; f2y = f2y - tmp20 * r21y; f2z = f2z - tmp20 * r21z; @@ -3203,8 +3203,8 @@ static fvec aut_frebo_sum_omega( f1z = f1z + tmp20 * r21z; fvec tmp21 = VA * (c_1 - om1234 * om1234) * (c_1 - tspjik) * - (c_1 - tspijl) * w21 * dw34 * fvec::mask_recip(fvec::undefined(), - mask_inner_1, r34mag); + (c_1 - tspijl) * w21 * dw34 * fvec::mask_recip(fvec::undefined(), + mask_inner_1, r34mag); f3x = f3x - tmp21 * r34x; f3y = f3y - tmp21 * r34y; f3z = f3z - tmp21 * r34z; @@ -3214,35 +3214,35 @@ static fvec aut_frebo_sum_omega( // 1 == buf_idx_i, 2 == i, 3 == j, 4 == buf_idx_j i_data->force_k_x_buf[buf_idx_i] = - fvec::mask_add(i_data->force_k_x_buf[buf_idx_i], - mask_inner_1, i_data->force_k_x_buf[buf_idx_i], f1x); + fvec::mask_add(i_data->force_k_x_buf[buf_idx_i], + mask_inner_1, i_data->force_k_x_buf[buf_idx_i], f1x); i_data->force_k_y_buf[buf_idx_i] = - fvec::mask_add(i_data->force_k_y_buf[buf_idx_i], mask_inner_1, - i_data->force_k_y_buf[buf_idx_i], f1y); + fvec::mask_add(i_data->force_k_y_buf[buf_idx_i], mask_inner_1, + i_data->force_k_y_buf[buf_idx_i], f1y); i_data->force_k_z_buf[buf_idx_i] = - fvec::mask_add(i_data->force_k_z_buf[buf_idx_i], mask_inner_1, - i_data->force_k_z_buf[buf_idx_i], f1z); + fvec::mask_add(i_data->force_k_z_buf[buf_idx_i], mask_inner_1, + i_data->force_k_z_buf[buf_idx_i], f1z); i_data->force_i_x = - fvec::mask_add(i_data->force_i_x, mask_inner_1, i_data->force_i_x, f2x); + fvec::mask_add(i_data->force_i_x, mask_inner_1, i_data->force_i_x, f2x); i_data->force_i_y = - fvec::mask_add(i_data->force_i_y, mask_inner_1, i_data->force_i_y, f2y); + fvec::mask_add(i_data->force_i_y, mask_inner_1, i_data->force_i_y, f2y); i_data->force_i_z = - fvec::mask_add(i_data->force_i_z, mask_inner_1, i_data->force_i_z, f2z); + fvec::mask_add(i_data->force_i_z, mask_inner_1, i_data->force_i_z, f2z); j_data->force_i_x = - fvec::mask_add(j_data->force_i_x, mask_inner_1, j_data->force_i_x, f3x); + fvec::mask_add(j_data->force_i_x, mask_inner_1, j_data->force_i_x, f3x); j_data->force_i_y = - fvec::mask_add(j_data->force_i_y, mask_inner_1, j_data->force_i_y, f3y); + fvec::mask_add(j_data->force_i_y, mask_inner_1, j_data->force_i_y, f3y); j_data->force_i_z = - fvec::mask_add(j_data->force_i_z, mask_inner_1, j_data->force_i_z, f3z); + fvec::mask_add(j_data->force_i_z, mask_inner_1, j_data->force_i_z, f3z); j_data->force_k_x_buf[buf_idx_j] = - fvec::mask_add(j_data->force_k_x_buf[buf_idx_j], mask_inner_1, - j_data->force_k_x_buf[buf_idx_j], f4x); + fvec::mask_add(j_data->force_k_x_buf[buf_idx_j], mask_inner_1, + j_data->force_k_x_buf[buf_idx_j], f4x); j_data->force_k_y_buf[buf_idx_j] = - fvec::mask_add(j_data->force_k_y_buf[buf_idx_j], mask_inner_1, - j_data->force_k_y_buf[buf_idx_j], f4y); + fvec::mask_add(j_data->force_k_y_buf[buf_idx_j], mask_inner_1, + j_data->force_k_y_buf[buf_idx_j], f4y); j_data->force_k_z_buf[buf_idx_j] = - fvec::mask_add(j_data->force_k_z_buf[buf_idx_j], mask_inner_1, - j_data->force_k_z_buf[buf_idx_j], f4z); + fvec::mask_add(j_data->force_k_z_buf[buf_idx_j], mask_inner_1, + j_data->force_k_z_buf[buf_idx_j], f4z); } } return sum_omega; @@ -3269,9 +3269,9 @@ static fvec aut_frebo_pi_dh( r23x, r23y, r23z, r23mag, VA * Tij, fij); sum_omega = fvec::mask_blend(TijgtTOLmask, fvec::setzero(), sum_omega); aut_frebo_N_spline_force(ka, i_data, itype, jtype, vi, vj, VA * sum_omega, - dN3[0], dN3[2], NconjtmpI); + dN3[0], dN3[2], NconjtmpI); aut_frebo_N_spline_force(ka, j_data, jtype, itype, vj, vi, VA * sum_omega, - dN3[1], dN3[2], NconjtmpJ); + dN3[1], dN3[2], NconjtmpJ); } return Tij * sum_omega; } @@ -3351,7 +3351,7 @@ static void aut_torsion_vec( for (int buf_idx_j = 0; buf_idx_j < j_data->buf_len; buf_idx_j++) { ivec l = j_data->k_buf[buf_idx_j]; bvec mask_inner_0 = ivec::mask_cmpneq(mask_start, k, l) & - j_data->mask_buf[buf_idx_j]; + j_data->mask_buf[buf_idx_j]; if (! bvec::test_any_set(mask_inner_0)) continue; fvec del34x = j_data->rikx_buf[buf_idx_j]; fvec del34y = j_data->riky_buf[buf_idx_j]; @@ -3380,16 +3380,16 @@ static void aut_torsion_vec( fvec cross321y = del32z * del21x - del32x * del21z; fvec cross321z = del32x * del21y - del32y * del21x; fvec cross321mag = fvec::sqrt(cross321x * cross321x + - cross321y * cross321y + - cross321z * cross321z); + cross321y * cross321y + + cross321z * cross321z); fvec cross234x = del23y * del34z - del23z * del34y; fvec cross234y = del23z * del34x - del23x * del34z; fvec cross234z = del23x * del34y - del23y * del34x; fvec cross234mag = fvec::sqrt(cross234x * cross234x + - cross234y * cross234y + - cross234z * cross234z); + cross234y * cross234y + + cross234z * cross234z); fvec cwnum = cross321x * cross234x + cross321y * cross234y + - cross321z * cross234z; + cross321z * cross234z; fvec cwnom = r21 * r34 * r32 * r32 * sin321 * sin234; fvec cw = cwnum / cwnom; @@ -3459,7 +3459,7 @@ static void aut_torsion_vec( fvec dcwdn = fvec::recip(cwnom); fvec cw2_4 = cw2 * cw2 * cw2 * cw2; fvec dvpdcw = c_2_5 * Ec * cw2_4 * w23 * w21 * w34 * (c_1_0 - tspjik) * - (c_1_0 - tspijl); + (c_1_0 - tspijl); fvec Ftmpx = dvpdcw * (dcwdn * dndijx + dcwddn * ddndij * del23x / r23); fvec Ftmpy = dvpdcw * (dcwdn * dndijy + dcwddn * ddndij * del23y / r23); @@ -3514,7 +3514,7 @@ static void aut_torsion_vec( // coordination forces fvec fpair = Vtors * dw21 * w23 * w34 * (c_1_0 - tspjik) * - (c_1_0 - tspijl) / r21; + (c_1_0 - tspijl) / r21; fix = fix - del21x * fpair; fiy = fiy - del21y * fpair; fiz = fiz - del21z * fpair; @@ -3523,7 +3523,7 @@ static void aut_torsion_vec( fkz = fkz + del21z * fpair; fpair = Vtors * w21 * dw23 * w34 * (c_1_0 - tspjik) * (c_1_0 - tspijl) / - r23; + r23; fix = fix - del23x * fpair; fiy = fiy - del23y * fpair; fiz = fiz - del23z * fpair; @@ -3532,7 +3532,7 @@ static void aut_torsion_vec( fjz = fjz + del23z * fpair; fpair = Vtors * w21 * w23 * dw34 * (c_1_0 - tspjik) * (c_1_0 - tspijl) / - r34; + r34; fjx = fjx - del34x * fpair; fjy = fjy - del34y * fpair; fjz = fjz - del34z * fpair; @@ -3543,7 +3543,7 @@ static void aut_torsion_vec( // additional cut off function forces fvec fcpc = fvec::setzero() - Vtors * w21 * w23 * w34 * dtsjik * (c_1_0 - - tspijl); + tspijl); fpair = fcpc * dcidij / rij; fix = fix + fpair * del23x; fiy = fiy + fpair * del23y; @@ -3569,7 +3569,7 @@ static void aut_torsion_vec( fkz = fkz - fpair * deljkz; fcpc = fvec::setzero() - Vtors * w21 * w23 * w34 * (c_1_0 - tspjik) * - dtsijl; + dtsijl; fpair = fcpc * dcjdji / rij; fix = fix + fpair * del23x; fiy = fiy + fpair * del23y; @@ -3597,35 +3597,35 @@ static void aut_torsion_vec( // sum per-atom forces into atom force array i_data->force_i_x = fvec::mask_add(i_data->force_i_x, mask_inner_0, - i_data->force_i_x, fix); + i_data->force_i_x, fix); i_data->force_i_y = fvec::mask_add(i_data->force_i_y, mask_inner_0, - i_data->force_i_y, fiy); + i_data->force_i_y, fiy); i_data->force_i_z = fvec::mask_add(i_data->force_i_z, mask_inner_0, - i_data->force_i_z, fiz); + i_data->force_i_z, fiz); i_data->force_j_x = fvec::mask_add(i_data->force_j_x, mask_inner_0, - i_data->force_j_x, fjx); + i_data->force_j_x, fjx); i_data->force_j_y = fvec::mask_add(i_data->force_j_y, mask_inner_0, - i_data->force_j_y, fjy); + i_data->force_j_y, fjy); i_data->force_j_z = fvec::mask_add(i_data->force_j_z, mask_inner_0, - i_data->force_j_z, fjz); + i_data->force_j_z, fjz); i_data->force_k_x_buf[buf_idx_i] = - fvec::mask_add(i_data->force_k_x_buf[buf_idx_i], mask_inner_0, - i_data->force_k_x_buf[buf_idx_i], fkx); + fvec::mask_add(i_data->force_k_x_buf[buf_idx_i], mask_inner_0, + i_data->force_k_x_buf[buf_idx_i], fkx); i_data->force_k_y_buf[buf_idx_i] = - fvec::mask_add(i_data->force_k_y_buf[buf_idx_i], mask_inner_0, - i_data->force_k_y_buf[buf_idx_i], fky); + fvec::mask_add(i_data->force_k_y_buf[buf_idx_i], mask_inner_0, + i_data->force_k_y_buf[buf_idx_i], fky); i_data->force_k_z_buf[buf_idx_i] = - fvec::mask_add(i_data->force_k_z_buf[buf_idx_i], mask_inner_0, - i_data->force_k_z_buf[buf_idx_i], fkz); + fvec::mask_add(i_data->force_k_z_buf[buf_idx_i], mask_inner_0, + i_data->force_k_z_buf[buf_idx_i], fkz); j_data->force_k_x_buf[buf_idx_j] = - fvec::mask_add(j_data->force_k_x_buf[buf_idx_j], mask_inner_0, - j_data->force_k_x_buf[buf_idx_j], flx); + fvec::mask_add(j_data->force_k_x_buf[buf_idx_j], mask_inner_0, + j_data->force_k_x_buf[buf_idx_j], flx); j_data->force_k_y_buf[buf_idx_j] = - fvec::mask_add(j_data->force_k_y_buf[buf_idx_j], mask_inner_0, - j_data->force_k_y_buf[buf_idx_j], fly); + fvec::mask_add(j_data->force_k_y_buf[buf_idx_j], mask_inner_0, + j_data->force_k_y_buf[buf_idx_j], fly); j_data->force_k_z_buf[buf_idx_j] = - fvec::mask_add(j_data->force_k_z_buf[buf_idx_j], mask_inner_0, - j_data->force_k_z_buf[buf_idx_j], flz); + fvec::mask_add(j_data->force_k_z_buf[buf_idx_j], mask_inner_0, + j_data->force_k_z_buf[buf_idx_j], flz); } } } @@ -3636,8 +3636,8 @@ static void aut_torsion_vec( * torsion calculaltion. */ static void aut_frebo_batch_of_kind(KernelArgsAIREBOT<flt_t,acc_t> * ka, - int torflag, int itype, int jtype, - int * i_buf, int * j_buf) { + int torflag, int itype, int jtype, + int * i_buf, int * j_buf) { { // jump-scope for exceed_limits AtomAIREBOT<flt_t> * x = ka->x; int * map = ka->map; @@ -3758,12 +3758,12 @@ static void aut_frebo_batch_of_kind(KernelArgsAIREBOT<flt_t,acc_t> * ka, fvec dN3[3]; fvec pi_rc = aut_frebo_pi_rc_pd(ka, itype, jtype, Nij, Nji, Nijconj, dN3); aut_frebo_N_spline_force(ka, &i_data, itype, jtype, vi, vj, VA, dN3[0], - dN3[2], NconjtmpI); + dN3[2], NconjtmpI); aut_frebo_N_spline_force(ka, &j_data, jtype, itype, vj, vi, VA, dN3[1], - dN3[2], NconjtmpJ); + dN3[2], NconjtmpJ); fvec pi_dh = aut_frebo_pi_dh(ka, &i_data, &j_data, itype, jtype, vi, vj, - delx, dely, delz, rij, VA, Nij, Nji, Nijconj, - NconjtmpI, NconjtmpJ, fij); + delx, dely, delz, rij, VA, Nij, Nji, Nijconj, + NconjtmpI, NconjtmpJ, fij); fvec bij = c_0_5 * ( pij + pji) + pi_rc + pi_dh; fvec dVAdi = bij * dVA; @@ -3895,7 +3895,7 @@ static void aut_frebo(KernelArgsAIREBOT<flt_t,acc_t> * ka, int torflag) { int j = j_buf[itype][jtype][l]; ref_frebo_single_interaction(ka, i, j); if (torflag && itype == 0 && jtype == 0) - ref_torsion_single_interaction(ka, i, j); + ref_torsion_single_interaction(ka, i, j); } } } @@ -3983,7 +3983,7 @@ static bool aut_airebo_lj_test_all_paths(KernelArgsAIREBOT<flt_t,acc_t> * ka, int start_hash_slot = aut_lj_tap_hash_fn(j, attempt); int hash_slot = start_hash_slot; while (result->i[hash_slot] == i && result->j[hash_slot] != j && - attempt < OPT_TEST_PATH_SIZE) { + attempt < OPT_TEST_PATH_SIZE) { hash_slot = aut_lj_tap_hash_fn(j, ++attempt); } if (attempt >= OPT_TEST_PATH_SIZE) goto exceed_limits; @@ -3996,7 +3996,7 @@ static bool aut_airebo_lj_test_all_paths(KernelArgsAIREBOT<flt_t,acc_t> * ka, if (path_insert_pos >= OPT_TEST_PATH_ITEMS) goto exceed_limits; result->testpath_idx[hash_slot] = path_insert_pos; LennardJonesPathAIREBOT<flt_t> *path = - &result->testpath[path_insert_pos++]; + &result->testpath[path_insert_pos++]; path->num = 2; path->del[0].x = dijx; path->del[0].y = dijy; @@ -4028,7 +4028,7 @@ static bool aut_airebo_lj_test_all_paths(KernelArgsAIREBOT<flt_t,acc_t> * ka, int start_hash_slot = aut_lj_tap_hash_fn(k, attempt); int hash_slot = start_hash_slot; while (result->i[hash_slot] == i && result->j[hash_slot] != k && - attempt < OPT_TEST_PATH_SIZE) { + attempt < OPT_TEST_PATH_SIZE) { hash_slot = aut_lj_tap_hash_fn(k, ++attempt); } if (attempt >= OPT_TEST_PATH_SIZE) goto exceed_limits; @@ -4041,7 +4041,7 @@ static bool aut_airebo_lj_test_all_paths(KernelArgsAIREBOT<flt_t,acc_t> * ka, if (path_insert_pos >= OPT_TEST_PATH_ITEMS) goto exceed_limits; result->testpath_idx[hash_slot] = path_insert_pos; LennardJonesPathAIREBOT<flt_t> *path = - &result->testpath[path_insert_pos++]; + &result->testpath[path_insert_pos++]; path->num = 3; path->del[0].x = dijx; path->del[0].y = dijy; @@ -4081,7 +4081,7 @@ static bool aut_airebo_lj_test_all_paths(KernelArgsAIREBOT<flt_t,acc_t> * ka, int start_hash_slot = aut_lj_tap_hash_fn(l, attempt); int hash_slot = start_hash_slot; while (result->i[hash_slot] == i && result->j[hash_slot] != l && - attempt < OPT_TEST_PATH_SIZE) { + attempt < OPT_TEST_PATH_SIZE) { hash_slot = aut_lj_tap_hash_fn(l, ++attempt); } if (attempt >= OPT_TEST_PATH_SIZE) goto exceed_limits; @@ -4094,7 +4094,7 @@ static bool aut_airebo_lj_test_all_paths(KernelArgsAIREBOT<flt_t,acc_t> * ka, if (path_insert_pos >= OPT_TEST_PATH_ITEMS) goto exceed_limits; result->testpath_idx[hash_slot] = path_insert_pos; LennardJonesPathAIREBOT<flt_t> *path = - &result->testpath[path_insert_pos++]; + &result->testpath[path_insert_pos++]; path->num = 4; path->del[0].x = dijx; path->del[0].y = dijy; @@ -4174,7 +4174,7 @@ static fvec aut_airebo_lj_tap_test_path(KernelArgsAIREBOT<flt_t,acc_t> * ka, another_attempt = correct_i & ~ found_items; } cij = fvec::mask_gather(cij, found_items, hash_slot, - &test_path_result->cij[0], sizeof(flt_t)); + &test_path_result->cij[0], sizeof(flt_t)); bvec need_testpath = fvec::mask_cmplt(found_items, fvec::setzero(), cij); if (bvec::test_any_set(need_testpath)) { for (int i = 0; i < fvec::VL; i++) { @@ -4304,8 +4304,8 @@ static void aut_lj_with_bo( fvec NconjtmpI; fvec pij = aut_frebo_pij_pd_2(ka, &i_data, itype, jtype, vi, vj, - delx * scale, dely * scale, delz * scale, - the_r, wij, VA, &NconjtmpI, fij); + delx * scale, dely * scale, delz * scale, + the_r, wij, VA, &NconjtmpI, fij); if (i_data.buf_len < 0) goto exceed_limits; @@ -4314,8 +4314,8 @@ static void aut_lj_with_bo( fvec rjiy = fvec::setzero() - dely; fvec rjiz = fvec::setzero() - delz; fvec pji = aut_frebo_pij_pd_2(ka, &j_data, jtype, itype, vj, vi, - rjix * scale, rjiy * scale, rjiz * scale, - the_r, wij, VA, &NconjtmpJ, fji); + rjix * scale, rjiy * scale, rjiz * scale, + the_r, wij, VA, &NconjtmpJ, fji); fij[0] = fij[0] - fji[0]; fij[1] = fij[1] - fji[1]; fij[2] = fij[2] - fji[2]; @@ -4376,23 +4376,23 @@ static void aut_lj_with_bo( fijc[1] = dStb * fij[1]; fijc[2] = dStb * fij[2]; fij[0] = scale * (fijc[0] - (delx * delx * fijc[0] + dely * delx * - fijc[1] + delz * delx * fijc[2]) / rsq); + fijc[1] + delz * delx * fijc[2]) / rsq); fij[1] = scale * (fijc[1] - (delx * dely * fijc[0] + dely * dely * - fijc[1] + delz * dely * fijc[2]) / rsq); + fijc[1] + delz * dely * fijc[2]) / rsq); fij[2] = scale * (fijc[2] - (delx * delz * fijc[0] + dely * delz * - fijc[1] + delz * delz * fijc[2]) / rsq); + fijc[1] + delz * delz * fijc[2]) / rsq); aut_frebo_N_spline_force(ka, &i_data, itype, jtype, vi, vj, dStb * VA, - dN3[0], dN3[2], NconjtmpI); + dN3[0], dN3[2], NconjtmpI); aut_frebo_N_spline_force(ka, &j_data, jtype, itype, vj, vi, dStb * VA, - dN3[1], dN3[2], NconjtmpJ); + dN3[1], dN3[2], NconjtmpJ); if (bvec::test_any_set(TijgtTOLmask)) { aut_frebo_N_spline_force(ka, &i_data, itype, jtype, vi, vj, - dStb * VA * sum_omega, dN3_dh[0], dN3_dh[2], - NconjtmpI); + dStb * VA * sum_omega, dN3_dh[0], dN3_dh[2], + NconjtmpI); aut_frebo_N_spline_force(ka, &j_data, jtype, itype, vj, vi, - dStb * VA * sum_omega, dN3_dh[1], dN3_dh[2], - NconjtmpJ); + dStb * VA * sum_omega, dN3_dh[1], dN3_dh[2], + NconjtmpJ); } aut_frebo_data_writeback(ka, &i_data); @@ -4475,7 +4475,7 @@ static void aut_lj_with_bo( exceed_limits: for (int l = 0; l < fvec::VL; l++) { ref_lennard_jones_single_interaction(ka, ivec::at(i, l), ivec::at(j, l), - MORSEFLAG); + MORSEFLAG); } return; } @@ -4584,14 +4584,14 @@ static void aut_lennard_jones(KernelArgsAIREBOT<flt_t,acc_t> * ka) { ivec j; if (rest_j) { bvec mask_0 = bvec::full(); - //0xFF >> (8 - (jnum - jj)); + //0xFF >> (8 - (jnum - jj)); if (jj + (fvec::VL - 1) >= jnum) mask_0 = bvec::only(jnum - jj); j = ivec::maskz_loadu(mask_0, &neighs[jj]); fvec x_j, y_j, z_j; aut_loadatoms_vec(x, j, &x_j, &y_j, &z_j, &jtype_mask, map, map_i, - c_i1); + c_i1); fvec::gather_prefetch0(ivec::mullo(c_i4, - ivec::maskz_loadu(bvec::full(), &neighs[jj + fvec::VL])), x); + ivec::maskz_loadu(bvec::full(), &neighs[jj + fvec::VL])), x); _mm_prefetch((const char*)&neighs[jj + 2 * fvec::VL], _MM_HINT_T0); delx = x_i - x_j; dely = y_i - y_j; @@ -4624,7 +4624,7 @@ static void aut_lennard_jones(KernelArgsAIREBOT<flt_t,acc_t> * ka) { } num_2 -= fvec::VL; - //(0xFF >> (8 - num_2)) << (_cc_popcnt(within_cutoff) - num_2); + //(0xFF >> (8 - num_2)) << (_cc_popcnt(within_cutoff) - num_2); mask_2 = bvec::onlyafter(num_2, bvec::popcnt(within_cutoff) - num_2); { ivec tmp_j = j_2; @@ -4676,7 +4676,7 @@ static void aut_lennard_jones(KernelArgsAIREBOT<flt_t,acc_t> * ka) { fvec p_rcmax = fvec::mask_blend(jtype_mask, p_rcmax0, p_rcmax1); #pragma noinline cij = aut_airebo_lj_tap_test_path(ka, &test_path_result, need_search, - i_bc, j, testpath); + i_bc, j, testpath); } current_mask = fvec::mask_cmplt(current_mask, c_0_0, cij); if (bvec::test_all_unset(current_mask)) { @@ -4735,13 +4735,13 @@ static void aut_lennard_jones(KernelArgsAIREBOT<flt_t,acc_t> * ka) { fvec cijtmp = fvec::masku_compress(need_bo_with_jtype, cij); bvec insert_mask = bvec::after(num_bo[itype][jtype]); i_bo[itype][jtype] = ivec::mask_expand(i_bo[itype][jtype], - insert_mask, itmp); + insert_mask, itmp); j_bo[itype][jtype] = ivec::mask_expand(j_bo[itype][jtype], - insert_mask, jtmp); + insert_mask, jtmp); cij_bo[itype][jtype] = fvec::mask_expand(cij_bo[itype][jtype], - insert_mask, cijtmp); + insert_mask, cijtmp); bvec need_path_force_with_jtype = need_bo_with_jtype & - need_path_force; + need_path_force; int testpath_end = fvec::VL; if (bvec::test_any_set(need_path_force_with_jtype)) { int pos = num_bo[itype][jtype]; @@ -4759,16 +4759,16 @@ static void aut_lennard_jones(KernelArgsAIREBOT<flt_t,acc_t> * ka) { } } num_bo[itype][jtype] = num_bo[itype][jtype] + - bvec::popcnt(need_bo_with_jtype); + bvec::popcnt(need_bo_with_jtype); if (num_bo[itype][jtype] >= fvec::VL) { #pragma noinline aut_lj_with_bo<MORSEFLAG>(ka, itype, jtype, i_bo[itype][jtype], - j_bo[itype][jtype], cij_bo[itype][jtype], - testpath_bo[itype][jtype]); + j_bo[itype][jtype], cij_bo[itype][jtype], + testpath_bo[itype][jtype]); num_bo[itype][jtype] -= fvec::VL; insert_mask = bvec::onlyafter(num_bo[itype][jtype], - bvec::popcnt(need_bo_with_jtype) - - num_bo[itype][jtype]); + bvec::popcnt(need_bo_with_jtype) - + num_bo[itype][jtype]); i_bo[itype][jtype] = ivec::masku_compress(insert_mask, itmp); j_bo[itype][jtype] = ivec::masku_compress(insert_mask, jtmp); cij_bo[itype][jtype] = fvec::masku_compress(insert_mask, cijtmp); @@ -4798,30 +4798,30 @@ static void aut_lennard_jones(KernelArgsAIREBOT<flt_t,acc_t> * ka) { fvec fiy = fpair * dely + fij[1]; fvec fiz = fpair * delz + fij[2]; result_f_i_x = fvec::mask_add(result_f_i_x, current_mask, result_f_i_x, - fix); + fix); result_f_i_y = fvec::mask_add(result_f_i_y, current_mask, result_f_i_y, - fiy); + fiy); result_f_i_z = fvec::mask_add(result_f_i_z, current_mask, result_f_i_z, - fiz); + fiz); result_eng = fvec::mask_add(result_eng, current_mask, result_eng, evdwl); ivec j_dbl_idx = ivec::mullo(j, c_i4); avec fjx = avec::mask_gather(avec::undefined(), current_mask, j_dbl_idx, - &ka->result_f[0].x, sizeof(acc_t)); + &ka->result_f[0].x, sizeof(acc_t)); avec fjy = avec::mask_gather(avec::undefined(), current_mask, j_dbl_idx, - &ka->result_f[0].y, sizeof(acc_t)); + &ka->result_f[0].y, sizeof(acc_t)); avec fjz = avec::mask_gather(avec::undefined(), current_mask, j_dbl_idx, - &ka->result_f[0].z, sizeof(acc_t)); + &ka->result_f[0].z, sizeof(acc_t)); fjx = fjx - fix; fjy = fjy - fiy; fjz = fjz - fiz; avec::mask_i32loscatter(&ka->result_f[0].x, current_mask, j_dbl_idx, fjx, - sizeof(acc_t)); + sizeof(acc_t)); avec::mask_i32loscatter(&ka->result_f[0].y, current_mask, j_dbl_idx, fjy, - sizeof(acc_t)); + sizeof(acc_t)); avec::mask_i32loscatter(&ka->result_f[0].z, current_mask, j_dbl_idx, fjz, - sizeof(acc_t)); + sizeof(acc_t)); if (bvec::test_any_set(need_path_force)) { fvec dC = VLJ * ( Str * Stb + c_1_0 - Str); @@ -4839,8 +4839,8 @@ static void aut_lennard_jones(KernelArgsAIREBOT<flt_t,acc_t> * ka) { for (int jtype = 0; jtype < 2; jtype++) { for (int l = 0; l < num_bo[itype][jtype]; l++) { ref_lennard_jones_single_interaction(ka,ivec::at(i_bo[itype][jtype],l), - ivec::at(j_bo[itype][jtype], l), - MORSEFLAG); + ivec::at(j_bo[itype][jtype], l), + MORSEFLAG); } } } diff --git a/src/USER-INTEL/pair_airebo_intel.h b/src/USER-INTEL/pair_airebo_intel.h index d3179c09f1..2d32925f68 100644 --- a/src/USER-INTEL/pair_airebo_intel.h +++ b/src/USER-INTEL/pair_airebo_intel.h @@ -47,8 +47,8 @@ class PairAIREBOIntel : public PairAIREBO { template <int EVFLAG, int EFLAG, class flt_t, class acc_t> void eval(const int offload, const int vflag, - IntelBuffers<flt_t,acc_t> * buffers, - const int astart, const int aend); + IntelBuffers<flt_t,acc_t> * buffers, + const int astart, const int aend); template <class flt_t, class acc_t> void pack_force_const(IntelBuffers<flt_t,acc_t> * buffers); diff --git a/src/USER-INTEL/pair_dpd_intel.cpp b/src/USER-INTEL/pair_dpd_intel.cpp index 09f27504a1..889e1a1da2 100644 --- a/src/USER-INTEL/pair_dpd_intel.cpp +++ b/src/USER-INTEL/pair_dpd_intel.cpp @@ -255,33 +255,33 @@ void PairDPDIntel::eval(const int offload, const int vflag, const flt_t xtmp = x[i].x; const flt_t ytmp = x[i].y; const flt_t ztmp = x[i].z; - const flt_t vxtmp = v[i].x; - const flt_t vytmp = v[i].y; - const flt_t vztmp = v[i].z; + const flt_t vxtmp = v[i].x; + const flt_t vytmp = v[i].y; + const flt_t vztmp = v[i].z; fxtmp = fytmp = fztmp = (acc_t)0; if (EFLAG) fwtmp = sevdwl = (acc_t)0; if (NEWTON_PAIR == 0) if (vflag==1) sv0 = sv1 = sv2 = sv3 = sv4 = sv5 = (acc_t)0; - if (rngi + jnum > rng_size) { + if (rngi + jnum > rng_size) { #ifdef LMP_USE_MKL_RNG - if (sizeof(flt_t) == sizeof(float)) - vsRngGaussian(VSL_RNG_METHOD_GAUSSIAN_ICDF, *my_random, rngi, - (float*)my_rand_buffer, (float)0.0, (float)1.0 ); - else - vdRngGaussian(VSL_RNG_METHOD_GAUSSIAN_ICDF, *my_random, rngi, - (double*)my_rand_buffer, 0.0, 1.0 ); + if (sizeof(flt_t) == sizeof(float)) + vsRngGaussian(VSL_RNG_METHOD_GAUSSIAN_ICDF, *my_random, rngi, + (float*)my_rand_buffer, (float)0.0, (float)1.0 ); + else + vdRngGaussian(VSL_RNG_METHOD_GAUSSIAN_ICDF, *my_random, rngi, + (double*)my_rand_buffer, 0.0, 1.0 ); #else for (int jj = 0; jj < rngi; jj++) my_rand_buffer[jj] = my_random->gaussian(); #endif - rngi = 0; - } + rngi = 0; + } #if defined(LMP_SIMD_COMPILER) - #pragma vector aligned - #pragma simd reduction(+:fxtmp, fytmp, fztmp, fwtmp, sevdwl, \ - sv0, sv1, sv2, sv3, sv4, sv5) + #pragma vector aligned + #pragma simd reduction(+:fxtmp, fytmp, fztmp, fwtmp, sevdwl, \ + sv0, sv1, sv2, sv3, sv4, sv5) #endif for (int jj = 0; jj < jnum; jj++) { flt_t forcelj, evdwl; @@ -302,29 +302,29 @@ void PairDPDIntel::eval(const int offload, const int vflag, icut = parami[jtype].icut; } const flt_t rsq = delx * delx + dely * dely + delz * delz; - const flt_t rinv = (flt_t)1.0/sqrt(rsq); + const flt_t rinv = (flt_t)1.0/sqrt(rsq); if (rinv > icut) { flt_t factor_dpd; if (!ONETYPE) factor_dpd = special_lj[sbindex]; - flt_t delvx = vxtmp - v[j].x; - flt_t delvy = vytmp - v[j].y; - flt_t delvz = vztmp - v[j].z; - flt_t dot = delx*delvx + dely*delvy + delz*delvz; - flt_t randnum = my_rand_buffer[jj]; + flt_t delvx = vxtmp - v[j].x; + flt_t delvy = vytmp - v[j].y; + flt_t delvz = vztmp - v[j].z; + flt_t dot = delx*delvx + dely*delvy + delz*delvz; + flt_t randnum = my_rand_buffer[jj]; - flt_t iwd = rinv - icut; - if (rinv > (flt_t)IEPSILON) iwd = (flt_t)0.0; + flt_t iwd = rinv - icut; + if (rinv > (flt_t)IEPSILON) iwd = (flt_t)0.0; - if (!ONETYPE) { - a0 = parami[jtype].a0; - gamma = parami[jtype].gamma; - sigma = parami[jtype].sigma; - } - flt_t fpair = a0 - iwd * gamma * dot + sigma * randnum * dtinvsqrt; - if (!ONETYPE) fpair *= factor_dpd; - fpair *= iwd; + if (!ONETYPE) { + a0 = parami[jtype].a0; + gamma = parami[jtype].gamma; + sigma = parami[jtype].sigma; + } + flt_t fpair = a0 - iwd * gamma * dot + sigma * randnum * dtinvsqrt; + if (!ONETYPE) fpair *= factor_dpd; + fpair *= iwd; const flt_t fpx = fpair * delx; fxtmp += fpx; @@ -337,10 +337,10 @@ void PairDPDIntel::eval(const int offload, const int vflag, if (NEWTON_PAIR) f[j].z -= fpz; if (EFLAG) { - flt_t cut = (flt_t)1.0/icut; - flt_t r = (flt_t)1.0/rinv; - evdwl = (flt_t)0.5 * a0 * (cut - (flt_t)2.0*r + rsq * icut); - if (!ONETYPE) evdwl *= factor_dpd; + flt_t cut = (flt_t)1.0/icut; + flt_t r = (flt_t)1.0/rinv; + evdwl = (flt_t)0.5 * a0 * (cut - (flt_t)2.0*r + rsq * icut); + if (!ONETYPE) evdwl *= factor_dpd; sevdwl += evdwl; if (eatom) { fwtmp += (flt_t)0.5 * evdwl; @@ -364,7 +364,7 @@ void PairDPDIntel::eval(const int offload, const int vflag, } IP_PRE_ev_tally_atom(NEWTON_PAIR, EFLAG, vflag, f, fwtmp); - rngi += jnum; + rngi += jnum; } // for ii IP_PRE_fdotr_reduce_omp(NEWTON_PAIR, nall, minlocal, nthreads, f_start, @@ -441,7 +441,7 @@ void PairDPDIntel::settings(int narg, char **arg) { { int tid = omp_get_thread_num(); vslNewStream(&random_thread[tid], LMP_MKL_RNG, - seed + comm->me + comm->nprocs * tid ); + seed + comm->me + comm->nprocs * tid ); } #endif @@ -545,7 +545,7 @@ void PairDPDIntel::pack_force_const(ForceConst<flt_t> &fc, template <class flt_t> void PairDPDIntel::ForceConst<flt_t>::set_ntypes(const int ntypes, const int nthreads, - const int max_nbors, + const int max_nbors, Memory *memory, const int cop) { if (ntypes != _ntypes) { @@ -558,7 +558,7 @@ void PairDPDIntel::ForceConst<flt_t>::set_ntypes(const int ntypes, _cop = cop; memory->create(param,ntypes,ntypes,"fc.param"); memory->create(rand_buffer_thread, nthreads, max_nbors, - "fc.rand_buffer_thread"); + "fc.rand_buffer_thread"); memory->create(rngi,nthreads,"fc.param"); for (int i = 0; i < nthreads; i++) rngi[i] = max_nbors; } @@ -596,7 +596,7 @@ void PairDPDIntel::read_restart_settings(FILE *fp) { int tid = omp_get_thread_num(); vslNewStream(&random_thread[tid], LMP_MKL_RNG, - seed + comm->me + comm->nprocs * tid ); + seed + comm->me + comm->nprocs * tid ); } #endif diff --git a/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp b/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp index e3afcd64a6..05ffa2d50e 100644 --- a/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp +++ b/src/USER-INTEL/pair_lj_charmm_coul_charmm_intel.cpp @@ -297,11 +297,11 @@ void PairLJCharmmCoulCharmmIntel::eval(const int offload, const int vflag, const int sbindex = tj[jj] >> SBBITS & 3; const flt_t rsq = trsq[jj]; const flt_t r2inv = (flt_t)1.0 / rsq; - const flt_t r_inv = (flt_t)1.0 / sqrt(rsq); - forcecoul = qqrd2e * qtmp * q[j] * r_inv; - if (rsq > cut_coul_innersq) { - const flt_t ccr = cut_coulsq - rsq; - const flt_t switch1 = ccr * ccr * inv_denom_coul * + const flt_t r_inv = (flt_t)1.0 / sqrt(rsq); + forcecoul = qqrd2e * qtmp * q[j] * r_inv; + if (rsq > cut_coul_innersq) { + const flt_t ccr = cut_coulsq - rsq; + const flt_t switch1 = ccr * ccr * inv_denom_coul * (cut_coulsq + (flt_t)2.0 * rsq - (flt_t)3.0 * cut_coul_innersq); forcecoul *= switch1; } @@ -309,7 +309,7 @@ void PairLJCharmmCoulCharmmIntel::eval(const int offload, const int vflag, #ifdef INTEL_VMASK if (rsq < cut_ljsq) { #endif - const int jtype = tjtype[jj]; + const int jtype = tjtype[jj]; flt_t r6inv = r2inv * r2inv * r2inv; forcelj = r6inv * (lji[jtype].x * r6inv - lji[jtype].y); if (EFLAG) evdwl = r6inv*(lji[jtype].z * r6inv - lji[jtype].w); @@ -348,12 +348,12 @@ void PairLJCharmmCoulCharmmIntel::eval(const int offload, const int vflag, #else if (rsq > cut_ljsq) { forcelj = (flt_t)0.0; evdwl = (flt_t)0.0; } #endif - if (sbindex) { - const flt_t factor_coul = special_coul[sbindex]; - forcecoul *= factor_coul; - const flt_t factor_lj = special_lj[sbindex]; - forcelj *= factor_lj; - if (EFLAG) evdwl *= factor_lj; + if (sbindex) { + const flt_t factor_coul = special_coul[sbindex]; + forcecoul *= factor_coul; + const flt_t factor_lj = special_lj[sbindex]; + forcelj *= factor_lj; + if (EFLAG) evdwl *= factor_lj; } const flt_t fpair = (forcecoul + forcelj) * r2inv; diff --git a/src/USER-INTEL/pair_sw_intel.cpp b/src/USER-INTEL/pair_sw_intel.cpp index fff104f39b..2c28fcfd94 100644 --- a/src/USER-INTEL/pair_sw_intel.cpp +++ b/src/USER-INTEL/pair_sw_intel.cpp @@ -346,10 +346,10 @@ void PairSWIntel::eval(const int offload, const int vflag, } } - int ejrem = ejnum & (pad_width - 1); - if (ejrem) ejrem = pad_width - ejrem; - const int ejnum_pad = ejnum + ejrem; - for (int jj = ejnum; jj < ejnum_pad; jj++) { + int ejrem = ejnum & (pad_width - 1); + if (ejrem) ejrem = pad_width - ejrem; + const int ejnum_pad = ejnum + ejrem; + for (int jj = ejnum; jj < ejnum_pad; jj++) { tdelx[jj] = (flt_t)0.0; tdely[jj] = (flt_t)0.0; tdelz[jj] = (flt_t)0.0; diff --git a/src/USER-INTEL/pppm_disp_intel.cpp b/src/USER-INTEL/pppm_disp_intel.cpp index bd41f8b531..52e418c713 100644 --- a/src/USER-INTEL/pppm_disp_intel.cpp +++ b/src/USER-INTEL/pppm_disp_intel.cpp @@ -1500,8 +1500,8 @@ void PPPMDispIntel::fieldforce_c_ik(IntelBuffers<flt_t,acc_t> *buffers) for (int l = 0; l < order; l++) { ekx += ekx_arr[l]; - eky += eky_arr[l]; - ekz += ekz_arr[l]; + eky += eky_arr[l]; + ekz += ekz_arr[l]; } // convert E-field to force @@ -1848,8 +1848,8 @@ void PPPMDispIntel::fieldforce_g_ik(IntelBuffers<flt_t,acc_t> *buffers) for (int l = 0; l < order; l++) { ekx += ekx_arr[l]; - eky += eky_arr[l]; - ekz += ekz_arr[l]; + eky += eky_arr[l]; + ekz += ekz_arr[l]; } // convert E-field to force @@ -2232,27 +2232,27 @@ void PPPMDispIntel::fieldforce_a_ik(IntelBuffers<flt_t,acc_t> *buffers) ekx6 = eky6 = ekz6 = ZEROF; for (int l = 0; l < order; l++) { - ekx0 += ekx0_arr[l]; - eky0 += eky0_arr[l]; - ekz0 += ekz0_arr[l]; - ekx1 += ekx1_arr[l]; - eky1 += eky1_arr[l]; - ekz1 += ekz1_arr[l]; - ekx2 += ekx2_arr[l]; - eky2 += eky2_arr[l]; - ekz2 += ekz2_arr[l]; - ekx3 += ekx3_arr[l]; - eky3 += eky3_arr[l]; - ekz3 += ekz3_arr[l]; - ekx4 += ekx4_arr[l]; - eky4 += eky4_arr[l]; - ekz4 += ekz4_arr[l]; - ekx5 += ekx5_arr[l]; - eky5 += eky5_arr[l]; - ekz5 += ekz5_arr[l]; - ekx6 += ekx6_arr[l]; - eky6 += eky6_arr[l]; - ekz6 += ekz6_arr[l]; + ekx0 += ekx0_arr[l]; + eky0 += eky0_arr[l]; + ekz0 += ekz0_arr[l]; + ekx1 += ekx1_arr[l]; + eky1 += eky1_arr[l]; + ekz1 += ekz1_arr[l]; + ekx2 += ekx2_arr[l]; + eky2 += eky2_arr[l]; + ekz2 += ekz2_arr[l]; + ekx3 += ekx3_arr[l]; + eky3 += eky3_arr[l]; + ekz3 += ekz3_arr[l]; + ekx4 += ekx4_arr[l]; + eky4 += eky4_arr[l]; + ekz4 += ekz4_arr[l]; + ekx5 += ekx5_arr[l]; + eky5 += eky5_arr[l]; + ekz5 += ekz5_arr[l]; + ekx6 += ekx6_arr[l]; + eky6 += eky6_arr[l]; + ekz6 += ekz6_arr[l]; } // convert D-field to force @@ -2729,11 +2729,11 @@ void PPPMDispIntel::fieldforce_none_ik(IntelBuffers<flt_t,acc_t> *buffers) } for (int l = 0; l < order; l++) { - for (int k = 0; k < nsplit; k++) { - ekx[k] += ekx_arr[k*INTEL_P3M_ALIGNED_MAXORDER + l]; - eky[k] += eky_arr[k*INTEL_P3M_ALIGNED_MAXORDER + l]; - ekz[k] += ekz_arr[k*INTEL_P3M_ALIGNED_MAXORDER + l]; - } + for (int k = 0; k < nsplit; k++) { + ekx[k] += ekx_arr[k*INTEL_P3M_ALIGNED_MAXORDER + l]; + eky[k] += eky_arr[k*INTEL_P3M_ALIGNED_MAXORDER + l]; + ekz[k] += ekz_arr[k*INTEL_P3M_ALIGNED_MAXORDER + l]; + } } // convert E-field to force diff --git a/src/USER-INTEL/pppm_intel.cpp b/src/USER-INTEL/pppm_intel.cpp index 30f8f4c5c0..e187216b62 100644 --- a/src/USER-INTEL/pppm_intel.cpp +++ b/src/USER-INTEL/pppm_intel.cpp @@ -626,7 +626,7 @@ void PPPMIntel::fieldforce_ik(IntelBuffers<flt_t,acc_t> *buffers) #pragma simd #endif for (int k = 0; k < INTEL_P3M_ALIGNED_MAXORDER; k++) { - rho0[k] = rho_lookup[idx][k]; + rho0[k] = rho_lookup[idx][k]; rho1[k] = rho_lookup[idy][k]; rho2[k] = rho_lookup[idz][k]; } @@ -643,7 +643,7 @@ void PPPMIntel::fieldforce_ik(IntelBuffers<flt_t,acc_t> *buffers) r2 = rho_coeff[l][k] + r2*dy; r3 = rho_coeff[l][k] + r3*dz; } - rho0[k-nlower] = r1; + rho0[k-nlower] = r1; rho1[k-nlower] = r2; rho2[k-nlower] = r3; } @@ -673,9 +673,9 @@ void PPPMIntel::fieldforce_ik(IntelBuffers<flt_t,acc_t> *buffers) for (int l = 0; l < INTEL_P3M_ALIGNED_MAXORDER; l++) { int mx = l+nxsum; FFT_SCALAR x0 = y0*rho0[l]; - ekx_arr[l] -= x0*vdx_brick[mz][my][mx]; - eky_arr[l] -= x0*vdy_brick[mz][my][mx]; - ekz_arr[l] -= x0*vdz_brick[mz][my][mx]; + ekx_arr[l] -= x0*vdx_brick[mz][my][mx]; + eky_arr[l] -= x0*vdy_brick[mz][my][mx]; + ekz_arr[l] -= x0*vdz_brick[mz][my][mx]; } } } @@ -684,9 +684,9 @@ void PPPMIntel::fieldforce_ik(IntelBuffers<flt_t,acc_t> *buffers) ekx = eky = ekz = ZEROF; for (int l = 0; l < order; l++) { - ekx += ekx_arr[l]; - eky += eky_arr[l]; - ekz += ekz_arr[l]; + ekx += ekx_arr[l]; + eky += eky_arr[l]; + ekz += ekz_arr[l]; } // convert E-field to force @@ -1004,22 +1004,22 @@ void PPPMIntel::allocate() PPPM::allocate(); memory->destroy3d_offset(density_brick,nzlo_out,nylo_out,nxlo_out); create3d_offset(density_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm:density_brick"); + nxlo_out,nxhi_out,"pppm:density_brick"); if (differentiation_flag == 1) { memory->destroy3d_offset(u_brick,nzlo_out,nylo_out,nxlo_out); create3d_offset(u_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm:u_brick"); + nxlo_out,nxhi_out,"pppm:u_brick"); } else { memory->destroy3d_offset(vdx_brick,nzlo_out,nylo_out,nxlo_out); memory->destroy3d_offset(vdy_brick,nzlo_out,nylo_out,nxlo_out); memory->destroy3d_offset(vdz_brick,nzlo_out,nylo_out,nxlo_out); create3d_offset(vdx_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm:vdx_brick"); + nxlo_out,nxhi_out,"pppm:vdx_brick"); create3d_offset(vdy_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm:vdy_brick"); + nxlo_out,nxhi_out,"pppm:vdy_brick"); create3d_offset(vdz_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm:vdz_brick"); + nxlo_out,nxhi_out,"pppm:vdz_brick"); } } @@ -1028,9 +1028,9 @@ void PPPMIntel::allocate() ------------------------------------------------------------------------- */ FFT_SCALAR *** PPPMIntel::create3d_offset(FFT_SCALAR ***&array, int n1lo, - int n1hi, int n2lo, int n2hi, - int n3lo, int n3hi, - const char *name) + int n1hi, int n2lo, int n2hi, + int n3lo, int n3hi, + const char *name) { int n1 = n1hi - n1lo + 1; int n2 = n2hi - n2lo + 1; diff --git a/src/USER-INTEL/pppm_intel.h b/src/USER-INTEL/pppm_intel.h index 2a57372558..87f0bc9de8 100644 --- a/src/USER-INTEL/pppm_intel.h +++ b/src/USER-INTEL/pppm_intel.h @@ -105,7 +105,7 @@ class PPPMIntel : public PPPM { } } FFT_SCALAR ***create3d_offset(FFT_SCALAR ***&, int, int, int, - int, int, int, const char *name); + int, int, int, const char *name); }; } diff --git a/src/USER-LB/fix_lb_fluid.cpp b/src/USER-LB/fix_lb_fluid.cpp index d6c3e23ab4..638901d6b3 100644 --- a/src/USER-LB/fix_lb_fluid.cpp +++ b/src/USER-LB/fix_lb_fluid.cpp @@ -48,7 +48,7 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) : // fix # group lb/fluid nevery typeLB viscosity densityinit_real // // where: nevery: call this fix every nevery timesteps. - // (keep this set to 1 for now). + // (keep this set to 1 for now). // typeLB: there are two different integrators // in the code labeled "1" and "2". // viscosity: the viscosity of the fluid. @@ -124,37 +124,37 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg){ if(strcmp(arg[iarg],"setArea")==0){ if(setGamma == 1) - error->all(FLERR,"Illegal fix lb/fluid command: cannot use a combination of default and user-specified gamma values"); + error->all(FLERR,"Illegal fix lb/fluid command: cannot use a combination of default and user-specified gamma values"); setArea = 1; int itype = atoi(arg[iarg+1]); double areafactor = atof(arg[iarg+2]); if(itype <= 0 || itype > atom->ntypes || areafactor < 0.0) - error->all(FLERR,"Illegal fix lb/fluid command: setArea"); + error->all(FLERR,"Illegal fix lb/fluid command: setArea"); if(NodeArea == NULL){ - NodeArea = new double[atom->ntypes+1]; - for(int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; + NodeArea = new double[atom->ntypes+1]; + for(int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; } NodeArea[itype] = areafactor; iarg += 3; } else if(strcmp(arg[iarg],"setGamma")==0){ if(setArea == 1) - error->all(FLERR,"Illegal fix lb/fluid command: cannot use a combination of default and user-specified gamma values"); + error->all(FLERR,"Illegal fix lb/fluid command: cannot use a combination of default and user-specified gamma values"); setGamma = 1; double Gammaone; Gammaone = atof(arg[iarg+1]); if(Gamma == NULL) - Gamma = new double[atom->ntypes+1]; + Gamma = new double[atom->ntypes+1]; for(int i=0; i<=atom->ntypes; i++) Gamma[i] = Gammaone; iarg += 2; } else if(strcmp(arg[iarg],"scaleGamma")==0){ if(setGamma == 0) - error->all(FLERR,"Illegal fix lb/fluid command: must set a value for Gamma before scaling it"); + error->all(FLERR,"Illegal fix lb/fluid command: must set a value for Gamma before scaling it"); int itype = atoi(arg[iarg+1]); double scalefactor = atof(arg[iarg+2]); if(itype <= 0 || itype > atom->ntypes || scalefactor < 0.0) - error->all(FLERR,"Illegal fix lb/fluid command: scaleGamma"); + error->all(FLERR,"Illegal fix lb/fluid command: scaleGamma"); Gamma[itype] *= scalefactor; iarg += 3; } @@ -295,7 +295,7 @@ a z wall velocity without implementing fixed BCs in z"); if(setGamma == 0){ if(setArea == 0){ if(comm->me==0){ - error->message(FLERR,"Assuming an area per node of dx*dx for all of the MD particles. This should only be used if these all correspond to point particles; otherwise, change using the setArea keyword"); + error->message(FLERR,"Assuming an area per node of dx*dx for all of the MD particles. This should only be used if these all correspond to point particles; otherwise, change using the setArea keyword"); } NodeArea = new double[atom->ntypes+1]; for(int i=0; i<=atom->ntypes; i++) NodeArea[i] = -1.0; @@ -637,10 +637,10 @@ void FixLbFluid::init(void) int *mask = atom->mask; int nlocal = atom->nlocal; for(j=0; j<nlocal; j++){ - if((mask[j] & groupbit) && (mask[j] & groupbit_viscouslb) && (mask[j] & groupbit_pc)) - error->one(FLERR,"should not use the lb/viscous command when integrating with the lb/pc fix"); - if((mask[j] & groupbit) && (mask[j] & groupbit_viscouslb) && (mask[j] & groupbit_rigid_pc_sphere)) - error->one(FLERR,"should not use the lb/viscous command when integrating with the lb/rigid/pc/sphere fix"); + if((mask[j] & groupbit) && (mask[j] & groupbit_viscouslb) && (mask[j] & groupbit_pc)) + error->one(FLERR,"should not use the lb/viscous command when integrating with the lb/pc fix"); + if((mask[j] & groupbit) && (mask[j] & groupbit_viscouslb) && (mask[j] & groupbit_rigid_pc_sphere)) + error->one(FLERR,"should not use the lb/viscous command when integrating with the lb/rigid/pc/sphere fix"); } } @@ -817,15 +817,15 @@ void FixLbFluid::calc_fluidforce(void) for(i=0; i<nlocal; i++){ if(mask[i] & group->bitmask[igroupforce]){ - domain->unmap(x[i],image[i],unwrap); + domain->unmap(x[i],image[i],unwrap); - if(rmass) massone = rmass[i]; - else massone = mass[type[i]]; + if(rmass) massone = rmass[i]; + else massone = mass[type[i]]; - sum[0] += unwrap[0]*massone; - sum[1] += unwrap[1]*massone; - sum[2] += unwrap[2]*massone; - sum[3] += massone; + sum[0] += unwrap[0]*massone; + sum[1] += unwrap[1]*massone; + sum[2] += unwrap[2]*massone; + sum[3] += massone; } } MPI_Allreduce(&sum[0],&xcm[0],4,MPI_DOUBLE,MPI_SUM,world); @@ -840,26 +840,26 @@ void FixLbFluid::calc_fluidforce(void) for(i=0; i<nlocal; i++){ if(mask[i] & groupbit){ if(trilinear_stencil==1) { - trilinear_interpolation(i); + trilinear_interpolation(i); }else{ - peskin_interpolation(i); + peskin_interpolation(i); } if(force_diagnostic > 0 && update->ntimestep > 0 && (update->ntimestep % force_diagnostic == 0)){ - if(mask[i] & group->bitmask[igroupforce]){ - - domain->unmap(x[i],image[i],unwrap); - dx = unwrap[0] - xcm[0]; - dy = unwrap[1] - xcm[1]; - dz = unwrap[2] - xcm[2]; - - forceloc[0] += hydroF[i][0]; - forceloc[1] += hydroF[i][1]; - forceloc[2] += hydroF[i][2]; - torqueloc[0] += dy*hydroF[i][2] - dz*hydroF[i][1]; - torqueloc[1] += dz*hydroF[i][0] - dx*hydroF[i][2]; - torqueloc[2] += dx*hydroF[i][1] - dy*hydroF[i][0]; - } + if(mask[i] & group->bitmask[igroupforce]){ + + domain->unmap(x[i],image[i],unwrap); + dx = unwrap[0] - xcm[0]; + dy = unwrap[1] - xcm[1]; + dz = unwrap[2] - xcm[2]; + + forceloc[0] += hydroF[i][0]; + forceloc[1] += hydroF[i][1]; + forceloc[2] += hydroF[i][2]; + torqueloc[0] += dy*hydroF[i][2] - dz*hydroF[i][1]; + torqueloc[1] += dz*hydroF[i][0] - dx*hydroF[i][2]; + torqueloc[2] += dx*hydroF[i][1] - dy*hydroF[i][0]; + } } } } @@ -885,11 +885,11 @@ void FixLbFluid::calc_fluidforce(void) for(j=0; j<subNby+3; j++){ for(k=0; k<subNbz+3; k++){ for(m=0; m<3; m++){ - Ff[subNbx-2][j][k][m] += Fftempx[0][j][k][m]; - Ff[subNbx-3][j][k][m] += Fftempx[1][j][k][m]; - Ff[1][j][k][m] += Fftempx[2][j][k][m]; - Ff[2][j][k][m] += Fftempx[3][j][k][m]; - Ff[3][j][k][m] += Fftempx[4][j][k][m]; + Ff[subNbx-2][j][k][m] += Fftempx[0][j][k][m]; + Ff[subNbx-3][j][k][m] += Fftempx[1][j][k][m]; + Ff[1][j][k][m] += Fftempx[2][j][k][m]; + Ff[2][j][k][m] += Fftempx[3][j][k][m]; + Ff[3][j][k][m] += Fftempx[4][j][k][m]; } } } @@ -911,11 +911,11 @@ void FixLbFluid::calc_fluidforce(void) for(i=0; i<subNbx+3; i++){ for(k=0; k<subNbz+3; k++){ for(m=0; m<3; m++){ - Ff[i][subNby-2][k][m] += Fftempy[i][0][k][m]; - Ff[i][subNby-3][k][m] += Fftempy[i][1][k][m]; - Ff[i][1][k][m] += Fftempy[i][2][k][m]; - Ff[i][2][k][m] += Fftempy[i][3][k][m]; - Ff[i][3][k][m] += Fftempy[i][4][k][m]; + Ff[i][subNby-2][k][m] += Fftempy[i][0][k][m]; + Ff[i][subNby-3][k][m] += Fftempy[i][1][k][m]; + Ff[i][1][k][m] += Fftempy[i][2][k][m]; + Ff[i][2][k][m] += Fftempy[i][3][k][m]; + Ff[i][3][k][m] += Fftempy[i][4][k][m]; } } } @@ -937,11 +937,11 @@ void FixLbFluid::calc_fluidforce(void) for(i=0; i<subNbx+3; i++){ for(j=0; j<subNby+3; j++){ for(m=0; m<3; m++){ - Ff[i][j][subNbz-2][m] += Fftempz[i][j][0][m]; - Ff[i][j][subNbz-3][m] += Fftempz[i][j][1][m]; - Ff[i][j][1][m] += Fftempz[i][j][2][m]; - Ff[i][j][2][m] += Fftempz[i][j][3][m]; - Ff[i][j][3][m] += Fftempz[i][j][4][m]; + Ff[i][j][subNbz-2][m] += Fftempz[i][j][0][m]; + Ff[i][j][subNbz-3][m] += Fftempz[i][j][1][m]; + Ff[i][j][1][m] += Fftempz[i][j][2][m]; + Ff[i][j][2][m] += Fftempz[i][j][3][m]; + Ff[i][j][3][m] += Fftempz[i][j][4][m]; } } } @@ -955,7 +955,7 @@ void FixLbFluid::calc_fluidforce(void) if(me==0){ printf("%E %E %E %E %E %E\n",force[0],force[1],force[2], - torque[0],torque[1],torque[2]); + torque[0],torque[1],torque[2]); } } @@ -1022,63 +1022,63 @@ void FixLbFluid::peskin_interpolation(int i) else{ r=sqrt(rsq); if(rsq>1){ - weightx=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; + weightx=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; } else{ - weightx=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; + weightx=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; } } for(jj=-1; jj<3; jj++){ rsq=(-dy1+jj)*(-dy1+jj); if(rsq>=4) - weighty=0.0; + weighty=0.0; else{ - r=sqrt(rsq); - if(rsq>1){ - weighty=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; - } else{ - weighty=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; - } + r=sqrt(rsq); + if(rsq>1){ + weighty=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; + } else{ + weighty=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; + } } for(kk=-1; kk<3; kk++){ - rsq=(-dz1+kk)*(-dz1+kk); - if(rsq>=4) - weightz=0.0; - else{ - r=sqrt(rsq); - if(rsq>1){ - weightz=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; - } else{ - weightz=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; - } - } - ixp = ix+ii; - iyp = iy+jj; - izp = iz+kk; - - //The atom is allowed to be within one lattice grid point outside the - //local processor sub-domain. - if(ixp < -1 || ixp > (subNbx+1) || iyp < -1 || iyp > (subNby+1) || izp < -1 || izp > (subNbz+1)) - error->one(FLERR,"Atom outside local processor simulation domain. Either unstable fluid pararmeters, or \ + rsq=(-dz1+kk)*(-dz1+kk); + if(rsq>=4) + weightz=0.0; + else{ + r=sqrt(rsq); + if(rsq>1){ + weightz=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; + } else{ + weightz=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; + } + } + ixp = ix+ii; + iyp = iy+jj; + izp = iz+kk; + + //The atom is allowed to be within one lattice grid point outside the + //local processor sub-domain. + if(ixp < -1 || ixp > (subNbx+1) || iyp < -1 || iyp > (subNby+1) || izp < -1 || izp > (subNbz+1)) + error->one(FLERR,"Atom outside local processor simulation domain. Either unstable fluid pararmeters, or \ require more frequent neighborlist rebuilds"); - if(domain->periodicity[2] == 0 && comm->myloc[2] == 0 && izp < 1) - error->warning(FLERR,"Atom too close to lower z wall. Unphysical results may occur"); - if(domain->periodicity[2] == 0 && comm->myloc[2] == (comm->procgrid[2]-1) && (izp > (subNbz-2) )) - error->warning(FLERR,"Atom too close to upper z wall. Unphysical results may occur"); + if(domain->periodicity[2] == 0 && comm->myloc[2] == 0 && izp < 1) + error->warning(FLERR,"Atom too close to lower z wall. Unphysical results may occur"); + if(domain->periodicity[2] == 0 && comm->myloc[2] == (comm->procgrid[2]-1) && (izp > (subNbz-2) )) + error->warning(FLERR,"Atom too close to upper z wall. Unphysical results may occur"); - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; + if(ixp==-1) ixp=subNbx+2; + if(iyp==-1) iyp=subNby+2; + if(izp==-1) izp=subNbz+2; - FfP[isten] = weightx*weighty*weightz; - // interpolated velocity based on delta function. - for(k=0; k<3; k++){ - unode[k] += u_lb[ixp][iyp][izp][k]*FfP[isten]; - } - if(setGamma==0) - mnode += density_lb[ixp][iyp][izp]*FfP[isten]; + FfP[isten] = weightx*weighty*weightz; + // interpolated velocity based on delta function. + for(k=0; k<3; k++){ + unode[k] += u_lb[ixp][iyp][izp][k]*FfP[isten]; + } + if(setGamma==0) + mnode += density_lb[ixp][iyp][izp]*FfP[isten]; - isten++; + isten++; } } } @@ -1099,20 +1099,20 @@ require more frequent neighborlist rebuilds"); for(ii=-1; ii<3; ii++) for(jj=-1; jj<3; jj++) for(kk=-1; kk<3; kk++){ - ixp = ix+ii; - iyp = iy+jj; - izp = iz+kk; - - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; - // Compute the force on the fluid. Need to convert the velocity from - // LAMMPS units to LB units. - for(k=0; k<3; k++){ - Ff[ixp][iyp][izp][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[isten]; - } - - isten++; + ixp = ix+ii; + iyp = iy+jj; + izp = iz+kk; + + if(ixp==-1) ixp=subNbx+2; + if(iyp==-1) iyp=subNby+2; + if(izp==-1) izp=subNbz+2; + // Compute the force on the fluid. Need to convert the velocity from + // LAMMPS units to LB units. + for(k=0; k<3; k++){ + Ff[ixp][iyp][izp][k] += gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*FfP[isten]; + } + + isten++; } for(k=0; k<3; k++) hydroF[i][k] = -1.0*gammavalue*((v[i][k]*dt_lb/dx_lb)-unode[k])*dm_lb*dx_lb/dt_lb/dt_lb; @@ -1191,7 +1191,7 @@ require more frequent neighborlist rebuilds"); error->warning(FLERR,"Atom too close to upper z wall. Unphysical results may occur"); - for (k=0; k<3; k++) { // tri-linearly interpolated velocity at node + for (k=0; k<3; k++) { // tri-linearly interpolated velocity at node unode[k] = u_lb[ix][iy][iz][k]*FfP[0] + u_lb[ix][iy][izp][k]*FfP[1] + u_lb[ix][iyp][iz][k]*FfP[2] @@ -1397,7 +1397,7 @@ satisfy the Courant condition.\n"); Dcoeff=(1.0-(1.0-expminusdtovertau)*tau); namp = 2.0*kB*T/3.; noisefactor=sqrt((1.0-expminusdtovertau*expminusdtovertau)/ - (2.0))/(1.0-expminusdtovertau); + (2.0))/(1.0-expminusdtovertau); K_0 = 4.5*(1.0/3.0-a_0); dtoverdtcollision = dt_lb*3.0*viscosity/densityinit_real/dx_lb/dx_lb; } @@ -1558,16 +1558,16 @@ void FixLbFluid::initializeLB15(void) for(i=0; i<subNbx+3; i++) for(j=0; j<subNby+3; j++) for(k=0; k<subNbz+3; k++){ - u_lb[i][j][k][0]=0.0; - u_lb[i][j][k][1]=0.0; - u_lb[i][j][k][2]=0.0; - density_lb[i][j][k] = densityinit; + u_lb[i][j][k][0]=0.0; + u_lb[i][j][k][1]=0.0; + u_lb[i][j][k][2]=0.0; + density_lb[i][j][k] = densityinit; } for(i=0; i<subNbx; i++) for(j=0; j<subNby; j++) for(k=0; k<subNbz; k++) - for(m=0; m<15; m++) - f_lb[i][j][k][m] = density_lb[i][j][k]/15.0; + for(m=0; m<15; m++) + f_lb[i][j][k][m] = density_lb[i][j][k]/15.0; } @@ -1795,16 +1795,16 @@ void FixLbFluid::initializeLB19(void) for(i=0; i<subNbx+3; i++) for(j=0; j<subNby+3; j++) for(k=0; k<subNbz+3; k++){ - u_lb[i][j][k][0]=0.0; - u_lb[i][j][k][1]=0.0; - u_lb[i][j][k][2]=0.0; - density_lb[i][j][k] = densityinit; + u_lb[i][j][k][0]=0.0; + u_lb[i][j][k][1]=0.0; + u_lb[i][j][k][2]=0.0; + density_lb[i][j][k] = densityinit; } for(i=0; i<subNbx; i++) for(j=0; j<subNby; j++) for(k=0; k<subNbz; k++) - for(m=0; m<19; m++) - f_lb[i][j][k][m] = density_lb[i][j][k]/19.0; + for(m=0; m<19; m++) + f_lb[i][j][k][m] = density_lb[i][j][k]/19.0; } @@ -1881,12 +1881,12 @@ void FixLbFluid::initialize_feq(void) //Save feqold. if(typeLB == 2){ for(i=0; i<subNbx; i++) - for(j=0; j<subNby; j++) - for(k=0; k<subNbz; k++) - for(p=0; p<numvel; p++){ - feqold[i][j][k][p] = feq[i][j][k][p]; - feqoldn[i][j][k][p] = feqn[i][j][k][p]; - } + for(j=0; j<subNby; j++) + for(k=0; k<subNbz; k++) + for(p=0; p<numvel; p++){ + feqold[i][j][k][p] = feq[i][j][k][p]; + feqoldn[i][j][k][p] = feqn[i][j][k][p]; + } } }else{ step = 1; @@ -1895,7 +1895,7 @@ void FixLbFluid::initialize_feq(void) if(typeLB == 2){ for(i=0; i<8; i++) - requests[i]=MPI_REQUEST_NULL; + requests[i]=MPI_REQUEST_NULL; MPI_Isend(&feqold[1][1][1][0],1,passxf,comm->procneigh[0][0],15,world,&requests[0]); MPI_Irecv(&feqold[0][1][1][0],1,passxf,comm->procneigh[0][0],25,world,&requests[1]); MPI_Isend(&feqold[subNbx-2][1][1][0],1,passxf,comm->procneigh[0][1],25,world,&requests[2]); @@ -1907,7 +1907,7 @@ void FixLbFluid::initialize_feq(void) MPI_Waitall(8,requests,MPI_STATUS_IGNORE); for(i=0; i<8; i++) - requests[i]=MPI_REQUEST_NULL; + requests[i]=MPI_REQUEST_NULL; MPI_Isend(&feqold[0][1][1][0],1,passyf,comm->procneigh[1][0],15,world,&requests[0]); MPI_Irecv(&feqold[0][0][1][0],1,passyf,comm->procneigh[1][0],25,world,&requests[1]); MPI_Isend(&feqold[0][subNby-2][1][0],1,passyf,comm->procneigh[1][1],25,world,&requests[2]); @@ -1919,7 +1919,7 @@ void FixLbFluid::initialize_feq(void) MPI_Waitall(8,requests,MPI_STATUS_IGNORE); for(i=0; i<8; i++) - requests[i]=MPI_REQUEST_NULL; + requests[i]=MPI_REQUEST_NULL; MPI_Isend(&feqold[0][0][1][0],1,passzf,comm->procneigh[2][0],15,world,&requests[0]); MPI_Irecv(&feqold[0][0][0][0],1,passzf,comm->procneigh[2][0],25,world,&requests[1]); MPI_Isend(&feqold[0][0][subNbz-2][0],1,passzf,comm->procneigh[2][1],25,world,&requests[2]); @@ -1963,151 +1963,151 @@ void FixLbFluid::equilibriumdist15(int xstart, int xend, int ystart, int yend, i jup=j+1; jdwn=j-1; for (k=zstart; k<zend; k++) { - kup=k+1; - kdwn=k-1; - - rho=density_lb[i][j][k]; - total_density += rho; - - // Derivatives. - drhox = (density_lb[iup][j][k] - density_lb[idwn][j][k])/2.0; - drhoxx = (density_lb[iup][j][k] - 2.0*density_lb[i][j][k] + - density_lb[idwn][j][k]); - - drhoy = (density_lb[i][jup][k] - density_lb[i][jdwn][k])/2.0; - drhoyy = (density_lb[i][jup][k] - 2.0*density_lb[i][j][k] + - density_lb[i][jdwn][k]); - - drhoz = (density_lb[i][j][kup] - density_lb[i][j][kdwn])/2.0; - drhozz = (density_lb[i][j][kup] - 2.0*density_lb[i][j][k] + - density_lb[i][j][kdwn]); - - // Need one-sided derivatives for the boundary of the domain, if fixed boundary - // conditions are used. - if(domain->periodicity[2]==0){ - if(comm->myloc[2]==0 && k==1){ - drhoz = (-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k+1] - - density_lb[i][j][k+2])/2.0; - drhozz = (-density_lb[i][j][k+3] + 4.0*density_lb[i][j][k+2] - - 5.0*density_lb[i][j][k+1] + 2.0*rho); - } - if(comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2){ - drhoz = -(-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k-1] - - density_lb[i][j][k-2])/2.0; - drhozz = (-density_lb[i][j][k-3] + 4.0*density_lb[i][j][k-2] - - 5.0*density_lb[i][j][k-1] + 2.0*rho); - } - } - - grs = drhox*drhox + drhoy*drhoy + drhoz*drhoz; - - p0 = rho*a_0-kappa_lb*rho*(drhoxx + drhoyy + drhozz); + kup=k+1; + kdwn=k-1; + + rho=density_lb[i][j][k]; + total_density += rho; + + // Derivatives. + drhox = (density_lb[iup][j][k] - density_lb[idwn][j][k])/2.0; + drhoxx = (density_lb[iup][j][k] - 2.0*density_lb[i][j][k] + + density_lb[idwn][j][k]); + + drhoy = (density_lb[i][jup][k] - density_lb[i][jdwn][k])/2.0; + drhoyy = (density_lb[i][jup][k] - 2.0*density_lb[i][j][k] + + density_lb[i][jdwn][k]); + + drhoz = (density_lb[i][j][kup] - density_lb[i][j][kdwn])/2.0; + drhozz = (density_lb[i][j][kup] - 2.0*density_lb[i][j][k] + + density_lb[i][j][kdwn]); + + // Need one-sided derivatives for the boundary of the domain, if fixed boundary + // conditions are used. + if(domain->periodicity[2]==0){ + if(comm->myloc[2]==0 && k==1){ + drhoz = (-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k+1] - + density_lb[i][j][k+2])/2.0; + drhozz = (-density_lb[i][j][k+3] + 4.0*density_lb[i][j][k+2] - + 5.0*density_lb[i][j][k+1] + 2.0*rho); + } + if(comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2){ + drhoz = -(-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k-1] - + density_lb[i][j][k-2])/2.0; + drhozz = (-density_lb[i][j][k-3] + 4.0*density_lb[i][j][k-2] - + 5.0*density_lb[i][j][k-1] + 2.0*rho); + } + } + + grs = drhox*drhox + drhoy*drhoy + drhoz*drhoz; + + p0 = rho*a_0-kappa_lb*rho*(drhoxx + drhoyy + drhozz); // kappa_lb is the square gradient coeff in the pressure tensor - dPdrho = a_0; //assuming here that kappa_lb = 0. - - - if(typeLB==1){ - Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* - (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); - Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhox+3.0*u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); - Pzz = p0 + kappa_lb*(drhoz*drhoz - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+3.0*u_lb[i][j][k][2]*drhoz); - Pxy = kappa_lb*drhox*drhoy+(tau-0.5)*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhoy+u_lb[i][j][k][1]*drhox); - Pxz = kappa_lb*drhox*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); - Pyz = kappa_lb*drhoy*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); - }else if(typeLB==2){ - Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+tau*(1.0/3.0-dPdrho)* - (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); - Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+tau*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhox+3.0*u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); - Pzz = p0 + kappa_lb*(drhoz*drhoz - 0.5*grs)+tau*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+3.0*u_lb[i][j][k][2]*drhoz); - Pxy = kappa_lb*drhox*drhoy+tau*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhoy+u_lb[i][j][k][1]*drhox); - Pxz = kappa_lb*drhox*drhoz+tau*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); - Pyz = kappa_lb*drhoy*drhoz+tau*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); - } - - Fx_w = Ff[i][j][k][0]; - Fy_w = Ff[i][j][k][1]; - Fz_w = Ff[i][j][k][2]; - - etacov[0] = rho; - etacov[1] = rho*u_lb[i][j][k][0] + Fx_w*tau + rho*bodyforcex*tau; - etacov[2] = rho*u_lb[i][j][k][1] + Fy_w*tau + rho*bodyforcey*tau; - etacov[3] = rho*u_lb[i][j][k][2] + Fz_w*tau + rho*bodyforcez*tau; - - etacov[4] = Pxx + rho*u_lb[i][j][k][0]*u_lb[i][j][k][0] -rho/3. + - tau*(2.0*u_lb[i][j][k][0]*(Fx_w+rho*bodyforcex)); - etacov[5] = Pyy + rho*u_lb[i][j][k][1]*u_lb[i][j][k][1] -rho/3. + - tau*(2.0*u_lb[i][j][k][1]*(Fy_w+rho*bodyforcey)); - etacov[6] = Pzz + rho*u_lb[i][j][k][2]*u_lb[i][j][k][2] -rho/3. + - tau*(2.0*u_lb[i][j][k][2]*(Fz_w+rho*bodyforcez)); - etacov[7] = Pxy + rho*u_lb[i][j][k][0]*u_lb[i][j][k][1] + - tau*(u_lb[i][j][k][0]*(Fy_w+rho*bodyforcey) + (Fx_w+rho*bodyforcex)*u_lb[i][j][k][1]); - etacov[8] = Pyz + rho*u_lb[i][j][k][1]*u_lb[i][j][k][2] + - tau*(u_lb[i][j][k][1]*(Fz_w+rho*bodyforcez) + (Fy_w+rho*bodyforcey)*u_lb[i][j][k][2]); - etacov[9] = Pxz + rho*u_lb[i][j][k][0]*u_lb[i][j][k][2] + - tau*(u_lb[i][j][k][0]*(Fz_w+rho*bodyforcez) + (Fx_w+rho*bodyforcex)*u_lb[i][j][k][2]); - etacov[10] = 0.0; - etacov[11] = 0.0; - etacov[12] = 0.0; - etacov[13] = rho*u_lb[i][j][k][0]*u_lb[i][j][k][1]*u_lb[i][j][k][2]; - const double TrP = Pxx+Pyy+Pzz; - etacov[14] = K_0*(rho-TrP); - - for (l=0; l<15; l++) { - - feq[i][j][k][l] = 0.0; - for (int ii=0; ii<15; ii++) - feq[i][j][k][l] += w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; - - if(typeLB == 2){ - feqn[i][j][k][l] = feq[i][j][k][l]; - } - } - - if(noisestress==1){ - std = sqrt(namp*rho); - - for(jj=0; jj<3; jj++) - S[0][jj] = std*random->gaussian(); - for(jj=0; jj<3; jj++) - S[1][jj] = std*random->gaussian(); - - etacov[4] = (S[0][0]*sqrt(3.0-3.0*a_0)); - etacov[5] = ((1.0-3.0*a_0)*S[0][0]/sqrt(3.0-3.0*a_0)+ - sqrt((8.0-12.0*a_0)/(3.0-3.0*a_0))*S[0][1]); - etacov[6] = ((1.0-3.0*a_0)*S[0][0]/sqrt(3.0-3.0*a_0)+ - (2.0-6.0*a_0)*S[0][1]/sqrt((8.0-12.0*a_0)*(3.0-3.0*a_0))+ - sqrt((5.0-9.0*a_0)/(2.0-3.0*a_0))*S[0][2]); - etacov[7] = S[1][0]; - etacov[8] = S[1][1]; - etacov[9] = S[1][2]; - - for (l=10; l<15; l++) { - etacov[l] = sqrt(9.0*namp*rho/Ng_lb[l])*random->gaussian(); - } - etacov[14] += -K_0*(etacov[4]+etacov[5]+etacov[6]); //correction from noise to TrP - - for (l=0; l<15; l++) { - ghostnoise = w_lb[l]* - (mg_lb[4][l]*etacov[4]*Ng_lb[4] + mg_lb[5][l]*etacov[5]*Ng_lb[5] + - mg_lb[6][l]*etacov[6]*Ng_lb[6] + mg_lb[7][l]*etacov[7]*Ng_lb[7] + - mg_lb[8][l]*etacov[8]*Ng_lb[8] + mg_lb[9][l]*etacov[9]*Ng_lb[9] + - mg_lb[10][l]*etacov[10]*Ng_lb[10] + mg_lb[11][l]*etacov[11]*Ng_lb[11] - + mg_lb[12][l]*etacov[12]*Ng_lb[12] + mg_lb[13][l]*etacov[13]*Ng_lb[13] - + mg_lb[14][l]*etacov[14]*Ng_lb[14]); - feq[i][j][k][l] += ghostnoise*noisefactor; - } - } + dPdrho = a_0; //assuming here that kappa_lb = 0. + + + if(typeLB==1){ + Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* + (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); + Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhox+3.0*u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); + Pzz = p0 + kappa_lb*(drhoz*drhoz - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+3.0*u_lb[i][j][k][2]*drhoz); + Pxy = kappa_lb*drhox*drhoy+(tau-0.5)*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhoy+u_lb[i][j][k][1]*drhox); + Pxz = kappa_lb*drhox*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); + Pyz = kappa_lb*drhoy*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); + }else if(typeLB==2){ + Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+tau*(1.0/3.0-dPdrho)* + (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); + Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+tau*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhox+3.0*u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); + Pzz = p0 + kappa_lb*(drhoz*drhoz - 0.5*grs)+tau*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+3.0*u_lb[i][j][k][2]*drhoz); + Pxy = kappa_lb*drhox*drhoy+tau*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhoy+u_lb[i][j][k][1]*drhox); + Pxz = kappa_lb*drhox*drhoz+tau*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); + Pyz = kappa_lb*drhoy*drhoz+tau*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); + } + + Fx_w = Ff[i][j][k][0]; + Fy_w = Ff[i][j][k][1]; + Fz_w = Ff[i][j][k][2]; + + etacov[0] = rho; + etacov[1] = rho*u_lb[i][j][k][0] + Fx_w*tau + rho*bodyforcex*tau; + etacov[2] = rho*u_lb[i][j][k][1] + Fy_w*tau + rho*bodyforcey*tau; + etacov[3] = rho*u_lb[i][j][k][2] + Fz_w*tau + rho*bodyforcez*tau; + + etacov[4] = Pxx + rho*u_lb[i][j][k][0]*u_lb[i][j][k][0] -rho/3. + + tau*(2.0*u_lb[i][j][k][0]*(Fx_w+rho*bodyforcex)); + etacov[5] = Pyy + rho*u_lb[i][j][k][1]*u_lb[i][j][k][1] -rho/3. + + tau*(2.0*u_lb[i][j][k][1]*(Fy_w+rho*bodyforcey)); + etacov[6] = Pzz + rho*u_lb[i][j][k][2]*u_lb[i][j][k][2] -rho/3. + + tau*(2.0*u_lb[i][j][k][2]*(Fz_w+rho*bodyforcez)); + etacov[7] = Pxy + rho*u_lb[i][j][k][0]*u_lb[i][j][k][1] + + tau*(u_lb[i][j][k][0]*(Fy_w+rho*bodyforcey) + (Fx_w+rho*bodyforcex)*u_lb[i][j][k][1]); + etacov[8] = Pyz + rho*u_lb[i][j][k][1]*u_lb[i][j][k][2] + + tau*(u_lb[i][j][k][1]*(Fz_w+rho*bodyforcez) + (Fy_w+rho*bodyforcey)*u_lb[i][j][k][2]); + etacov[9] = Pxz + rho*u_lb[i][j][k][0]*u_lb[i][j][k][2] + + tau*(u_lb[i][j][k][0]*(Fz_w+rho*bodyforcez) + (Fx_w+rho*bodyforcex)*u_lb[i][j][k][2]); + etacov[10] = 0.0; + etacov[11] = 0.0; + etacov[12] = 0.0; + etacov[13] = rho*u_lb[i][j][k][0]*u_lb[i][j][k][1]*u_lb[i][j][k][2]; + const double TrP = Pxx+Pyy+Pzz; + etacov[14] = K_0*(rho-TrP); + + for (l=0; l<15; l++) { + + feq[i][j][k][l] = 0.0; + for (int ii=0; ii<15; ii++) + feq[i][j][k][l] += w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; + + if(typeLB == 2){ + feqn[i][j][k][l] = feq[i][j][k][l]; + } + } + + if(noisestress==1){ + std = sqrt(namp*rho); + + for(jj=0; jj<3; jj++) + S[0][jj] = std*random->gaussian(); + for(jj=0; jj<3; jj++) + S[1][jj] = std*random->gaussian(); + + etacov[4] = (S[0][0]*sqrt(3.0-3.0*a_0)); + etacov[5] = ((1.0-3.0*a_0)*S[0][0]/sqrt(3.0-3.0*a_0)+ + sqrt((8.0-12.0*a_0)/(3.0-3.0*a_0))*S[0][1]); + etacov[6] = ((1.0-3.0*a_0)*S[0][0]/sqrt(3.0-3.0*a_0)+ + (2.0-6.0*a_0)*S[0][1]/sqrt((8.0-12.0*a_0)*(3.0-3.0*a_0))+ + sqrt((5.0-9.0*a_0)/(2.0-3.0*a_0))*S[0][2]); + etacov[7] = S[1][0]; + etacov[8] = S[1][1]; + etacov[9] = S[1][2]; + + for (l=10; l<15; l++) { + etacov[l] = sqrt(9.0*namp*rho/Ng_lb[l])*random->gaussian(); + } + etacov[14] += -K_0*(etacov[4]+etacov[5]+etacov[6]); //correction from noise to TrP + + for (l=0; l<15; l++) { + ghostnoise = w_lb[l]* + (mg_lb[4][l]*etacov[4]*Ng_lb[4] + mg_lb[5][l]*etacov[5]*Ng_lb[5] + + mg_lb[6][l]*etacov[6]*Ng_lb[6] + mg_lb[7][l]*etacov[7]*Ng_lb[7] + + mg_lb[8][l]*etacov[8]*Ng_lb[8] + mg_lb[9][l]*etacov[9]*Ng_lb[9] + + mg_lb[10][l]*etacov[10]*Ng_lb[10] + mg_lb[11][l]*etacov[11]*Ng_lb[11] + + mg_lb[12][l]*etacov[12]*Ng_lb[12] + mg_lb[13][l]*etacov[13]*Ng_lb[13] + + mg_lb[14][l]*etacov[14]*Ng_lb[14]); + feq[i][j][k][l] += ghostnoise*noisefactor; + } + } } } } @@ -2141,155 +2141,155 @@ void FixLbFluid::equilibriumdist19(int xstart, int xend, int ystart, int yend, i jup=j+1; jdwn=j-1; for (k=zstart; k<zend; k++) { - kup=k+1; - kdwn=k-1; - - rho=density_lb[i][j][k]; - total_density += rho; - - // Derivatives. - drhox = (density_lb[iup][j][k] - density_lb[idwn][j][k])/2.0; - drhoxx = (density_lb[iup][j][k] - 2.0*density_lb[i][j][k] + - density_lb[idwn][j][k]); - - drhoy = (density_lb[i][jup][k] - density_lb[i][jdwn][k])/2.0; - drhoyy = (density_lb[i][jup][k] - 2.0*density_lb[i][j][k] + - density_lb[i][jdwn][k]); - - drhoz = (density_lb[i][j][kup] - density_lb[i][j][kdwn])/2.0; - drhozz = (density_lb[i][j][kup] - 2.0*density_lb[i][j][k] + - density_lb[i][j][kdwn]); - - // Need one-sided derivatives for the boundary of the domain, if fixed boundary - // conditions are used. - if(domain->periodicity[2]==0){ - if(comm->myloc[2]==0 && k==1){ - drhoz = (-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k+1] - - density_lb[i][j][k+2])/2.0; - drhozz = (-density_lb[i][j][k+3] + 4.0*density_lb[i][j][k+2] - - 5.0*density_lb[i][j][k+1] + 2.0*rho); - } - if(comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2){ - drhoz = -(-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k-1] - - density_lb[i][j][k-2])/2.0; - drhozz = (-density_lb[i][j][k-3] + 4.0*density_lb[i][j][k-2] - - 5.0*density_lb[i][j][k-1] + 2.0*rho); - } - } - - grs = drhox*drhox + drhoy*drhoy + drhoz*drhoz; - - p0 = rho*a_0-kappa_lb*rho*(drhoxx + drhoyy + drhozz); + kup=k+1; + kdwn=k-1; + + rho=density_lb[i][j][k]; + total_density += rho; + + // Derivatives. + drhox = (density_lb[iup][j][k] - density_lb[idwn][j][k])/2.0; + drhoxx = (density_lb[iup][j][k] - 2.0*density_lb[i][j][k] + + density_lb[idwn][j][k]); + + drhoy = (density_lb[i][jup][k] - density_lb[i][jdwn][k])/2.0; + drhoyy = (density_lb[i][jup][k] - 2.0*density_lb[i][j][k] + + density_lb[i][jdwn][k]); + + drhoz = (density_lb[i][j][kup] - density_lb[i][j][kdwn])/2.0; + drhozz = (density_lb[i][j][kup] - 2.0*density_lb[i][j][k] + + density_lb[i][j][kdwn]); + + // Need one-sided derivatives for the boundary of the domain, if fixed boundary + // conditions are used. + if(domain->periodicity[2]==0){ + if(comm->myloc[2]==0 && k==1){ + drhoz = (-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k+1] - + density_lb[i][j][k+2])/2.0; + drhozz = (-density_lb[i][j][k+3] + 4.0*density_lb[i][j][k+2] - + 5.0*density_lb[i][j][k+1] + 2.0*rho); + } + if(comm->myloc[2]==comm->procgrid[2]-1 && k==subNbz-2){ + drhoz = -(-3.0*density_lb[i][j][k] + 4.0*density_lb[i][j][k-1] - + density_lb[i][j][k-2])/2.0; + drhozz = (-density_lb[i][j][k-3] + 4.0*density_lb[i][j][k-2] - + 5.0*density_lb[i][j][k-1] + 2.0*rho); + } + } + + grs = drhox*drhox + drhoy*drhoy + drhoz*drhoz; + + p0 = rho*a_0-kappa_lb*rho*(drhoxx + drhoyy + drhozz); // kappa_lb is the square gradient coeff in the pressure tensor - dPdrho = a_0; //assuming here that kappa_lb = 0. - - - if(typeLB==1){ - Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* - (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); - Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhox+3.0*u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); - Pzz = p0 + kappa_lb*(drhoz*drhoz - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+3.0*u_lb[i][j][k][2]*drhoz); - Pxy = kappa_lb*drhox*drhoy+(tau-0.5)*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhoy+u_lb[i][j][k][1]*drhox); - Pxz = kappa_lb*drhox*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); - Pyz = kappa_lb*drhoy*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); - }else if(typeLB==2){ - Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+tau*(1.0/3.0-dPdrho)* - (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); - Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+tau*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhox+3.0*u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); - Pzz = p0 + kappa_lb*(drhoz*drhoz - 0.5*grs)+tau*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+3.0*u_lb[i][j][k][2]*drhoz); - Pxy = kappa_lb*drhox*drhoy+tau*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhoy+u_lb[i][j][k][1]*drhox); - Pxz = kappa_lb*drhox*drhoz+tau*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); - Pyz = kappa_lb*drhoy*drhoz+tau*(1.0/3.0-dPdrho)* - (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); - } - - Fx_w = Ff[i][j][k][0]; - Fy_w = Ff[i][j][k][1]; - Fz_w = Ff[i][j][k][2]; - - etacov[0] = rho; - etacov[1] = rho*u_lb[i][j][k][0] + Fx_w*tau + rho*bodyforcex*tau; - etacov[2] = rho*u_lb[i][j][k][1] + Fy_w*tau + rho*bodyforcey*tau; - etacov[3] = rho*u_lb[i][j][k][2] + Fz_w*tau + rho*bodyforcez*tau; - - etacov[4] = Pxx + rho*u_lb[i][j][k][0]*u_lb[i][j][k][0] -rho/3. + - tau*(2.0*u_lb[i][j][k][0]*(Fx_w+rho*bodyforcex)); - etacov[5] = Pyy + rho*u_lb[i][j][k][1]*u_lb[i][j][k][1] -rho/3. + - tau*(2.0*u_lb[i][j][k][1]*(Fy_w+rho*bodyforcey)); - etacov[6] = Pzz + rho*u_lb[i][j][k][2]*u_lb[i][j][k][2] -rho/3. + - tau*(2.0*u_lb[i][j][k][2]*(Fz_w+rho*bodyforcez)); - etacov[7] = Pxy + rho*u_lb[i][j][k][0]*u_lb[i][j][k][1] + - tau*(u_lb[i][j][k][0]*(Fy_w+rho*bodyforcey) + (Fx_w+rho*bodyforcex)*u_lb[i][j][k][1]); - etacov[8] = Pxz + rho*u_lb[i][j][k][0]*u_lb[i][j][k][2] + - tau*(u_lb[i][j][k][0]*(Fz_w+rho*bodyforcez) + (Fx_w+rho*bodyforcex)*u_lb[i][j][k][2]); - etacov[9] = Pyz + rho*u_lb[i][j][k][1]*u_lb[i][j][k][2] + - tau*(u_lb[i][j][k][1]*(Fz_w+rho*bodyforcez) + (Fy_w+rho*bodyforcey)*u_lb[i][j][k][2]); - etacov[10] = 0.0; - etacov[11] = 0.0; - etacov[12] = 0.0; - etacov[13] = 0.0; - etacov[14] = 0.0; - etacov[15] = 0.0; - etacov[16] = 0.0; - etacov[17] = 0.0; - etacov[18] = 0.0; - - for (l=0; l<19; l++) { - - feq[i][j][k][l] = 0.0; - for (int ii=0; ii<19; ii++) - feq[i][j][k][l] += w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; - - if(typeLB == 2){ - feqn[i][j][k][l] = feq[i][j][k][l]; - } - } - - if(noisestress==1){ - std = sqrt(namp*rho); - - for(jj=0; jj<3; jj++) - S[0][jj] = std*random->gaussian(); - for(jj=0; jj<3; jj++) - S[1][jj] = std*random->gaussian(); - - etacov[4] = (S[0][0]*sqrt(3.0-3.0*a_0)); - etacov[5] = ((1.0-3.0*a_0)*S[0][0]/sqrt(3.0-3.0*a_0)+ - sqrt((8.0-12.0*a_0)/(3.0-3.0*a_0))*S[0][1]); - etacov[6] = ((1.0-3.0*a_0)*S[0][0]/sqrt(3.0-3.0*a_0)+ - (2.0-6.0*a_0)*S[0][1]/sqrt((8.0-12.0*a_0)*(3.0-3.0*a_0))+ - sqrt((5.0-9.0*a_0)/(2.0-3.0*a_0))*S[0][2]); - etacov[7] = S[1][0]; - etacov[8] = S[1][1]; - etacov[9] = S[1][2]; - - for (l=10; l<19; l++) { - etacov[l] = sqrt(9.0*namp*rho/Ng_lb[l])*random->gaussian(); - } - - for (l=0; l<19; l++) { - ghostnoise = w_lb[l]* - (mg_lb[4][l]*etacov[4]*Ng_lb[4] + mg_lb[5][l]*etacov[5]*Ng_lb[5] + - mg_lb[6][l]*etacov[6]*Ng_lb[6] + mg_lb[7][l]*etacov[7]*Ng_lb[7] + - mg_lb[8][l]*etacov[8]*Ng_lb[8] + mg_lb[9][l]*etacov[9]*Ng_lb[9] + - mg_lb[10][l]*etacov[10]*Ng_lb[10] + mg_lb[11][l]*etacov[11]*Ng_lb[11] - + mg_lb[12][l]*etacov[12]*Ng_lb[12] + mg_lb[13][l]*etacov[13]*Ng_lb[13] - + mg_lb[14][l]*etacov[14]*Ng_lb[14] + mg_lb[15][l]*etacov[15]*Ng_lb[15] - + mg_lb[16][l]*etacov[16]*Ng_lb[16] + mg_lb[17][l]*etacov[17]*Ng_lb[17] - + mg_lb[18][l]*etacov[18]*Ng_lb[18]); - feq[i][j][k][l] += ghostnoise*noisefactor; - } - } + dPdrho = a_0; //assuming here that kappa_lb = 0. + + + if(typeLB==1){ + Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* + (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); + Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhox+3.0*u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); + Pzz = p0 + kappa_lb*(drhoz*drhoz - 0.5*grs)+(tau-0.5)*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+3.0*u_lb[i][j][k][2]*drhoz); + Pxy = kappa_lb*drhox*drhoy+(tau-0.5)*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhoy+u_lb[i][j][k][1]*drhox); + Pxz = kappa_lb*drhox*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); + Pyz = kappa_lb*drhoy*drhoz+(tau-0.5)*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); + }else if(typeLB==2){ + Pxx = p0 + kappa_lb*(drhox*drhox - 0.5*grs)+tau*(1.0/3.0-dPdrho)* + (3.0*u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); + Pyy = p0 + kappa_lb*(drhoy*drhoy - 0.5*grs)+tau*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhox+3.0*u_lb[i][j][k][1]*drhoy+u_lb[i][j][k][2]*drhoz); + Pzz = p0 + kappa_lb*(drhoz*drhoz - 0.5*grs)+tau*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhox+u_lb[i][j][k][1]*drhoy+3.0*u_lb[i][j][k][2]*drhoz); + Pxy = kappa_lb*drhox*drhoy+tau*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhoy+u_lb[i][j][k][1]*drhox); + Pxz = kappa_lb*drhox*drhoz+tau*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][0]*drhoz+u_lb[i][j][k][2]*drhox); + Pyz = kappa_lb*drhoy*drhoz+tau*(1.0/3.0-dPdrho)* + (u_lb[i][j][k][1]*drhoz+u_lb[i][j][k][2]*drhoy); + } + + Fx_w = Ff[i][j][k][0]; + Fy_w = Ff[i][j][k][1]; + Fz_w = Ff[i][j][k][2]; + + etacov[0] = rho; + etacov[1] = rho*u_lb[i][j][k][0] + Fx_w*tau + rho*bodyforcex*tau; + etacov[2] = rho*u_lb[i][j][k][1] + Fy_w*tau + rho*bodyforcey*tau; + etacov[3] = rho*u_lb[i][j][k][2] + Fz_w*tau + rho*bodyforcez*tau; + + etacov[4] = Pxx + rho*u_lb[i][j][k][0]*u_lb[i][j][k][0] -rho/3. + + tau*(2.0*u_lb[i][j][k][0]*(Fx_w+rho*bodyforcex)); + etacov[5] = Pyy + rho*u_lb[i][j][k][1]*u_lb[i][j][k][1] -rho/3. + + tau*(2.0*u_lb[i][j][k][1]*(Fy_w+rho*bodyforcey)); + etacov[6] = Pzz + rho*u_lb[i][j][k][2]*u_lb[i][j][k][2] -rho/3. + + tau*(2.0*u_lb[i][j][k][2]*(Fz_w+rho*bodyforcez)); + etacov[7] = Pxy + rho*u_lb[i][j][k][0]*u_lb[i][j][k][1] + + tau*(u_lb[i][j][k][0]*(Fy_w+rho*bodyforcey) + (Fx_w+rho*bodyforcex)*u_lb[i][j][k][1]); + etacov[8] = Pxz + rho*u_lb[i][j][k][0]*u_lb[i][j][k][2] + + tau*(u_lb[i][j][k][0]*(Fz_w+rho*bodyforcez) + (Fx_w+rho*bodyforcex)*u_lb[i][j][k][2]); + etacov[9] = Pyz + rho*u_lb[i][j][k][1]*u_lb[i][j][k][2] + + tau*(u_lb[i][j][k][1]*(Fz_w+rho*bodyforcez) + (Fy_w+rho*bodyforcey)*u_lb[i][j][k][2]); + etacov[10] = 0.0; + etacov[11] = 0.0; + etacov[12] = 0.0; + etacov[13] = 0.0; + etacov[14] = 0.0; + etacov[15] = 0.0; + etacov[16] = 0.0; + etacov[17] = 0.0; + etacov[18] = 0.0; + + for (l=0; l<19; l++) { + + feq[i][j][k][l] = 0.0; + for (int ii=0; ii<19; ii++) + feq[i][j][k][l] += w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; + + if(typeLB == 2){ + feqn[i][j][k][l] = feq[i][j][k][l]; + } + } + + if(noisestress==1){ + std = sqrt(namp*rho); + + for(jj=0; jj<3; jj++) + S[0][jj] = std*random->gaussian(); + for(jj=0; jj<3; jj++) + S[1][jj] = std*random->gaussian(); + + etacov[4] = (S[0][0]*sqrt(3.0-3.0*a_0)); + etacov[5] = ((1.0-3.0*a_0)*S[0][0]/sqrt(3.0-3.0*a_0)+ + sqrt((8.0-12.0*a_0)/(3.0-3.0*a_0))*S[0][1]); + etacov[6] = ((1.0-3.0*a_0)*S[0][0]/sqrt(3.0-3.0*a_0)+ + (2.0-6.0*a_0)*S[0][1]/sqrt((8.0-12.0*a_0)*(3.0-3.0*a_0))+ + sqrt((5.0-9.0*a_0)/(2.0-3.0*a_0))*S[0][2]); + etacov[7] = S[1][0]; + etacov[8] = S[1][1]; + etacov[9] = S[1][2]; + + for (l=10; l<19; l++) { + etacov[l] = sqrt(9.0*namp*rho/Ng_lb[l])*random->gaussian(); + } + + for (l=0; l<19; l++) { + ghostnoise = w_lb[l]* + (mg_lb[4][l]*etacov[4]*Ng_lb[4] + mg_lb[5][l]*etacov[5]*Ng_lb[5] + + mg_lb[6][l]*etacov[6]*Ng_lb[6] + mg_lb[7][l]*etacov[7]*Ng_lb[7] + + mg_lb[8][l]*etacov[8]*Ng_lb[8] + mg_lb[9][l]*etacov[9]*Ng_lb[9] + + mg_lb[10][l]*etacov[10]*Ng_lb[10] + mg_lb[11][l]*etacov[11]*Ng_lb[11] + + mg_lb[12][l]*etacov[12]*Ng_lb[12] + mg_lb[13][l]*etacov[13]*Ng_lb[13] + + mg_lb[14][l]*etacov[14]*Ng_lb[14] + mg_lb[15][l]*etacov[15]*Ng_lb[15] + + mg_lb[16][l]*etacov[16]*Ng_lb[16] + mg_lb[17][l]*etacov[17]*Ng_lb[17] + + mg_lb[18][l]*etacov[18]*Ng_lb[18]); + feq[i][j][k][l] += ghostnoise*noisefactor; + } + } } } @@ -2430,38 +2430,38 @@ void FixLbFluid::parametercalc_part(int xstart, int xend, int ystart, int yend, for(j=ystart; j<yend; j++){ for(k=zstart; k<zend; k++){ - density_lb[i][j][k]=0.0; - u_lb[i][j][k][0]=0.0; - u_lb[i][j][k][1]=0.0; - u_lb[i][j][k][2]=0.0; - for (m=0; m<numvel; m++) { - - density_lb[i][j][k] += f_lb[i][j][k][m]; - - u_lb[i][j][k][0] += f_lb[i][j][k][m]*e[m][0]; - u_lb[i][j][k][1] += f_lb[i][j][k][m]*e[m][1]; - u_lb[i][j][k][2] += f_lb[i][j][k][m]*e[m][2]; - - } - - //For the on-lattice wall scheme, need to set this velocity to zero. - if(domain->periodicity[2]==0){ - if(comm->myloc[2]==0){ - if(k==1){ - u_lb[i][j][k][2]=0.0; - } - } - if(comm->myloc[2]==comm->procgrid[2]-1){ - if(k==subNbz-2){ - u_lb[i][j][k][2]=0.0; - } - } - - } - - u_lb[i][j][k][0]=u_lb[i][j][k][0]/density_lb[i][j][k]; - u_lb[i][j][k][1]=u_lb[i][j][k][1]/density_lb[i][j][k]; - u_lb[i][j][k][2]=u_lb[i][j][k][2]/density_lb[i][j][k]; + density_lb[i][j][k]=0.0; + u_lb[i][j][k][0]=0.0; + u_lb[i][j][k][1]=0.0; + u_lb[i][j][k][2]=0.0; + for (m=0; m<numvel; m++) { + + density_lb[i][j][k] += f_lb[i][j][k][m]; + + u_lb[i][j][k][0] += f_lb[i][j][k][m]*e[m][0]; + u_lb[i][j][k][1] += f_lb[i][j][k][m]*e[m][1]; + u_lb[i][j][k][2] += f_lb[i][j][k][m]*e[m][2]; + + } + + //For the on-lattice wall scheme, need to set this velocity to zero. + if(domain->periodicity[2]==0){ + if(comm->myloc[2]==0){ + if(k==1){ + u_lb[i][j][k][2]=0.0; + } + } + if(comm->myloc[2]==comm->procgrid[2]-1){ + if(k==subNbz-2){ + u_lb[i][j][k][2]=0.0; + } + } + + } + + u_lb[i][j][k][0]=u_lb[i][j][k][0]/density_lb[i][j][k]; + u_lb[i][j][k][1]=u_lb[i][j][k][1]/density_lb[i][j][k]; + u_lb[i][j][k][2]=u_lb[i][j][k][2]/density_lb[i][j][k]; } } } @@ -2481,37 +2481,37 @@ void FixLbFluid::update_periodic(int xstart, int xend, int ystart, int yend, int for(j=ystart; j<yend; j++) for(k=zstart; k<zend; k++){ - if(typeLB==1){ - for(m=0; m<numvel; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - - fnew[i][j][k][m] = f_lb[imod][jmod][kmod][m] + (feq[imod][jmod][kmod][m]-f_lb[imod][jmod][kmod][m])/tau; - } - }else if(typeLB==2){ - for(m=0; m<numvel; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - - fnew[i][j][k][m] = feq[imod][jmod][kmod][m] + (f_lb[imod][jmod][kmod][m] - feq[imod][jmod][kmod][m])*expminusdtovertau; - } - - fnew[i][j][k][0]+=Dcoeff*(feq[i][j][k][0]-feqold[i][j][k][0]); - for(m=1; m<numvel; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - imodm = i+e[m][0]; - jmodm = j+e[m][1]; - kmodm = k+e[m][2]; - - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + (0.5-Dcoeff*(tau+0.5))* - (feqn[imodm][jmodm][kmodm][m] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - - } - } + if(typeLB==1){ + for(m=0; m<numvel; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + + fnew[i][j][k][m] = f_lb[imod][jmod][kmod][m] + (feq[imod][jmod][kmod][m]-f_lb[imod][jmod][kmod][m])/tau; + } + }else if(typeLB==2){ + for(m=0; m<numvel; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + + fnew[i][j][k][m] = feq[imod][jmod][kmod][m] + (f_lb[imod][jmod][kmod][m] - feq[imod][jmod][kmod][m])*expminusdtovertau; + } + + fnew[i][j][k][0]+=Dcoeff*(feq[i][j][k][0]-feqold[i][j][k][0]); + for(m=1; m<numvel; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + imodm = i+e[m][0]; + jmodm = j+e[m][1]; + kmodm = k+e[m][2]; + + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + (0.5-Dcoeff*(tau+0.5))* + (feqn[imodm][jmodm][kmodm][m] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + + } + } } } @@ -2536,10 +2536,10 @@ void FixLbFluid::streamout(void) // for(i=1; i<subNbx-1; i++){ // for(j=1; j<subNby-1; j++){ // for(k=1; k<subNbz-1; k++){ - // massloc += density_lb[i][j][k]; - // momentumloc[0] += density_lb[i][j][k]*u_lb[i][j][k][0]; - // momentumloc[1] += density_lb[i][j][k]*u_lb[i][j][k][1]; - // momentumloc[2] += density_lb[i][j][k]*u_lb[i][j][k][2]; + // massloc += density_lb[i][j][k]; + // momentumloc[0] += density_lb[i][j][k]*u_lb[i][j][k][0]; + // momentumloc[1] += density_lb[i][j][k]*u_lb[i][j][k][1]; + // momentumloc[2] += density_lb[i][j][k]*u_lb[i][j][k][2]; // } // } // } @@ -2557,45 +2557,45 @@ void FixLbFluid::streamout(void) if(me==0){ for(iproc=0; iproc < comm->nprocs; iproc++){ if(iproc){ - MPI_Irecv(&buf[0][0][0][0],size,MPI_DOUBLE,iproc,0,world,&request_recv); - MPI_Wait(&request_recv,&status); - - istart=static_cast<int> (buf[0][0][0][0]); - jstart=static_cast<int> (buf[0][0][0][1]); - kstart=static_cast<int> (buf[0][0][0][2]); - iend=static_cast<int> (buf[0][0][1][0]); - jend=static_cast<int> (buf[0][0][1][1]); - kend=static_cast<int> (buf[0][0][1][2]); - - for(i=istart; i<iend; i++){ - for(j=jstart; j<jend; j++){ - for(k=kstart; k<kend; k++){ - for(w=0; w<4; w++){ - altogether[i][j][k][w]=buf[i-istart+1][j-jstart+1][k-kstart+1][w]; - } - } - } - } + MPI_Irecv(&buf[0][0][0][0],size,MPI_DOUBLE,iproc,0,world,&request_recv); + MPI_Wait(&request_recv,&status); + + istart=static_cast<int> (buf[0][0][0][0]); + jstart=static_cast<int> (buf[0][0][0][1]); + kstart=static_cast<int> (buf[0][0][0][2]); + iend=static_cast<int> (buf[0][0][1][0]); + jend=static_cast<int> (buf[0][0][1][1]); + kend=static_cast<int> (buf[0][0][1][2]); + + for(i=istart; i<iend; i++){ + for(j=jstart; j<jend; j++){ + for(k=kstart; k<kend; k++){ + for(w=0; w<4; w++){ + altogether[i][j][k][w]=buf[i-istart+1][j-jstart+1][k-kstart+1][w]; + } + } + } + } }else{ - for(i=1; i<subNbx-1; i++){ - for(j=1; j<subNby-1; j++){ - for(k=1; k<subNbz-1; k++){ - altogether[i-1][j-1][k-1][0]=density_lb[i][j][k]; - altogether[i-1][j-1][k-1][1]=u_lb[i][j][k][0]; - altogether[i-1][j-1][k-1][2]=u_lb[i][j][k][1]; - altogether[i-1][j-1][k-1][3]=u_lb[i][j][k][2]; - } - } - } + for(i=1; i<subNbx-1; i++){ + for(j=1; j<subNby-1; j++){ + for(k=1; k<subNbz-1; k++){ + altogether[i-1][j-1][k-1][0]=density_lb[i][j][k]; + altogether[i-1][j-1][k-1][1]=u_lb[i][j][k][0]; + altogether[i-1][j-1][k-1][2]=u_lb[i][j][k][1]; + altogether[i-1][j-1][k-1][3]=u_lb[i][j][k][2]; + } + } + } } } //i = Nbx/2; //j = Nby/2; for(i=0; i<Nbx; i++) for(j=0; j<Nby; j++) - for(k=0; k<Nbz; k++){ - printf("%16.12f %16.12f %16.12f %16.12f\n",altogether[i][j][k][0]*dm_lb/dx_lb/dx_lb/dx_lb,altogether[i][j][k][1]*dx_lb/dt_lb,altogether[i][j][k][2]*dx_lb/dt_lb,altogether[i][j][k][3]*dx_lb/dt_lb); - } + for(k=0; k<Nbz; k++){ + printf("%16.12f %16.12f %16.12f %16.12f\n",altogether[i][j][k][0]*dm_lb/dx_lb/dx_lb/dx_lb,altogether[i][j][k][1]*dx_lb/dt_lb,altogether[i][j][k][2]*dx_lb/dt_lb,altogether[i][j][k][3]*dx_lb/dt_lb); + } } else { @@ -2603,9 +2603,9 @@ void FixLbFluid::streamout(void) jstart=comm->myloc[1]*(subNby-2); if(domain->periodicity[2]==0){ if(comm->myloc[2]==comm->procgrid[2]-1){ - kstart=comm->myloc[2]*(subNbz-3); + kstart=comm->myloc[2]*(subNbz-3); }else{ - kstart=comm->myloc[2]*(subNbz-2); + kstart=comm->myloc[2]*(subNbz-2); } }else{ kstart=comm->myloc[2]*(subNbz-2); @@ -2615,12 +2615,12 @@ void FixLbFluid::streamout(void) kend=kstart+subNbz-2; for(i=0; i<subNbx; i++){ for(j=0; j<subNby; j++){ - for(k=0; k<subNbz; k++){ - buf[i][j][k][0]=density_lb[i][j][k]; - buf[i][j][k][1]=u_lb[i][j][k][0]; - buf[i][j][k][2]=u_lb[i][j][k][1]; - buf[i][j][k][3]=u_lb[i][j][k][2]; - } + for(k=0; k<subNbz; k++){ + buf[i][j][k][0]=density_lb[i][j][k]; + buf[i][j][k][1]=u_lb[i][j][k][0]; + buf[i][j][k][2]=u_lb[i][j][k][1]; + buf[i][j][k][3]=u_lb[i][j][k][2]; + } } } buf[0][0][0][0]=istart; @@ -2721,124 +2721,124 @@ void FixLbFluid::update_full15(void) update_periodic(1,subNbx-1,1,subNby-1,subNbz-2,subNbz-1); }else if(typeLB==2){ if(comm->myloc[2]==0){ - for(i=1; i<subNbx-1; i++){ - for(j=1;j<subNby-1;j++){ - k=1; - for(m=0; m<15; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - - fnew[i][j][k][m] = feq[imod][jmod][kmod][m] + (f_lb[imod][jmod][kmod][m]-feq[imod][jmod][kmod][m])*expminusdtovertau; - } - - for(m=0; m<15; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - imodm = i+e[m][0]; - jmodm = j+e[m][1]; - kmodm = k+e[m][2]; - - if(m==5) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][6] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][6] - feqn[imod][jmod][kmod][6]); - else if(m==7) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][11] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][11] - feqn[imod][jmod][kmod][11]); - else if(m==8) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][12] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][12] - feqn[imod][jmod][kmod][12]); - else if(m==9) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][13] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][13] - feqn[imod][jmod][kmod][13]); - else if(m==10) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][14] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][14] - feqn[imod][jmod][kmod][14]); - else if(m==6) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m]-feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][5] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==11) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m]-feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][7] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==12) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m]-feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][8] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==13) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m]-feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][9] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==14) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m]-feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][10] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[imodm][jmodm][kmodm][m] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - - } - } - } + for(i=1; i<subNbx-1; i++){ + for(j=1;j<subNby-1;j++){ + k=1; + for(m=0; m<15; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + + fnew[i][j][k][m] = feq[imod][jmod][kmod][m] + (f_lb[imod][jmod][kmod][m]-feq[imod][jmod][kmod][m])*expminusdtovertau; + } + + for(m=0; m<15; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + imodm = i+e[m][0]; + jmodm = j+e[m][1]; + kmodm = k+e[m][2]; + + if(m==5) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][6] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][6] - feqn[imod][jmod][kmod][6]); + else if(m==7) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][11] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][11] - feqn[imod][jmod][kmod][11]); + else if(m==8) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][12] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][12] - feqn[imod][jmod][kmod][12]); + else if(m==9) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][13] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][13] - feqn[imod][jmod][kmod][13]); + else if(m==10) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][14] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][14] - feqn[imod][jmod][kmod][14]); + else if(m==6) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m]-feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][5] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==11) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m]-feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][7] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==12) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m]-feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][8] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==13) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m]-feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][9] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==14) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m]-feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][10] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[imodm][jmodm][kmodm][m] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + + } + } + } }else{ - update_periodic(1,subNbx-1,1,subNby-1,1,2); + update_periodic(1,subNbx-1,1,subNby-1,1,2); } if(comm->myloc[2]==comm->procgrid[2]-1){ - for(i=1;i<subNbx-1;i++){ - for(j=1;j<subNby-1;j++){ - k=subNbz-2; - for(m=0; m<15; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - - fnew[i][j][k][m] = feq[imod][jmod][kmod][m] + (f_lb[imod][jmod][kmod][m]-feq[imod][jmod][kmod][m])*expminusdtovertau; - } - for(m=0; m<15; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - imodm = i+e[m][0]; - jmodm = j+e[m][1]; - kmodm = k+e[m][2]; - - if(m==6) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][5] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][5] - feqn[imod][jmod][kmod][5]); - else if(m==11) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][7] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][7] - feqn[imod][jmod][kmod][7]); - else if(m==12) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][8] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][8] - feqn[imod][jmod][kmod][8]); - else if(m==13) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][9] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][9] - feqn[imod][jmod][kmod][9]); - else if(m==14) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][10] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][10] - feqn[imod][jmod][kmod][10]); - else if(m==5) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][6] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==7) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][11] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==8) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][12] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==9) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][13] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==10) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][14] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[imodm][jmodm][kmodm][m] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - - } - } - } + for(i=1;i<subNbx-1;i++){ + for(j=1;j<subNby-1;j++){ + k=subNbz-2; + for(m=0; m<15; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + + fnew[i][j][k][m] = feq[imod][jmod][kmod][m] + (f_lb[imod][jmod][kmod][m]-feq[imod][jmod][kmod][m])*expminusdtovertau; + } + for(m=0; m<15; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + imodm = i+e[m][0]; + jmodm = j+e[m][1]; + kmodm = k+e[m][2]; + + if(m==6) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][5] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][5] - feqn[imod][jmod][kmod][5]); + else if(m==11) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][7] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][7] - feqn[imod][jmod][kmod][7]); + else if(m==12) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][8] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][8] - feqn[imod][jmod][kmod][8]); + else if(m==13) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][9] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][9] - feqn[imod][jmod][kmod][9]); + else if(m==14) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][10] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][10] - feqn[imod][jmod][kmod][10]); + else if(m==5) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][6] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==7) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][11] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==8) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][12] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==9) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][13] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==10) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][14] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[imodm][jmodm][kmodm][m] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + + } + } + } } else{ - update_periodic(1,subNbx-1,1,subNby-1,subNbz-2,subNbz-1); + update_periodic(1,subNbx-1,1,subNby-1,subNbz-2,subNbz-1); } } @@ -2861,39 +2861,39 @@ void FixLbFluid::update_full15(void) MPI_Wait(&req_recv25,&status); for(i=1;i<subNbx-1;i++){ - for(j=1;j<subNby-1;j++){ - k=1; - if(typeLB == 1){ - fnew[i][j][k][5]=fnew[i][j][k-1][6]; - tmp1=fnew[i][j][k-1][11]+fnew[i][j][k-1][12]+fnew[i][j][k-1][13]+fnew[i][j][k-1][14]; - } - else{ - fnew[i][j][k][5]=fnew[i][j][k-1][6] + (0.5-Dcoeff*(tau+0.5))*feqn[i][j][k+1][5]; - tmp1=fnew[i][j][k-1][11]+fnew[i][j][k-1][12]+fnew[i][j][k-1][13]+fnew[i][j][k-1][14] + - (0.5-Dcoeff*(tau+0.5))*(feqn[i-1][j-1][k+1][7] + feqn[i+1][j-1][k+1][8] + - feqn[i+1][j+1][k+1][9] + feqn[i-1][j+1][k+1][10]); - } - - fnew[i][j][k][7]=-0.25*(fnew[i][j][k][1]+fnew[i][j][k][2]-fnew[i][j][k][3]- - fnew[i][j][k][4]+2.0*fnew[i][j][k][11]-2.0*fnew[i][j][k][13]-tmp1); - fnew[i][j][k][8]=0.25*(fnew[i][j][k][1]-fnew[i][j][k][2]-fnew[i][j][k][3]+ - fnew[i][j][k][4]+2.0*fnew[i][j][k][14]-2.0*fnew[i][j][k][12]+tmp1); - fnew[i][j][k][9]=0.25*(fnew[i][j][k][1]+fnew[i][j][k][2]-fnew[i][j][k][3]- - fnew[i][j][k][4]+2.0*fnew[i][j][k][11]-2.0*fnew[i][j][k][13]+tmp1); - fnew[i][j][k][10]=-0.25*(fnew[i][j][k][1]-fnew[i][j][k][2]-fnew[i][j][k][3]+ - fnew[i][j][k][4]+2.0*fnew[i][j][k][14]-2.0*fnew[i][j][k][12]-tmp1); - - - - rb=fnew[i][j][k][0]+fnew[i][j][k][1]+fnew[i][j][k][2]+fnew[i][j][k][3]+fnew[i][j][k][4]+ - fnew[i][j][k][5]+fnew[i][j][k][6]+tmp1+fnew[i][j][k][11]+fnew[i][j][k][12]+ - fnew[i][j][k][13]+fnew[i][j][k][14]; - - fnew[i][j][k][7] += 0.25*rb*vwbt; - fnew[i][j][k][8] += 0.25*rb*vwbt; - fnew[i][j][k][9] += -0.25*rb*vwbt; - fnew[i][j][k][10] += -0.25*rb*vwbt; - } + for(j=1;j<subNby-1;j++){ + k=1; + if(typeLB == 1){ + fnew[i][j][k][5]=fnew[i][j][k-1][6]; + tmp1=fnew[i][j][k-1][11]+fnew[i][j][k-1][12]+fnew[i][j][k-1][13]+fnew[i][j][k-1][14]; + } + else{ + fnew[i][j][k][5]=fnew[i][j][k-1][6] + (0.5-Dcoeff*(tau+0.5))*feqn[i][j][k+1][5]; + tmp1=fnew[i][j][k-1][11]+fnew[i][j][k-1][12]+fnew[i][j][k-1][13]+fnew[i][j][k-1][14] + + (0.5-Dcoeff*(tau+0.5))*(feqn[i-1][j-1][k+1][7] + feqn[i+1][j-1][k+1][8] + + feqn[i+1][j+1][k+1][9] + feqn[i-1][j+1][k+1][10]); + } + + fnew[i][j][k][7]=-0.25*(fnew[i][j][k][1]+fnew[i][j][k][2]-fnew[i][j][k][3]- + fnew[i][j][k][4]+2.0*fnew[i][j][k][11]-2.0*fnew[i][j][k][13]-tmp1); + fnew[i][j][k][8]=0.25*(fnew[i][j][k][1]-fnew[i][j][k][2]-fnew[i][j][k][3]+ + fnew[i][j][k][4]+2.0*fnew[i][j][k][14]-2.0*fnew[i][j][k][12]+tmp1); + fnew[i][j][k][9]=0.25*(fnew[i][j][k][1]+fnew[i][j][k][2]-fnew[i][j][k][3]- + fnew[i][j][k][4]+2.0*fnew[i][j][k][11]-2.0*fnew[i][j][k][13]+tmp1); + fnew[i][j][k][10]=-0.25*(fnew[i][j][k][1]-fnew[i][j][k][2]-fnew[i][j][k][3]+ + fnew[i][j][k][4]+2.0*fnew[i][j][k][14]-2.0*fnew[i][j][k][12]-tmp1); + + + + rb=fnew[i][j][k][0]+fnew[i][j][k][1]+fnew[i][j][k][2]+fnew[i][j][k][3]+fnew[i][j][k][4]+ + fnew[i][j][k][5]+fnew[i][j][k][6]+tmp1+fnew[i][j][k][11]+fnew[i][j][k][12]+ + fnew[i][j][k][13]+fnew[i][j][k][14]; + + fnew[i][j][k][7] += 0.25*rb*vwbt; + fnew[i][j][k][8] += 0.25*rb*vwbt; + fnew[i][j][k][9] += -0.25*rb*vwbt; + fnew[i][j][k][10] += -0.25*rb*vwbt; + } } } @@ -2902,39 +2902,39 @@ void FixLbFluid::update_full15(void) MPI_Wait(&req_recv15,&status); for(i=1;i<subNbx-1;i++){ - for(j=1;j<subNby-1;j++){ - k=subNbz-2; - - if(typeLB == 1){ - fnew[i][j][k][6]=fnew[i][j][k+1][5]; - tmp1=fnew[i][j][k+1][7]+fnew[i][j][k+1][8]+fnew[i][j][k+1][9]+fnew[i][j][k+1][10]; - } - else{ - fnew[i][j][k][6]=fnew[i][j][k+1][5] + (0.5-Dcoeff*(tau+0.5))*feqn[i][j][k-1][6]; - tmp1=fnew[i][j][k+1][7]+fnew[i][j][k+1][8]+fnew[i][j][k+1][9]+fnew[i][j][k+1][10] + - (0.5-Dcoeff*(tau+0.5))*(feqn[i-1][j-1][k-1][11] + feqn[i+1][j-1][k-1][12] + - feqn[i+1][j+1][k-1][13] + feqn[i-1][j+1][k-1][14]); - } - - fnew[i][j][k][11]=-0.25*(fnew[i][j][k][1]+fnew[i][j][k][2]-fnew[i][j][k][3]- - fnew[i][j][k][4]+2.0*fnew[i][j][k][7]-2.0*fnew[i][j][k][9]-tmp1); - fnew[i][j][k][12]=0.25*(fnew[i][j][k][1]-fnew[i][j][k][2]-fnew[i][j][k][3]+ - fnew[i][j][k][4]-2.0*fnew[i][j][k][8]+2.0*fnew[i][j][k][10]+tmp1); - fnew[i][j][k][13]=0.25*(fnew[i][j][k][1]+fnew[i][j][k][2]-fnew[i][j][k][3]- - fnew[i][j][k][4]+2.0*fnew[i][j][k][7]-2.0*fnew[i][j][k][9]+tmp1); - fnew[i][j][k][14]=-0.25*(fnew[i][j][k][1]-fnew[i][j][k][2]-fnew[i][j][k][3]+ - fnew[i][j][k][4]-2.0*fnew[i][j][k][8]+2.0*fnew[i][j][k][10]-tmp1); - - - rb=fnew[i][j][k][0]+fnew[i][j][k][1]+fnew[i][j][k][2]+fnew[i][j][k][3]+fnew[i][j][k][4]+ - fnew[i][j][k][5]+fnew[i][j][k][6]+fnew[i][j][k][7]+fnew[i][j][k][8]+fnew[i][j][k][9]+ - fnew[i][j][k][10]+tmp1; - - fnew[i][j][k][11] += 0.25*rb*vwtp; - fnew[i][j][k][12] += 0.25*rb*vwtp; - fnew[i][j][k][13] += -0.25*rb*vwtp; - fnew[i][j][k][14] += -0.25*rb*vwtp; - } + for(j=1;j<subNby-1;j++){ + k=subNbz-2; + + if(typeLB == 1){ + fnew[i][j][k][6]=fnew[i][j][k+1][5]; + tmp1=fnew[i][j][k+1][7]+fnew[i][j][k+1][8]+fnew[i][j][k+1][9]+fnew[i][j][k+1][10]; + } + else{ + fnew[i][j][k][6]=fnew[i][j][k+1][5] + (0.5-Dcoeff*(tau+0.5))*feqn[i][j][k-1][6]; + tmp1=fnew[i][j][k+1][7]+fnew[i][j][k+1][8]+fnew[i][j][k+1][9]+fnew[i][j][k+1][10] + + (0.5-Dcoeff*(tau+0.5))*(feqn[i-1][j-1][k-1][11] + feqn[i+1][j-1][k-1][12] + + feqn[i+1][j+1][k-1][13] + feqn[i-1][j+1][k-1][14]); + } + + fnew[i][j][k][11]=-0.25*(fnew[i][j][k][1]+fnew[i][j][k][2]-fnew[i][j][k][3]- + fnew[i][j][k][4]+2.0*fnew[i][j][k][7]-2.0*fnew[i][j][k][9]-tmp1); + fnew[i][j][k][12]=0.25*(fnew[i][j][k][1]-fnew[i][j][k][2]-fnew[i][j][k][3]+ + fnew[i][j][k][4]-2.0*fnew[i][j][k][8]+2.0*fnew[i][j][k][10]+tmp1); + fnew[i][j][k][13]=0.25*(fnew[i][j][k][1]+fnew[i][j][k][2]-fnew[i][j][k][3]- + fnew[i][j][k][4]+2.0*fnew[i][j][k][7]-2.0*fnew[i][j][k][9]+tmp1); + fnew[i][j][k][14]=-0.25*(fnew[i][j][k][1]-fnew[i][j][k][2]-fnew[i][j][k][3]+ + fnew[i][j][k][4]-2.0*fnew[i][j][k][8]+2.0*fnew[i][j][k][10]-tmp1); + + + rb=fnew[i][j][k][0]+fnew[i][j][k][1]+fnew[i][j][k][2]+fnew[i][j][k][3]+fnew[i][j][k][4]+ + fnew[i][j][k][5]+fnew[i][j][k][6]+fnew[i][j][k][7]+fnew[i][j][k][8]+fnew[i][j][k][9]+ + fnew[i][j][k][10]+tmp1; + + fnew[i][j][k][11] += 0.25*rb*vwtp; + fnew[i][j][k][12] += 0.25*rb*vwtp; + fnew[i][j][k][13] += -0.25*rb*vwtp; + fnew[i][j][k][14] += -0.25*rb*vwtp; + } } } @@ -3080,122 +3080,122 @@ void FixLbFluid::update_full19(void) update_periodic(1,subNbx-1,1,subNby-1,subNbz-2,subNbz-1); }else if(typeLB==2){ if(comm->myloc[2]==0){ - for(i=1; i<subNbx-1; i++){ - for(j=1;j<subNby-1;j++){ - k=1; - for(m=0; m<19; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - - fnew[i][j][k][m] = feq[imod][jmod][kmod][m] + (f_lb[imod][jmod][kmod][m]-feq[imod][jmod][kmod][m])*expminusdtovertau; - } - - for(m=0; m<19; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - imodm = i+e[m][0]; - jmodm = j+e[m][1]; - kmodm = k+e[m][2]; - - if(m==5) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][6] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][6] - feqn[imod][jmod][kmod][6]); - else if(m==11) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][12] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][12] - feqn[imod][jmod][kmod][12]); - else if(m==13) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][14] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][14] - feqn[imod][jmod][kmod][14]); - else if(m==15) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][16] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][16] - feqn[imod][jmod][kmod][16]); - else if(m==17) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][18] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][18] - feqn[imod][jmod][kmod][18]); - else if(m==6) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][5] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==12) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][11] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==14) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][13] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==16) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][15] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==18) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][17] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[imodm][jmodm][kmodm][m] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - } - } - } + for(i=1; i<subNbx-1; i++){ + for(j=1;j<subNby-1;j++){ + k=1; + for(m=0; m<19; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + + fnew[i][j][k][m] = feq[imod][jmod][kmod][m] + (f_lb[imod][jmod][kmod][m]-feq[imod][jmod][kmod][m])*expminusdtovertau; + } + + for(m=0; m<19; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + imodm = i+e[m][0]; + jmodm = j+e[m][1]; + kmodm = k+e[m][2]; + + if(m==5) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][6] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][6] - feqn[imod][jmod][kmod][6]); + else if(m==11) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][12] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][12] - feqn[imod][jmod][kmod][12]); + else if(m==13) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][14] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][14] - feqn[imod][jmod][kmod][14]); + else if(m==15) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][16] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][16] - feqn[imod][jmod][kmod][16]); + else if(m==17) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][18] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][18] - feqn[imod][jmod][kmod][18]); + else if(m==6) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][5] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==12) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][11] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==14) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][13] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==16) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][15] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==18) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][17] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[imodm][jmodm][kmodm][m] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + } + } + } }else{ - update_periodic(1,subNbx-1,1,subNby-1,1,2); + update_periodic(1,subNbx-1,1,subNby-1,1,2); } if(comm->myloc[2]==comm->procgrid[2]-1){ - for(i=1;i<subNbx-1;i++){ - for(j=1;j<subNby-1;j++){ - k=subNbz-2; - for(m=0; m<19; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - - fnew[i][j][k][m] = feq[imod][jmod][kmod][m] + (f_lb[imod][jmod][kmod][m]-feq[imod][jmod][kmod][m])*expminusdtovertau; - } - for(m=0; m<19; m++){ - imod = i-e[m][0]; - jmod = j-e[m][1]; - kmod = k-e[m][2]; - imodm = i+e[m][0]; - jmodm = j+e[m][1]; - kmodm = k+e[m][2]; - - if(m==6) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][5] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][5] - feqn[imod][jmod][kmod][5]); - else if(m==12) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][11] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][11] - feqn[imod][jmod][kmod][11]); - else if(m==14) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][13] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][13] - feqn[imod][jmod][kmod][13]); - else if(m==16) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][15] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][15] - feqn[imod][jmod][kmod][15]); - else if(m==18) - fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][17] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][17] - feqn[imod][jmod][kmod][17]); - else if(m==5) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][6] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==11) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][12] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==13) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][14] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==15) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][16] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else if(m==17) - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][18] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - else - fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + - (0.5-Dcoeff*(tau+0.5))*(feqn[imodm][jmodm][kmodm][m] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); - } - } - } + for(i=1;i<subNbx-1;i++){ + for(j=1;j<subNby-1;j++){ + k=subNbz-2; + for(m=0; m<19; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + + fnew[i][j][k][m] = feq[imod][jmod][kmod][m] + (f_lb[imod][jmod][kmod][m]-feq[imod][jmod][kmod][m])*expminusdtovertau; + } + for(m=0; m<19; m++){ + imod = i-e[m][0]; + jmod = j-e[m][1]; + kmod = k-e[m][2]; + imodm = i+e[m][0]; + jmodm = j+e[m][1]; + kmodm = k+e[m][2]; + + if(m==6) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][5] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][5] - feqn[imod][jmod][kmod][5]); + else if(m==12) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][11] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][11] - feqn[imod][jmod][kmod][11]); + else if(m==14) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][13] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][13] - feqn[imod][jmod][kmod][13]); + else if(m==16) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][15] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][15] - feqn[imod][jmod][kmod][15]); + else if(m==18) + fnew[i][j][k][m] += Dcoeff*(feq[imod][jmod][kmod][17] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqoldn[imod][jmod][kmod][m] - feqoldn[imod][jmod][kmod][17] - feqn[imod][jmod][kmod][17]); + else if(m==5) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][6] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==11) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][12] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==13) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][14] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==15) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][16] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else if(m==17) + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[i][j][k][18] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + else + fnew[i][j][k][m] += Dcoeff*(feq[i][j][k][m] - feqold[imod][jmod][kmod][m]) + + (0.5-Dcoeff*(tau+0.5))*(feqn[imodm][jmodm][kmodm][m] - feqoldn[i][j][k][m] - feqn[i][j][k][m] + feqoldn[imod][jmod][kmod][m]); + } + } + } } else{ - update_periodic(1,subNbx-1,1,subNby-1,subNbz-2,subNbz-1); + update_periodic(1,subNbx-1,1,subNby-1,subNbz-2,subNbz-1); } } @@ -3218,35 +3218,35 @@ void FixLbFluid::update_full19(void) MPI_Wait(&req_recv25,&status); for(i=1;i<subNbx-1;i++){ - for(j=1;j<subNby-1;j++){ - k=1; - - if(typeLB == 1){ - fnew[i][j][k][5]=fnew[i][j][k-1][6]; - tmp1=fnew[i][j][k-1][12]+fnew[i][j][k-1][14]+fnew[i][j][k-1][16]+fnew[i][j][k-1][18]; - } - else{ - fnew[i][j][k][5]=fnew[i][j][k-1][6] + (0.5-Dcoeff*(tau+0.5))*feqn[i][j][k+1][5]; - tmp1=fnew[i][j][k-1][12]+fnew[i][j][k-1][14]+fnew[i][j][k-1][16]+fnew[i][j][k-1][18] + - (0.5-Dcoeff*(tau+0.5))*(feqn[i-1][j][k+1][11] + feqn[i+1][j][k+1][13] + - feqn[i][j-1][k+1][15] + feqn[i][j+1][k+1][17]); - } - - tmp2=fnew[i][j][k][3]+fnew[i][j][k][9]+fnew[i][j][k][10]+fnew[i][j][k][14]- - fnew[i][j][k][1]-fnew[i][j][k][7]-fnew[i][j][k][8]-fnew[i][j][k][12]; - - rb=fnew[i][j][k][0]+fnew[i][j][k][1]+fnew[i][j][k][2]+fnew[i][j][k][3]+fnew[i][j][k][4]+ - fnew[i][j][k][5]+fnew[i][j][k][6]+fnew[i][j][k][7]+fnew[i][j][k][8]+fnew[i][j][k][9]+ - fnew[i][j][k][10]+fnew[i][j][k][12]+fnew[i][j][k][14]+fnew[i][j][k][16]+fnew[i][j][k][18]+tmp1; - - tmp3=rb*vwbt-fnew[i][j][k][2]+fnew[i][j][k][4]-fnew[i][j][k][7]+fnew[i][j][k][8]-fnew[i][j][k][9]+ - fnew[i][j][k][10]-fnew[i][j][k][16]+fnew[i][j][k][18]; - - fnew[i][j][k][11] = 0.25*(tmp1+2.0*tmp2); - fnew[i][j][k][13] = 0.25*(tmp1-2.0*tmp2); - fnew[i][j][k][15] = 0.25*(tmp1+2.0*tmp3); - fnew[i][j][k][17] = 0.25*(tmp1-2.0*tmp3); - } + for(j=1;j<subNby-1;j++){ + k=1; + + if(typeLB == 1){ + fnew[i][j][k][5]=fnew[i][j][k-1][6]; + tmp1=fnew[i][j][k-1][12]+fnew[i][j][k-1][14]+fnew[i][j][k-1][16]+fnew[i][j][k-1][18]; + } + else{ + fnew[i][j][k][5]=fnew[i][j][k-1][6] + (0.5-Dcoeff*(tau+0.5))*feqn[i][j][k+1][5]; + tmp1=fnew[i][j][k-1][12]+fnew[i][j][k-1][14]+fnew[i][j][k-1][16]+fnew[i][j][k-1][18] + + (0.5-Dcoeff*(tau+0.5))*(feqn[i-1][j][k+1][11] + feqn[i+1][j][k+1][13] + + feqn[i][j-1][k+1][15] + feqn[i][j+1][k+1][17]); + } + + tmp2=fnew[i][j][k][3]+fnew[i][j][k][9]+fnew[i][j][k][10]+fnew[i][j][k][14]- + fnew[i][j][k][1]-fnew[i][j][k][7]-fnew[i][j][k][8]-fnew[i][j][k][12]; + + rb=fnew[i][j][k][0]+fnew[i][j][k][1]+fnew[i][j][k][2]+fnew[i][j][k][3]+fnew[i][j][k][4]+ + fnew[i][j][k][5]+fnew[i][j][k][6]+fnew[i][j][k][7]+fnew[i][j][k][8]+fnew[i][j][k][9]+ + fnew[i][j][k][10]+fnew[i][j][k][12]+fnew[i][j][k][14]+fnew[i][j][k][16]+fnew[i][j][k][18]+tmp1; + + tmp3=rb*vwbt-fnew[i][j][k][2]+fnew[i][j][k][4]-fnew[i][j][k][7]+fnew[i][j][k][8]-fnew[i][j][k][9]+ + fnew[i][j][k][10]-fnew[i][j][k][16]+fnew[i][j][k][18]; + + fnew[i][j][k][11] = 0.25*(tmp1+2.0*tmp2); + fnew[i][j][k][13] = 0.25*(tmp1-2.0*tmp2); + fnew[i][j][k][15] = 0.25*(tmp1+2.0*tmp3); + fnew[i][j][k][17] = 0.25*(tmp1-2.0*tmp3); + } } } @@ -3255,35 +3255,35 @@ void FixLbFluid::update_full19(void) MPI_Wait(&req_recv15,&status); for(i=1;i<subNbx-1;i++){ - for(j=1;j<subNby-1;j++){ - k=subNbz-2; - - if(typeLB == 1){ - fnew[i][j][k][6]=fnew[i][j][k+1][5]; - tmp1=fnew[i][j][k+1][11]+fnew[i][j][k+1][13]+fnew[i][j][k+1][15]+fnew[i][j][k+1][17]; - } - else{ - fnew[i][j][k][6]=fnew[i][j][k+1][5] + (0.5-Dcoeff*(tau+0.5))*feqn[i][j][k-1][6]; - tmp1=fnew[i][j][k+1][11]+fnew[i][j][k+1][13]+fnew[i][j][k+1][15]+fnew[i][j][k+1][17] + - (0.5-Dcoeff*(tau+0.5))*(feqn[i-1][j][k-1][12] + feqn[i+1][j][k-1][14] + - feqn[i][j-1][k-1][16] + feqn[i][j+1][k-1][18]); - } - - tmp2=fnew[i][j][k][3]+fnew[i][j][k][9]+fnew[i][j][k][10]+fnew[i][j][k][13]-fnew[i][j][k][1]- - fnew[i][j][k][7]-fnew[i][j][k][8]-fnew[i][j][k][11]; - - rb=fnew[i][j][k][0]+fnew[i][j][k][1]+fnew[i][j][k][2]+fnew[i][j][k][3]+fnew[i][j][k][4]+ - fnew[i][j][k][5]+fnew[i][j][k][6]+fnew[i][j][k][7]+fnew[i][j][k][8]+fnew[i][j][k][9]+ - fnew[i][j][k][10]+fnew[i][j][k][11]+fnew[i][j][k][13]+fnew[i][j][k][15]+fnew[i][j][k][17]+tmp1; - - tmp3=rb*vwtp-fnew[i][j][k][2]+fnew[i][j][k][4]-fnew[i][j][k][7]+fnew[i][j][k][8]-fnew[i][j][k][9]+ - fnew[i][j][k][10]-fnew[i][j][k][15]+fnew[i][j][k][17]; - - fnew[i][j][k][12] = 0.25*(tmp1+2.0*tmp2); - fnew[i][j][k][14] = 0.25*(tmp1-2.0*tmp2); - fnew[i][j][k][16] = 0.25*(tmp1+2.0*tmp3); - fnew[i][j][k][18] = 0.25*(tmp1-2.0*tmp3); - } + for(j=1;j<subNby-1;j++){ + k=subNbz-2; + + if(typeLB == 1){ + fnew[i][j][k][6]=fnew[i][j][k+1][5]; + tmp1=fnew[i][j][k+1][11]+fnew[i][j][k+1][13]+fnew[i][j][k+1][15]+fnew[i][j][k+1][17]; + } + else{ + fnew[i][j][k][6]=fnew[i][j][k+1][5] + (0.5-Dcoeff*(tau+0.5))*feqn[i][j][k-1][6]; + tmp1=fnew[i][j][k+1][11]+fnew[i][j][k+1][13]+fnew[i][j][k+1][15]+fnew[i][j][k+1][17] + + (0.5-Dcoeff*(tau+0.5))*(feqn[i-1][j][k-1][12] + feqn[i+1][j][k-1][14] + + feqn[i][j-1][k-1][16] + feqn[i][j+1][k-1][18]); + } + + tmp2=fnew[i][j][k][3]+fnew[i][j][k][9]+fnew[i][j][k][10]+fnew[i][j][k][13]-fnew[i][j][k][1]- + fnew[i][j][k][7]-fnew[i][j][k][8]-fnew[i][j][k][11]; + + rb=fnew[i][j][k][0]+fnew[i][j][k][1]+fnew[i][j][k][2]+fnew[i][j][k][3]+fnew[i][j][k][4]+ + fnew[i][j][k][5]+fnew[i][j][k][6]+fnew[i][j][k][7]+fnew[i][j][k][8]+fnew[i][j][k][9]+ + fnew[i][j][k][10]+fnew[i][j][k][11]+fnew[i][j][k][13]+fnew[i][j][k][15]+fnew[i][j][k][17]+tmp1; + + tmp3=rb*vwtp-fnew[i][j][k][2]+fnew[i][j][k][4]-fnew[i][j][k][7]+fnew[i][j][k][8]-fnew[i][j][k][9]+ + fnew[i][j][k][10]-fnew[i][j][k][15]+fnew[i][j][k][17]; + + fnew[i][j][k][12] = 0.25*(tmp1+2.0*tmp2); + fnew[i][j][k][14] = 0.25*(tmp1-2.0*tmp2); + fnew[i][j][k][16] = 0.25*(tmp1+2.0*tmp3); + fnew[i][j][k][18] = 0.25*(tmp1-2.0*tmp3); + } } } diff --git a/src/USER-LB/fix_lb_momentum.cpp b/src/USER-LB/fix_lb_momentum.cpp index 18d98edda8..d604d8fed4 100644 --- a/src/USER-LB/fix_lb_momentum.cpp +++ b/src/USER-LB/fix_lb_momentum.cpp @@ -64,7 +64,7 @@ FixLbMomentum::FixLbMomentum(LAMMPS *lmp, int narg, char **arg) : if (linear) if (xflag < 0 || xflag > 1 || yflag < 0 || yflag > 1 || - zflag < 0 || zflag > 1) error->all(FLERR,"Illegal fix lb/momentum command"); + zflag < 0 || zflag > 1) error->all(FLERR,"Illegal fix lb/momentum command"); // cannot have 0 atoms in group @@ -138,12 +138,12 @@ void FixLbMomentum::end_of_step() for(int i = 1; i<subNbx-1; i++) for(int j = 1; j<subNby-1; j++) - for(int k = 1; k<subNbz-1; k++){ - masslbloc += density_lb[i][j][k]; - momentumlbloc[0] += density_lb[i][j][k]*u_lb[i][j][k][0]; - momentumlbloc[1] += density_lb[i][j][k]*u_lb[i][j][k][1]; - momentumlbloc[2] += density_lb[i][j][k]*u_lb[i][j][k][2]; - } + for(int k = 1; k<subNbz-1; k++){ + masslbloc += density_lb[i][j][k]; + momentumlbloc[0] += density_lb[i][j][k]*u_lb[i][j][k][0]; + momentumlbloc[1] += density_lb[i][j][k]*u_lb[i][j][k][1]; + momentumlbloc[2] += density_lb[i][j][k]*u_lb[i][j][k][2]; + } MPI_Allreduce(&masslbloc,&masslb,1,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(&momentumlbloc[0],&momentumlb[0],3,MPI_DOUBLE,MPI_SUM,world); @@ -160,9 +160,9 @@ void FixLbMomentum::end_of_step() //Subtract vcm from the particles. for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - if (xflag) v[i][0] -= vcmtotal[0]; - if (yflag) v[i][1] -= vcmtotal[1]; - if (zflag) v[i][2] -= vcmtotal[2]; + if (xflag) v[i][0] -= vcmtotal[0]; + if (yflag) v[i][1] -= vcmtotal[1]; + if (zflag) v[i][2] -= vcmtotal[2]; } vcmtotal[0] *= dt_lb/dx_lb; @@ -177,121 +177,121 @@ void FixLbMomentum::end_of_step() //Subtract vcm from the fluid. for(int i=0; i<subNbx; i++) for(int j=0; j<subNby; j++) - for(int k=0; k<subNbz; k++){ - rho = density_lb[i][j][k]; - if(xflag) ucmx = vcmtotal[0]; - if(yflag) ucmy = vcmtotal[1]; - if(zflag) ucmz = vcmtotal[2]; - if(numvel==15){ - etacov[0]=0.0; - etacov[1]=rho*ucmx; - etacov[2]=rho*ucmy; - etacov[3]=rho*ucmz; - etacov[4]=rho*(2.*u_lb[i][j][k][0]*ucmx-ucmx*ucmx); - etacov[5]=rho*(2.*u_lb[i][j][k][1]*ucmy-ucmy*ucmy); - etacov[6]=rho*(2.*u_lb[i][j][k][2]*ucmz-ucmz*ucmz); - etacov[7]=rho*(u_lb[i][j][k][0]*ucmy+u_lb[i][j][k][1]*ucmx-ucmx*ucmy); - etacov[8]=rho*(u_lb[i][j][k][1]*ucmz+u_lb[i][j][k][2]*ucmy-ucmy*ucmz); - etacov[9]=rho*(u_lb[i][j][k][0]*ucmz+u_lb[i][j][k][2]*ucmx-ucmx*ucmz); - etacov[10]=0.0; - etacov[11]=0.0; - etacov[12]=0.0; - etacov[13]=rho*(u_lb[i][j][k][0]*u_lb[i][j][k][1]*ucmz+u_lb[i][j][k][0]*ucmy*u_lb[i][j][k][2]- - u_lb[i][j][k][0]*ucmy*ucmz+ucmx*u_lb[i][j][k][1]*u_lb[i][j][k][2]- - ucmx*u_lb[i][j][k][1]*ucmz-ucmx*ucmy*u_lb[i][j][k][2]+ - ucmx*ucmy*ucmz); - etacov[14]=0.0; - }else{ - etacov[0] = 0.0; - etacov[1] = rho*ucmx; - etacov[2] = rho*ucmy; - etacov[3] = rho*ucmz; - etacov[4]=rho*(2.*u_lb[i][j][k][0]*ucmx-ucmx*ucmx); - etacov[5]=rho*(2.*u_lb[i][j][k][1]*ucmy-ucmy*ucmy); - etacov[6]=rho*(2.*u_lb[i][j][k][2]*ucmz-ucmz*ucmz); - etacov[7]=rho*(u_lb[i][j][k][0]*ucmy+u_lb[i][j][k][1]*ucmx-ucmx*ucmy); - etacov[8]=rho*(u_lb[i][j][k][0]*ucmz+u_lb[i][j][k][2]*ucmx-ucmx*ucmz); - etacov[9]=rho*(u_lb[i][j][k][1]*ucmz+u_lb[i][j][k][2]*ucmy-ucmy*ucmz); - etacov[10] = 0.0; - etacov[11] = 0.0; - etacov[12] = 0.0; - etacov[13] = 0.0; - etacov[14] = 0.0; - etacov[15] = 0.0; - etacov[16] = 0.0; - etacov[17] = 0.0; - etacov[18] = 0.0; - } - - for(int l=0; l<numvel; l++) - for(int ii=0; ii<numvel; ii++){ - f_lb[i][j][k][l] -= w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; - } - - - if(typeLB == 2){ - double ****feqold = fix_lb_fluid->feqold; - double ****feqoldn = fix_lb_fluid->feqoldn; - density_old = 0.0; - u_old[0] = u_old[1] = u_old[2] = 0.0; - for(int l=0; l<numvel; l++){ - density_old += feqold[i][j][k][l]; - u_old[0] += feqold[i][j][k][l]*e[l][0]; - u_old[1] += feqold[i][j][k][l]*e[l][1]; - u_old[2] += feqold[i][j][k][l]*e[l][2]; - } - u_old[0] = u_old[0]/density_old; - u_old[1] = u_old[1]/density_old; - u_old[2] = u_old[2]/density_old; - - if(numvel==15){ - etacov[0]=0.0; - etacov[1]=density_old*ucmx; - etacov[2]=density_old*ucmy; - etacov[3]=density_old*ucmz; - etacov[4]=density_old*(2.*u_old[0]*ucmx-ucmx*ucmx); - etacov[5]=density_old*(2.*u_old[1]*ucmy-ucmy*ucmy); - etacov[6]=density_old*(2.*u_old[2]*ucmz-ucmz*ucmz); - etacov[7]=density_old*(u_old[0]*ucmy+u_old[1]*ucmx-ucmx*ucmy); - etacov[8]=density_old*(u_old[1]*ucmz+u_old[2]*ucmy-ucmy*ucmz); - etacov[9]=density_old*(u_old[0]*ucmz+u_old[2]*ucmx-ucmx*ucmz); - etacov[10]=0.0; - etacov[11]=0.0; - etacov[12]=0.0; - etacov[13]=density_old*(u_old[0]*u_old[1]*ucmz+u_old[0]*ucmy*u_old[2]- - u_old[0]*ucmy*ucmz+ucmx*u_old[1]*u_old[2]- - ucmx*u_old[1]*ucmz-ucmx*ucmy*u_old[2]+ - ucmx*ucmy*ucmz); - etacov[14]=0.0; - }else{ - etacov[0] = 0.0; - etacov[1] = density_old*ucmx; - etacov[2] = density_old*ucmy; - etacov[3] = density_old*ucmz; - etacov[4] = density_old*(2.*u_lb[i][j][k][0]*ucmx-ucmx*ucmx); - etacov[5] = density_old*(2.*u_lb[i][j][k][1]*ucmy-ucmy*ucmy); - etacov[6] = density_old*(2.*u_lb[i][j][k][2]*ucmz-ucmz*ucmz); - etacov[7] = density_old*(u_lb[i][j][k][0]*ucmy+u_lb[i][j][k][1]*ucmx-ucmx*ucmy); - etacov[8] = density_old*(u_lb[i][j][k][0]*ucmz+u_lb[i][j][k][2]*ucmx-ucmx*ucmz); - etacov[9] = density_old*(u_lb[i][j][k][1]*ucmz+u_lb[i][j][k][2]*ucmy-ucmy*ucmz); - etacov[10] = 0.0; - etacov[11] = 0.0; - etacov[12] = 0.0; - etacov[13] = 0.0; - etacov[14] = 0.0; - etacov[15] = 0.0; - etacov[16] = 0.0; - etacov[17] = 0.0; - etacov[18] = 0.0; - } - - for(int l=0; l<numvel; l++) - for(int ii=0; ii<numvel; ii++){ - feqold[i][j][k][l] -= w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; - feqoldn[i][j][k][l] -= w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; - } - } - } + for(int k=0; k<subNbz; k++){ + rho = density_lb[i][j][k]; + if(xflag) ucmx = vcmtotal[0]; + if(yflag) ucmy = vcmtotal[1]; + if(zflag) ucmz = vcmtotal[2]; + if(numvel==15){ + etacov[0]=0.0; + etacov[1]=rho*ucmx; + etacov[2]=rho*ucmy; + etacov[3]=rho*ucmz; + etacov[4]=rho*(2.*u_lb[i][j][k][0]*ucmx-ucmx*ucmx); + etacov[5]=rho*(2.*u_lb[i][j][k][1]*ucmy-ucmy*ucmy); + etacov[6]=rho*(2.*u_lb[i][j][k][2]*ucmz-ucmz*ucmz); + etacov[7]=rho*(u_lb[i][j][k][0]*ucmy+u_lb[i][j][k][1]*ucmx-ucmx*ucmy); + etacov[8]=rho*(u_lb[i][j][k][1]*ucmz+u_lb[i][j][k][2]*ucmy-ucmy*ucmz); + etacov[9]=rho*(u_lb[i][j][k][0]*ucmz+u_lb[i][j][k][2]*ucmx-ucmx*ucmz); + etacov[10]=0.0; + etacov[11]=0.0; + etacov[12]=0.0; + etacov[13]=rho*(u_lb[i][j][k][0]*u_lb[i][j][k][1]*ucmz+u_lb[i][j][k][0]*ucmy*u_lb[i][j][k][2]- + u_lb[i][j][k][0]*ucmy*ucmz+ucmx*u_lb[i][j][k][1]*u_lb[i][j][k][2]- + ucmx*u_lb[i][j][k][1]*ucmz-ucmx*ucmy*u_lb[i][j][k][2]+ + ucmx*ucmy*ucmz); + etacov[14]=0.0; + }else{ + etacov[0] = 0.0; + etacov[1] = rho*ucmx; + etacov[2] = rho*ucmy; + etacov[3] = rho*ucmz; + etacov[4]=rho*(2.*u_lb[i][j][k][0]*ucmx-ucmx*ucmx); + etacov[5]=rho*(2.*u_lb[i][j][k][1]*ucmy-ucmy*ucmy); + etacov[6]=rho*(2.*u_lb[i][j][k][2]*ucmz-ucmz*ucmz); + etacov[7]=rho*(u_lb[i][j][k][0]*ucmy+u_lb[i][j][k][1]*ucmx-ucmx*ucmy); + etacov[8]=rho*(u_lb[i][j][k][0]*ucmz+u_lb[i][j][k][2]*ucmx-ucmx*ucmz); + etacov[9]=rho*(u_lb[i][j][k][1]*ucmz+u_lb[i][j][k][2]*ucmy-ucmy*ucmz); + etacov[10] = 0.0; + etacov[11] = 0.0; + etacov[12] = 0.0; + etacov[13] = 0.0; + etacov[14] = 0.0; + etacov[15] = 0.0; + etacov[16] = 0.0; + etacov[17] = 0.0; + etacov[18] = 0.0; + } + + for(int l=0; l<numvel; l++) + for(int ii=0; ii<numvel; ii++){ + f_lb[i][j][k][l] -= w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; + } + + + if(typeLB == 2){ + double ****feqold = fix_lb_fluid->feqold; + double ****feqoldn = fix_lb_fluid->feqoldn; + density_old = 0.0; + u_old[0] = u_old[1] = u_old[2] = 0.0; + for(int l=0; l<numvel; l++){ + density_old += feqold[i][j][k][l]; + u_old[0] += feqold[i][j][k][l]*e[l][0]; + u_old[1] += feqold[i][j][k][l]*e[l][1]; + u_old[2] += feqold[i][j][k][l]*e[l][2]; + } + u_old[0] = u_old[0]/density_old; + u_old[1] = u_old[1]/density_old; + u_old[2] = u_old[2]/density_old; + + if(numvel==15){ + etacov[0]=0.0; + etacov[1]=density_old*ucmx; + etacov[2]=density_old*ucmy; + etacov[3]=density_old*ucmz; + etacov[4]=density_old*(2.*u_old[0]*ucmx-ucmx*ucmx); + etacov[5]=density_old*(2.*u_old[1]*ucmy-ucmy*ucmy); + etacov[6]=density_old*(2.*u_old[2]*ucmz-ucmz*ucmz); + etacov[7]=density_old*(u_old[0]*ucmy+u_old[1]*ucmx-ucmx*ucmy); + etacov[8]=density_old*(u_old[1]*ucmz+u_old[2]*ucmy-ucmy*ucmz); + etacov[9]=density_old*(u_old[0]*ucmz+u_old[2]*ucmx-ucmx*ucmz); + etacov[10]=0.0; + etacov[11]=0.0; + etacov[12]=0.0; + etacov[13]=density_old*(u_old[0]*u_old[1]*ucmz+u_old[0]*ucmy*u_old[2]- + u_old[0]*ucmy*ucmz+ucmx*u_old[1]*u_old[2]- + ucmx*u_old[1]*ucmz-ucmx*ucmy*u_old[2]+ + ucmx*ucmy*ucmz); + etacov[14]=0.0; + }else{ + etacov[0] = 0.0; + etacov[1] = density_old*ucmx; + etacov[2] = density_old*ucmy; + etacov[3] = density_old*ucmz; + etacov[4] = density_old*(2.*u_lb[i][j][k][0]*ucmx-ucmx*ucmx); + etacov[5] = density_old*(2.*u_lb[i][j][k][1]*ucmy-ucmy*ucmy); + etacov[6] = density_old*(2.*u_lb[i][j][k][2]*ucmz-ucmz*ucmz); + etacov[7] = density_old*(u_lb[i][j][k][0]*ucmy+u_lb[i][j][k][1]*ucmx-ucmx*ucmy); + etacov[8] = density_old*(u_lb[i][j][k][0]*ucmz+u_lb[i][j][k][2]*ucmx-ucmx*ucmz); + etacov[9] = density_old*(u_lb[i][j][k][1]*ucmz+u_lb[i][j][k][2]*ucmy-ucmy*ucmz); + etacov[10] = 0.0; + etacov[11] = 0.0; + etacov[12] = 0.0; + etacov[13] = 0.0; + etacov[14] = 0.0; + etacov[15] = 0.0; + etacov[16] = 0.0; + etacov[17] = 0.0; + etacov[18] = 0.0; + } + + for(int l=0; l<numvel; l++) + for(int ii=0; ii<numvel; ii++){ + feqold[i][j][k][l] -= w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; + feqoldn[i][j][k][l] -= w_lb[l]*mg_lb[ii][l]*etacov[ii]*Ng_lb[ii]; + } + } + } } fix_lb_fluid->parametercalc_full(); diff --git a/src/USER-LB/fix_lb_pc.cpp b/src/USER-LB/fix_lb_pc.cpp index 9ea1afc2ea..c4d7cf70d3 100644 --- a/src/USER-LB/fix_lb_pc.cpp +++ b/src/USER-LB/fix_lb_pc.cpp @@ -148,30 +148,30 @@ void FixLbPC::initial_integrate(int vflag) { if(rmass){ for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - dtfm = dtf/rmass[i]; - expminusdttimesgamma = exp(-dtv*Gamma_MD[type[i]]/rmass[i]); - - dx[0] = dtv*v[i][0] + 0.5*(f[i][0]*force->ftm2v - Gamma_MD[type[i]]*(v[i][0]-up[i][0]))*dtv*dtv/rmass[i]; - dx[1] = dtv*v[i][1] + 0.5*(f[i][1]*force->ftm2v - Gamma_MD[type[i]]*(v[i][1]-up[i][1]))*dtv*dtv/rmass[i]; - dx[2] = dtv*v[i][2] + 0.5*(f[i][2]*force->ftm2v - Gamma_MD[type[i]]*(v[i][2]-up[i][2]))*dtv*dtv/rmass[i]; - - x[i][0] += dx[0]; - x[i][1] += dx[1]; - x[i][2] += dx[2]; - - // Approximation for v - if(Gamma_MD[type[i]] == 0.0){ - v[i][0] += f[i][0]*dtfm; - v[i][1] += f[i][1]*dtfm; - v[i][2] += f[i][2]*dtfm; - }else{ - v[i][0] = (v[i][0]-up[i][0]-f[i][0]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + - f[i][0]*force->ftm2v/Gamma_MD[type[i]] + up[i][0]; - v[i][1] = (v[i][1]-up[i][1]-f[i][1]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + - f[i][1]*force->ftm2v/Gamma_MD[type[i]] + up[i][1]; - v[i][2] = (v[i][2]-up[i][2]-f[i][2]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + - f[i][2]*force->ftm2v/Gamma_MD[type[i]] + up[i][2]; - } + dtfm = dtf/rmass[i]; + expminusdttimesgamma = exp(-dtv*Gamma_MD[type[i]]/rmass[i]); + + dx[0] = dtv*v[i][0] + 0.5*(f[i][0]*force->ftm2v - Gamma_MD[type[i]]*(v[i][0]-up[i][0]))*dtv*dtv/rmass[i]; + dx[1] = dtv*v[i][1] + 0.5*(f[i][1]*force->ftm2v - Gamma_MD[type[i]]*(v[i][1]-up[i][1]))*dtv*dtv/rmass[i]; + dx[2] = dtv*v[i][2] + 0.5*(f[i][2]*force->ftm2v - Gamma_MD[type[i]]*(v[i][2]-up[i][2]))*dtv*dtv/rmass[i]; + + x[i][0] += dx[0]; + x[i][1] += dx[1]; + x[i][2] += dx[2]; + + // Approximation for v + if(Gamma_MD[type[i]] == 0.0){ + v[i][0] += f[i][0]*dtfm; + v[i][1] += f[i][1]*dtfm; + v[i][2] += f[i][2]*dtfm; + }else{ + v[i][0] = (v[i][0]-up[i][0]-f[i][0]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + + f[i][0]*force->ftm2v/Gamma_MD[type[i]] + up[i][0]; + v[i][1] = (v[i][1]-up[i][1]-f[i][1]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + + f[i][1]*force->ftm2v/Gamma_MD[type[i]] + up[i][1]; + v[i][2] = (v[i][2]-up[i][2]-f[i][2]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + + f[i][2]*force->ftm2v/Gamma_MD[type[i]] + up[i][2]; + } } } @@ -179,30 +179,30 @@ void FixLbPC::initial_integrate(int vflag) { // this does NOT take varying masses into account for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - dtfm = dtf/mass[type[i]]; - expminusdttimesgamma = exp(-dtv*Gamma_MD[type[i]]/mass[type[i]]); - - dx[0] = dtv*v[i][0] + 0.5*(f[i][0]*force->ftm2v - Gamma_MD[type[i]]*(v[i][0]-up[i][0]))*dtv*dtv/mass[type[i]]; - dx[1] = dtv*v[i][1] + 0.5*(f[i][1]*force->ftm2v - Gamma_MD[type[i]]*(v[i][1]-up[i][1]))*dtv*dtv/mass[type[i]]; - dx[2] = dtv*v[i][2] + 0.5*(f[i][2]*force->ftm2v - Gamma_MD[type[i]]*(v[i][2]-up[i][2]))*dtv*dtv/mass[type[i]]; - - x[i][0] += dx[0]; - x[i][1] += dx[1]; - x[i][2] += dx[2]; - - // Approximation for v - if(Gamma_MD[type[i]] == 0.0){ - v[i][0] += f[i][0]*dtfm; - v[i][1] += f[i][1]*dtfm; - v[i][2] += f[i][2]*dtfm; - }else{ - v[i][0] = (v[i][0]-up[i][0]-f[i][0]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + - f[i][0]*force->ftm2v/Gamma_MD[type[i]] + up[i][0]; - v[i][1] = (v[i][1]-up[i][1]-f[i][1]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + - f[i][1]*force->ftm2v/Gamma_MD[type[i]] + up[i][1]; - v[i][2] = (v[i][2]-up[i][2]-f[i][2]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + - f[i][2]*force->ftm2v/Gamma_MD[type[i]] + up[i][2]; - } + dtfm = dtf/mass[type[i]]; + expminusdttimesgamma = exp(-dtv*Gamma_MD[type[i]]/mass[type[i]]); + + dx[0] = dtv*v[i][0] + 0.5*(f[i][0]*force->ftm2v - Gamma_MD[type[i]]*(v[i][0]-up[i][0]))*dtv*dtv/mass[type[i]]; + dx[1] = dtv*v[i][1] + 0.5*(f[i][1]*force->ftm2v - Gamma_MD[type[i]]*(v[i][1]-up[i][1]))*dtv*dtv/mass[type[i]]; + dx[2] = dtv*v[i][2] + 0.5*(f[i][2]*force->ftm2v - Gamma_MD[type[i]]*(v[i][2]-up[i][2]))*dtv*dtv/mass[type[i]]; + + x[i][0] += dx[0]; + x[i][1] += dx[1]; + x[i][2] += dx[2]; + + // Approximation for v + if(Gamma_MD[type[i]] == 0.0){ + v[i][0] += f[i][0]*dtfm; + v[i][1] += f[i][1]*dtfm; + v[i][2] += f[i][2]*dtfm; + }else{ + v[i][0] = (v[i][0]-up[i][0]-f[i][0]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + + f[i][0]*force->ftm2v/Gamma_MD[type[i]] + up[i][0]; + v[i][1] = (v[i][1]-up[i][1]-f[i][1]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + + f[i][1]*force->ftm2v/Gamma_MD[type[i]] + up[i][1]; + v[i][2] = (v[i][2]-up[i][2]-f[i][2]*force->ftm2v/Gamma_MD[type[i]])*expminusdttimesgamma + + f[i][2]*force->ftm2v/Gamma_MD[type[i]] + up[i][2]; + } } } } @@ -226,19 +226,19 @@ void FixLbPC::final_integrate() if(rmass){ for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - dtfm = dtf/rmass[i]; - expminusdttimesgamma = exp(-dtv*Gamma_MD[type[i]]/rmass[i]); - DMDcoeff = (dtv - rmass[i]*(1.0-expminusdttimesgamma)/Gamma_MD[type[i]]); + dtfm = dtf/rmass[i]; + expminusdttimesgamma = exp(-dtv*Gamma_MD[type[i]]/rmass[i]); + DMDcoeff = (dtv - rmass[i]*(1.0-expminusdttimesgamma)/Gamma_MD[type[i]]); - if(Gamma_MD[type[i]] == 0.0){ - v[i][0] += 0.5*(f[i][0] - force_old[i][0])*dtfm; - v[i][1] += 0.5*(f[i][1] - force_old[i][1])*dtfm; - v[i][2] += 0.5*(f[i][2] - force_old[i][2])*dtfm; - }else{ - v[i][0] += DMDcoeff*((f[i][0] - force_old[i][0])*force->ftm2v/Gamma_MD[type[i]] + up[i][0] - up_old[i][0])/dtv; - v[i][1] += DMDcoeff*((f[i][1] - force_old[i][1])*force->ftm2v/Gamma_MD[type[i]] + up[i][1] - up_old[i][1])/dtv; - v[i][2] += DMDcoeff*((f[i][2] - force_old[i][2])*force->ftm2v/Gamma_MD[type[i]] + up[i][2] - up_old[i][2])/dtv; - } + if(Gamma_MD[type[i]] == 0.0){ + v[i][0] += 0.5*(f[i][0] - force_old[i][0])*dtfm; + v[i][1] += 0.5*(f[i][1] - force_old[i][1])*dtfm; + v[i][2] += 0.5*(f[i][2] - force_old[i][2])*dtfm; + }else{ + v[i][0] += DMDcoeff*((f[i][0] - force_old[i][0])*force->ftm2v/Gamma_MD[type[i]] + up[i][0] - up_old[i][0])/dtv; + v[i][1] += DMDcoeff*((f[i][1] - force_old[i][1])*force->ftm2v/Gamma_MD[type[i]] + up[i][1] - up_old[i][1])/dtv; + v[i][2] += DMDcoeff*((f[i][2] - force_old[i][2])*force->ftm2v/Gamma_MD[type[i]] + up[i][2] - up_old[i][2])/dtv; + } } @@ -247,19 +247,19 @@ void FixLbPC::final_integrate() // this does NOT take varying masses into account for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - dtfm = dtf/mass[type[i]]; - expminusdttimesgamma = exp(-dtv*Gamma_MD[type[i]]/mass[type[i]]); - DMDcoeff = (dtv - mass[type[i]]*(1.0-expminusdttimesgamma)/Gamma_MD[type[i]]); - - if(Gamma_MD[type[i]] == 0.0){ - v[i][0] += 0.5*(f[i][0] - force_old[i][0])*dtfm; - v[i][1] += 0.5*(f[i][1] - force_old[i][1])*dtfm; - v[i][2] += 0.5*(f[i][2] - force_old[i][2])*dtfm; - }else{ - v[i][0] += DMDcoeff*((f[i][0] - force_old[i][0])*force->ftm2v/Gamma_MD[type[i]] + up[i][0] - up_old[i][0])/dtv; - v[i][1] += DMDcoeff*((f[i][1] - force_old[i][1])*force->ftm2v/Gamma_MD[type[i]] + up[i][1] - up_old[i][1])/dtv; - v[i][2] += DMDcoeff*((f[i][2] - force_old[i][2])*force->ftm2v/Gamma_MD[type[i]] + up[i][2] - up_old[i][2])/dtv; - } + dtfm = dtf/mass[type[i]]; + expminusdttimesgamma = exp(-dtv*Gamma_MD[type[i]]/mass[type[i]]); + DMDcoeff = (dtv - mass[type[i]]*(1.0-expminusdttimesgamma)/Gamma_MD[type[i]]); + + if(Gamma_MD[type[i]] == 0.0){ + v[i][0] += 0.5*(f[i][0] - force_old[i][0])*dtfm; + v[i][1] += 0.5*(f[i][1] - force_old[i][1])*dtfm; + v[i][2] += 0.5*(f[i][2] - force_old[i][2])*dtfm; + }else{ + v[i][0] += DMDcoeff*((f[i][0] - force_old[i][0])*force->ftm2v/Gamma_MD[type[i]] + up[i][0] - up_old[i][0])/dtv; + v[i][1] += DMDcoeff*((f[i][1] - force_old[i][1])*force->ftm2v/Gamma_MD[type[i]] + up[i][1] - up_old[i][1])/dtv; + v[i][2] += DMDcoeff*((f[i][2] - force_old[i][2])*force->ftm2v/Gamma_MD[type[i]] + up[i][2] - up_old[i][2])/dtv; + } } } @@ -383,88 +383,88 @@ int FixLbPC::unpack_exchange(int nlocal, double *buf) up[i][0]=0.0; up[i][1]=0.0; up[i][2]=0.0; if(trilinear_stencil==0){ - isten=0; - for(ii=-1; ii<3; ii++){ - rsq=(-dx1+ii)*(-dx1+ii); - - if(rsq>=4) - weightx=0.0; - else{ - r=sqrt(rsq); - if(rsq>1){ - weightx=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; - } else{ - weightx=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; - } - } - for(jj=-1; jj<3; jj++){ - rsq=(-dy1+jj)*(-dy1+jj); - if(rsq>=4) - weighty=0.0; - else{ - r=sqrt(rsq); - if(rsq>1){ - weighty=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; - } else{ - weighty=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; - } - } - for(kk=-1; kk<3; kk++){ - rsq=(-dz1+kk)*(-dz1+kk); - if(rsq>=4) - weightz=0.0; - else{ - r=sqrt(rsq); - if(rsq>1){ - weightz=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; - } else{ - weightz=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; - } - } - ixp = ix+ii; - iyp = iy+jj; - izp = iz+kk; - - - if(ixp==-1) ixp=subNbx+2; - if(iyp==-1) iyp=subNby+2; - if(izp==-1) izp=subNbz+2; - - FfP[isten] = weightx*weighty*weightz; - // interpolated velocity based on delta function. - for(k=0; k<3; k++){ - up[i][k] += u_lb[ixp][iyp][izp][k]*FfP[isten]; - } - } - } - } + isten=0; + for(ii=-1; ii<3; ii++){ + rsq=(-dx1+ii)*(-dx1+ii); + + if(rsq>=4) + weightx=0.0; + else{ + r=sqrt(rsq); + if(rsq>1){ + weightx=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; + } else{ + weightx=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; + } + } + for(jj=-1; jj<3; jj++){ + rsq=(-dy1+jj)*(-dy1+jj); + if(rsq>=4) + weighty=0.0; + else{ + r=sqrt(rsq); + if(rsq>1){ + weighty=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; + } else{ + weighty=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; + } + } + for(kk=-1; kk<3; kk++){ + rsq=(-dz1+kk)*(-dz1+kk); + if(rsq>=4) + weightz=0.0; + else{ + r=sqrt(rsq); + if(rsq>1){ + weightz=(5.0-2.0*r-sqrt(-7.0+12.0*r-4.0*rsq))/8.; + } else{ + weightz=(3.0-2.0*r+sqrt(1.0+4.0*r-4.0*rsq))/8.; + } + } + ixp = ix+ii; + iyp = iy+jj; + izp = iz+kk; + + + if(ixp==-1) ixp=subNbx+2; + if(iyp==-1) iyp=subNby+2; + if(izp==-1) izp=subNbz+2; + + FfP[isten] = weightx*weighty*weightz; + // interpolated velocity based on delta function. + for(k=0; k<3; k++){ + up[i][k] += u_lb[ixp][iyp][izp][k]*FfP[isten]; + } + } + } + } }else{ - FfP[0] = (1.-dx1)*(1.-dy1)*(1.-dz1); - FfP[1] = (1.-dx1)*(1.-dy1)*dz1; - FfP[2] = (1.-dx1)*dy1*(1.-dz1); - FfP[3] = (1.-dx1)*dy1*dz1; - FfP[4] = dx1*(1.-dy1)*(1.-dz1); - FfP[5] = dx1*(1.-dy1)*dz1; - FfP[6] = dx1*dy1*(1.-dz1); - FfP[7] = dx1*dy1*dz1; - - ixp = (ix+1); - iyp = (iy+1); - izp = (iz+1); - - for (k=0; k<3; k++) { // tri-linearly interpolated velocity at node - up[i][k] = u_lb[ix][iy][iz][k]*FfP[0] - + u_lb[ix][iy][izp][k]*FfP[1] - + u_lb[ix][iyp][iz][k]*FfP[2] - + u_lb[ix][iyp][izp][k]*FfP[3] - + u_lb[ixp][iy][iz][k]*FfP[4] - + u_lb[ixp][iy][izp][k]*FfP[5] - + u_lb[ixp][iyp][iz][k]*FfP[6] - + u_lb[ixp][iyp][izp][k]*FfP[7]; - } + FfP[0] = (1.-dx1)*(1.-dy1)*(1.-dz1); + FfP[1] = (1.-dx1)*(1.-dy1)*dz1; + FfP[2] = (1.-dx1)*dy1*(1.-dz1); + FfP[3] = (1.-dx1)*dy1*dz1; + FfP[4] = dx1*(1.-dy1)*(1.-dz1); + FfP[5] = dx1*(1.-dy1)*dz1; + FfP[6] = dx1*dy1*(1.-dz1); + FfP[7] = dx1*dy1*dz1; + + ixp = (ix+1); + iyp = (iy+1); + izp = (iz+1); + + for (k=0; k<3; k++) { // tri-linearly interpolated velocity at node + up[i][k] = u_lb[ix][iy][iz][k]*FfP[0] + + u_lb[ix][iy][izp][k]*FfP[1] + + u_lb[ix][iyp][iz][k]*FfP[2] + + u_lb[ix][iyp][izp][k]*FfP[3] + + u_lb[ixp][iy][iz][k]*FfP[4] + + u_lb[ixp][iy][izp][k]*FfP[5] + + u_lb[ixp][iyp][iz][k]*FfP[6] + + u_lb[ixp][iyp][izp][k]*FfP[7]; + } } for(k=0; k<3; k++) - up[i][k] = up[i][k]*dx_lb/dt_lb; + up[i][k] = up[i][k]*dx_lb/dt_lb; } } diff --git a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp index 67f298d8df..5d32ef777d 100644 --- a/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp +++ b/src/USER-MANIFOLD/fix_nve_manifold_rattle.cpp @@ -156,7 +156,7 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg, next_output = update->ntimestep + nevery; if( comm->me == 0 ){ fprintf(screen,"Outputing every %d steps, next is %d\n", - nevery, next_output); + nevery, next_output); } argi += 2; }else if( error_on_unknown_keyword ){ diff --git a/src/USER-MISC/angle_dipole.cpp b/src/USER-MISC/angle_dipole.cpp index 990096ae7f..e393b3717b 100644 --- a/src/USER-MISC/angle_dipole.cpp +++ b/src/USER-MISC/angle_dipole.cpp @@ -101,7 +101,7 @@ void AngleDipole::compute(int eflag, int vflag) torque[iDip][0] += delTx; torque[iDip][1] += delTy; torque[iDip][2] += delTz; - + // Force couple that counterbalances dipolar torque fx = dely*delTz - delz*delTy; // direction (fi): - r x (-T) fy = delz*delTx - delx*delTz; diff --git a/src/USER-MISC/angle_fourier.cpp b/src/USER-MISC/angle_fourier.cpp index c4dbf3f08b..689caeaa5f 100644 --- a/src/USER-MISC/angle_fourier.cpp +++ b/src/USER-MISC/angle_fourier.cpp @@ -143,7 +143,7 @@ void AngleFourier::compute(int eflag, int vflag) } if (evflag) ev_tally(i1,i2,i3,nlocal,newton_bond,eangle,f1,f3, - delx1,dely1,delz1,delx2,dely2,delz2); + delx1,dely1,delz1,delx2,dely2,delz2); } } diff --git a/src/USER-MISC/angle_quartic.cpp b/src/USER-MISC/angle_quartic.cpp index f9801edb0e..5d990003a8 100644 --- a/src/USER-MISC/angle_quartic.cpp +++ b/src/USER-MISC/angle_quartic.cpp @@ -153,7 +153,7 @@ void AngleQuartic::compute(int eflag, int vflag) } if (evflag) ev_tally(i1,i2,i3,nlocal,newton_bond,eangle,f1,f3, - delx1,dely1,delz1,delx2,dely2,delz2); + delx1,dely1,delz1,delx2,dely2,delz2); } } diff --git a/src/USER-MISC/bond_harmonic_shift.cpp b/src/USER-MISC/bond_harmonic_shift.cpp index c4ee00cb27..70db2cc2bd 100644 --- a/src/USER-MISC/bond_harmonic_shift.cpp +++ b/src/USER-MISC/bond_harmonic_shift.cpp @@ -204,7 +204,7 @@ void BondHarmonicShift::write_data(FILE *fp) /* ---------------------------------------------------------------------- */ double BondHarmonicShift::single(int type, double rsq, int i, int j, - double &fforce) + double &fforce) { double r = sqrt(rsq); double dr = r - r0[type]; diff --git a/src/USER-MISC/bond_harmonic_shift_cut.cpp b/src/USER-MISC/bond_harmonic_shift_cut.cpp index 26fd32c1b5..aa0091019d 100644 --- a/src/USER-MISC/bond_harmonic_shift_cut.cpp +++ b/src/USER-MISC/bond_harmonic_shift_cut.cpp @@ -206,7 +206,7 @@ void BondHarmonicShiftCut::write_data(FILE *fp) /* ---------------------------------------------------------------------- */ double BondHarmonicShiftCut::single(int type, double rsq, int i, int j, - double &fforce) + double &fforce) { fforce = 0.0; double r = sqrt(rsq); diff --git a/src/USER-MISC/compute_ackland_atom.cpp b/src/USER-MISC/compute_ackland_atom.cpp index ac48d75bc6..285f64a5e9 100644 --- a/src/USER-MISC/compute_ackland_atom.cpp +++ b/src/USER-MISC/compute_ackland_atom.cpp @@ -256,25 +256,25 @@ void ComputeAcklandAtom::compute_peratom() +(double)chi[1]+(double)chi[2]+(double)chi[3] -9.0))/12.0; - // Identification of the local structure according to the reference + // Identification of the local structure according to the reference if (delta_bcc >= 0.1 && delta_cp >= 0.1 && delta_fcc >= 0.1 && delta_hcp >= 0.1) structure[i] = UNKNOWN; - // not part of Ackland-Jones 2006; included for backward compatibility + // not part of Ackland-Jones 2006; included for backward compatibility if (chi[4] < 3. && n1 == 12) structure[i] = ICO; else { - if (delta_bcc <= delta_cp && n1 > 10 && n1 < 13) structure[i] = BCC; - else { - if (n0 > 12) structure[i] = UNKNOWN; - else { - if (delta_fcc < delta_hcp) structure[i] = FCC; - else - structure[i] = HCP; - } - } - } + if (delta_bcc <= delta_cp && n1 > 10 && n1 < 13) structure[i] = BCC; + else { + if (n0 > 12) structure[i] = UNKNOWN; + else { + if (delta_fcc < delta_hcp) structure[i] = FCC; + else + structure[i] = HCP; + } + } + } } } else structure[i] = 0.0; } diff --git a/src/USER-MISC/compute_basal_atom.cpp b/src/USER-MISC/compute_basal_atom.cpp index 881b253131..cd393eb2ac 100644 --- a/src/USER-MISC/compute_basal_atom.cpp +++ b/src/USER-MISC/compute_basal_atom.cpp @@ -144,15 +144,15 @@ void ComputeBasalAtom::compute_peratom() // ensure distsq and nearest arrays are long enough if (jnum > maxneigh) { - memory->destroy(distsq); - memory->destroy(nearest); - memory->destroy(nearest_n0); - memory->destroy(nearest_n1); - maxneigh = jnum; - memory->create(distsq,maxneigh,"compute/basal/atom:distsq"); - memory->create(nearest,maxneigh,"compute/basal/atom:nearest"); - memory->create(nearest_n0,maxneigh,"compute/basal/atom:nearest_n0"); - memory->create(nearest_n1,maxneigh,"compute/basal/atom:nearest_n1"); + memory->destroy(distsq); + memory->destroy(nearest); + memory->destroy(nearest_n0); + memory->destroy(nearest_n1); + maxneigh = jnum; + memory->create(distsq,maxneigh,"compute/basal/atom:distsq"); + memory->create(nearest,maxneigh,"compute/basal/atom:nearest"); + memory->create(nearest_n0,maxneigh,"compute/basal/atom:nearest_n0"); + memory->create(nearest_n1,maxneigh,"compute/basal/atom:nearest_n1"); } // neighbor selection is identical to ackland/atom algorithm @@ -162,17 +162,17 @@ void ComputeBasalAtom::compute_peratom() n = 0; for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq < cutsq) { - distsq[n] = rsq; - nearest[n++] = j; - } + j = jlist[jj]; + j &= NEIGHMASK; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq < cutsq) { + distsq[n] = rsq; + nearest[n++] = j; + } } // Select 6 nearest neighbors @@ -189,7 +189,7 @@ void ComputeBasalAtom::compute_peratom() // n1 near neighbors with: distsq<1.55*r0_sq double n0_dist_sq = 1.45*r0_sq, - n1_dist_sq = 1.55*r0_sq; + n1_dist_sq = 1.55*r0_sq; int n0 = 0, n1 = 0; for (j = 0; j < n; j++) { if (distsq[j] < n1_dist_sq) { @@ -207,31 +207,31 @@ void ComputeBasalAtom::compute_peratom() double x_ij, y_ij, z_ij, x_ik, y_ik, z_ik,x3[n0],y3[n0],z3[n0], xmean5, ymean5, zmean5, xmean6, ymean6, zmean6, xmean7, ymean7, zmean7; for (j = 0; j < n0; j++) { - x_ij = x[i][0]-x[nearest_n0[j]][0]; - y_ij = x[i][1]-x[nearest_n0[j]][1]; - z_ij = x[i][2]-x[nearest_n0[j]][2]; - norm_j = sqrt (x_ij*x_ij + y_ij*y_ij + z_ij*z_ij); - if (norm_j <= 0.) {continue;} - for (k = j+1; k < n0; k++) { - x_ik = x[i][0]-x[nearest_n0[k]][0]; - y_ik = x[i][1]-x[nearest_n0[k]][1]; - z_ik = x[i][2]-x[nearest_n0[k]][2]; - norm_k = sqrt (x_ik*x_ik + y_ik*y_ik + z_ik*z_ik); - if (norm_k <= 0.) {continue;} - bond_angle = (x_ij*x_ik + y_ij*y_ik + z_ij*z_ik) / (norm_j*norm_k); - //find all bond angles that are about 180 degrees - if (-1. <= bond_angle && bond_angle < -0.945) { - x3[chi[0]] = x_ik - x_ij; - y3[chi[0]] = y_ik - y_ij; - z3[chi[0]] = z_ik - z_ij; + x_ij = x[i][0]-x[nearest_n0[j]][0]; + y_ij = x[i][1]-x[nearest_n0[j]][1]; + z_ij = x[i][2]-x[nearest_n0[j]][2]; + norm_j = sqrt (x_ij*x_ij + y_ij*y_ij + z_ij*z_ij); + if (norm_j <= 0.) {continue;} + for (k = j+1; k < n0; k++) { + x_ik = x[i][0]-x[nearest_n0[k]][0]; + y_ik = x[i][1]-x[nearest_n0[k]][1]; + z_ik = x[i][2]-x[nearest_n0[k]][2]; + norm_k = sqrt (x_ik*x_ik + y_ik*y_ik + z_ik*z_ik); + if (norm_k <= 0.) {continue;} + bond_angle = (x_ij*x_ik + y_ij*y_ik + z_ij*z_ik) / (norm_j*norm_k); + //find all bond angles that are about 180 degrees + if (-1. <= bond_angle && bond_angle < -0.945) { + x3[chi[0]] = x_ik - x_ij; + y3[chi[0]] = y_ik - y_ij; + z3[chi[0]] = z_ik - z_ij; chi[0]++; - } - } + } + } } // for atoms that have 2 or 3 ~180 bond angles: if (2 == chi[0] || 3 == chi[0]) { count = value = 0; - if (chi[0] == 2) { + if (chi[0] == 2) { k2[0] = 0; j1[0] = 1; } @@ -244,13 +244,13 @@ void ComputeBasalAtom::compute_peratom() j1[2]=2; } xmean5 = ymean5 = zmean5 = xmean6 = ymean6 = zmean6 = xmean7 = ymean7 = zmean7 = 0.0; - for (j = 0; j < chi[0]; j++) { + for (j = 0; j < chi[0]; j++) { for (k = j+1; k < chi[0]; k++) { - //get cross products + //get cross products x4[count] = y3[j1[count]]*z3[k2[count]]-y3[k2[count]]*z3[j1[count]]; y4[count] = z3[j1[count]]*x3[k2[count]]-z3[k2[count]]*x3[j1[count]]; z4[count] = x3[j1[count]]*y3[k2[count]]-x3[k2[count]]*y3[j1[count]]; - //get all sign combinations of cross products + //get all sign combinations of cross products x5[count] = x4[count]*copysign(1.0,x4[count]); y5[count] = y4[count]*copysign(1.0,x4[count]); z5[count] = z4[count]*copysign(1.0,x4[count]); @@ -260,7 +260,7 @@ void ComputeBasalAtom::compute_peratom() x7[count] = x4[count]*copysign(1.0,z4[count]); y7[count] = y4[count]*copysign(1.0,z4[count]); z7[count] = z4[count]*copysign(1.0,z4[count]); - //get average cross products + //get average cross products xmean5 += x5[count]; ymean5 += y5[count]; zmean5 += z5[count]; @@ -285,7 +285,7 @@ void ComputeBasalAtom::compute_peratom() zmean7 /= count; } var5 = var6 = var7 = 0.0; - //find standard deviations + //find standard deviations for (j=0;j<count;j++){ var5 = var5 + x5[j]*x5[j]-2*x5[j]*xmean5+xmean5*xmean5+y5[j]*y5[j]-2*y5[j]*ymean5+ymean5*ymean5+z5[j]*z5[j]-2*z5[j]*zmean5+zmean5*zmean5; var6 = var6 + x6[j]*x6[j]-2*x6[j]*xmean6+xmean6*xmean6+y6[j]*y6[j]-2*y6[j]*ymean6+ymean6*ymean6+z6[j]*z6[j]-2*z6[j]*zmean6+zmean6*zmean6; @@ -298,7 +298,7 @@ void ComputeBasalAtom::compute_peratom() } else if (var6 < var7) {value = 1;} else {value = 2;} - //BPV is average of cross products of all neighbor vectors which are part of 180 degree angles + //BPV is average of cross products of all neighbor vectors which are part of 180 degree angles BPV[i][0] = 0; BPV[i][1] = 0; BPV[i][2] = 0; @@ -332,12 +332,12 @@ void ComputeBasalAtom::compute_peratom() j1[0]=1; j1[1]=2; j1[2]=2; - //algorithm is as above, but now all combinations of three 180 degree angles are compared, and the combination with minimum standard deviation is chosen + //algorithm is as above, but now all combinations of three 180 degree angles are compared, and the combination with minimum standard deviation is chosen for (j=0; j<chi[0]; j++) { for (k=j+1; k<chi[0]; k++) { for (l=k+1; l<chi[0]; l++) { if (k >= chi[0] || l >= chi[0]) continue; - //get unique combination of three neighbor vectors + //get unique combination of three neighbor vectors x4[0] = x3[j]; x4[1] = x3[k]; x4[2] = x3[l]; @@ -349,7 +349,7 @@ void ComputeBasalAtom::compute_peratom() z4[2] = z3[l]; xmean5 = ymean5 = zmean5 = xmean6 = ymean6 = zmean6 = xmean7 = ymean7 = zmean7 = 0; for (m=0;m<3;m++) { - //get cross products + //get cross products x44[m] = y4[j1[m]]*z4[k2[m]]-y4[k2[m]]*z4[j1[m]]; y44[m] = z4[j1[m]]*x4[k2[m]]-z4[k2[m]]*x4[j1[m]]; z44[m] = x4[j1[m]]*y4[k2[m]]-x4[k2[m]]*y4[j1[m]]; @@ -362,7 +362,7 @@ void ComputeBasalAtom::compute_peratom() x7[m] = x44[m]*copysign(1.0,z44[m]); y7[m] = y44[m]*copysign(1.0,z44[m]); z7[m] = z44[m]*copysign(1.0,z44[m]); - //get average cross products + //get average cross products xmean5 = xmean5 + x5[m]; ymean5 = ymean5 + y5[m]; zmean5 = zmean5 + z5[m]; @@ -383,13 +383,13 @@ void ComputeBasalAtom::compute_peratom() zmean6 = zmean6/3; zmean7 = zmean7/3; var5 = var6 = var7 = 0; - //get standard deviations + //get standard deviations for (m=0;m<3;m++){ var5 = var5 + x5[m]*x5[m]-2*x5[m]*xmean5+xmean5*xmean5+y5[m]*y5[m]-2*y5[m]*ymean5+ymean5*ymean5+z5[m]*z5[m]-2*z5[m]*zmean5+zmean5*zmean5; var6 = var6 + x6[m]*x6[m]-2*x6[m]*xmean6+xmean6*xmean6+y6[m]*y6[m]-2*y6[m]*ymean6+ymean6*ymean6+z6[m]*z6[m]-2*z6[m]*zmean6+zmean6*zmean6; var7 = var7 + x7[m]*x7[m]-2*x7[m]*xmean7+xmean7*xmean7+y7[m]*y7[m]-2*y7[m]*ymean7+ymean7*ymean7+z7[m]*z7[m]-2*z7[m]*zmean7+zmean7*zmean7; } - //choose minimum standard deviation + //choose minimum standard deviation if (var5 < S0) { S0 = var5; BPV[i][0] = (x5[0]+x5[1]+x5[2])/3; @@ -446,29 +446,29 @@ void ComputeBasalAtom::select(int k, int n, double *arr) for (;;) { if (ir <= l+1) { if (ir == l+1 && arr[ir] < arr[l]) { - SWAP(arr[l],arr[ir]) + SWAP(arr[l],arr[ir]) } return; } else { mid=(l+ir) >> 1; SWAP(arr[mid],arr[l+1]) if (arr[l] > arr[ir]) { - SWAP(arr[l],arr[ir]) + SWAP(arr[l],arr[ir]) } if (arr[l+1] > arr[ir]) { - SWAP(arr[l+1],arr[ir]) + SWAP(arr[l+1],arr[ir]) } if (arr[l] > arr[l+1]) { - SWAP(arr[l],arr[l+1]) + SWAP(arr[l],arr[l+1]) } i = l+1; j = ir; a = arr[l+1]; for (;;) { - do i++; while (arr[i] < a); - do j--; while (arr[j] > a); - if (j < i) break; - SWAP(arr[i],arr[j]) + do i++; while (arr[i] < a); + do j--; while (arr[j] > a); + if (j < i) break; + SWAP(arr[i],arr[j]) } arr[l+1] = arr[j]; arr[j] = a; @@ -492,8 +492,8 @@ void ComputeBasalAtom::select2(int k, int n, double *arr, int *iarr) for (;;) { if (ir <= l+1) { if (ir == l+1 && arr[ir] < arr[l]) { - SWAP(arr[l],arr[ir]) - ISWAP(iarr[l],iarr[ir]) + SWAP(arr[l],arr[ir]) + ISWAP(iarr[l],iarr[ir]) } return; } else { @@ -501,27 +501,27 @@ void ComputeBasalAtom::select2(int k, int n, double *arr, int *iarr) SWAP(arr[mid],arr[l+1]) ISWAP(iarr[mid],iarr[l+1]) if (arr[l] > arr[ir]) { - SWAP(arr[l],arr[ir]) - ISWAP(iarr[l],iarr[ir]) + SWAP(arr[l],arr[ir]) + ISWAP(iarr[l],iarr[ir]) } if (arr[l+1] > arr[ir]) { - SWAP(arr[l+1],arr[ir]) - ISWAP(iarr[l+1],iarr[ir]) + SWAP(arr[l+1],arr[ir]) + ISWAP(iarr[l+1],iarr[ir]) } if (arr[l] > arr[l+1]) { - SWAP(arr[l],arr[l+1]) - ISWAP(iarr[l],iarr[l+1]) + SWAP(arr[l],arr[l+1]) + ISWAP(iarr[l],iarr[l+1]) } i = l+1; j = ir; a = arr[l+1]; ia = iarr[l+1]; for (;;) { - do i++; while (arr[i] < a); - do j--; while (arr[j] > a); - if (j < i) break; - SWAP(arr[i],arr[j]) - ISWAP(iarr[i],iarr[j]) + do i++; while (arr[i] < a); + do j--; while (arr[j] > a); + if (j < i) break; + SWAP(arr[i],arr[j]) + ISWAP(iarr[i],iarr[j]) } arr[l+1] = arr[j]; arr[j] = a; diff --git a/src/USER-MISC/compute_pressure_grem.cpp b/src/USER-MISC/compute_pressure_grem.cpp index 984ac9894e..ae9179cc43 100644 --- a/src/USER-MISC/compute_pressure_grem.cpp +++ b/src/USER-MISC/compute_pressure_grem.cpp @@ -116,7 +116,7 @@ void ComputePressureGrem::compute_vector() if (force->kspace && kspace_virial && force->kspace->scalar_pressure_flag) error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' for " - "tensor components with kspace_style msm"); + "tensor components with kspace_style msm"); // invoke temperature if it hasn't been already diff --git a/src/USER-MISC/dihedral_quadratic.cpp b/src/USER-MISC/dihedral_quadratic.cpp index ac261153b4..6841492b2f 100644 --- a/src/USER-MISC/dihedral_quadratic.cpp +++ b/src/USER-MISC/dihedral_quadratic.cpp @@ -161,21 +161,21 @@ void DihedralQuadratic::compute(int eflag, int vflag) int me; MPI_Comm_rank(world,&me); if (screen) { - char str[128]; + char str[128]; sprintf(str,"Dihedral problem: %d " BIGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT, me,update->ntimestep, - atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); - error->warning(FLERR,str,0); - fprintf(screen," 1st atom: %d %g %g %g\n", - me,x[i1][0],x[i1][1],x[i1][2]); - fprintf(screen," 2nd atom: %d %g %g %g\n", - me,x[i2][0],x[i2][1],x[i2][2]); - fprintf(screen," 3rd atom: %d %g %g %g\n", - me,x[i3][0],x[i3][1],x[i3][2]); - fprintf(screen," 4th atom: %d %g %g %g\n", - me,x[i4][0],x[i4][1],x[i4][2]); + atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]); + error->warning(FLERR,str,0); + fprintf(screen," 1st atom: %d %g %g %g\n", + me,x[i1][0],x[i1][1],x[i1][2]); + fprintf(screen," 2nd atom: %d %g %g %g\n", + me,x[i2][0],x[i2][1],x[i2][2]); + fprintf(screen," 3rd atom: %d %g %g %g\n", + me,x[i3][0],x[i3][1],x[i3][2]); + fprintf(screen," 4th atom: %d %g %g %g\n", + me,x[i4][0],x[i4][1],x[i4][2]); } } @@ -257,7 +257,7 @@ void DihedralQuadratic::compute(int eflag, int vflag) if (evflag) ev_tally(i1,i2,i3,i4,nlocal,newton_bond,edihedral,f1,f3,f4, - vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z); + vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z); } } diff --git a/src/USER-MISC/dihedral_spherical.h b/src/USER-MISC/dihedral_spherical.h index a21c322083..0067e5eca8 100644 --- a/src/USER-MISC/dihedral_spherical.h +++ b/src/USER-MISC/dihedral_spherical.h @@ -31,7 +31,7 @@ class DihedralSpherical : public Dihedral { virtual ~DihedralSpherical(); virtual void compute(int, int); double CalcGeneralizedForces(int, double, double, double, - double*, double*, double*); + double*, double*, double*); void coeff(int, char **); void write_restart(FILE *); void read_restart(FILE *); diff --git a/src/USER-MISC/fix_filter_corotate.h b/src/USER-MISC/fix_filter_corotate.h index 67e3fb4f01..7693feb94c 100644 --- a/src/USER-MISC/fix_filter_corotate.h +++ b/src/USER-MISC/fix_filter_corotate.h @@ -36,7 +36,7 @@ namespace LAMMPS_NS FixFilterCorotate(class LAMMPS *, int, char **); ~FixFilterCorotate(); - void setup(int); + void setup(int); void setup_pre_neighbor(); void pre_neighbor(); void setup_pre_force_respa(int,int); diff --git a/src/USER-MISC/fix_flow_gauss.cpp b/src/USER-MISC/fix_flow_gauss.cpp index 6817170013..435e3972c8 100644 --- a/src/USER-MISC/fix_flow_gauss.cpp +++ b/src/USER-MISC/fix_flow_gauss.cpp @@ -179,8 +179,8 @@ void FixFlowGauss::post_force(int vflag) for(ii=0; ii<nlocal; ii++) if (mask[ii] & groupbit) for (jj=0; jj<3; jj++) - if (flow[jj]) - f_thisProc[jj] += f[ii][jj]; + if (flow[jj]) + f_thisProc[jj] += f[ii][jj]; //add the processor sums together MPI_Allreduce(f_thisProc, f_tot, 3, MPI_DOUBLE, MPI_SUM, world); @@ -210,7 +210,7 @@ void FixFlowGauss::post_force(int vflag) //calculate added energy, since more costly, only do this if requested if (workflag) - peAdded += f_app[0]*v[ii][0] + f_app[1]*v[ii][1] + f_app[2]*v[ii][2]; + peAdded += f_app[0]*v[ii][0] + f_app[1]*v[ii][1] + f_app[2]*v[ii][2]; } //finish calculation of work done, sum over all procs diff --git a/src/USER-MISC/fix_gle.cpp b/src/USER-MISC/fix_gle.cpp index 40d1047648..ecb3390e5e 100644 --- a/src/USER-MISC/fix_gle.cpp +++ b/src/USER-MISC/fix_gle.cpp @@ -85,10 +85,10 @@ void StabCholesky(int n, const double* MMt, double* M) for(i=0; i<n; ++i) { #ifdef GLE_DEBUG - if (D[i]<0) fprintf(stderr,"GLE Cholesky: Negative diagonal term %le, has been set to zero.\n", D[i]); + if (D[i]<0) fprintf(stderr,"GLE Cholesky: Negative diagonal term %le, has been set to zero.\n", D[i]); #endif - D[i]=(D[i]>0.?sqrt(D[i]):0.); - } + D[i]=(D[i]>0.?sqrt(D[i]):0.); + } for(i=0; i<n; ++i) for (j=0; j<n; j++) M[midx(n,i,j)]=L[midx(n,i,j)]*D[j]; } diff --git a/src/USER-MISC/fix_ipi.cpp b/src/USER-MISC/fix_ipi.cpp index 2715746139..8326ef6667 100644 --- a/src/USER-MISC/fix_ipi.cpp +++ b/src/USER-MISC/fix_ipi.cpp @@ -252,7 +252,7 @@ void FixIPI::init() { //only opens socket on master process if (master) { - if (!socketflag) open_socket(ipisock, inet, port, host, error); + if (!socketflag) open_socket(ipisock, inet, port, host, error); } else ipisock=0; //! should check for success in socket opening -- but the current open_socket routine dies brutally if unsuccessful // tell lammps we have assigned a socket diff --git a/src/USER-MISC/fix_pimd.cpp b/src/USER-MISC/fix_pimd.cpp index bba6b2e2be..2c89ddda57 100644 --- a/src/USER-MISC/fix_pimd.cpp +++ b/src/USER-MISC/fix_pimd.cpp @@ -397,7 +397,7 @@ void FixPIMD::nhc_update_v() expfac = exp(-dt8 * eta_dot[ichain+1]); eta_dot[ichain] *= expfac; eta_dotdot[ichain] = (nhc_eta_mass[i][ichain-1] * eta_dot[ichain-1] * eta_dot[ichain-1] - - KT) / nhc_eta_mass[i][ichain]; + - KT) / nhc_eta_mass[i][ichain]; eta_dot[ichain] += eta_dotdot[ichain] * dt4; eta_dot[ichain] *= expfac; } diff --git a/src/USER-MISC/pair_edip_multi.cpp b/src/USER-MISC/pair_edip_multi.cpp index 3345549ae3..bcef1b013b 100644 --- a/src/USER-MISC/pair_edip_multi.cpp +++ b/src/USER-MISC/pair_edip_multi.cpp @@ -168,12 +168,12 @@ void PairEDIPMulti::compute(int eflag, int vflag) r_ij = sqrt(r_ij); - // zeta and its derivative dZ/dr + // zeta and its derivative dZ/dr if (r_ij < params[ijparam].cutoffC) zeta_i += 1.0; else { - double f, fdr; - edip_fc(r_ij, ¶ms[ijparam], f, fdr); + double f, fdr; + edip_fc(r_ij, ¶ms[ijparam], f, fdr); zeta_i += f; dzetair = -fdr / r_ij; @@ -248,24 +248,24 @@ void PairEDIPMulti::compute(int eflag, int vflag) r_ik = sqrt(r_ik); - costheta=vec3_dot(dr_ij, dr_ik) / r_ij / r_ik; + costheta=vec3_dot(dr_ij, dr_ik) / r_ij / r_ik; - double v1, v2, v3, v4, v5, v6, v7; + double v1, v2, v3, v4, v5, v6, v7; - edip_fcut3(r_ij, ¶ms[ijparam], v1, v2); - edip_fcut3(r_ik, ¶ms[ikparam], v3, v4); - edip_h(costheta, zeta_i, ¶ms[ijkparam], v5, v6, v7); + edip_fcut3(r_ij, ¶ms[ijparam], v1, v2); + edip_fcut3(r_ik, ¶ms[ikparam], v3, v4); + edip_h(costheta, zeta_i, ¶ms[ijkparam], v5, v6, v7); - // potential energy and forces - evdwl = v1 * v3 * v5; - dtripleZ += v1 * v3 * v7; + // potential energy and forces + evdwl = v1 * v3 * v5; + dtripleZ += v1 * v3 * v7; - double dri[3], drj[3], drk[3]; + double dri[3], drj[3], drk[3]; double dhl, dfr; dhl = v1 * v3 * v6; - costheta_d(dr_ij, r_ij, dr_ik, r_ik, dri, drj, drk); + costheta_d(dr_ij, r_ij, dr_ik, r_ik, dri, drj, drk); f_ij[0] = -dhl * drj[0]; f_ij[1] = -dhl * drj[1]; @@ -315,7 +315,7 @@ void PairEDIPMulti::compute(int eflag, int vflag) delz = preForceCoord[preForceCoord_counter+3]; j = static_cast<int> (preForceCoord[preForceCoord_counter+4]); - dzetair *= (dpairZ + dtripleZ); + dzetair *= (dpairZ + dtripleZ); f[j][0] += dzetair * delx; f[j][1] += dzetair * dely; @@ -586,8 +586,8 @@ void PairEDIPMulti::coeff(int narg, char **arg) for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - count++; + setflag[i][j] = 1; + count++; } if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); @@ -661,8 +661,8 @@ void PairEDIPMulti::read_file(char *file) if (comm->me == 0) { ptr = fgets(line,MAXLINE,fp); if (ptr == NULL) { - eof = 1; - fclose(fp); + eof = 1; + fclose(fp); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -683,8 +683,8 @@ void PairEDIPMulti::read_file(char *file) if (comm->me == 0) { ptr = fgets(&line[n],MAXLINE-n,fp); if (ptr == NULL) { - eof = 1; - fclose(fp); + eof = 1; + fclose(fp); } else n = strlen(line) + 1; } MPI_Bcast(&eof,1,MPI_INT,0,world); @@ -723,7 +723,7 @@ void PairEDIPMulti::read_file(char *file) if (nparams == maxparam) { maxparam += DELTA; params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); + "pair:params"); } params[nparams].ielement = ielement; @@ -748,11 +748,11 @@ void PairEDIPMulti::read_file(char *file) params[nparams].u4 = atof(words[19]); if (params[nparams].A < 0.0 || params[nparams].B < 0.0 || - params[nparams].cutoffA < 0.0 || params[nparams].cutoffC < 0.0 || - params[nparams].alpha < 0.0 || params[nparams].beta < 0.0 || - params[nparams].eta < 0.0 || params[nparams].gamma < 0.0 || - params[nparams].lambda < 0.0 || params[nparams].mu < 0.0 || - params[nparams].rho < 0.0 || params[nparams].sigma < 0.0) + params[nparams].cutoffA < 0.0 || params[nparams].cutoffC < 0.0 || + params[nparams].alpha < 0.0 || params[nparams].beta < 0.0 || + params[nparams].eta < 0.0 || params[nparams].gamma < 0.0 || + params[nparams].lambda < 0.0 || params[nparams].mu < 0.0 || + params[nparams].rho < 0.0 || params[nparams].sigma < 0.0) error->all(FLERR,"Illegal EDIP parameter"); nparams++; @@ -778,16 +778,16 @@ void PairEDIPMulti::setup() for (i = 0; i < nelements; i++) for (j = 0; j < nelements; j++) for (k = 0; k < nelements; k++) { - n = -1; - for (m = 0; m < nparams; m++) { - if (i == params[m].ielement && j == params[m].jelement && - k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); - n = m; - } - } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); - elem2param[i][j][k] = n; + n = -1; + for (m = 0; m < nparams; m++) { + if (i == params[m].ielement && j == params[m].jelement && + k == params[m].kelement) { + if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + n = m; + } + } + if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + elem2param[i][j][k] = n; } // set cutoff square diff --git a/src/USER-MISC/pair_edip_multi.h b/src/USER-MISC/pair_edip_multi.h index fd94594d93..26433a66fa 100644 --- a/src/USER-MISC/pair_edip_multi.h +++ b/src/USER-MISC/pair_edip_multi.h @@ -95,7 +95,7 @@ class PairEDIPMulti : public Pair { //dr_ij=r_j - r_i //dr_ik=r_k - r_i void costheta_d(double *dr_ij, double r_ij, double *dr_ik, double r_ik, - double *dri, double *drj, double *drk) + double *dri, double *drj, double *drk) { double costheta; diff --git a/src/USER-MISC/pair_gauss_cut.cpp b/src/USER-MISC/pair_gauss_cut.cpp index 4408545c34..c1daf9c923 100644 --- a/src/USER-MISC/pair_gauss_cut.cpp +++ b/src/USER-MISC/pair_gauss_cut.cpp @@ -226,7 +226,7 @@ double PairGaussCut::init_one(int i, int j) { if (setflag[i][j] == 0) { hgauss[i][j] = mix_energy(fabs(hgauss[i][i]), fabs(hgauss[j][j]), - fabs(sigmah[i][i]), fabs(sigmah[j][j])); + fabs(sigmah[i][i]), fabs(sigmah[j][j])); // If either of the particles is repulsive (ie, if hgauss > 0), // then the interaction between both is repulsive. diff --git a/src/USER-MISC/pair_lj_sf_dipole_sf.cpp b/src/USER-MISC/pair_lj_sf_dipole_sf.cpp index fb63638b52..ab342fd055 100644 --- a/src/USER-MISC/pair_lj_sf_dipole_sf.cpp +++ b/src/USER-MISC/pair_lj_sf_dipole_sf.cpp @@ -535,8 +535,8 @@ void PairLJSFDipoleSF::read_restart_settings(FILE *fp) // PairLJSFDipoleSF: calculation of force is missing (to be implemented) double PairLJSFDipoleSF::single(int i, int j, int itype, int jtype, double rsq, - double factor_coul, double factor_lj, - double &fforce) + double factor_coul, double factor_lj, + double &fforce) { double r2inv,r6inv; double pdotp,pidotr,pjdotr,pre1,delx,dely,delz; @@ -580,7 +580,7 @@ double PairLJSFDipoleSF::single(int i, int j, int itype, int jtype, double rsq, pidotr = mu[i][0]*delx + mu[i][1]*dely + mu[i][2]*delz; pjdotr = mu[j][0]*delx + mu[j][1]*dely + mu[j][2]*delz; bfac = 1.0 - 4.0*rsq*sqrt(rsq)*rcutcoul2inv*sqrt(rcutcoul2inv) + - 3.0*rsq*rsq*rcutcoul2inv*rcutcoul2inv; + 3.0*rsq*rsq*rcutcoul2inv*rcutcoul2inv; } if (mu[i][3] > 0.0 && q[j] != 0.0) { r3inv = r2inv*rinv; @@ -588,7 +588,7 @@ double PairLJSFDipoleSF::single(int i, int j, int itype, int jtype, double rsq, pidotr = mu[i][0]*delx + mu[i][1]*dely + mu[i][2]*delz; rcutcoul2inv=1.0/cut_coulsq[itype][jtype]; pqfac = 1.0 - 3.0*rsq*rcutcoul2inv + - 2.0*rsq*sqrt(rsq)*rcutcoul2inv*sqrt(rcutcoul2inv); + 2.0*rsq*sqrt(rsq)*rcutcoul2inv*sqrt(rcutcoul2inv); } if (mu[j][3] > 0.0 && qtmp != 0.0) { r3inv = r2inv*rinv; @@ -596,7 +596,7 @@ double PairLJSFDipoleSF::single(int i, int j, int itype, int jtype, double rsq, pjdotr = mu[j][0]*delx + mu[j][1]*dely + mu[j][2]*delz; rcutcoul2inv=1.0/cut_coulsq[itype][jtype]; qpfac = 1.0 - 3.0*rsq*rcutcoul2inv + - 2.0*rsq*sqrt(rsq)*rcutcoul2inv*sqrt(rcutcoul2inv); + 2.0*rsq*sqrt(rsq)*rcutcoul2inv*sqrt(rcutcoul2inv); } } if (rsq < cut_ljsq[itype][jtype]) { diff --git a/src/USER-MISC/pair_meam_spline.cpp b/src/USER-MISC/pair_meam_spline.cpp index 0148ed51cb..10659e8654 100644 --- a/src/USER-MISC/pair_meam_spline.cpp +++ b/src/USER-MISC/pair_meam_spline.cpp @@ -600,7 +600,7 @@ double PairMEAMSpline::init_one(int i, int j) /* ---------------------------------------------------------------------- */ int PairMEAMSpline::pack_forward_comm(int n, int *list, double *buf, - int pbc_flag, int *pbc) + int pbc_flag, int *pbc) { int* list_iter = list; int* list_iter_end = list + n; @@ -640,7 +640,7 @@ double PairMEAMSpline::memory_usage() /// Parses the spline knots from a text file. void PairMEAMSpline::SplineFunction::parse(FILE* fp, Error* error, - bool isNewFormat) + bool isNewFormat) { char line[MAXLINE]; @@ -756,7 +756,7 @@ void PairMEAMSpline::SplineFunction::communicate(MPI_Comm& world, int me) /// /// This function is for debugging only! void PairMEAMSpline::SplineFunction::writeGnuplot(const char* filename, - const char* title) const + const char* title) const { FILE* fp = fopen(filename, "w"); fprintf(fp, "#!/usr/bin/env gnuplot\n"); diff --git a/src/USER-MISC/pair_meam_spline.h b/src/USER-MISC/pair_meam_spline.h index d3554f056e..7b5ff3bf6d 100644 --- a/src/USER-MISC/pair_meam_spline.h +++ b/src/USER-MISC/pair_meam_spline.h @@ -139,7 +139,7 @@ protected: double a = (Xs[khi] - x)/h; double b = 1.0 - a; // = (x - X[klo])/h return a * Y[klo] + b * Y[khi] + - ((a*a*a - a) * Y2[klo] + (b*b*b - b) * Y2[khi])*(h*h)/6.0; + ((a*a*a - a) * Y2[klo] + (b*b*b - b) * Y2[khi])*(h*h)/6.0; #else // For a spline with regular grid, we directly calculate the interval X is in. int klo = (int)(x / h); @@ -147,7 +147,7 @@ protected: double a = Xs[khi] - x; double b = h - a; return Y[khi] - a * Ydelta[klo] + - ((a*a - hsq) * a * Y2[klo] + (b*b - hsq) * b * Y2[khi]); + ((a*a - hsq) * a * Y2[klo] + (b*b - hsq) * b * Y2[khi]); #endif } } @@ -179,11 +179,11 @@ protected: double a = (Xs[khi] - x)/h; double b = 1.0 - a; // = (x - X[klo])/h deriv = (Y[khi] - Y[klo]) / h + - ((3.0*b*b - 1.0) * Y2[khi] - - (3.0*a*a - 1.0) * Y2[klo]) * h / 6.0; + ((3.0*b*b - 1.0) * Y2[khi] - + (3.0*a*a - 1.0) * Y2[klo]) * h / 6.0; return a * Y[klo] + b * Y[khi] + - ((a*a*a - a) * Y2[klo] + - (b*b*b - b) * Y2[khi]) * (h*h) / 6.0; + ((a*a*a - a) * Y2[klo] + + (b*b*b - b) * Y2[khi]) * (h*h) / 6.0; #else // For a spline with regular grid, we directly calculate the interval X is in. int klo = (int)(x / h); @@ -191,9 +191,9 @@ protected: double a = Xs[khi] - x; double b = h - a; deriv = Ydelta[klo] + ((3.0*b*b - hsq) * Y2[khi] - - (3.0*a*a - hsq) * Y2[klo]); + - (3.0*a*a - hsq) * Y2[klo]); return Y[khi] - a * Ydelta[klo] + - ((a*a - hsq) * a * Y2[klo] + (b*b - hsq) * b * Y2[khi]); + ((a*a - hsq) * a * Y2[klo] + (b*b - hsq) * b * Y2[khi]); #endif } } diff --git a/src/USER-MISC/pair_momb.cpp b/src/USER-MISC/pair_momb.cpp index 0d8d2e060e..98339bf60a 100644 --- a/src/USER-MISC/pair_momb.cpp +++ b/src/USER-MISC/pair_momb.cpp @@ -366,8 +366,8 @@ void PairMomb::read_restart_settings(FILE *fp) /* ---------------------------------------------------------------------- */ double PairMomb::single(int i, int j, int itype, int jtype, double rsq, - double factor_coul, double factor_lj, - double &fforce) + double factor_coul, double factor_lj, + double &fforce) { double r,dr,dexp,phi,r2inv,r6inv,ddexp,invexp; diff --git a/src/USER-MISC/temper_npt.cpp b/src/USER-MISC/temper_npt.cpp index 60f9313fdd..66ab92a43b 100644 --- a/src/USER-MISC/temper_npt.cpp +++ b/src/USER-MISC/temper_npt.cpp @@ -264,16 +264,16 @@ void TemperNPT::command(int narg, char **arg) if (partner != -1) { if (me_universe > partner) { MPI_Send(&pe,1,MPI_DOUBLE,partner,0,universe->uworld); - } + } else { - MPI_Recv(&pe_partner,1,MPI_DOUBLE,partner,0,universe->uworld,MPI_STATUS_IGNORE); - } + MPI_Recv(&pe_partner,1,MPI_DOUBLE,partner,0,universe->uworld,MPI_STATUS_IGNORE); + } if (me_universe > partner) { - MPI_Send(&vol,1, MPI_DOUBLE,partner,0,universe->uworld); - } + MPI_Send(&vol,1, MPI_DOUBLE,partner,0,universe->uworld); + } else { - MPI_Recv(&vol_partner,1,MPI_DOUBLE,partner,0,universe->uworld,MPI_STATUS_IGNORE); - } + MPI_Recv(&vol_partner,1,MPI_DOUBLE,partner,0,universe->uworld,MPI_STATUS_IGNORE); + } // Acceptance criteria changed for NPT ensemble if (me_universe < partner) { press_units = press_set/nktv2p; diff --git a/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp b/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp index 415348cbec..baa42a4bc0 100644 --- a/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp +++ b/src/USER-MOFFF/pair_buck6d_coul_gauss_dsf.cpp @@ -400,7 +400,7 @@ void PairBuck6dCoulGaussDSF::write_restart(FILE *fp) fwrite(&buck6d4[i][j],sizeof(double),1,fp); fwrite(&alpha_ij[i][j],sizeof(double),1,fp); fwrite(&cut_lj[i][j],sizeof(double),1,fp); - } + } } } diff --git a/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp b/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp index 46ef91f0b1..36018613a2 100644 --- a/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp +++ b/src/USER-MOFFF/pair_buck6d_coul_gauss_long.cpp @@ -433,7 +433,7 @@ void PairBuck6dCoulGaussLong::write_restart(FILE *fp) fwrite(&buck6d4[i][j],sizeof(double),1,fp); fwrite(&alpha_ij[i][j],sizeof(double),1,fp); fwrite(&cut_lj[i][j],sizeof(double),1,fp); - } + } } } diff --git a/src/USER-OMP/angle_dipole_omp.cpp b/src/USER-OMP/angle_dipole_omp.cpp index f582ce4c41..2fa6fff0ef 100644 --- a/src/USER-OMP/angle_dipole_omp.cpp +++ b/src/USER-OMP/angle_dipole_omp.cpp @@ -126,7 +126,7 @@ void AngleDipoleOMP::eval(int nfrom, int nto, ThrData * const thr) torque[iDip][0] += delTx; torque[iDip][1] += delTy; torque[iDip][2] += delTz; - + // Force couple that counterbalances dipolar torque fx = dely*delTz - delz*delTy; // direction (fi): - r x (-T) fy = delz*delTx - delx*delTz; diff --git a/src/USER-OMP/fix_omp.cpp b/src/USER-OMP/fix_omp.cpp index b3fe2c29e8..2a3717da0d 100644 --- a/src/USER-OMP/fix_omp.cpp +++ b/src/USER-OMP/fix_omp.cpp @@ -110,13 +110,13 @@ FixOMP::FixOMP(LAMMPS *lmp, int narg, char **arg) if (screen) { if (reset_thr) - fprintf(screen,"set %d OpenMP thread(s) per MPI task\n", nthreads); + fprintf(screen,"set %d OpenMP thread(s) per MPI task\n", nthreads); fprintf(screen,"using %s neighbor list subroutines\n", nmode); } if (logfile) { if (reset_thr) - fprintf(logfile,"set %d OpenMP thread(s) per MPI task\n", nthreads); + fprintf(logfile,"set %d OpenMP thread(s) per MPI task\n", nthreads); fprintf(logfile,"using %s neighbor list subroutines\n", nmode); } #else @@ -226,29 +226,29 @@ void FixOMP::init() // determine which is the last force style with OpenMP // support as this is the one that has to reduce the forces -#define CheckStyleForOMP(name) \ - check_hybrid = 0; \ - if (force->name) { \ - if ( (strcmp(force->name ## _style,"hybrid") == 0) || \ - (strcmp(force->name ## _style,"hybrid/overlay") == 0) ) \ - check_hybrid=1; \ - if (force->name->suffix_flag & Suffix::OMP) { \ - last_force_name = (const char *) #name; \ - last_omp_name = force->name ## _style; \ - last_omp_style = (void *) force->name; \ - } \ +#define CheckStyleForOMP(name) \ + check_hybrid = 0; \ + if (force->name) { \ + if ( (strcmp(force->name ## _style,"hybrid") == 0) || \ + (strcmp(force->name ## _style,"hybrid/overlay") == 0) ) \ + check_hybrid=1; \ + if (force->name->suffix_flag & Suffix::OMP) { \ + last_force_name = (const char *) #name; \ + last_omp_name = force->name ## _style; \ + last_omp_style = (void *) force->name; \ + } \ } #define CheckHybridForOMP(name,Class) \ - if (check_hybrid) { \ + if (check_hybrid) { \ Class ## Hybrid *style = (Class ## Hybrid *) force->name; \ - for (int i=0; i < style->nstyles; i++) { \ + for (int i=0; i < style->nstyles; i++) { \ if (style->styles[i]->suffix_flag & Suffix::OMP) { \ - last_force_name = (const char *) #name; \ - last_omp_name = style->keywords[i]; \ - last_omp_style = style->styles[i]; \ - } \ - } \ + last_force_name = (const char *) #name; \ + last_omp_name = style->keywords[i]; \ + last_omp_style = style->styles[i]; \ + } \ + } \ } if (kspace_split <= 0) { diff --git a/src/USER-OMP/fix_rigid_nh_omp.cpp b/src/USER-OMP/fix_rigid_nh_omp.cpp index f2d6d8513b..9341f83079 100644 --- a/src/USER-OMP/fix_rigid_nh_omp.cpp +++ b/src/USER-OMP/fix_rigid_nh_omp.cpp @@ -42,8 +42,8 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -enum{SINGLE,MOLECULE,GROUP}; // same as in FixRigid -enum{ISO,ANISO,TRICLINIC}; // same as in FixRigid +enum{SINGLE,MOLECULE,GROUP}; // same as in FixRigid +enum{ISO,ANISO,TRICLINIC}; // same as in FixRigid #define EINERTIA 0.4 // moment of inertia prefactor for ellipsoid @@ -294,9 +294,9 @@ void FixRigidNHOMP::final_integrate() s5 += dx*f[i].y - dy*f[i].x; if (extended && (eflags[i] & TORQUE)) { - s3 += torque_one[i][0]; - s4 += torque_one[i][1]; - s5 += torque_one[i][2]; + s3 += torque_one[i][0]; + s4 += torque_one[i][1]; + s5 += torque_one[i][2]; } } sum[0][0]=s0; sum[0][1]=s1; sum[0][2]=s2; @@ -315,28 +315,28 @@ void FixRigidNHOMP::final_integrate() #pragma omp parallel for default(none) private(i) shared(ib) reduction(+:s0,s1,s2,s3,s4,s5) #endif for (i = 0; i < nlocal; i++) { - const int ibody = body[i]; - if (ibody != ib) continue; - - s0 += f[i].x; - s1 += f[i].y; - s2 += f[i].z; - - double unwrap[3]; - domain->unmap(x[i],xcmimage[i],unwrap); - const double dx = unwrap[0] - xcm[ibody][0]; - const double dy = unwrap[1] - xcm[ibody][1]; - const double dz = unwrap[2] - xcm[ibody][2]; - - s3 += dy*f[i].z - dz*f[i].y; - s4 += dz*f[i].x - dx*f[i].z; - s5 += dx*f[i].y - dy*f[i].x; - - if (extended && (eflags[i] & TORQUE)) { - s3 += torque_one[i][0]; - s4 += torque_one[i][1]; - s5 += torque_one[i][2]; - } + const int ibody = body[i]; + if (ibody != ib) continue; + + s0 += f[i].x; + s1 += f[i].y; + s2 += f[i].z; + + double unwrap[3]; + domain->unmap(x[i],xcmimage[i],unwrap); + const double dx = unwrap[0] - xcm[ibody][0]; + const double dy = unwrap[1] - xcm[ibody][1]; + const double dz = unwrap[2] - xcm[ibody][2]; + + s3 += dy*f[i].z - dz*f[i].y; + s4 += dz*f[i].x - dx*f[i].z; + s5 += dx*f[i].y - dy*f[i].x; + + if (extended && (eflags[i] & TORQUE)) { + s3 += torque_one[i][0]; + s4 += torque_one[i][1]; + s5 += torque_one[i][2]; + } } sum[ib][0]=s0; sum[ib][1]=s1; sum[ib][2]=s2; @@ -363,31 +363,31 @@ void FixRigidNHOMP::final_integrate() #endif for (int i = 0; i < nlocal; i++) { - const int ibody = body[i]; - if ((ibody < 0) || (ibody % nthreads != tid)) continue; - - double unwrap[3]; - domain->unmap(x[i],xcmimage[i],unwrap); - const double dx = unwrap[0] - xcm[ibody][0]; - const double dy = unwrap[1] - xcm[ibody][1]; - const double dz = unwrap[2] - xcm[ibody][2]; - - const double s0 = f[i].x; - const double s1 = f[i].y; - const double s2 = f[i].z; - - double s3 = dy*s2 - dz*s1; - double s4 = dz*s0 - dx*s2; - double s5 = dx*s1 - dy*s0; - - if (extended && (eflags[i] & TORQUE)) { - s3 += torque_one[i][0]; - s4 += torque_one[i][1]; - s5 += torque_one[i][2]; - } - - sum[ibody][0] += s0; sum[ibody][1] += s1; sum[ibody][2] += s2; - sum[ibody][3] += s3; sum[ibody][4] += s4; sum[ibody][5] += s5; + const int ibody = body[i]; + if ((ibody < 0) || (ibody % nthreads != tid)) continue; + + double unwrap[3]; + domain->unmap(x[i],xcmimage[i],unwrap); + const double dx = unwrap[0] - xcm[ibody][0]; + const double dy = unwrap[1] - xcm[ibody][1]; + const double dz = unwrap[2] - xcm[ibody][2]; + + const double s0 = f[i].x; + const double s1 = f[i].y; + const double s2 = f[i].z; + + double s3 = dy*s2 - dz*s1; + double s4 = dz*s0 - dx*s2; + double s5 = dx*s1 - dy*s0; + + if (extended && (eflags[i] & TORQUE)) { + s3 += torque_one[i][0]; + s4 += torque_one[i][1]; + s5 += torque_one[i][2]; + } + + sum[ibody][0] += s0; sum[ibody][1] += s1; sum[ibody][2] += s2; + sum[ibody][3] += s3; sum[ibody][4] += s4; sum[ibody][5] += s5; } } } else @@ -678,22 +678,22 @@ void FixRigidNHOMP::set_xv_thr() // Fix::v_tally() is not thread safe, so we do this manually here // accumulate global virial into thread-local variables for reduction if (vflag_global) { - v0 += vr[0]; - v1 += vr[1]; - v2 += vr[2]; - v3 += vr[3]; - v4 += vr[4]; - v5 += vr[5]; + v0 += vr[0]; + v1 += vr[1]; + v2 += vr[2]; + v3 += vr[3]; + v4 += vr[4]; + v5 += vr[5]; } // accumulate per atom virial directly since we parallelize over atoms. if (vflag_atom) { - vatom[i][0] += vr[0]; - vatom[i][1] += vr[1]; - vatom[i][2] += vr[2]; - vatom[i][3] += vr[3]; - vatom[i][4] += vr[4]; - vatom[i][5] += vr[5]; + vatom[i][0] += vr[0]; + vatom[i][1] += vr[1]; + vatom[i][2] += vr[2]; + vatom[i][3] += vr[3]; + vatom[i][4] += vr[4]; + vatom[i][5] += vr[5]; } } } @@ -868,22 +868,22 @@ void FixRigidNHOMP::set_v_thr() // Fix::v_tally() is not thread safe, so we do this manually here // accumulate global virial into thread-local variables and reduce them later if (vflag_global) { - v0 += vr[0]; - v1 += vr[1]; - v2 += vr[2]; - v3 += vr[3]; - v4 += vr[4]; - v5 += vr[5]; + v0 += vr[0]; + v1 += vr[1]; + v2 += vr[2]; + v3 += vr[3]; + v4 += vr[4]; + v5 += vr[5]; } // accumulate per atom virial directly since we parallelize over atoms. if (vflag_atom) { - vatom[i][0] += vr[0]; - vatom[i][1] += vr[1]; - vatom[i][2] += vr[2]; - vatom[i][3] += vr[3]; - vatom[i][4] += vr[4]; - vatom[i][5] += vr[5]; + vatom[i][0] += vr[0]; + vatom[i][1] += vr[1]; + vatom[i][2] += vr[2]; + vatom[i][3] += vr[3]; + vatom[i][4] += vr[4]; + vatom[i][5] += vr[5]; } } } // end of parallel for diff --git a/src/USER-OMP/fix_rigid_omp.cpp b/src/USER-OMP/fix_rigid_omp.cpp index f3ef1d2985..6f084c628c 100644 --- a/src/USER-OMP/fix_rigid_omp.cpp +++ b/src/USER-OMP/fix_rigid_omp.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -enum{SINGLE,MOLECULE,GROUP}; // same as in FixRigid +enum{SINGLE,MOLECULE,GROUP}; // same as in FixRigid #define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid @@ -145,9 +145,9 @@ void FixRigidOMP::final_integrate() s5 += dx*f[i].y - dy*f[i].x; if (extended && (eflags[i] & TORQUE)) { - s3 += torque_one[i][0]; - s4 += torque_one[i][1]; - s5 += torque_one[i][2]; + s3 += torque_one[i][0]; + s4 += torque_one[i][1]; + s5 += torque_one[i][2]; } } sum[0][0]=s0; sum[0][1]=s1; sum[0][2]=s2; @@ -166,28 +166,28 @@ void FixRigidOMP::final_integrate() #pragma omp parallel for default(none) private(i) shared(ib) reduction(+:s0,s1,s2,s3,s4,s5) #endif for (i = 0; i < nlocal; i++) { - const int ibody = body[i]; - if (ibody != ib) continue; - - s0 += f[i].x; - s1 += f[i].y; - s2 += f[i].z; - - double unwrap[3]; - domain->unmap(x[i],xcmimage[i],unwrap); - const double dx = unwrap[0] - xcm[ibody][0]; - const double dy = unwrap[1] - xcm[ibody][1]; - const double dz = unwrap[2] - xcm[ibody][2]; - - s3 += dy*f[i].z - dz*f[i].y; - s4 += dz*f[i].x - dx*f[i].z; - s5 += dx*f[i].y - dy*f[i].x; - - if (extended && (eflags[i] & TORQUE)) { - s3 += torque_one[i][0]; - s4 += torque_one[i][1]; - s5 += torque_one[i][2]; - } + const int ibody = body[i]; + if (ibody != ib) continue; + + s0 += f[i].x; + s1 += f[i].y; + s2 += f[i].z; + + double unwrap[3]; + domain->unmap(x[i],xcmimage[i],unwrap); + const double dx = unwrap[0] - xcm[ibody][0]; + const double dy = unwrap[1] - xcm[ibody][1]; + const double dz = unwrap[2] - xcm[ibody][2]; + + s3 += dy*f[i].z - dz*f[i].y; + s4 += dz*f[i].x - dx*f[i].z; + s5 += dx*f[i].y - dy*f[i].x; + + if (extended && (eflags[i] & TORQUE)) { + s3 += torque_one[i][0]; + s4 += torque_one[i][1]; + s5 += torque_one[i][2]; + } } sum[ib][0]=s0; sum[ib][1]=s1; sum[ib][2]=s2; @@ -214,31 +214,31 @@ void FixRigidOMP::final_integrate() #endif for (int i = 0; i < nlocal; i++) { - const int ibody = body[i]; - if ((ibody < 0) || (ibody % nthreads != tid)) continue; - - double unwrap[3]; - domain->unmap(x[i],xcmimage[i],unwrap); - const double dx = unwrap[0] - xcm[ibody][0]; - const double dy = unwrap[1] - xcm[ibody][1]; - const double dz = unwrap[2] - xcm[ibody][2]; - - const double s0 = f[i].x; - const double s1 = f[i].y; - const double s2 = f[i].z; - - double s3 = dy*s2 - dz*s1; - double s4 = dz*s0 - dx*s2; - double s5 = dx*s1 - dy*s0; - - if (extended && (eflags[i] & TORQUE)) { - s3 += torque_one[i][0]; - s4 += torque_one[i][1]; - s5 += torque_one[i][2]; - } - - sum[ibody][0] += s0; sum[ibody][1] += s1; sum[ibody][2] += s2; - sum[ibody][3] += s3; sum[ibody][4] += s4; sum[ibody][5] += s5; + const int ibody = body[i]; + if ((ibody < 0) || (ibody % nthreads != tid)) continue; + + double unwrap[3]; + domain->unmap(x[i],xcmimage[i],unwrap); + const double dx = unwrap[0] - xcm[ibody][0]; + const double dy = unwrap[1] - xcm[ibody][1]; + const double dz = unwrap[2] - xcm[ibody][2]; + + const double s0 = f[i].x; + const double s1 = f[i].y; + const double s2 = f[i].z; + + double s3 = dy*s2 - dz*s1; + double s4 = dz*s0 - dx*s2; + double s5 = dx*s1 - dy*s0; + + if (extended && (eflags[i] & TORQUE)) { + s3 += torque_one[i][0]; + s4 += torque_one[i][1]; + s5 += torque_one[i][2]; + } + + sum[ibody][0] += s0; sum[ibody][1] += s1; sum[ibody][2] += s2; + sum[ibody][3] += s3; sum[ibody][4] += s4; sum[ibody][5] += s5; } } } else @@ -393,22 +393,22 @@ void FixRigidOMP::set_xv_thr() // Fix::v_tally() is not thread safe, so we do this manually here // accumulate global virial into thread-local variables for reduction if (vflag_global) { - v0 += vr[0]; - v1 += vr[1]; - v2 += vr[2]; - v3 += vr[3]; - v4 += vr[4]; - v5 += vr[5]; + v0 += vr[0]; + v1 += vr[1]; + v2 += vr[2]; + v3 += vr[3]; + v4 += vr[4]; + v5 += vr[5]; } // accumulate per atom virial directly since we parallelize over atoms. if (vflag_atom) { - vatom[i][0] += vr[0]; - vatom[i][1] += vr[1]; - vatom[i][2] += vr[2]; - vatom[i][3] += vr[3]; - vatom[i][4] += vr[4]; - vatom[i][5] += vr[5]; + vatom[i][0] += vr[0]; + vatom[i][1] += vr[1]; + vatom[i][2] += vr[2]; + vatom[i][3] += vr[3]; + vatom[i][4] += vr[4]; + vatom[i][5] += vr[5]; } } } @@ -583,22 +583,22 @@ void FixRigidOMP::set_v_thr() // Fix::v_tally() is not thread safe, so we do this manually here // accumulate global virial into thread-local variables and reduce them later if (vflag_global) { - v0 += vr[0]; - v1 += vr[1]; - v2 += vr[2]; - v3 += vr[3]; - v4 += vr[4]; - v5 += vr[5]; + v0 += vr[0]; + v1 += vr[1]; + v2 += vr[2]; + v3 += vr[3]; + v4 += vr[4]; + v5 += vr[5]; } // accumulate per atom virial directly since we parallelize over atoms. if (vflag_atom) { - vatom[i][0] += vr[0]; - vatom[i][1] += vr[1]; - vatom[i][2] += vr[2]; - vatom[i][3] += vr[3]; - vatom[i][4] += vr[4]; - vatom[i][5] += vr[5]; + vatom[i][0] += vr[0]; + vatom[i][1] += vr[1]; + vatom[i][2] += vr[2]; + vatom[i][3] += vr[3]; + vatom[i][4] += vr[4]; + vatom[i][5] += vr[5]; } } } // end of parallel for diff --git a/src/USER-OMP/fix_rigid_small_omp.cpp b/src/USER-OMP/fix_rigid_small_omp.cpp index e3939a829d..156ef8a2d7 100644 --- a/src/USER-OMP/fix_rigid_small_omp.cpp +++ b/src/USER-OMP/fix_rigid_small_omp.cpp @@ -343,22 +343,22 @@ void FixRigidSmallOMP::set_xv_thr() // Fix::v_tally() is not thread safe, so we do this manually here // accumulate global virial into thread-local variables for reduction if (vflag_global) { - v0 += vr[0]; - v1 += vr[1]; - v2 += vr[2]; - v3 += vr[3]; - v4 += vr[4]; - v5 += vr[5]; + v0 += vr[0]; + v1 += vr[1]; + v2 += vr[2]; + v3 += vr[3]; + v4 += vr[4]; + v5 += vr[5]; } // accumulate per atom virial directly since we parallelize over atoms. if (vflag_atom) { - vatom[i][0] += vr[0]; - vatom[i][1] += vr[1]; - vatom[i][2] += vr[2]; - vatom[i][3] += vr[3]; - vatom[i][4] += vr[4]; - vatom[i][5] += vr[5]; + vatom[i][0] += vr[0]; + vatom[i][1] += vr[1]; + vatom[i][2] += vr[2]; + vatom[i][3] += vr[3]; + vatom[i][4] += vr[4]; + vatom[i][5] += vr[5]; } } } @@ -529,22 +529,22 @@ void FixRigidSmallOMP::set_v_thr() // Fix::v_tally() is not thread safe, so we do this manually here // accumulate global virial into thread-local variables and reduce them later if (vflag_global) { - v0 += vr[0]; - v1 += vr[1]; - v2 += vr[2]; - v3 += vr[3]; - v4 += vr[4]; - v5 += vr[5]; + v0 += vr[0]; + v1 += vr[1]; + v2 += vr[2]; + v3 += vr[3]; + v4 += vr[4]; + v5 += vr[5]; } // accumulate per atom virial directly since we parallelize over atoms. if (vflag_atom) { - vatom[i][0] += vr[0]; - vatom[i][1] += vr[1]; - vatom[i][2] += vr[2]; - vatom[i][3] += vr[3]; - vatom[i][4] += vr[4]; - vatom[i][5] += vr[5]; + vatom[i][0] += vr[0]; + vatom[i][1] += vr[1]; + vatom[i][2] += vr[2]; + vatom[i][3] += vr[3]; + vatom[i][4] += vr[4]; + vatom[i][5] += vr[5]; } } } // end of parallel for diff --git a/src/USER-OMP/improper_fourier_omp.cpp b/src/USER-OMP/improper_fourier_omp.cpp index 9e7912e335..c1699baf02 100644 --- a/src/USER-OMP/improper_fourier_omp.cpp +++ b/src/USER-OMP/improper_fourier_omp.cpp @@ -117,36 +117,36 @@ void ImproperFourierOMP::eval(int nfrom, int nto, ThrData * const thr) vb3z = x[i4][2] - x[i1][2]; add1_thr<EVFLAG,EFLAG,NEWTON_BOND>(i1,i2,i3,i4,type, - vb1x,vb1y,vb1z, - vb2x,vb2y,vb2z, - vb3x,vb3y,vb3z,thr); + vb1x,vb1y,vb1z, + vb2x,vb2y,vb2z, + vb3x,vb3y,vb3z,thr); if ( all[type] ) { add1_thr<EVFLAG,EFLAG,NEWTON_BOND>(i1,i4,i2,i3,type, - vb3x,vb3y,vb3z, - vb1x,vb1y,vb1z, - vb2x,vb2y,vb2z,thr); + vb3x,vb3y,vb3z, + vb1x,vb1y,vb1z, + vb2x,vb2y,vb2z,thr); add1_thr<EVFLAG,EFLAG,NEWTON_BOND>(i1,i3,i4,i2,type, - vb2x,vb2y,vb2z, - vb3x,vb3y,vb3z, - vb1x,vb1y,vb1z,thr); + vb2x,vb2y,vb2z, + vb3x,vb3y,vb3z, + vb1x,vb1y,vb1z,thr); } } } template <int EVFLAG, int EFLAG, int NEWTON_BOND> void ImproperFourierOMP::add1_thr(const int i1,const int i2, - const int i3,const int i4, - const int type, - const double &vb1x, - const double &vb1y, - const double &vb1z, - const double &vb2x, - const double &vb2y, - const double &vb2z, - const double &vb3x, - const double &vb3y, - const double &vb3z, - ThrData * const thr) + const int i3,const int i4, + const int type, + const double &vb1x, + const double &vb1y, + const double &vb1z, + const double &vb2x, + const double &vb2y, + const double &vb2z, + const double &vb3x, + const double &vb3y, + const double &vb3z, + ThrData * const thr) { double eimproper,f1[3],f2[3],f3[3],f4[3]; double c,c2,a,s,projhfg,dhax,dhay,dhaz,dahx,dahy,dahz,cotphi; @@ -283,5 +283,5 @@ void ImproperFourierOMP::add1_thr(const int i1,const int i2, if (EVFLAG) ev_tally_thr(this,i1,i2,i3,i4,nlocal,NEWTON_BOND,eimproper,f1,f3,f4, - vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z,thr); + vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z,thr); } diff --git a/src/USER-OMP/improper_fourier_omp.h b/src/USER-OMP/improper_fourier_omp.h index 765554bcaf..8bd99cf4ca 100644 --- a/src/USER-OMP/improper_fourier_omp.h +++ b/src/USER-OMP/improper_fourier_omp.h @@ -41,10 +41,10 @@ class ImproperFourierOMP : public ImproperFourier, public ThrOMP { template <int EVFLAG, int EFLAG, int NEWTON_BOND> void add1_thr(const int,const int,const int,const int,const int, - const double &, const double &, const double &, - const double &, const double &, const double &, - const double &, const double &, const double &, - ThrData * const thr); + const double &, const double &, const double &, + const double &, const double &, const double &, + const double &, const double &, const double &, + ThrData * const thr); }; } diff --git a/src/USER-OMP/pair_buck_long_coul_long_omp.cpp b/src/USER-OMP/pair_buck_long_coul_long_omp.cpp index f996372409..dbcef106d2 100644 --- a/src/USER-OMP/pair_buck_long_coul_long_omp.cpp +++ b/src/USER-OMP/pair_buck_long_coul_long_omp.cpp @@ -788,7 +788,7 @@ void PairBuckLongCoulLongOMP::eval(int iifrom, int iito, ThrData * const thr) } if (EVFLAG) ev_tally_thr(this,i,j,nlocal,NEWTON_PAIR, - evdwl,ecoul,fpair,d[0],d[1],d[2],thr); + evdwl,ecoul,fpair,d[0],d[1],d[2],thr); } } } @@ -1116,7 +1116,7 @@ void PairBuckLongCoulLongOMP::eval_outer(int iiform, int iito, ThrData * const t force_buck = r*expr*buck1i[typej]-g8*(((6.0*a2+6.0)*a2+3.0)*a2+1.0)*x2*rsq-respa_buck; if (EFLAG) evdwl = expr*buckai[typej]-g6*((a2+1.0)*a2+0.5)*x2; - } + } else { // correct for special register double f = special_lj[ni], t = rn*(1.0-f); force_buck = f*r*expr*buck1i[typej]- @@ -1175,7 +1175,7 @@ void PairBuckLongCoulLongOMP::eval_outer(int iiform, int iito, ThrData * const t if (EVFLAG) { fvirial = (force_coul + force_buck + respa_coul + respa_buck)*r2inv; ev_tally_thr(this,i,j,nlocal,NEWTON_PAIR, - evdwl,ecoul,fvirial,d[0],d[1],d[2],thr); + evdwl,ecoul,fvirial,d[0],d[1],d[2],thr); } } } diff --git a/src/USER-OMP/pair_lj_long_coul_long_omp.cpp b/src/USER-OMP/pair_lj_long_coul_long_omp.cpp index c0c87e7481..8cc4c95fc2 100644 --- a/src/USER-OMP/pair_lj_long_coul_long_omp.cpp +++ b/src/USER-OMP/pair_lj_long_coul_long_omp.cpp @@ -733,7 +733,7 @@ void PairLJLongCoulLongOMP::eval(int iifrom, int iito, ThrData * const thr) if (EFLAG) evdwl = f*rn*lj3i[typej]-g6*((a2+1.0)*a2+0.5)*x2+t*lj4i[typej]; } - } + } else { // table real space register union_int_float_t disp_t; disp_t.f = rsq; @@ -744,7 +744,7 @@ void PairLJLongCoulLongOMP::eval(int iifrom, int iito, ThrData * const thr) force_lj = (rn*=rn)*lj1i[typej]-(fdisptable[disp_k]+f_disp*dfdisptable[disp_k])*lj4i[typej]; if (EFLAG) evdwl = rn*lj3i[typej]-(edisptable[disp_k]+f_disp*dedisptable[disp_k])*lj4i[typej]; } - else { // special case + else { // special case register double f = special_lj[ni], t = rn*(1.0-f); force_lj = f*(rn *= rn)*lj1i[typej]-(fdisptable[disp_k]+f_disp*dfdisptable[disp_k])*lj4i[typej]+t*lj2i[typej]; if (EFLAG) evdwl = f*rn*lj3i[typej]-(edisptable[disp_k]+f_disp*dedisptable[disp_k])*lj4i[typej]+t*lj4i[typej]; @@ -1116,7 +1116,7 @@ void PairLJLongCoulLongOMP::eval_outer(int iiform, int iito, ThrData * const thr evdwl = f*rn*lj3i[typej]-g6*((a2+1.0)*a2+0.5)*x2+t*lj4i[typej]; } } - else { // table real space + else { // table real space register union_int_float_t disp_t; disp_t.f = rsq; register const int disp_k = (disp_t.i & ndispmask)>>ndispshiftbits; @@ -1126,7 +1126,7 @@ void PairLJLongCoulLongOMP::eval_outer(int iiform, int iito, ThrData * const thr force_lj = (rn*=rn)*lj1i[typej]-(fdisptable[disp_k]+f_disp*dfdisptable[disp_k])*lj4i[typej]-respa_lj; if (EFLAG) evdwl = rn*lj3i[typej]-(edisptable[disp_k]+f_disp*dedisptable[disp_k])*lj4i[typej]; } - else { // special case + else { // special case register double f = special_lj[ni], t = rn*(1.0-f); force_lj = f*(rn *= rn)*lj1i[typej]-(fdisptable[disp_k]+f_disp*dfdisptable[disp_k])*lj4i[typej]+t*lj2i[typej]-respa_lj; if (EFLAG) evdwl = f*rn*lj3i[typej]-(edisptable[disp_k]+f_disp*dedisptable[disp_k])*lj4i[typej]+t*lj4i[typej]; @@ -1165,7 +1165,7 @@ void PairLJLongCoulLongOMP::eval_outer(int iiform, int iito, ThrData * const thr if (EVFLAG) { fvirial = (force_coul + force_lj + respa_coul + respa_lj)*r2inv; ev_tally_thr(this,i,j,nlocal,NEWTON_PAIR, - evdwl,ecoul,fvirial,d[0],d[1],d[2],thr); + evdwl,ecoul,fvirial,d[0],d[1],d[2],thr); } } } diff --git a/src/USER-OMP/pair_morse_smooth_linear_omp.cpp b/src/USER-OMP/pair_morse_smooth_linear_omp.cpp index d207f58fa6..113f6f2a02 100644 --- a/src/USER-OMP/pair_morse_smooth_linear_omp.cpp +++ b/src/USER-OMP/pair_morse_smooth_linear_omp.cpp @@ -143,7 +143,7 @@ void PairMorseSmoothLinearOMP::eval(int iifrom, int iito, ThrData * const thr) if (EFLAG) { evdwl = d0[itype][jtype] * (dexp*dexp - 2.0*dexp) - - offset[itype][jtype]; + offset[itype][jtype]; evdwl += ( r - cut[itype][jtype] ) * der_at_cutoff[itype][jtype]; evdwl *= factor_lj; } diff --git a/src/USER-OMP/pair_reaxc_omp.h b/src/USER-OMP/pair_reaxc_omp.h index d0dedf7e3c..ad8c368aaf 100644 --- a/src/USER-OMP/pair_reaxc_omp.h +++ b/src/USER-OMP/pair_reaxc_omp.h @@ -34,44 +34,44 @@ class PairReaxCOMP : public PairReaxC, public ThrOMP { virtual void init_style(); inline FixOMP *getFixOMP() { - return fix; + return fix; }; inline void ev_setup_thr_proxy(int eflagparm, int vflagparm, int nallparm, - double *eatomparm, double **vatomparm, ThrData *thrparm) { + double *eatomparm, double **vatomparm, ThrData *thrparm) { ev_setup_thr(eflagparm, vflagparm, nallparm, eatomparm, vatomparm, thrparm); }; // reduce per thread data as needed inline void reduce_thr_proxy(void * const styleparm, const int eflagparm, - const int vflagparm, ThrData * const thrparm) { + const int vflagparm, ThrData * const thrparm) { reduce_thr(styleparm, eflagparm, vflagparm, thrparm); } inline void ev_tally_thr_proxy(Pair * const pairparm, const int iparm, const int jparm, - const int nlocalparm, const int newton_pairparm, - const double evdwlparm, const double ecoulparm, - const double fpairparm, const double delxparm, - const double delyparm, const double delzparm, - ThrData * const thrparm) { + const int nlocalparm, const int newton_pairparm, + const double evdwlparm, const double ecoulparm, + const double fpairparm, const double delxparm, + const double delyparm, const double delzparm, + ThrData * const thrparm) { ev_tally_thr(pairparm, iparm, jparm, nlocalparm, newton_pairparm, - evdwlparm, ecoulparm, fpairparm, delxparm, delyparm, delzparm, thrparm); + evdwlparm, ecoulparm, fpairparm, delxparm, delyparm, delzparm, thrparm); } inline void ev_tally_xyz_thr_proxy(Pair * const pairparm, const int iparm, const int jparm, - const int nlocalparm, const int newton_pairparm, - const double evdwlparm, const double ecoulparm, - const double fxparm, const double fyparm, const double fzparm, - const double delxparm, const double delyparm, - const double delzparm, ThrData * const thrparm) { + const int nlocalparm, const int newton_pairparm, + const double evdwlparm, const double ecoulparm, + const double fxparm, const double fyparm, const double fzparm, + const double delxparm, const double delyparm, + const double delzparm, ThrData * const thrparm) { ev_tally_xyz_thr(pairparm, iparm, jparm, nlocalparm, newton_pairparm, - evdwlparm, ecoulparm, fxparm, fyparm, fzparm, - delxparm, delyparm, delzparm, thrparm); + evdwlparm, ecoulparm, fxparm, fyparm, fzparm, + delxparm, delyparm, delzparm, thrparm); } inline void ev_tally3_thr_proxy(Pair * const pairparm,int i, int j, int k, - double evdwl, double ecoul, double *fj, double *fk, - double *drji, double *drki, ThrData * const thrparm) { + double evdwl, double ecoul, double *fj, double *fk, + double *drji, double *drki, ThrData * const thrparm) { ev_tally3_thr(pairparm, i, j, k, evdwl, ecoul, fj, fk, drji, drki, thrparm); } diff --git a/src/USER-OMP/pppm_cg_omp.cpp b/src/USER-OMP/pppm_cg_omp.cpp index df0e632f78..eb230a3bb4 100644 --- a/src/USER-OMP/pppm_cg_omp.cpp +++ b/src/USER-OMP/pppm_cg_omp.cpp @@ -159,35 +159,35 @@ void PPPMCGOMP::compute_gf_ik() sqk = square(unitkx*kper) + square(unitky*lper) + square(unitkz*mper); if (sqk != 0.0) { - numerator = 12.5663706/sqk; - denominator = gf_denom(snx,sny,snz); - sum1 = 0.0; - - for (nx = -nbx; nx <= nbx; nx++) { - qx = unitkx*(kper+nx_pppm*nx); - sx = exp(-0.25*square(qx/g_ewald)); - argx = 0.5*qx*xprd/nx_pppm; - wx = powsinxx(argx,twoorder); - - for (ny = -nby; ny <= nby; ny++) { - qy = unitky*(lper+ny_pppm*ny); - sy = exp(-0.25*square(qy/g_ewald)); - argy = 0.5*qy*yprd/ny_pppm; - wy = powsinxx(argy,twoorder); - - for (nz = -nbz; nz <= nbz; nz++) { - qz = unitkz*(mper+nz_pppm*nz); - sz = exp(-0.25*square(qz/g_ewald)); - argz = 0.5*qz*zprd_slab/nz_pppm; - wz = powsinxx(argz,twoorder); - - dot1 = unitkx*kper*qx + unitky*lper*qy + unitkz*mper*qz; - dot2 = qx*qx+qy*qy+qz*qz; - sum1 += (dot1/dot2) * sx*sy*sz * wx*wy*wz; - } - } - } - greensfn[n] = numerator*sum1/denominator; + numerator = 12.5663706/sqk; + denominator = gf_denom(snx,sny,snz); + sum1 = 0.0; + + for (nx = -nbx; nx <= nbx; nx++) { + qx = unitkx*(kper+nx_pppm*nx); + sx = exp(-0.25*square(qx/g_ewald)); + argx = 0.5*qx*xprd/nx_pppm; + wx = powsinxx(argx,twoorder); + + for (ny = -nby; ny <= nby; ny++) { + qy = unitky*(lper+ny_pppm*ny); + sy = exp(-0.25*square(qy/g_ewald)); + argy = 0.5*qy*yprd/ny_pppm; + wy = powsinxx(argy,twoorder); + + for (nz = -nbz; nz <= nbz; nz++) { + qz = unitkz*(mper+nz_pppm*nz); + sz = exp(-0.25*square(qz/g_ewald)); + argz = 0.5*qz*zprd_slab/nz_pppm; + wz = powsinxx(argz,twoorder); + + dot1 = unitkx*kper*qx + unitky*lper*qy + unitkz*mper*qz; + dot2 = qx*qx+qy*qy+qz*qz; + sum1 += (dot1/dot2) * sx*sy*sz * wx*wy*wz; + } + } + } + greensfn[n] = numerator*sum1/denominator; } else greensfn[n] = 0.0; } thr->timer(Timer::KSPACE); @@ -263,23 +263,23 @@ void PPPMCGOMP::compute_gf_ad() sqk = qx*qx + qy*qy + qz*qz; if (sqk != 0.0) { - numerator = MY_4PI/sqk; - denominator = gf_denom(snx,sny,snz); - greensfn[n] = numerator*sx*sy*sz*wx*wy*wz/denominator; - sf0 += sf_precoeff1[n]*greensfn[n]; - sf1 += sf_precoeff2[n]*greensfn[n]; - sf2 += sf_precoeff3[n]*greensfn[n]; - sf3 += sf_precoeff4[n]*greensfn[n]; - sf4 += sf_precoeff5[n]*greensfn[n]; - sf5 += sf_precoeff6[n]*greensfn[n]; + numerator = MY_4PI/sqk; + denominator = gf_denom(snx,sny,snz); + greensfn[n] = numerator*sx*sy*sz*wx*wy*wz/denominator; + sf0 += sf_precoeff1[n]*greensfn[n]; + sf1 += sf_precoeff2[n]*greensfn[n]; + sf2 += sf_precoeff3[n]*greensfn[n]; + sf3 += sf_precoeff4[n]*greensfn[n]; + sf4 += sf_precoeff5[n]*greensfn[n]; + sf5 += sf_precoeff6[n]*greensfn[n]; } else { - greensfn[n] = 0.0; - sf0 += sf_precoeff1[n]*greensfn[n]; - sf1 += sf_precoeff2[n]*greensfn[n]; - sf2 += sf_precoeff3[n]*greensfn[n]; - sf3 += sf_precoeff4[n]*greensfn[n]; - sf4 += sf_precoeff5[n]*greensfn[n]; - sf5 += sf_precoeff6[n]*greensfn[n]; + greensfn[n] = 0.0; + sf0 += sf_precoeff1[n]*greensfn[n]; + sf1 += sf_precoeff2[n]*greensfn[n]; + sf2 += sf_precoeff3[n]*greensfn[n]; + sf3 += sf_precoeff4[n]*greensfn[n]; + sf4 += sf_precoeff5[n]*greensfn[n]; + sf5 += sf_precoeff6[n]*greensfn[n]; } } thr->timer(Timer::KSPACE); @@ -713,7 +713,7 @@ void PPPMCGOMP::compute_rho1d_thr(FFT_SCALAR * const * const r1d, const FFT_SCAL ------------------------------------------------------------------------- */ void PPPMCGOMP::compute_drho1d_thr(FFT_SCALAR * const * const d1d, const FFT_SCALAR &dx, - const FFT_SCALAR &dy, const FFT_SCALAR &dz) + const FFT_SCALAR &dy, const FFT_SCALAR &dz) { int k,l; FFT_SCALAR r1,r2,r3; diff --git a/src/USER-OMP/pppm_cg_omp.h b/src/USER-OMP/pppm_cg_omp.h index 07763eba38..057f86099d 100644 --- a/src/USER-OMP/pppm_cg_omp.h +++ b/src/USER-OMP/pppm_cg_omp.h @@ -46,7 +46,7 @@ class PPPMCGOMP : public PPPMCG, public ThrOMP { void compute_rho1d_thr(FFT_SCALAR * const * const, const FFT_SCALAR &, const FFT_SCALAR &, const FFT_SCALAR &); void compute_drho1d_thr(FFT_SCALAR * const * const, const FFT_SCALAR &, - const FFT_SCALAR &, const FFT_SCALAR &); + const FFT_SCALAR &, const FFT_SCALAR &); }; } diff --git a/src/USER-OMP/pppm_disp_omp.cpp b/src/USER-OMP/pppm_disp_omp.cpp index 6cf2983761..74881c9a8a 100644 --- a/src/USER-OMP/pppm_disp_omp.cpp +++ b/src/USER-OMP/pppm_disp_omp.cpp @@ -272,24 +272,24 @@ void PPPMDispOMP::compute_gf_6() nn = k-nxlo_fft_6 + nnx*(l-nylo_fft_6 + nny*(m-nzlo_fft_6)); if ((nn < nnfrom) || (nn >=nnto)) continue; - kper = k - nx_pppm_6*(2*k/nx_pppm_6); + kper = k - nx_pppm_6*(2*k/nx_pppm_6); qx = unitkx*kper; - snx = sin(0.5*unitkx*kper*xprd/nx_pppm_6); - snx2 = snx*snx; + snx = sin(0.5*unitkx*kper*xprd/nx_pppm_6); + snx2 = snx*snx; sx = exp(-qx*qx*inv2ew*inv2ew); - wx = 1.0; - argx = 0.5*qx*xprd/nx_pppm_6; - if (argx != 0.0) wx = pow(sin(argx)/argx,order_6); + wx = 1.0; + argx = 0.5*qx*xprd/nx_pppm_6; + if (argx != 0.0) wx = pow(sin(argx)/argx,order_6); wx *= wx; - sqk = pow(qx,2.0) + pow(qy,2.0) + pow(qz,2.0); + sqk = pow(qx,2.0) + pow(qy,2.0) + pow(qz,2.0); if (sqk != 0.0) { - denominator = gf_denom(snx2,sny2,snz2, gf_b_6, order_6); - rtsqk = sqrt(sqk); + denominator = gf_denom(snx2,sny2,snz2, gf_b_6, order_6); + rtsqk = sqrt(sqk); term = (1-2*sqk*inv2ew*inv2ew)*sx*sy*sz + 2*sqk*rtsqk*inv2ew*inv2ew*inv2ew*rtpi*erfc(rtsqk*inv2ew); - greensfn_6[nn] = numerator*term*wx*wy*wz/denominator; + greensfn_6[nn] = numerator*term*wx*wy*wz/denominator; } else greensfn_6[nn] = 0.0; } } @@ -1404,27 +1404,27 @@ void PPPMDispOMP::fieldforce_a_ik() for (l = nlower_6; l <= nupper_6; l++) { mx = l+nx; x0 = y0*r1d[0][l]; - ekx0 -= x0*vdx_brick_a0[mz][my][mx]; - eky0 -= x0*vdy_brick_a0[mz][my][mx]; - ekz0 -= x0*vdz_brick_a0[mz][my][mx]; - ekx1 -= x0*vdx_brick_a1[mz][my][mx]; - eky1 -= x0*vdy_brick_a1[mz][my][mx]; - ekz1 -= x0*vdz_brick_a1[mz][my][mx]; + ekx0 -= x0*vdx_brick_a0[mz][my][mx]; + eky0 -= x0*vdy_brick_a0[mz][my][mx]; + ekz0 -= x0*vdz_brick_a0[mz][my][mx]; + ekx1 -= x0*vdx_brick_a1[mz][my][mx]; + eky1 -= x0*vdy_brick_a1[mz][my][mx]; + ekz1 -= x0*vdz_brick_a1[mz][my][mx]; ekx2 -= x0*vdx_brick_a2[mz][my][mx]; - eky2 -= x0*vdy_brick_a2[mz][my][mx]; - ekz2 -= x0*vdz_brick_a2[mz][my][mx]; - ekx3 -= x0*vdx_brick_a3[mz][my][mx]; - eky3 -= x0*vdy_brick_a3[mz][my][mx]; - ekz3 -= x0*vdz_brick_a3[mz][my][mx]; - ekx4 -= x0*vdx_brick_a4[mz][my][mx]; - eky4 -= x0*vdy_brick_a4[mz][my][mx]; - ekz4 -= x0*vdz_brick_a4[mz][my][mx]; + eky2 -= x0*vdy_brick_a2[mz][my][mx]; + ekz2 -= x0*vdz_brick_a2[mz][my][mx]; + ekx3 -= x0*vdx_brick_a3[mz][my][mx]; + eky3 -= x0*vdy_brick_a3[mz][my][mx]; + ekz3 -= x0*vdz_brick_a3[mz][my][mx]; + ekx4 -= x0*vdx_brick_a4[mz][my][mx]; + eky4 -= x0*vdy_brick_a4[mz][my][mx]; + ekz4 -= x0*vdz_brick_a4[mz][my][mx]; ekx5 -= x0*vdx_brick_a5[mz][my][mx]; - eky5 -= x0*vdy_brick_a5[mz][my][mx]; - ekz5 -= x0*vdz_brick_a5[mz][my][mx]; + eky5 -= x0*vdy_brick_a5[mz][my][mx]; + ekz5 -= x0*vdz_brick_a5[mz][my][mx]; ekx6 -= x0*vdx_brick_a6[mz][my][mx]; - eky6 -= x0*vdy_brick_a6[mz][my][mx]; - ekz6 -= x0*vdz_brick_a6[mz][my][mx]; + eky6 -= x0*vdy_brick_a6[mz][my][mx]; + ekz6 -= x0*vdz_brick_a6[mz][my][mx]; } } } @@ -1728,7 +1728,7 @@ void PPPMDispOMP::fieldforce_a_peratom() u4 += x0*u_brick_a4[mz][my][mx]; u5 += x0*u_brick_a5[mz][my][mx]; u6 += x0*u_brick_a6[mz][my][mx]; - } + } if (vflag_atom) { v00 += x0*v0_brick_a0[mz][my][mx]; v10 += x0*v1_brick_a0[mz][my][mx]; @@ -1815,7 +1815,7 @@ void PPPMDispOMP::fieldforce_a_peratom() dx,dy,dz = distance of particle from "lower left" grid point ------------------------------------------------------------------------- */ void PPPMDispOMP::compute_rho1d_thr(FFT_SCALAR * const * const r1d, const FFT_SCALAR &dx, - const FFT_SCALAR &dy, const FFT_SCALAR &dz, + const FFT_SCALAR &dy, const FFT_SCALAR &dz, const int ord, FFT_SCALAR * const * const rho_c) { int k,l; @@ -1841,7 +1841,7 @@ void PPPMDispOMP::compute_rho1d_thr(FFT_SCALAR * const * const r1d, const FFT_SC ------------------------------------------------------------------------- */ void PPPMDispOMP::compute_drho1d_thr(FFT_SCALAR * const * const dr1d, const FFT_SCALAR &dx, - const FFT_SCALAR &dy, const FFT_SCALAR &dz, + const FFT_SCALAR &dy, const FFT_SCALAR &dz, const int ord, FFT_SCALAR * const * const drho_c) { int k,l; diff --git a/src/USER-OMP/pppm_disp_omp.h b/src/USER-OMP/pppm_disp_omp.h index b1ec2856bb..ac4a54c9f8 100644 --- a/src/USER-OMP/pppm_disp_omp.h +++ b/src/USER-OMP/pppm_disp_omp.h @@ -60,7 +60,7 @@ namespace LAMMPS_NS { const FFT_SCALAR &, const FFT_SCALAR &, const int, FFT_SCALAR * const * const); void compute_drho1d_thr(FFT_SCALAR * const * const, const FFT_SCALAR &, - const FFT_SCALAR &, const FFT_SCALAR &, + const FFT_SCALAR &, const FFT_SCALAR &, const int, FFT_SCALAR * const * const); // void compute_rho_coeff(); // void slabcorr(int); diff --git a/src/USER-OMP/pppm_disp_tip4p_omp.cpp b/src/USER-OMP/pppm_disp_tip4p_omp.cpp index 29aeeb79dc..49e3681f6e 100644 --- a/src/USER-OMP/pppm_disp_tip4p_omp.cpp +++ b/src/USER-OMP/pppm_disp_tip4p_omp.cpp @@ -269,23 +269,23 @@ void PPPMDispTIP4POMP::compute_gf_6() nn = k-nxlo_fft_6 + nnx*(l-nylo_fft_6 + nny*(m-nzlo_fft_6)); if ((nn < nnfrom) || (nn >=nnto)) continue; - kper = k - nx_pppm_6*(2*k/nx_pppm_6); + kper = k - nx_pppm_6*(2*k/nx_pppm_6); qx = unitkx*kper; - snx = sin(0.5*unitkx*kper*xprd/nx_pppm_6); - snx2 = snx*snx; + snx = sin(0.5*unitkx*kper*xprd/nx_pppm_6); + snx2 = snx*snx; sx = exp(-qx*qx*inv2ew*inv2ew); - wx = 1.0; - argx = 0.5*qx*xprd/nx_pppm_6; - if (argx != 0.0) wx = pow(sin(argx)/argx,order_6); + wx = 1.0; + argx = 0.5*qx*xprd/nx_pppm_6; + if (argx != 0.0) wx = pow(sin(argx)/argx,order_6); wx *= wx; - sqk = pow(qx,2.0) + pow(qy,2.0) + pow(qz,2.0); + sqk = pow(qx,2.0) + pow(qy,2.0) + pow(qz,2.0); - denominator = gf_denom(snx2,sny2,snz2, gf_b_6, order_6); - rtsqk = sqrt(sqk); + denominator = gf_denom(snx2,sny2,snz2, gf_b_6, order_6); + rtsqk = sqrt(sqk); term = (1-2*sqk*inv2ew*inv2ew)*sx*sy*sz + 2*sqk*rtsqk*inv2ew*inv2ew*inv2ew*rtpi*erfc(rtsqk*inv2ew); - greensfn_6[nn] = numerator*term*wx*wy*wz/denominator; + greensfn_6[nn] = numerator*term*wx*wy*wz/denominator; } } } @@ -1383,27 +1383,27 @@ void PPPMDispTIP4POMP::fieldforce_a_ik() for (l = nlower_6; l <= nupper_6; l++) { mx = l+nx; x0 = y0*r1d[0][l]; - ekx0 -= x0*vdx_brick_a0[mz][my][mx]; - eky0 -= x0*vdy_brick_a0[mz][my][mx]; - ekz0 -= x0*vdz_brick_a0[mz][my][mx]; - ekx1 -= x0*vdx_brick_a1[mz][my][mx]; - eky1 -= x0*vdy_brick_a1[mz][my][mx]; - ekz1 -= x0*vdz_brick_a1[mz][my][mx]; + ekx0 -= x0*vdx_brick_a0[mz][my][mx]; + eky0 -= x0*vdy_brick_a0[mz][my][mx]; + ekz0 -= x0*vdz_brick_a0[mz][my][mx]; + ekx1 -= x0*vdx_brick_a1[mz][my][mx]; + eky1 -= x0*vdy_brick_a1[mz][my][mx]; + ekz1 -= x0*vdz_brick_a1[mz][my][mx]; ekx2 -= x0*vdx_brick_a2[mz][my][mx]; - eky2 -= x0*vdy_brick_a2[mz][my][mx]; - ekz2 -= x0*vdz_brick_a2[mz][my][mx]; - ekx3 -= x0*vdx_brick_a3[mz][my][mx]; - eky3 -= x0*vdy_brick_a3[mz][my][mx]; - ekz3 -= x0*vdz_brick_a3[mz][my][mx]; - ekx4 -= x0*vdx_brick_a4[mz][my][mx]; - eky4 -= x0*vdy_brick_a4[mz][my][mx]; - ekz4 -= x0*vdz_brick_a4[mz][my][mx]; + eky2 -= x0*vdy_brick_a2[mz][my][mx]; + ekz2 -= x0*vdz_brick_a2[mz][my][mx]; + ekx3 -= x0*vdx_brick_a3[mz][my][mx]; + eky3 -= x0*vdy_brick_a3[mz][my][mx]; + ekz3 -= x0*vdz_brick_a3[mz][my][mx]; + ekx4 -= x0*vdx_brick_a4[mz][my][mx]; + eky4 -= x0*vdy_brick_a4[mz][my][mx]; + ekz4 -= x0*vdz_brick_a4[mz][my][mx]; ekx5 -= x0*vdx_brick_a5[mz][my][mx]; - eky5 -= x0*vdy_brick_a5[mz][my][mx]; - ekz5 -= x0*vdz_brick_a5[mz][my][mx]; + eky5 -= x0*vdy_brick_a5[mz][my][mx]; + ekz5 -= x0*vdz_brick_a5[mz][my][mx]; ekx6 -= x0*vdx_brick_a6[mz][my][mx]; - eky6 -= x0*vdy_brick_a6[mz][my][mx]; - ekz6 -= x0*vdz_brick_a6[mz][my][mx]; + eky6 -= x0*vdy_brick_a6[mz][my][mx]; + ekz6 -= x0*vdz_brick_a6[mz][my][mx]; } } } @@ -1701,7 +1701,7 @@ void PPPMDispTIP4POMP::fieldforce_a_peratom() u4 += x0*u_brick_a4[mz][my][mx]; u5 += x0*u_brick_a5[mz][my][mx]; u6 += x0*u_brick_a6[mz][my][mx]; - } + } if (vflag_atom) { v00 += x0*v0_brick_a0[mz][my][mx]; v10 += x0*v1_brick_a0[mz][my][mx]; @@ -1787,7 +1787,7 @@ void PPPMDispTIP4POMP::fieldforce_a_peratom() dx,dy,dz = distance of particle from "lower left" grid point ------------------------------------------------------------------------- */ void PPPMDispTIP4POMP::compute_rho1d_thr(FFT_SCALAR * const * const r1d, const FFT_SCALAR &dx, - const FFT_SCALAR &dy, const FFT_SCALAR &dz, + const FFT_SCALAR &dy, const FFT_SCALAR &dz, const int ord, FFT_SCALAR * const * const rho_c) { int k,l; @@ -1813,7 +1813,7 @@ void PPPMDispTIP4POMP::compute_rho1d_thr(FFT_SCALAR * const * const r1d, const F ------------------------------------------------------------------------- */ void PPPMDispTIP4POMP::compute_drho1d_thr(FFT_SCALAR * const * const dr1d, const FFT_SCALAR &dx, - const FFT_SCALAR &dy, const FFT_SCALAR &dz, + const FFT_SCALAR &dy, const FFT_SCALAR &dz, const int ord, FFT_SCALAR * const * const drho_c) { int k,l; diff --git a/src/USER-OMP/pppm_disp_tip4p_omp.h b/src/USER-OMP/pppm_disp_tip4p_omp.h index 296444366b..8f499e2964 100644 --- a/src/USER-OMP/pppm_disp_tip4p_omp.h +++ b/src/USER-OMP/pppm_disp_tip4p_omp.h @@ -63,7 +63,7 @@ namespace LAMMPS_NS { const FFT_SCALAR &, const FFT_SCALAR &, const int, FFT_SCALAR * const * const); void compute_drho1d_thr(FFT_SCALAR * const * const, const FFT_SCALAR &, - const FFT_SCALAR &, const FFT_SCALAR &, + const FFT_SCALAR &, const FFT_SCALAR &, const int, FFT_SCALAR * const * const); virtual void find_M_thr(int, int &, int &, dbl3_t &); diff --git a/src/USER-OMP/pppm_omp.cpp b/src/USER-OMP/pppm_omp.cpp index 48b91e3a7b..ef03ef1bba 100644 --- a/src/USER-OMP/pppm_omp.cpp +++ b/src/USER-OMP/pppm_omp.cpp @@ -718,7 +718,7 @@ void PPPMOMP::compute_rho1d_thr(FFT_SCALAR * const * const r1d, const FFT_SCALAR ------------------------------------------------------------------------- */ void PPPMOMP::compute_drho1d_thr(FFT_SCALAR * const * const d1d, const FFT_SCALAR &dx, - const FFT_SCALAR &dy, const FFT_SCALAR &dz) + const FFT_SCALAR &dy, const FFT_SCALAR &dz) { int k,l; FFT_SCALAR r1,r2,r3; diff --git a/src/USER-OMP/pppm_omp.h b/src/USER-OMP/pppm_omp.h index bf8a9e0c21..c447003605 100644 --- a/src/USER-OMP/pppm_omp.h +++ b/src/USER-OMP/pppm_omp.h @@ -46,7 +46,7 @@ class PPPMOMP : public PPPM, public ThrOMP { void compute_rho1d_thr(FFT_SCALAR * const * const, const FFT_SCALAR &, const FFT_SCALAR &, const FFT_SCALAR &); void compute_drho1d_thr(FFT_SCALAR * const * const, const FFT_SCALAR &, - const FFT_SCALAR &, const FFT_SCALAR &); + const FFT_SCALAR &, const FFT_SCALAR &); // void slabcorr(int); }; diff --git a/src/USER-OMP/pppm_tip4p_omp.cpp b/src/USER-OMP/pppm_tip4p_omp.cpp index 1eab140cec..f9733ed95b 100644 --- a/src/USER-OMP/pppm_tip4p_omp.cpp +++ b/src/USER-OMP/pppm_tip4p_omp.cpp @@ -871,7 +871,7 @@ void PPPMTIP4POMP::compute_rho1d_thr(FFT_SCALAR * const * const r1d, const FFT_S ------------------------------------------------------------------------- */ void PPPMTIP4POMP::compute_drho1d_thr(FFT_SCALAR * const * const d1d, const FFT_SCALAR &dx, - const FFT_SCALAR &dy, const FFT_SCALAR &dz) + const FFT_SCALAR &dy, const FFT_SCALAR &dz) { int k,l; FFT_SCALAR r1,r2,r3; diff --git a/src/USER-OMP/pppm_tip4p_omp.h b/src/USER-OMP/pppm_tip4p_omp.h index 59559cd587..1060f73c07 100644 --- a/src/USER-OMP/pppm_tip4p_omp.h +++ b/src/USER-OMP/pppm_tip4p_omp.h @@ -48,7 +48,7 @@ class PPPMTIP4POMP : public PPPMTIP4P, public ThrOMP { void compute_rho1d_thr(FFT_SCALAR * const * const, const FFT_SCALAR &, const FFT_SCALAR &, const FFT_SCALAR &); void compute_drho1d_thr(FFT_SCALAR * const * const, const FFT_SCALAR &, - const FFT_SCALAR &, const FFT_SCALAR &); + const FFT_SCALAR &, const FFT_SCALAR &); void find_M_thr(const int, int &, int &, dbl3_t &); diff --git a/src/USER-OMP/reaxc_bond_orders_omp.cpp b/src/USER-OMP/reaxc_bond_orders_omp.cpp index e0bd5e9f94..e0b08fa49e 100644 --- a/src/USER-OMP/reaxc_bond_orders_omp.cpp +++ b/src/USER-OMP/reaxc_bond_orders_omp.cpp @@ -118,8 +118,8 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, rvec_ScaledSum( delij, 1., system->my_atoms[i].x,-1., system->my_atoms[j].x ); pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,i,j,system->N,0,0,0, - fi_tmp[0],fi_tmp[1],fi_tmp[2], - delij[0],delij[1],delij[2],thr); + fi_tmp[0],fi_tmp[1],fi_tmp[2], + delij[0],delij[1],delij[2],thr); } // forces on j @@ -152,8 +152,8 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, rvec_ScaledSum( delji, 1., system->my_atoms[j].x,-1., system->my_atoms[i].x ); pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,j,i,system->N,0,0,0, - fj_tmp[0],fj_tmp[1],fj_tmp[2], - delji[0],delji[1],delji[2],thr); + fj_tmp[0],fj_tmp[1],fj_tmp[2], + delji[0],delji[1],delji[2],thr); } // forces on k: i neighbor @@ -176,13 +176,13 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, rvec_ScaledSum(delki,1.,system->my_atoms[k].x,-1.,system->my_atoms[i].x); pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,k,i,system->N,0,0,0, - fk_tmp[0],fk_tmp[1],fk_tmp[2], - delki[0],delki[1],delki[2],thr); + fk_tmp[0],fk_tmp[1],fk_tmp[2], + delki[0],delki[1],delki[2],thr); rvec_ScaledSum(delkj,1.,system->my_atoms[k].x,-1.,system->my_atoms[j].x); pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,k,j,system->N,0,0,0, - fk_tmp[0],fk_tmp[1],fk_tmp[2], - delkj[0],delkj[1],delkj[2],thr); + fk_tmp[0],fk_tmp[1],fk_tmp[2], + delkj[0],delkj[1],delkj[2],thr); } } @@ -206,14 +206,14 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, rvec_ScaledSum(delki,1.,system->my_atoms[k].x,-1.,system->my_atoms[i].x); pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,k,i,system->N,0,0,0, - fk_tmp[0],fk_tmp[1],fk_tmp[2], - delki[0],delki[1],delki[2],thr); + fk_tmp[0],fk_tmp[1],fk_tmp[2], + delki[0],delki[1],delki[2],thr); rvec_ScaledSum(delkj,1.,system->my_atoms[k].x,-1.,system->my_atoms[j].x); pair_reax_ptr->ev_tally_xyz_thr_proxy(system->pair_ptr,k,j,system->N,0,0,0, - fk_tmp[0],fk_tmp[1],fk_tmp[2], - delkj[0],delkj[1],delkj[2],thr); + fk_tmp[0],fk_tmp[1],fk_tmp[2], + delkj[0],delkj[1],delkj[2],thr); } } } @@ -221,7 +221,7 @@ void Add_dBond_to_ForcesOMP( reax_system *system, int i, int pj, /* ---------------------------------------------------------------------- */ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, simulation_data *data, - storage *workspace, reax_list **lists ) { + storage *workspace, reax_list **lists ) { reax_list *bonds = (*lists) + BONDS; bond_data *nbr_j, *nbr_k; bond_order_data *bo_ij, *bo_ji; @@ -344,10 +344,10 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int i, int pj, simulation_ /* ---------------------------------------------------------------------- */ int BOp_OMP( storage *workspace, reax_list *bonds, double bo_cut, - int i, int btop_i, far_neighbor_data *nbr_pj, - single_body_parameters *sbp_i, single_body_parameters *sbp_j, - two_body_parameters *twbp, - int btop_j, double C12, double C34, double C56, double BO, double BO_s, double BO_pi, double BO_pi2) { + int i, int btop_i, far_neighbor_data *nbr_pj, + single_body_parameters *sbp_i, single_body_parameters *sbp_j, + two_body_parameters *twbp, + int btop_j, double C12, double C34, double C56, double BO, double BO_s, double BO_pi, double BO_pi2) { int j; double rr2; double Cln_BOp_s, Cln_BOp_pi, Cln_BOp_pi2; @@ -395,15 +395,15 @@ int BOp_OMP( storage *workspace, reax_list *bonds, double bo_cut, rvec_Scale(bo_ij->dln_BOp_s,-bo_ij->BO_s*Cln_BOp_s,ibond->dvec); rvec_Scale(bo_ij->dln_BOp_pi,-bo_ij->BO_pi*Cln_BOp_pi,ibond->dvec); rvec_Scale(bo_ij->dln_BOp_pi2, - -bo_ij->BO_pi2*Cln_BOp_pi2,ibond->dvec); + -bo_ij->BO_pi2*Cln_BOp_pi2,ibond->dvec); rvec_Scale(bo_ji->dln_BOp_s, -1., bo_ij->dln_BOp_s); rvec_Scale(bo_ji->dln_BOp_pi, -1., bo_ij->dln_BOp_pi ); rvec_Scale(bo_ji->dln_BOp_pi2, -1., bo_ij->dln_BOp_pi2 ); rvec_Scale( bo_ij->dBOp, - -(bo_ij->BO_s * Cln_BOp_s + - bo_ij->BO_pi * Cln_BOp_pi + - bo_ij->BO_pi2 * Cln_BOp_pi2), ibond->dvec ); + -(bo_ij->BO_s * Cln_BOp_s + + bo_ij->BO_pi * Cln_BOp_pi + + bo_ij->BO_pi2 * Cln_BOp_pi2), ibond->dvec ); rvec_Scale( bo_ji->dBOp, -1., bo_ij->dBOp ); bo_ij->BO_s -= bo_cut; @@ -420,7 +420,7 @@ int BOp_OMP( storage *workspace, reax_list *bonds, double bo_cut, /* ---------------------------------------------------------------------- */ void BOOMP( reax_system *system, control_params *control, simulation_data *data, - storage *workspace, reax_list **lists, output_controls *out_control ) + storage *workspace, reax_list **lists, output_controls *out_control ) { #ifdef OMP_TIMING double endTimeBase, startTimeBase; @@ -459,7 +459,7 @@ void BOOMP( reax_system *system, control_params *control, simulation_data *data, sbp_i = &(system->reax_param.sbp[type_i]); workspace->Deltap[i] = workspace->total_bond_order[i] - sbp_i->valency; workspace->Deltap_boc[i] = - workspace->total_bond_order[i] - sbp_i->valency_val; + workspace->total_bond_order[i] - sbp_i->valency_val; workspace->total_bond_order[i] = 0; } @@ -484,151 +484,151 @@ void BOOMP( reax_system *system, control_params *control, simulation_data *data, end_i = End_Index(i, bonds); for (pj = start_i; pj < end_i; ++pj) { - j = bonds->select.bond_list[pj].nbr; - type_j = system->my_atoms[j].type; - if(type_j < 0) continue; - bo_ij = &( bonds->select.bond_list[pj].bo_data ); - - if( i < j || workspace->bond_mark[j] > 3) { - twbp = &( system->reax_param.tbp[type_i][type_j] ); - - if( twbp->ovc < 0.001 && twbp->v13cor < 0.001 ) { - bo_ij->C1dbo = 1.000000; - bo_ij->C2dbo = 0.000000; - bo_ij->C3dbo = 0.000000; - - bo_ij->C1dbopi = 1.000000; - bo_ij->C2dbopi = 0.000000; - bo_ij->C3dbopi = 0.000000; - bo_ij->C4dbopi = 0.000000; - - bo_ij->C1dbopi2 = 1.000000; - bo_ij->C2dbopi2 = 0.000000; - bo_ij->C3dbopi2 = 0.000000; - bo_ij->C4dbopi2 = 0.000000; - - } - else { - val_j = system->reax_param.sbp[type_j].valency; - Deltap_j = workspace->Deltap[j]; - Deltap_boc_j = workspace->Deltap_boc[j]; - - /* on page 1 */ - if( twbp->ovc >= 0.001 ) { - /* Correction for overcoordination */ - exp_p1i = exp( -p_boc1 * Deltap_i ); - exp_p2i = exp( -p_boc2 * Deltap_i ); - exp_p1j = exp( -p_boc1 * Deltap_j ); - exp_p2j = exp( -p_boc2 * Deltap_j ); - - f2 = exp_p1i + exp_p1j; - f3 = -1.0 / p_boc2 * log( 0.5 * ( exp_p2i + exp_p2j ) ); - f1 = 0.5 * ( ( val_i + f2 )/( val_i + f2 + f3 ) + - ( val_j + f2 )/( val_j + f2 + f3 ) ); - - /* Now come the derivates */ - /* Bond Order pages 5-7, derivative of f1 */ - temp = f2 + f3; - u1_ij = val_i + temp; - u1_ji = val_j + temp; - Cf1A_ij = 0.5 * f3 * (1.0 / SQR( u1_ij ) + - 1.0 / SQR( u1_ji )); - Cf1B_ij = -0.5 * (( u1_ij - f3 ) / SQR( u1_ij ) + - ( u1_ji - f3 ) / SQR( u1_ji )); - - Cf1_ij = 0.50 * ( -p_boc1 * exp_p1i / u1_ij - - ((val_i+f2) / SQR(u1_ij)) * - ( -p_boc1 * exp_p1i + - exp_p2i / ( exp_p2i + exp_p2j ) ) + - -p_boc1 * exp_p1i / u1_ji - - ((val_j+f2) / SQR(u1_ji)) * - ( -p_boc1 * exp_p1i + - exp_p2i / ( exp_p2i + exp_p2j ) )); - - - Cf1_ji = -Cf1A_ij * p_boc1 * exp_p1j + - Cf1B_ij * exp_p2j / ( exp_p2i + exp_p2j ); - } - else { - /* No overcoordination correction! */ - f1 = 1.0; - Cf1_ij = Cf1_ji = 0.0; - } - - if( twbp->v13cor >= 0.001 ) { - /* Correction for 1-3 bond orders */ - exp_f4 =exp(-(twbp->p_boc4 * SQR( bo_ij->BO ) - - Deltap_boc_i) * twbp->p_boc3 + twbp->p_boc5); - exp_f5 =exp(-(twbp->p_boc4 * SQR( bo_ij->BO ) - - Deltap_boc_j) * twbp->p_boc3 + twbp->p_boc5); - - f4 = 1. / (1. + exp_f4); - f5 = 1. / (1. + exp_f5); - f4f5 = f4 * f5; - - /* Bond Order pages 8-9, derivative of f4 and f5 */ - Cf45_ij = -f4 * exp_f4; - Cf45_ji = -f5 * exp_f5; - } - else { - f4 = f5 = f4f5 = 1.0; - Cf45_ij = Cf45_ji = 0.0; - } - - /* Bond Order page 10, derivative of total bond order */ - A0_ij = f1 * f4f5; - A1_ij = -2 * twbp->p_boc3 * twbp->p_boc4 * bo_ij->BO * - (Cf45_ij + Cf45_ji); - A2_ij = Cf1_ij / f1 + twbp->p_boc3 * Cf45_ij; - A2_ji = Cf1_ji / f1 + twbp->p_boc3 * Cf45_ji; - A3_ij = A2_ij + Cf1_ij / f1; - A3_ji = A2_ji + Cf1_ji / f1; - - /* find corrected bond orders and their derivative coef */ - bo_ij->BO = bo_ij->BO * A0_ij; - bo_ij->BO_pi = bo_ij->BO_pi * A0_ij *f1; - bo_ij->BO_pi2= bo_ij->BO_pi2* A0_ij *f1; - bo_ij->BO_s = bo_ij->BO - ( bo_ij->BO_pi + bo_ij->BO_pi2 ); - - bo_ij->C1dbo = A0_ij + bo_ij->BO * A1_ij; - bo_ij->C2dbo = bo_ij->BO * A2_ij; - bo_ij->C3dbo = bo_ij->BO * A2_ji; - - bo_ij->C1dbopi = f1*f1*f4*f5; - bo_ij->C2dbopi = bo_ij->BO_pi * A1_ij; - bo_ij->C3dbopi = bo_ij->BO_pi * A3_ij; - bo_ij->C4dbopi = bo_ij->BO_pi * A3_ji; - - bo_ij->C1dbopi2 = f1*f1*f4*f5; - bo_ij->C2dbopi2 = bo_ij->BO_pi2 * A1_ij; - bo_ij->C3dbopi2 = bo_ij->BO_pi2 * A3_ij; - bo_ij->C4dbopi2 = bo_ij->BO_pi2 * A3_ji; - } - - /* neglect bonds that are < 1e-10 */ - if( bo_ij->BO < 1e-10 ) - bo_ij->BO = 0.0; - if( bo_ij->BO_s < 1e-10 ) - bo_ij->BO_s = 0.0; - if( bo_ij->BO_pi < 1e-10 ) - bo_ij->BO_pi = 0.0; - if( bo_ij->BO_pi2 < 1e-10 ) - bo_ij->BO_pi2 = 0.0; - - workspace->total_bond_order[i] += bo_ij->BO; //now keeps total_BO - } - // else { - // /* We only need to update bond orders from bo_ji - // everything else is set in uncorrected_bo calculations */ - // sym_index = bonds->select.bond_list[pj].sym_index; - // bo_ji = &(bonds->select.bond_list[ sym_index ].bo_data); - // bo_ij->BO = bo_ji->BO; - // bo_ij->BO_s = bo_ji->BO_s; - // bo_ij->BO_pi = bo_ji->BO_pi; - // bo_ij->BO_pi2 = bo_ji->BO_pi2; - - // workspace->total_bond_order[i] += bo_ij->BO;// now keeps total_BO - // } + j = bonds->select.bond_list[pj].nbr; + type_j = system->my_atoms[j].type; + if(type_j < 0) continue; + bo_ij = &( bonds->select.bond_list[pj].bo_data ); + + if( i < j || workspace->bond_mark[j] > 3) { + twbp = &( system->reax_param.tbp[type_i][type_j] ); + + if( twbp->ovc < 0.001 && twbp->v13cor < 0.001 ) { + bo_ij->C1dbo = 1.000000; + bo_ij->C2dbo = 0.000000; + bo_ij->C3dbo = 0.000000; + + bo_ij->C1dbopi = 1.000000; + bo_ij->C2dbopi = 0.000000; + bo_ij->C3dbopi = 0.000000; + bo_ij->C4dbopi = 0.000000; + + bo_ij->C1dbopi2 = 1.000000; + bo_ij->C2dbopi2 = 0.000000; + bo_ij->C3dbopi2 = 0.000000; + bo_ij->C4dbopi2 = 0.000000; + + } + else { + val_j = system->reax_param.sbp[type_j].valency; + Deltap_j = workspace->Deltap[j]; + Deltap_boc_j = workspace->Deltap_boc[j]; + + /* on page 1 */ + if( twbp->ovc >= 0.001 ) { + /* Correction for overcoordination */ + exp_p1i = exp( -p_boc1 * Deltap_i ); + exp_p2i = exp( -p_boc2 * Deltap_i ); + exp_p1j = exp( -p_boc1 * Deltap_j ); + exp_p2j = exp( -p_boc2 * Deltap_j ); + + f2 = exp_p1i + exp_p1j; + f3 = -1.0 / p_boc2 * log( 0.5 * ( exp_p2i + exp_p2j ) ); + f1 = 0.5 * ( ( val_i + f2 )/( val_i + f2 + f3 ) + + ( val_j + f2 )/( val_j + f2 + f3 ) ); + + /* Now come the derivates */ + /* Bond Order pages 5-7, derivative of f1 */ + temp = f2 + f3; + u1_ij = val_i + temp; + u1_ji = val_j + temp; + Cf1A_ij = 0.5 * f3 * (1.0 / SQR( u1_ij ) + + 1.0 / SQR( u1_ji )); + Cf1B_ij = -0.5 * (( u1_ij - f3 ) / SQR( u1_ij ) + + ( u1_ji - f3 ) / SQR( u1_ji )); + + Cf1_ij = 0.50 * ( -p_boc1 * exp_p1i / u1_ij - + ((val_i+f2) / SQR(u1_ij)) * + ( -p_boc1 * exp_p1i + + exp_p2i / ( exp_p2i + exp_p2j ) ) + + -p_boc1 * exp_p1i / u1_ji - + ((val_j+f2) / SQR(u1_ji)) * + ( -p_boc1 * exp_p1i + + exp_p2i / ( exp_p2i + exp_p2j ) )); + + + Cf1_ji = -Cf1A_ij * p_boc1 * exp_p1j + + Cf1B_ij * exp_p2j / ( exp_p2i + exp_p2j ); + } + else { + /* No overcoordination correction! */ + f1 = 1.0; + Cf1_ij = Cf1_ji = 0.0; + } + + if( twbp->v13cor >= 0.001 ) { + /* Correction for 1-3 bond orders */ + exp_f4 =exp(-(twbp->p_boc4 * SQR( bo_ij->BO ) - + Deltap_boc_i) * twbp->p_boc3 + twbp->p_boc5); + exp_f5 =exp(-(twbp->p_boc4 * SQR( bo_ij->BO ) - + Deltap_boc_j) * twbp->p_boc3 + twbp->p_boc5); + + f4 = 1. / (1. + exp_f4); + f5 = 1. / (1. + exp_f5); + f4f5 = f4 * f5; + + /* Bond Order pages 8-9, derivative of f4 and f5 */ + Cf45_ij = -f4 * exp_f4; + Cf45_ji = -f5 * exp_f5; + } + else { + f4 = f5 = f4f5 = 1.0; + Cf45_ij = Cf45_ji = 0.0; + } + + /* Bond Order page 10, derivative of total bond order */ + A0_ij = f1 * f4f5; + A1_ij = -2 * twbp->p_boc3 * twbp->p_boc4 * bo_ij->BO * + (Cf45_ij + Cf45_ji); + A2_ij = Cf1_ij / f1 + twbp->p_boc3 * Cf45_ij; + A2_ji = Cf1_ji / f1 + twbp->p_boc3 * Cf45_ji; + A3_ij = A2_ij + Cf1_ij / f1; + A3_ji = A2_ji + Cf1_ji / f1; + + /* find corrected bond orders and their derivative coef */ + bo_ij->BO = bo_ij->BO * A0_ij; + bo_ij->BO_pi = bo_ij->BO_pi * A0_ij *f1; + bo_ij->BO_pi2= bo_ij->BO_pi2* A0_ij *f1; + bo_ij->BO_s = bo_ij->BO - ( bo_ij->BO_pi + bo_ij->BO_pi2 ); + + bo_ij->C1dbo = A0_ij + bo_ij->BO * A1_ij; + bo_ij->C2dbo = bo_ij->BO * A2_ij; + bo_ij->C3dbo = bo_ij->BO * A2_ji; + + bo_ij->C1dbopi = f1*f1*f4*f5; + bo_ij->C2dbopi = bo_ij->BO_pi * A1_ij; + bo_ij->C3dbopi = bo_ij->BO_pi * A3_ij; + bo_ij->C4dbopi = bo_ij->BO_pi * A3_ji; + + bo_ij->C1dbopi2 = f1*f1*f4*f5; + bo_ij->C2dbopi2 = bo_ij->BO_pi2 * A1_ij; + bo_ij->C3dbopi2 = bo_ij->BO_pi2 * A3_ij; + bo_ij->C4dbopi2 = bo_ij->BO_pi2 * A3_ji; + } + + /* neglect bonds that are < 1e-10 */ + if( bo_ij->BO < 1e-10 ) + bo_ij->BO = 0.0; + if( bo_ij->BO_s < 1e-10 ) + bo_ij->BO_s = 0.0; + if( bo_ij->BO_pi < 1e-10 ) + bo_ij->BO_pi = 0.0; + if( bo_ij->BO_pi2 < 1e-10 ) + bo_ij->BO_pi2 = 0.0; + + workspace->total_bond_order[i] += bo_ij->BO; //now keeps total_BO + } + // else { + // /* We only need to update bond orders from bo_ji + // everything else is set in uncorrected_bo calculations */ + // sym_index = bonds->select.bond_list[pj].sym_index; + // bo_ji = &(bonds->select.bond_list[ sym_index ].bo_data); + // bo_ij->BO = bo_ji->BO; + // bo_ij->BO_s = bo_ji->BO_s; + // bo_ij->BO_pi = bo_ji->BO_pi; + // bo_ij->BO_pi2 = bo_ji->BO_pi2; + + // workspace->total_bond_order[i] += bo_ij->BO;// now keeps total_BO + // } } } @@ -649,26 +649,26 @@ void BOOMP( reax_system *system, control_params *control, simulation_data *data, end_i = End_Index(i, bonds); for (pj = start_i; pj < end_i; ++pj) { - j = bonds->select.bond_list[pj].nbr; - type_j = system->my_atoms[j].type; - if(type_j < 0) continue; - - if( i < j || workspace->bond_mark[j] > 3) { - // Computed in previous for-loop - } else { - /* We only need to update bond orders from bo_ji - everything else is set in uncorrected_bo calculations */ - sym_index = bonds->select.bond_list[pj].sym_index; - - bo_ij = &( bonds->select.bond_list[pj].bo_data ); - bo_ji = &(bonds->select.bond_list[ sym_index ].bo_data); - bo_ij->BO = bo_ji->BO; - bo_ij->BO_s = bo_ji->BO_s; - bo_ij->BO_pi = bo_ji->BO_pi; - bo_ij->BO_pi2 = bo_ji->BO_pi2; - - workspace->total_bond_order[i] += bo_ij->BO;// now keeps total_BO - } + j = bonds->select.bond_list[pj].nbr; + type_j = system->my_atoms[j].type; + if(type_j < 0) continue; + + if( i < j || workspace->bond_mark[j] > 3) { + // Computed in previous for-loop + } else { + /* We only need to update bond orders from bo_ji + everything else is set in uncorrected_bo calculations */ + sym_index = bonds->select.bond_list[pj].sym_index; + + bo_ij = &( bonds->select.bond_list[pj].bo_data ); + bo_ji = &(bonds->select.bond_list[ sym_index ].bo_data); + bo_ij->BO = bo_ji->BO; + bo_ij->BO_s = bo_ji->BO_s; + bo_ij->BO_pi = bo_ji->BO_pi; + bo_ij->BO_pi2 = bo_ji->BO_pi2; + + workspace->total_bond_order[i] += bo_ij->BO;// now keeps total_BO + } } } @@ -692,12 +692,12 @@ void BOOMP( reax_system *system, control_params *control, simulation_data *data, workspace->Delta[j] = workspace->total_bond_order[j] - sbp_j->valency; workspace->Delta_e[j] = workspace->total_bond_order[j] - sbp_j->valency_e; workspace->Delta_boc[j] = workspace->total_bond_order[j] - - sbp_j->valency_boc; + sbp_j->valency_boc; workspace->Delta_val[j] = workspace->total_bond_order[j] - - sbp_j->valency_val; + sbp_j->valency_val; workspace->vlpex[j] = workspace->Delta_e[j] - - 2.0 * (int)(workspace->Delta_e[j]/2.0); + 2.0 * (int)(workspace->Delta_e[j]/2.0); explp1 = exp(-p_lp1 * SQR(2.0 + workspace->vlpex[j])); workspace->nlp[j] = explp1 - (int)(workspace->Delta_e[j] / 2.0); workspace->Delta_lp[j] = sbp_j->nlp_opt - workspace->nlp[j]; @@ -705,22 +705,22 @@ void BOOMP( reax_system *system, control_params *control, simulation_data *data, workspace->dDelta_lp[j] = workspace->Clp[j]; if( sbp_j->mass > 21.0 ) { - workspace->nlp_temp[j] = 0.5 * (sbp_j->valency_e - sbp_j->valency); - workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; - workspace->dDelta_lp_temp[j] = 0.; + workspace->nlp_temp[j] = 0.5 * (sbp_j->valency_e - sbp_j->valency); + workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; + workspace->dDelta_lp_temp[j] = 0.; } else { - workspace->nlp_temp[j] = workspace->nlp[j]; - workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; - workspace->dDelta_lp_temp[j] = workspace->Clp[j]; + workspace->nlp_temp[j] = workspace->nlp[j]; + workspace->Delta_lp_temp[j] = sbp_j->nlp_opt - workspace->nlp_temp[j]; + workspace->dDelta_lp_temp[j] = workspace->Clp[j]; } } } // parallel region #ifdef OMP_TIMING - endTimeBase = MPI_Wtime(); - ompTimingData[COMPUTEBOINDEX] += (endTimeBase-startTimeBase); + endTimeBase = MPI_Wtime(); + ompTimingData[COMPUTEBOINDEX] += (endTimeBase-startTimeBase); #endif } diff --git a/src/USER-OMP/reaxc_bond_orders_omp.h b/src/USER-OMP/reaxc_bond_orders_omp.h index cea31539a9..36be3337ad 100644 --- a/src/USER-OMP/reaxc_bond_orders_omp.h +++ b/src/USER-OMP/reaxc_bond_orders_omp.h @@ -37,8 +37,8 @@ void Add_dBond_to_Forces_NPTOMP( reax_system *system, int, int, simulation_data*, storage*, reax_list** ); int BOp_OMP(storage*, reax_list*, double, int, int, far_neighbor_data*, - single_body_parameters*, single_body_parameters*, two_body_parameters*, - int, double, double, double, double, double, double, double); + single_body_parameters*, single_body_parameters*, two_body_parameters*, + int, double, double, double, double, double, double, double); void BOOMP( reax_system*, control_params*, simulation_data*, storage*, reax_list**, output_controls* ); diff --git a/src/USER-OMP/reaxc_bonds_omp.cpp b/src/USER-OMP/reaxc_bonds_omp.cpp index 7522df2f60..bc038e2aa1 100644 --- a/src/USER-OMP/reaxc_bonds_omp.cpp +++ b/src/USER-OMP/reaxc_bonds_omp.cpp @@ -86,8 +86,8 @@ void BondsOMP( reax_system *system, control_params *control, class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); pair_reax_ptr->ev_setup_thr_proxy(system->pair_ptr->eflag_either, - system->pair_ptr->vflag_either, system->N, - system->pair_ptr->eatom, system->pair_ptr->vatom, thr); + system->pair_ptr->vflag_either, system->N, + system->pair_ptr->eatom, system->pair_ptr->vatom, thr); #if defined(_OPENMP) #pragma omp for schedule(guided) @@ -103,11 +103,11 @@ void BondsOMP( reax_system *system, control_params *control, if( system->my_atoms[i].orig_id == system->my_atoms[j].orig_id ) { if (system->my_atoms[j].x[2] < system->my_atoms[i].x[2]) continue; - if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && - system->my_atoms[j].x[1] < system->my_atoms[i].x[1]) continue; if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && - system->my_atoms[j].x[1] == system->my_atoms[i].x[1] && - system->my_atoms[j].x[0] < system->my_atoms[i].x[0]) continue; + system->my_atoms[j].x[1] < system->my_atoms[i].x[1]) continue; + if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && + system->my_atoms[j].x[1] == system->my_atoms[i].x[1] && + system->my_atoms[j].x[0] < system->my_atoms[i].x[0]) continue; } /* set the pointers */ @@ -123,18 +123,18 @@ void BondsOMP( reax_system *system, control_params *control, else pow_BOs_be2 = pow( bo_ij->BO_s, twbp->p_be2 ); exp_be12 = exp( twbp->p_be1 * ( 1.0 - pow_BOs_be2 ) ); CEbo = -twbp->De_s * exp_be12 * - ( 1.0 - twbp->p_be1 * twbp->p_be2 * pow_BOs_be2 ); + ( 1.0 - twbp->p_be1 * twbp->p_be2 * pow_BOs_be2 ); /* calculate the Bond Energy */ total_Ebond += ebond = - -twbp->De_s * bo_ij->BO_s * exp_be12 - -twbp->De_p * bo_ij->BO_pi - -twbp->De_pp * bo_ij->BO_pi2; + -twbp->De_s * bo_ij->BO_s * exp_be12 + -twbp->De_p * bo_ij->BO_pi + -twbp->De_pp * bo_ij->BO_pi2; /* tally into per-atom energy */ if (system->pair_ptr->evflag) - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, natoms, 1, - ebond, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, natoms, 1, + ebond, 0.0, 0.0, 0.0, 0.0, 0.0, thr); /* calculate derivatives of Bond Orders */ bo_ij->Cdbo += CEbo; @@ -143,33 +143,33 @@ void BondsOMP( reax_system *system, control_params *control, /* Stabilisation terminal triple bond */ if (bo_ij->BO >= 1.00) { - if (gp37 == 2 || - (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || - (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990)) { - exphu = exp( -gp7 * SQR(bo_ij->BO - 2.50) ); - exphua1 = exp(-gp3 * (workspace->total_bond_order[i]-bo_ij->BO)); - exphub1 = exp(-gp3 * (workspace->total_bond_order[j]-bo_ij->BO)); - exphuov = exp(gp4 * (workspace->Delta[i] + workspace->Delta[j])); - hulpov = 1.0 / (1.0 + 25.0 * exphuov); - - estriph = gp10 * exphu * hulpov * (exphua1 + exphub1); - total_Ebond += estriph; - - decobdbo = gp10 * exphu * hulpov * (exphua1 + exphub1) * - ( gp3 - 2.0 * gp7 * (bo_ij->BO-2.50) ); - decobdboua = -gp10 * exphu * hulpov * - (gp3*exphua1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); - decobdboub = -gp10 * exphu * hulpov * - (gp3*exphub1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); - - /* tally into per-atom energy */ - if (system->pair_ptr->evflag) - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, natoms, 1, - estriph, 0.0, 0.0, 0.0, 0.0, 0.0, thr); - - bo_ij->Cdbo += decobdbo; - workspace->CdDelta[i] += decobdboua; - workspace->CdDeltaReduction[reductionOffset+j] += decobdboub; + if (gp37 == 2 || + (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || + (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990)) { + exphu = exp( -gp7 * SQR(bo_ij->BO - 2.50) ); + exphua1 = exp(-gp3 * (workspace->total_bond_order[i]-bo_ij->BO)); + exphub1 = exp(-gp3 * (workspace->total_bond_order[j]-bo_ij->BO)); + exphuov = exp(gp4 * (workspace->Delta[i] + workspace->Delta[j])); + hulpov = 1.0 / (1.0 + 25.0 * exphuov); + + estriph = gp10 * exphu * hulpov * (exphua1 + exphub1); + total_Ebond += estriph; + + decobdbo = gp10 * exphu * hulpov * (exphua1 + exphub1) * + ( gp3 - 2.0 * gp7 * (bo_ij->BO-2.50) ); + decobdboua = -gp10 * exphu * hulpov * + (gp3*exphua1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); + decobdboub = -gp10 * exphu * hulpov * + (gp3*exphub1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); + + /* tally into per-atom energy */ + if (system->pair_ptr->evflag) + pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, natoms, 1, + estriph, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + + bo_ij->Cdbo += decobdbo; + workspace->CdDelta[i] += decobdboua; + workspace->CdDeltaReduction[reductionOffset+j] += decobdboub; } } } diff --git a/src/USER-OMP/reaxc_forces_omp.cpp b/src/USER-OMP/reaxc_forces_omp.cpp index 321d104b00..f02c527d9f 100644 --- a/src/USER-OMP/reaxc_forces_omp.cpp +++ b/src/USER-OMP/reaxc_forces_omp.cpp @@ -115,10 +115,10 @@ void Compute_NonBonded_ForcesOMP( reax_system *system, control_params *control, if( control->tabulate == 0 ) vdW_Coulomb_Energy_OMP( system, control, data, workspace, - lists, out_control ); + lists, out_control ); else Tabulated_vdW_Coulomb_Energy_OMP( system, control, data, workspace, - lists, out_control ); + lists, out_control ); #ifdef OMP_TIMING endTimeBase = MPI_Wtime(); @@ -162,14 +162,14 @@ void Compute_Total_ForceOMP( reax_system *system, control_params *control, class ThrData *thr = pair_reax_ptr->getFixOMP()->get_thr(tid); pair_reax_ptr->ev_setup_thr_proxy(0, 1, natoms, system->pair_ptr->eatom, - system->pair_ptr->vatom, thr); + system->pair_ptr->vatom, thr); #if defined(_OPENMP) #pragma omp for schedule(guided) #endif for (i = 0; i < system->N; ++i) { for (j = 0; j < nthreads; ++j) - workspace->CdDelta[i] += workspace->CdDeltaReduction[system->N*j+i]; + workspace->CdDelta[i] += workspace->CdDeltaReduction[system->N*j+i]; } #if defined(_OPENMP) @@ -180,21 +180,21 @@ void Compute_Total_ForceOMP( reax_system *system, control_params *control, end_j = End_Index(j, bonds); for (pk = start_j; pk < end_j; ++pk) { - bo_jk = &( bonds->select.bond_list[pk].bo_data ); - for (k = 0; k < nthreads; ++k) - bo_jk->Cdbo += bo_jk->CdboReduction[k]; + bo_jk = &( bonds->select.bond_list[pk].bo_data ); + for (k = 0; k < nthreads; ++k) + bo_jk->Cdbo += bo_jk->CdboReduction[k]; } } // #pragma omp for schedule(guided) //(dynamic,50) // for (i = 0; i < system->N; ++i) // for (pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj) -// if (i < bonds->select.bond_list[pj].nbr) { -// if (control->virial == 0) -// Add_dBond_to_ForcesOMP( system, i, pj, workspace, lists ); -// else -// Add_dBond_to_Forces_NPTOMP(system, i, pj, data, workspace, lists ); -// } +// if (i < bonds->select.bond_list[pj].nbr) { +// if (control->virial == 0) +// Add_dBond_to_ForcesOMP( system, i, pj, workspace, lists ); +// else +// Add_dBond_to_Forces_NPTOMP(system, i, pj, data, workspace, lists ); +// } if(control->virial == 0) { @@ -202,11 +202,11 @@ void Compute_Total_ForceOMP( reax_system *system, control_params *control, #pragma omp for schedule(dynamic,50) #endif for (i = 0; i < system->N; ++i) { - const int startj = Start_Index(i, bonds); - const int endj = End_Index(i, bonds); - for (pj = startj; pj < endj; ++pj) - if (i < bonds->select.bond_list[pj].nbr) - Add_dBond_to_ForcesOMP( system, i, pj, workspace, lists ); + const int startj = Start_Index(i, bonds); + const int endj = End_Index(i, bonds); + for (pj = startj; pj < endj; ++pj) + if (i < bonds->select.bond_list[pj].nbr) + Add_dBond_to_ForcesOMP( system, i, pj, workspace, lists ); } } else { @@ -215,11 +215,11 @@ void Compute_Total_ForceOMP( reax_system *system, control_params *control, #pragma omp for schedule(dynamic,50) #endif for (i = 0; i < system->N; ++i) { - const int startj = Start_Index(i, bonds); - const int endj = End_Index(i, bonds); - for (pj = startj; pj < endj; ++pj) - if (i < bonds->select.bond_list[pj].nbr) - Add_dBond_to_Forces_NPTOMP(system, i, pj, data, workspace, lists ); + const int startj = Start_Index(i, bonds); + const int endj = End_Index(i, bonds); + for (pj = startj; pj < endj; ++pj) + if (i < bonds->select.bond_list[pj].nbr) + Add_dBond_to_Forces_NPTOMP(system, i, pj, data, workspace, lists ); } } // if(virial == 0) @@ -231,7 +231,7 @@ void Compute_Total_ForceOMP( reax_system *system, control_params *control, #endif for (i = 0; i < system->N; ++i) { for (j = 0; j < nthreads; ++j) - rvec_Add( workspace->f[i], workspace->forceReduction[system->N*j+i] ); + rvec_Add( workspace->f[i], workspace->forceReduction[system->N*j+i] ); } @@ -328,9 +328,9 @@ void Validate_ListsOMP( reax_system *system, storage *workspace, reax_list **lis void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control, - MPI_Comm comm ) { + simulation_data *data, storage *workspace, + reax_list **lists, output_controls *out_control, + MPI_Comm comm ) { #ifdef OMP_TIMING double startTimeBase, endTimeBase; startTimeBase = MPI_Wtime(); @@ -393,88 +393,88 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, for( pj = start_i; pj < end_i; ++pj ) { nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); if (nbr_pj->d <= cutoff) { - j = nbr_pj->nbr; - atom_j = &(system->my_atoms[j]); - type_j = atom_j->type; - sbp_j = &(system->reax_param.sbp[type_j]); - twbp = &(system->reax_param.tbp[type_i][type_j]); + j = nbr_pj->nbr; + atom_j = &(system->my_atoms[j]); + type_j = atom_j->type; + sbp_j = &(system->reax_param.sbp[type_j]); + twbp = &(system->reax_param.tbp[type_i][type_j]); // #pragma omp critical -// { -// btop_i = End_Index(i, bonds); -// if( BOp(workspace, bonds, control->bo_cut, i, btop_i, nbr_pj, sbp_i, sbp_j, twbp) ) { +// { +// btop_i = End_Index(i, bonds); +// if( BOp(workspace, bonds, control->bo_cut, i, btop_i, nbr_pj, sbp_i, sbp_j, twbp) ) { // num_bonds++; // btop_i++; // Set_End_Index(i, btop_i, bonds); -// } - -// } - - // Trying to minimize time spent in critical section by moving initial part of BOp() - // outside of critical section. - - // Start top portion of BOp() - double C12, C34, C56; - double BO, BO_s, BO_pi, BO_pi2; - double bo_cut = control->bo_cut; - - if( sbp_i->r_s > 0.0 && sbp_j->r_s > 0.0 ) { - C12 = twbp->p_bo1 * pow( nbr_pj->d / twbp->r_s, twbp->p_bo2 ); - BO_s = (1.0 + bo_cut) * exp( C12 ); - } - else BO_s = C12 = 0.0; - - if( sbp_i->r_pi > 0.0 && sbp_j->r_pi > 0.0 ) { - C34 = twbp->p_bo3 * pow( nbr_pj->d / twbp->r_p, twbp->p_bo4 ); - BO_pi = exp( C34 ); - } - else BO_pi = C34 = 0.0; - - if( sbp_i->r_pi_pi > 0.0 && sbp_j->r_pi_pi > 0.0 ) { - C56 = twbp->p_bo5 * pow( nbr_pj->d / twbp->r_pp, twbp->p_bo6 ); - BO_pi2= exp( C56 ); - } - else BO_pi2 = C56 = 0.0; - - /* Initially BO values are the uncorrected ones, page 1 */ - BO = BO_s + BO_pi + BO_pi2; - // End top portion of BOp() - - if(BO >= bo_cut) { - int btop_j; - - // Update indices in critical section +// } + +// } + + // Trying to minimize time spent in critical section by moving initial part of BOp() + // outside of critical section. + + // Start top portion of BOp() + double C12, C34, C56; + double BO, BO_s, BO_pi, BO_pi2; + double bo_cut = control->bo_cut; + + if( sbp_i->r_s > 0.0 && sbp_j->r_s > 0.0 ) { + C12 = twbp->p_bo1 * pow( nbr_pj->d / twbp->r_s, twbp->p_bo2 ); + BO_s = (1.0 + bo_cut) * exp( C12 ); + } + else BO_s = C12 = 0.0; + + if( sbp_i->r_pi > 0.0 && sbp_j->r_pi > 0.0 ) { + C34 = twbp->p_bo3 * pow( nbr_pj->d / twbp->r_p, twbp->p_bo4 ); + BO_pi = exp( C34 ); + } + else BO_pi = C34 = 0.0; + + if( sbp_i->r_pi_pi > 0.0 && sbp_j->r_pi_pi > 0.0 ) { + C56 = twbp->p_bo5 * pow( nbr_pj->d / twbp->r_pp, twbp->p_bo6 ); + BO_pi2= exp( C56 ); + } + else BO_pi2 = C56 = 0.0; + + /* Initially BO values are the uncorrected ones, page 1 */ + BO = BO_s + BO_pi + BO_pi2; + // End top portion of BOp() + + if(BO >= bo_cut) { + int btop_j; + + // Update indices in critical section #if defined(_OPENMP) #pragma omp critical #endif - { - btop_i = End_Index( i, bonds ); - btop_j = End_Index( j, bonds ); - Set_End_Index( j, btop_j+1, bonds ); - Set_End_Index( i, btop_i+1, bonds ); - } // omp critical - - // Finish remaining BOp() work - BOp_OMP(workspace, bonds, bo_cut, - i , btop_i, nbr_pj, sbp_i, sbp_j, twbp, btop_j, - C12, C34, C56, BO, BO_s, BO_pi, BO_pi2); - - bond_data * ibond = &(bonds->select.bond_list[btop_i]); - bond_order_data * bo_ij = &(ibond->bo_data); - - bond_data * jbond = &(bonds->select.bond_list[btop_j]); - bond_order_data * bo_ji = &(jbond->bo_data); - - workspace->total_bond_order[i] += bo_ij->BO; - tmp_bond_order[reductionOffset + j] += bo_ji->BO; - - rvec_Add(workspace->dDeltap_self[i], bo_ij->dBOp); - rvec_Add(tmp_ddelta[reductionOffset + j], bo_ji->dBOp); - - btop_i++; - num_bonds++; - } // if(BO>=bo_cut) - + { + btop_i = End_Index( i, bonds ); + btop_j = End_Index( j, bonds ); + Set_End_Index( j, btop_j+1, bonds ); + Set_End_Index( i, btop_i+1, bonds ); + } // omp critical + + // Finish remaining BOp() work + BOp_OMP(workspace, bonds, bo_cut, + i , btop_i, nbr_pj, sbp_i, sbp_j, twbp, btop_j, + C12, C34, C56, BO, BO_s, BO_pi, BO_pi2); + + bond_data * ibond = &(bonds->select.bond_list[btop_i]); + bond_order_data * bo_ij = &(ibond->bo_data); + + bond_data * jbond = &(bonds->select.bond_list[btop_j]); + bond_order_data * bo_ji = &(jbond->bo_data); + + workspace->total_bond_order[i] += bo_ij->BO; + tmp_bond_order[reductionOffset + j] += bo_ji->BO; + + rvec_Add(workspace->dDeltap_self[i], bo_ij->dBOp); + rvec_Add(tmp_ddelta[reductionOffset + j], bo_ji->dBOp); + + btop_i++; + num_bonds++; + } // if(BO>=bo_cut) + } // if(cutoff) } // for(pj) @@ -516,49 +516,49 @@ void Init_Forces_noQEq_OMP( reax_system *system, control_params *control, { if (ihb == 1 || ihb == 2) { - start_i = Start_Index(i, far_nbrs); - end_i = End_Index(i, far_nbrs); - - for (pj = start_i; pj < end_i; ++pj) { - nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); - j = nbr_pj->nbr; - atom_j = &(system->my_atoms[j]); - type_j = atom_j->type; - if(type_j < 0) continue; - sbp_j = &(system->reax_param.sbp[type_j]); - jhb = sbp_j->p_hbond; - - if (nbr_pj->d <= control->hbond_cut) { - int iflag = 0; - int jflag = 0; - - if(ihb==1 && jhb==2) iflag = 1; - else if(j<system->n && ihb == 2 && jhb == 1) jflag = 1; - - if(iflag || jflag) { - if(iflag) { - ihb_top = End_Index(atom_i->Hindex, hbonds); - Set_End_Index(atom_i->Hindex, ihb_top+1, hbonds); - } else if(jflag) { - jhb_top = End_Index(atom_j->Hindex, hbonds); - Set_End_Index(atom_j->Hindex, jhb_top+1, hbonds); - } - - if(iflag) { - hbonds->select.hbond_list[ihb_top].nbr = j; - hbonds->select.hbond_list[ihb_top].scl = 1; - hbonds->select.hbond_list[ihb_top].ptr = nbr_pj; - } else if(jflag) { - hbonds->select.hbond_list[jhb_top].nbr = i; - hbonds->select.hbond_list[jhb_top].scl = -1; - hbonds->select.hbond_list[jhb_top].ptr = nbr_pj; - } - - num_hbonds++; - } // if(iflag || jflag) - - } - } + start_i = Start_Index(i, far_nbrs); + end_i = End_Index(i, far_nbrs); + + for (pj = start_i; pj < end_i; ++pj) { + nbr_pj = &( far_nbrs->select.far_nbr_list[pj] ); + j = nbr_pj->nbr; + atom_j = &(system->my_atoms[j]); + type_j = atom_j->type; + if(type_j < 0) continue; + sbp_j = &(system->reax_param.sbp[type_j]); + jhb = sbp_j->p_hbond; + + if (nbr_pj->d <= control->hbond_cut) { + int iflag = 0; + int jflag = 0; + + if(ihb==1 && jhb==2) iflag = 1; + else if(j<system->n && ihb == 2 && jhb == 1) jflag = 1; + + if(iflag || jflag) { + if(iflag) { + ihb_top = End_Index(atom_i->Hindex, hbonds); + Set_End_Index(atom_i->Hindex, ihb_top+1, hbonds); + } else if(jflag) { + jhb_top = End_Index(atom_j->Hindex, hbonds); + Set_End_Index(atom_j->Hindex, jhb_top+1, hbonds); + } + + if(iflag) { + hbonds->select.hbond_list[ihb_top].nbr = j; + hbonds->select.hbond_list[ihb_top].scl = 1; + hbonds->select.hbond_list[ihb_top].ptr = nbr_pj; + } else if(jflag) { + hbonds->select.hbond_list[jhb_top].nbr = i; + hbonds->select.hbond_list[jhb_top].scl = -1; + hbonds->select.hbond_list[jhb_top].ptr = nbr_pj; + } + + num_hbonds++; + } // if(iflag || jflag) + + } + } } } // omp critical diff --git a/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp b/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp index c6486ae8e6..062436a703 100644 --- a/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp +++ b/src/USER-OMP/reaxc_hydrogen_bonds_omp.cpp @@ -124,7 +124,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, pbond_ij = &( bond_list[pi] ); i = pbond_ij->nbr; type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if(type_i < 0) continue; bo_ij = &(pbond_ij->bo_data); if( system->reax_param.sbp[type_i].p_hbond == 2 && @@ -136,7 +136,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, /* set k's varibles */ k = hbond_list[pk].nbr; type_k = system->my_atoms[k].type; - if(type_k < 0) continue; + if(type_k < 0) continue; nbr_jk = hbond_list[pk].ptr; r_jk = nbr_jk->d; rvec_Scale( dvec_jk, hbond_list[pk].scl, nbr_jk->dvec ); @@ -149,7 +149,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, if( system->my_atoms[i].orig_id != system->my_atoms[k].orig_id ) { bo_ij = &(pbond_ij->bo_data); type_i = system->my_atoms[i].type; - if(type_i < 0) continue; + if(type_i < 0) continue; hbp = &(system->reax_param.hbp[ type_i ][ type_j ][ type_k ]); ++num_hb_intrs; @@ -157,8 +157,8 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, &theta, &cos_theta ); /* the derivative of cos(theta) */ Calculate_dCos_ThetaOMP( pbond_ij->dvec, pbond_ij->d, dvec_jk, r_jk, - &dcos_theta_di, &dcos_theta_dj, - &dcos_theta_dk ); + &dcos_theta_di, &dcos_theta_dj, + &dcos_theta_dk ); /* hydrogen bond energy*/ sin_theta2 = sin( theta/2.0 ); @@ -180,7 +180,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, bo_ij->Cdbo += CEhb1; // dbo term if( control->virial == 0 ) { - // dcos terms + // dcos terms rvec_ScaledAdd(workspace->forceReduction[reductionOffset+i], +CEhb2, dcos_theta_di ); rvec_ScaledAdd(workspace->forceReduction[reductionOffset+j], +CEhb2, dcos_theta_dj ); rvec_ScaledAdd(workspace->forceReduction[reductionOffset+k], +CEhb2, dcos_theta_dk ); @@ -192,7 +192,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, /* for pressure coupling, terms that are not related to bond order derivatives are added directly into pressure vector/tensor */ rvec_Scale( force, +CEhb2, dcos_theta_di ); // dcos terms - rvec_Add(workspace->forceReduction[reductionOffset+i], force ); + rvec_Add(workspace->forceReduction[reductionOffset+i], force ); rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); rvec_ScaledAdd( workspace->my_ext_pressReduction[tid],1.0, ext_press ); @@ -224,7 +224,7 @@ void Hydrogen_BondsOMP( reax_system *system, control_params *control, rvec_ScaledAdd(fk_tmp, CEhb3/r_jk, dvec_jk); pair_reax_ptr->ev_tally3_thr_proxy(system->pair_ptr,i,j,k,e_hb,0.0,fi_tmp,fk_tmp,delij,delkj,thr); - } + } } } } diff --git a/src/USER-OMP/reaxc_multi_body_omp.cpp b/src/USER-OMP/reaxc_multi_body_omp.cpp index 27779f8e85..4653ada714 100644 --- a/src/USER-OMP/reaxc_multi_body_omp.cpp +++ b/src/USER-OMP/reaxc_multi_body_omp.cpp @@ -119,7 +119,7 @@ void Atom_EnergyOMP( reax_system *system, control_params *control, /* calculate the energy */ if(numbonds > 0) total_Elp += e_lp = - p_lp2 * workspace->Delta_lp[i] * inv_expvd2; + p_lp2 * workspace->Delta_lp[i] * inv_expvd2; dElp = p_lp2 * inv_expvd2 + 75 * p_lp2 * workspace->Delta_lp[i] * expvd2 * SQR(inv_expvd2); @@ -130,34 +130,34 @@ void Atom_EnergyOMP( reax_system *system, control_params *control, /* tally into per-atom energy */ if( system->pair_ptr->evflag) pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, i, system->n, 1, - e_lp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + e_lp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); /* correction for C2 */ if( p_lp3 > 0.001 && !strcmp(system->reax_param.sbp[type_i].name, "C") ) for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if(type_j < 0) continue; + if(type_j < 0) continue; if( !strcmp( system->reax_param.sbp[type_j].name, "C" ) ) { twbp = &( system->reax_param.tbp[type_i][type_j]); bo_ij = &( bonds->select.bond_list[pj].bo_data ); Di = workspace->Delta[i]; vov3 = bo_ij->BO - Di - 0.040*pow(Di, 4.); - + if( vov3 > 3. ) { - total_Elp += e_lph = p_lp3 * SQR(vov3-3.0); + total_Elp += e_lph = p_lp3 * SQR(vov3-3.0); deahu2dbo = 2.*p_lp3*(vov3 - 3.); deahu2dsbo = 2.*p_lp3*(vov3 - 3.)*(-1. - 0.16*pow(Di, 3.)); - + bo_ij->Cdbo += deahu2dbo; workspace->CdDelta[i] += deahu2dsbo; - + /* tally into per-atom energy */ if( system->pair_ptr->evflag) pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, system->n, 1, - e_lph, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + e_lph, 0.0, 0.0, 0.0, 0.0, 0.0, thr); } } } @@ -187,7 +187,7 @@ void Atom_EnergyOMP( reax_system *system, control_params *control, sum_ovun1 += twbp->p_ovun1 * twbp->De_s * bo_ij->BO; sum_ovun2 += (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j])* - ( bo_ij->BO_pi + bo_ij->BO_pi2 ); + ( bo_ij->BO_pi + bo_ij->BO_pi2 ); } exp_ovun1 = p_ovun3 * exp( p_ovun4 * sum_ovun2 ); @@ -228,7 +228,7 @@ void Atom_EnergyOMP( reax_system *system, control_params *control, numbonds ++; if(numbonds > 0) total_Eun += e_un = - -p_ovun5 * (1.0 - exp_ovun6) * inv_exp_ovun2n * inv_exp_ovun8; + -p_ovun5 * (1.0 - exp_ovun6) * inv_exp_ovun2n * inv_exp_ovun8; CEunder1 = inv_exp_ovun2n * ( p_ovun5 * p_ovun6 * exp_ovun6 * inv_exp_ovun8 + @@ -243,7 +243,7 @@ void Atom_EnergyOMP( reax_system *system, control_params *control, eng_tmp = e_ov; if(numbonds > 0) eng_tmp+= e_un; pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, i, system->n, 1, - eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); } /* forces */ @@ -259,7 +259,7 @@ void Atom_EnergyOMP( reax_system *system, control_params *control, bo_ij->Cdbo += CEover1 * twbp->p_ovun1 * twbp->De_s; // OvCoor-1st workspace->CdDeltaReduction[reductionOffset+j] += - CEover4 * (1.0 - dfvl*workspace->dDelta_lp[j]) * (bo_ij->BO_pi + bo_ij->BO_pi2); // OvCoor-3a + CEover4 * (1.0 - dfvl*workspace->dDelta_lp[j]) * (bo_ij->BO_pi + bo_ij->BO_pi2); // OvCoor-3a bo_ij->Cdbopi += CEover4 * (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // OvCoor-3b @@ -267,7 +267,7 @@ void Atom_EnergyOMP( reax_system *system, control_params *control, (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // OvCoor-3b workspace->CdDeltaReduction[reductionOffset+j] += - CEunder4 * (1.0 - dfvl*workspace->dDelta_lp[j]) * (bo_ij->BO_pi + bo_ij->BO_pi2); // UnCoor - 2a + CEunder4 * (1.0 - dfvl*workspace->dDelta_lp[j]) * (bo_ij->BO_pi + bo_ij->BO_pi2); // UnCoor - 2a bo_ij->Cdbopi += CEunder4 * (workspace->Delta[j] - dfvl*workspace->Delta_lp_temp[j]); // UnCoor-2b diff --git a/src/USER-OMP/reaxc_nonbonded_omp.cpp b/src/USER-OMP/reaxc_nonbonded_omp.cpp index d131195ca0..504dfbe685 100644 --- a/src/USER-OMP/reaxc_nonbonded_omp.cpp +++ b/src/USER-OMP/reaxc_nonbonded_omp.cpp @@ -46,8 +46,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, output_controls *out_control ) { + simulation_data *data, storage *workspace, + reax_list **lists, output_controls *out_control ) { int natoms = system->n; reax_list *far_nbrs = (*lists) + FAR_NBRS; @@ -108,139 +108,139 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, flag = 0; if(nbr_pj->d <= control->nonb_cut) { - if(j < natoms) flag = 1; - else if (orig_i < orig_j) flag = 1; - else if (orig_i == orig_j) { - if (nbr_pj->dvec[2] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[2]) < SMALL) { - if (nbr_pj->dvec[1] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) - flag = 1; - } - } + if(j < natoms) flag = 1; + else if (orig_i < orig_j) flag = 1; + else if (orig_i == orig_j) { + if (nbr_pj->dvec[2] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[2]) < SMALL) { + if (nbr_pj->dvec[1] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) + flag = 1; + } + } } if (flag) { - - r_ij = nbr_pj->d; - twbp = &(system->reax_param.tbp[ system->my_atoms[i].type ] - [ system->my_atoms[j].type ]); - - /* Calculate Taper and its derivative */ - // Tap = nbr_pj->Tap; -- precomputed during compte_H - Tap = workspace->Tap[7] * r_ij + workspace->Tap[6]; - Tap = Tap * r_ij + workspace->Tap[5]; - Tap = Tap * r_ij + workspace->Tap[4]; - Tap = Tap * r_ij + workspace->Tap[3]; - Tap = Tap * r_ij + workspace->Tap[2]; - Tap = Tap * r_ij + workspace->Tap[1]; - Tap = Tap * r_ij + workspace->Tap[0]; - - dTap = 7*workspace->Tap[7] * r_ij + 6*workspace->Tap[6]; - dTap = dTap * r_ij + 5*workspace->Tap[5]; - dTap = dTap * r_ij + 4*workspace->Tap[4]; - dTap = dTap * r_ij + 3*workspace->Tap[3]; - dTap = dTap * r_ij + 2*workspace->Tap[2]; - dTap += workspace->Tap[1]/r_ij; - - /*vdWaals Calculations*/ - if(system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) - { // shielding - powr_vdW1 = pow(r_ij, p_vdW1); - powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); - - fn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i ); - exp1 = exp( twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); - exp2 = exp( 0.5 * twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); - - e_vdW = twbp->D * (exp1 - 2.0 * exp2); - total_EvdW += Tap * e_vdW; - - dfn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i - 1.0) * - pow(r_ij, p_vdW1 - 2.0); - - CEvd = dTap * e_vdW - - Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) * dfn13; - } - else{ // no shielding - exp1 = exp( twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); - exp2 = exp( 0.5 * twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); - - e_vdW = twbp->D * (exp1 - 2.0 * exp2); - total_EvdW += Tap * e_vdW; - - CEvd = dTap * e_vdW - - Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; - } - - if(system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) - { // innner wall - e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); - total_EvdW += Tap * e_core; - - de_core = -(twbp->acore/twbp->rcore) * e_core; - CEvd += dTap * e_core + Tap * de_core / r_ij; - - // lg correction, only if lgvdw is yes - if (control->lgflag) { - r_ij5 = pow( r_ij, 5.0 ); - r_ij6 = pow( r_ij, 6.0 ); - re6 = pow( twbp->lgre, 6.0 ); - - e_lg = -(twbp->lgcij/( r_ij6 + re6 )); - total_EvdW += Tap * e_lg; - - de_lg = -6.0 * e_lg * r_ij5 / ( r_ij6 + re6 ) ; - CEvd += dTap * e_lg + Tap * de_lg / r_ij; - } - - } - - /*Coulomb Calculations*/ - dr3gamij_1 = ( r_ij * r_ij * r_ij + twbp->gamma ); - dr3gamij_3 = pow( dr3gamij_1 , 0.33333333333333 ); - - tmp = Tap / dr3gamij_3; - total_Eele += e_ele = - C_ele * system->my_atoms[i].q * system->my_atoms[j].q * tmp; - - CEclmb = C_ele * system->my_atoms[i].q * system->my_atoms[j].q * - ( dTap - Tap * r_ij / dr3gamij_1 ) / dr3gamij_3; - - /* tally into per-atom energy */ - if( system->pair_ptr->evflag || system->pair_ptr->vflag_atom) { - pe_vdw = Tap * (e_vdW + e_core + e_lg); - rvec_ScaledSum( delij, 1., system->my_atoms[i].x, - -1., system->my_atoms[j].x ); - f_tmp = -(CEvd + CEclmb); - pair_reax_ptr->ev_tally_thr_proxy( system->pair_ptr, i, j, natoms, - 1, pe_vdw, e_ele, f_tmp, - delij[0], delij[1], delij[2], thr); - } - - if( control->virial == 0 ) { - rvec_ScaledAdd( workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+j], - +(CEvd + CEclmb), nbr_pj->dvec ); - } - else { /* NPT, iNPT or sNPT */ - /* for pressure coupling, terms not related to bond order - derivatives are added directly into pressure vector/tensor */ - - rvec_Scale( temp, CEvd + CEclmb, nbr_pj->dvec ); - rvec_ScaledAdd( workspace->f[reductionOffset+i], -1., temp ); - rvec_Add( workspace->forceReduction[reductionOffset+j], temp); - - rvec_iMultiply( ext_press, nbr_pj->rel_box, temp ); - - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - } - } + + r_ij = nbr_pj->d; + twbp = &(system->reax_param.tbp[ system->my_atoms[i].type ] + [ system->my_atoms[j].type ]); + + /* Calculate Taper and its derivative */ + // Tap = nbr_pj->Tap; -- precomputed during compte_H + Tap = workspace->Tap[7] * r_ij + workspace->Tap[6]; + Tap = Tap * r_ij + workspace->Tap[5]; + Tap = Tap * r_ij + workspace->Tap[4]; + Tap = Tap * r_ij + workspace->Tap[3]; + Tap = Tap * r_ij + workspace->Tap[2]; + Tap = Tap * r_ij + workspace->Tap[1]; + Tap = Tap * r_ij + workspace->Tap[0]; + + dTap = 7*workspace->Tap[7] * r_ij + 6*workspace->Tap[6]; + dTap = dTap * r_ij + 5*workspace->Tap[5]; + dTap = dTap * r_ij + 4*workspace->Tap[4]; + dTap = dTap * r_ij + 3*workspace->Tap[3]; + dTap = dTap * r_ij + 2*workspace->Tap[2]; + dTap += workspace->Tap[1]/r_ij; + + /*vdWaals Calculations*/ + if(system->reax_param.gp.vdw_type==1 || system->reax_param.gp.vdw_type==3) + { // shielding + powr_vdW1 = pow(r_ij, p_vdW1); + powgi_vdW1 = pow( 1.0 / twbp->gamma_w, p_vdW1); + + fn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i ); + exp1 = exp( twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); + exp2 = exp( 0.5 * twbp->alpha * (1.0 - fn13 / twbp->r_vdW) ); + + e_vdW = twbp->D * (exp1 - 2.0 * exp2); + total_EvdW += Tap * e_vdW; + + dfn13 = pow( powr_vdW1 + powgi_vdW1, p_vdW1i - 1.0) * + pow(r_ij, p_vdW1 - 2.0); + + CEvd = dTap * e_vdW - + Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) * dfn13; + } + else{ // no shielding + exp1 = exp( twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); + exp2 = exp( 0.5 * twbp->alpha * (1.0 - r_ij / twbp->r_vdW) ); + + e_vdW = twbp->D * (exp1 - 2.0 * exp2); + total_EvdW += Tap * e_vdW; + + CEvd = dTap * e_vdW - + Tap * twbp->D * (twbp->alpha / twbp->r_vdW) * (exp1 - exp2) / r_ij; + } + + if(system->reax_param.gp.vdw_type==2 || system->reax_param.gp.vdw_type==3) + { // innner wall + e_core = twbp->ecore * exp(twbp->acore * (1.0-(r_ij/twbp->rcore))); + total_EvdW += Tap * e_core; + + de_core = -(twbp->acore/twbp->rcore) * e_core; + CEvd += dTap * e_core + Tap * de_core / r_ij; + + // lg correction, only if lgvdw is yes + if (control->lgflag) { + r_ij5 = pow( r_ij, 5.0 ); + r_ij6 = pow( r_ij, 6.0 ); + re6 = pow( twbp->lgre, 6.0 ); + + e_lg = -(twbp->lgcij/( r_ij6 + re6 )); + total_EvdW += Tap * e_lg; + + de_lg = -6.0 * e_lg * r_ij5 / ( r_ij6 + re6 ) ; + CEvd += dTap * e_lg + Tap * de_lg / r_ij; + } + + } + + /*Coulomb Calculations*/ + dr3gamij_1 = ( r_ij * r_ij * r_ij + twbp->gamma ); + dr3gamij_3 = pow( dr3gamij_1 , 0.33333333333333 ); + + tmp = Tap / dr3gamij_3; + total_Eele += e_ele = + C_ele * system->my_atoms[i].q * system->my_atoms[j].q * tmp; + + CEclmb = C_ele * system->my_atoms[i].q * system->my_atoms[j].q * + ( dTap - Tap * r_ij / dr3gamij_1 ) / dr3gamij_3; + + /* tally into per-atom energy */ + if( system->pair_ptr->evflag || system->pair_ptr->vflag_atom) { + pe_vdw = Tap * (e_vdW + e_core + e_lg); + rvec_ScaledSum( delij, 1., system->my_atoms[i].x, + -1., system->my_atoms[j].x ); + f_tmp = -(CEvd + CEclmb); + pair_reax_ptr->ev_tally_thr_proxy( system->pair_ptr, i, j, natoms, + 1, pe_vdw, e_ele, f_tmp, + delij[0], delij[1], delij[2], thr); + } + + if( control->virial == 0 ) { + rvec_ScaledAdd( workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec ); + rvec_ScaledAdd( workspace->forceReduction[reductionOffset+j], + +(CEvd + CEclmb), nbr_pj->dvec ); + } + else { /* NPT, iNPT or sNPT */ + /* for pressure coupling, terms not related to bond order + derivatives are added directly into pressure vector/tensor */ + + rvec_Scale( temp, CEvd + CEclmb, nbr_pj->dvec ); + rvec_ScaledAdd( workspace->f[reductionOffset+i], -1., temp ); + rvec_Add( workspace->forceReduction[reductionOffset+j], temp); + + rvec_iMultiply( ext_press, nbr_pj->rel_box, temp ); + + rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); + } + } } } pair_reax_ptr->reduce_thr_proxy(system->pair_ptr, system->pair_ptr->eflag_either, - system->pair_ptr->vflag_either, thr); + system->pair_ptr->vflag_either, thr); } // parallel region data->my_en.e_vdW = total_EvdW; @@ -252,9 +252,9 @@ void vdW_Coulomb_Energy_OMP( reax_system *system, control_params *control, /* ---------------------------------------------------------------------- */ void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *system,control_params *control, - simulation_data *data, storage *workspace, - reax_list **lists, - output_controls *out_control ) { + simulation_data *data, storage *workspace, + reax_list **lists, + output_controls *out_control ) { double SMALL = 0.0001; int natoms = system->n; @@ -306,80 +306,80 @@ void Tabulated_vdW_Coulomb_Energy_OMP(reax_system *system,control_params *contro flag = 0; if(nbr_pj->d <= control->nonb_cut) { - if(j < natoms) flag = 1; - else if (orig_i < orig_j) flag = 1; - else if (orig_i == orig_j) { - if (nbr_pj->dvec[2] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[2]) < SMALL) { - if (nbr_pj->dvec[1] > SMALL) flag = 1; - else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) - flag = 1; - } - } + if(j < natoms) flag = 1; + else if (orig_i < orig_j) flag = 1; + else if (orig_i == orig_j) { + if (nbr_pj->dvec[2] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[2]) < SMALL) { + if (nbr_pj->dvec[1] > SMALL) flag = 1; + else if (fabs(nbr_pj->dvec[1]) < SMALL && nbr_pj->dvec[0] > SMALL) + flag = 1; + } + } } if (flag) { - - r_ij = nbr_pj->d; - tmin = MIN( type_i, type_j ); - tmax = MAX( type_i, type_j ); - t = &( LR[tmin][tmax] ); - - /* Cubic Spline Interpolation */ - r = (int)(r_ij * t->inv_dx); - if( r == 0 ) ++r; - base = (double)(r+1) * t->dx; - dif = r_ij - base; - - e_vdW = ((t->vdW[r].d*dif + t->vdW[r].c)*dif + t->vdW[r].b)*dif + - t->vdW[r].a; - - e_ele = ((t->ele[r].d*dif + t->ele[r].c)*dif + t->ele[r].b)*dif + - t->ele[r].a; - e_ele *= system->my_atoms[i].q * system->my_atoms[j].q; - - total_EvdW += e_vdW; - total_Eele += e_ele; - - CEvd = ((t->CEvd[r].d*dif + t->CEvd[r].c)*dif + t->CEvd[r].b)*dif + - t->CEvd[r].a; - - CEclmb = ((t->CEclmb[r].d*dif+t->CEclmb[r].c)*dif+t->CEclmb[r].b)*dif + - t->CEclmb[r].a; - CEclmb *= system->my_atoms[i].q * system->my_atoms[j].q; - - /* tally into per-atom energy */ - if( system->pair_ptr->evflag || system->pair_ptr->vflag_atom) { - rvec_ScaledSum( delij, 1., system->my_atoms[i].x, - -1., system->my_atoms[j].x ); - f_tmp = -(CEvd + CEclmb); - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, natoms, 1, e_vdW, e_ele, - f_tmp, delij[0], delij[1], delij[2], thr); - } - - if( control->virial == 0 ) { - rvec_ScaledAdd( workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec ); - rvec_ScaledAdd( workspace->forceReduction[froffset+j], - +(CEvd + CEclmb), nbr_pj->dvec ); - } - else { // NPT, iNPT or sNPT - /* for pressure coupling, terms not related to bond order derivatives - are added directly into pressure vector/tensor */ - rvec_Scale( temp, CEvd + CEclmb, nbr_pj->dvec ); - - rvec_ScaledAdd( workspace->f[i], -1., temp ); - rvec_Add( workspace->forceReduction[froffset+j], temp ); - - rvec_iMultiply( ext_press, nbr_pj->rel_box, temp ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - } + + r_ij = nbr_pj->d; + tmin = MIN( type_i, type_j ); + tmax = MAX( type_i, type_j ); + t = &( LR[tmin][tmax] ); + + /* Cubic Spline Interpolation */ + r = (int)(r_ij * t->inv_dx); + if( r == 0 ) ++r; + base = (double)(r+1) * t->dx; + dif = r_ij - base; + + e_vdW = ((t->vdW[r].d*dif + t->vdW[r].c)*dif + t->vdW[r].b)*dif + + t->vdW[r].a; + + e_ele = ((t->ele[r].d*dif + t->ele[r].c)*dif + t->ele[r].b)*dif + + t->ele[r].a; + e_ele *= system->my_atoms[i].q * system->my_atoms[j].q; + + total_EvdW += e_vdW; + total_Eele += e_ele; + + CEvd = ((t->CEvd[r].d*dif + t->CEvd[r].c)*dif + t->CEvd[r].b)*dif + + t->CEvd[r].a; + + CEclmb = ((t->CEclmb[r].d*dif+t->CEclmb[r].c)*dif+t->CEclmb[r].b)*dif + + t->CEclmb[r].a; + CEclmb *= system->my_atoms[i].q * system->my_atoms[j].q; + + /* tally into per-atom energy */ + if( system->pair_ptr->evflag || system->pair_ptr->vflag_atom) { + rvec_ScaledSum( delij, 1., system->my_atoms[i].x, + -1., system->my_atoms[j].x ); + f_tmp = -(CEvd + CEclmb); + pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, i, j, natoms, 1, e_vdW, e_ele, + f_tmp, delij[0], delij[1], delij[2], thr); + } + + if( control->virial == 0 ) { + rvec_ScaledAdd( workspace->f[i], -(CEvd + CEclmb), nbr_pj->dvec ); + rvec_ScaledAdd( workspace->forceReduction[froffset+j], + +(CEvd + CEclmb), nbr_pj->dvec ); + } + else { // NPT, iNPT or sNPT + /* for pressure coupling, terms not related to bond order derivatives + are added directly into pressure vector/tensor */ + rvec_Scale( temp, CEvd + CEclmb, nbr_pj->dvec ); + + rvec_ScaledAdd( workspace->f[i], -1., temp ); + rvec_Add( workspace->forceReduction[froffset+j], temp ); + + rvec_iMultiply( ext_press, nbr_pj->rel_box, temp ); + rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); + } } } } pair_reax_ptr->reduce_thr_proxy(system->pair_ptr, system->pair_ptr->eflag_either, - system->pair_ptr->vflag_either, thr); + system->pair_ptr->vflag_either, thr); } // end omp parallel data->my_en.e_vdW = total_EvdW; diff --git a/src/USER-OMP/reaxc_nonbonded_omp.h b/src/USER-OMP/reaxc_nonbonded_omp.h index f64e1abe48..a5d895533a 100644 --- a/src/USER-OMP/reaxc_nonbonded_omp.h +++ b/src/USER-OMP/reaxc_nonbonded_omp.h @@ -32,9 +32,9 @@ #include "reaxc_types.h" void vdW_Coulomb_Energy_OMP( reax_system*, control_params*, simulation_data*, - storage*, reax_list**, output_controls* ); + storage*, reax_list**, output_controls* ); void Tabulated_vdW_Coulomb_Energy_OMP( reax_system*, control_params*, - simulation_data*, storage*, - reax_list**, output_controls* ); + simulation_data*, storage*, + reax_list**, output_controls* ); #endif diff --git a/src/USER-OMP/reaxc_torsion_angles_omp.cpp b/src/USER-OMP/reaxc_torsion_angles_omp.cpp index 4227f62763..ed9ae6c21e 100644 --- a/src/USER-OMP/reaxc_torsion_angles_omp.cpp +++ b/src/USER-OMP/reaxc_torsion_angles_omp.cpp @@ -46,8 +46,8 @@ using namespace LAMMPS_NS; // Functions defined in reaxc_torsion_angles.cpp extern double Calculate_Omega(rvec, double, rvec, double, rvec, double, rvec, double, - three_body_interaction_data*, three_body_interaction_data*, - rvec, rvec, rvec, rvec, output_controls*); + three_body_interaction_data*, three_body_interaction_data*, + rvec, rvec, rvec, rvec, output_controls*); /* ---------------------------------------------------------------------- */ @@ -134,7 +134,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, for (pk = start_j; pk < end_j; ++pk) { bo_jk = &( bonds->select.bond_list[pk].bo_data ); for (k = 0; k < nthreads; ++k) - bo_jk->CdboReduction[k] = 0.; + bo_jk->CdboReduction[k] = 0.; } } @@ -159,7 +159,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, if (system->my_atoms[j].orig_id < system->my_atoms[k].orig_id && bo_jk->BO > control->thb_cut/*0*/ && Num_Entries(pk, thb_intrs)) { pj = pbond_jk->sym_index; // pj points to j on k's list - + /* do the same check as above: are there any 3-body interactions involving k&j where k is the central atom */ @@ -167,28 +167,28 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, type_k = system->my_atoms[k].type; Delta_k = workspace->Delta_boc[k]; r_jk = pbond_jk->d; - + start_pk = Start_Index(pk, thb_intrs ); end_pk = End_Index(pk, thb_intrs ); start_pj = Start_Index(pj, thb_intrs ); end_pj = End_Index(pj, thb_intrs ); - + exp_tor2_jk = exp( -p_tor2 * BOA_jk ); exp_cot2_jk = exp( -p_cot2 * SQR(BOA_jk - 1.5) ); exp_tor3_DjDk = exp( -p_tor3 * (Delta_j + Delta_k) ); exp_tor4_DjDk = exp( p_tor4 * (Delta_j + Delta_k) ); exp_tor34_inv = 1.0 / (1.0 + exp_tor3_DjDk + exp_tor4_DjDk); f11_DjDk = (2.0 + exp_tor3_DjDk) * exp_tor34_inv; - - + + /* pick i up from j-k interaction where j is the central atom */ for (pi = start_pk; pi < end_pk; ++pi) { p_ijk = &( thb_intrs->select.three_body_list[pi] ); - pij = p_ijk->pthb; // pij is pointer to i on j's bond_list + pij = p_ijk->pthb; // pij is pointer to i on j's bond_list pbond_ij = &( bonds->select.bond_list[pij] ); bo_ij = &( pbond_ij->bo_data ); - - if (bo_ij->BO > control->thb_cut/*0*/) { + + if (bo_ij->BO > control->thb_cut/*0*/) { i = p_ijk->thb; type_i = system->my_atoms[i].type; r_ij = pbond_ij->d; @@ -221,18 +221,18 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, fbp = &(system->reax_param.fbp[type_i][type_j] [type_k][type_l].prm[0]); - if (i != l && fbh->cnt && + if (i != l && fbh->cnt && bo_kl->BO > control->thb_cut/*0*/ && bo_ij->BO * bo_jk->BO * bo_kl->BO > control->thb_cut/*0*/) { ++num_frb_intrs; //fprintf(stderr, - // "%5d: %6d %6d %6d %6d\n", num_frb_intrs, - // system->my_atoms[i].orig_id,system->my_atoms[j].orig_id, - // system->my_atoms[k].orig_id,system->my_atoms[l].orig_id); + // "%5d: %6d %6d %6d %6d\n", num_frb_intrs, + // system->my_atoms[i].orig_id,system->my_atoms[j].orig_id, + // system->my_atoms[k].orig_id,system->my_atoms[l].orig_id); r_kl = pbond_kl->d; BOA_kl = bo_kl->BO - control->thb_cut; - + theta_jkl = p_jkl->theta; sin_jkl = sin( theta_jkl ); cos_jkl = cos( theta_jkl ); @@ -242,12 +242,12 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, else if( sin_jkl <= 0 && sin_jkl >= -MIN_SINE ) tan_jkl_i = cos_jkl / -MIN_SINE; else tan_jkl_i = cos_jkl /sin_jkl; - + rvec_ScaledSum( dvec_li, 1., system->my_atoms[i].x, -1., system->my_atoms[l].x ); r_li = rvec_Norm( dvec_li ); - - + + /* omega and its derivative */ omega = Calculate_Omega( pbond_ij->dvec, r_ij, pbond_jk->dvec, r_jk, @@ -262,7 +262,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, cos2omega = cos( 2. * omega ); cos3omega = cos( 3. * omega ); /* end omega calculations */ - + /* torsion energy */ exp_tor1 = exp( fbp->p_tor1 * SQR(2.0 - bo_jk->BO_pi - f11_DjDk) ); @@ -275,7 +275,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, fbp->V2 * exp_tor1 * (1.0 - cos2omega) + fbp->V3 * (1.0 + cos3omega) ); - total_Etor += e_tor = fn10 * sin_ijk * sin_jkl * CV; + total_Etor += e_tor = fn10 * sin_ijk * sin_jkl * CV; dfn11 = (-p_tor3 * exp_tor3_DjDk + (p_tor3 * exp_tor3_DjDk - p_tor4 * exp_tor4_DjDk) * @@ -309,7 +309,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, /* 4-body conjugation energy */ fn12 = exp_cot2_ij * exp_cot2_jk * exp_cot2_kl; //data->my_en.e_con += e_con = - total_Econ += e_con = + total_Econ += e_con = fbp->p_cot1 * fn12 * (1.0 + (SQR(cos_omega) - 1.0) * sin_ijk * sin_jkl); @@ -331,18 +331,18 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, /* FORCES */ bo_jk->Cdbopi += CEtors2; workspace->CdDelta[j] += CEtors3; - //workspace->CdDelta[k] += CEtors3; + //workspace->CdDelta[k] += CEtors3; workspace->CdDeltaReduction[reductionOffset+k] += CEtors3; bo_ij->Cdbo += (CEtors4 + CEconj1); bo_jk->Cdbo += (CEtors5 + CEconj2); //bo_kl->Cdbo += (CEtors6 + CEconj3); - bo_kl->CdboReduction[tid] += (CEtors6 + CEconj3); + bo_kl->CdboReduction[tid] += (CEtors6 + CEconj3); if( control->virial == 0 ) { /* dcos_theta_ijk */ rvec_ScaledAdd( workspace->f[j], CEtors7 + CEconj4, p_ijk->dcos_dj ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+i], + rvec_ScaledAdd( workspace->forceReduction[reductionOffset+i], CEtors7 + CEconj4, p_ijk->dcos_dk ); rvec_ScaledAdd( workspace->forceReduction[reductionOffset+k], CEtors7 + CEconj4, p_ijk->dcos_di ); @@ -350,7 +350,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, /* dcos_theta_jkl */ rvec_ScaledAdd( workspace->f[j], CEtors8 + CEconj5, p_jkl->dcos_di ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+k], + rvec_ScaledAdd( workspace->forceReduction[reductionOffset+k], CEtors8 + CEconj5, p_jkl->dcos_dj ); rvec_ScaledAdd( workspace->forceReduction[reductionOffset+l], CEtors8 + CEconj5, p_jkl->dcos_dk ); @@ -358,7 +358,7 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, /* dcos_omega */ rvec_ScaledAdd( workspace->f[j], CEtors9 + CEconj6, dcos_omega_dj ); - rvec_ScaledAdd( workspace->forceReduction[reductionOffset+i], + rvec_ScaledAdd( workspace->forceReduction[reductionOffset+i], CEtors9 + CEconj6, dcos_omega_di ); rvec_ScaledAdd( workspace->forceReduction[reductionOffset+k], CEtors9 + CEconj6, dcos_omega_dk ); @@ -367,58 +367,58 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, } else { ivec_Sum(rel_box_jl, pbond_jk->rel_box, pbond_kl->rel_box); - + /* dcos_theta_ijk */ rvec_Scale( force, CEtors7 + CEconj4, p_ijk->dcos_dk ); - rvec_Add( workspace->forceReduction[reductionOffset+i], force ); + rvec_Add( workspace->forceReduction[reductionOffset+i], force ); rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - + rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); + rvec_ScaledAdd( workspace->f[j], CEtors7 + CEconj4, p_ijk->dcos_dj ); - + rvec_Scale( force, CEtors7 + CEconj4, p_ijk->dcos_di ); - rvec_Add( workspace->forceReduction[reductionOffset+k], force ); + rvec_Add( workspace->forceReduction[reductionOffset+k], force ); rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - + rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); + /* dcos_theta_jkl */ rvec_ScaledAdd( workspace->f[j], CEtors8 + CEconj5, p_jkl->dcos_di ); - + rvec_Scale( force, CEtors8 + CEconj5, p_jkl->dcos_dj ); - rvec_Add( workspace->forceReduction[reductionOffset+k], force ); + rvec_Add( workspace->forceReduction[reductionOffset+k], force ); rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - + rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); + rvec_Scale( force, CEtors8 + CEconj5, p_jkl->dcos_dk ); - rvec_Add( workspace->forceReduction[reductionOffset+l], force ); + rvec_Add( workspace->forceReduction[reductionOffset+l], force ); rvec_iMultiply( ext_press, rel_box_jl, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - + rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); + /* dcos_omega */ rvec_Scale( force, CEtors9 + CEconj6, dcos_omega_di ); - rvec_Add( workspace->forceReduction[reductionOffset+i], force ); + rvec_Add( workspace->forceReduction[reductionOffset+i], force ); rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); + rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); rvec_ScaledAdd( workspace->f[j], CEtors9 + CEconj6, dcos_omega_dj ); rvec_Scale( force, CEtors9 + CEconj6, dcos_omega_dk ); - rvec_Add( workspace->forceReduction[reductionOffset+k], force ); + rvec_Add( workspace->forceReduction[reductionOffset+k], force ); rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); + rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); rvec_Scale( force, CEtors9 + CEconj6, dcos_omega_dl ); - rvec_Add( workspace->forceReduction[reductionOffset+i], force ); + rvec_Add( workspace->forceReduction[reductionOffset+i], force ); rvec_iMultiply( ext_press, rel_box_jl, force ); - rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); + rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); } /* tally into per-atom virials */ if( system->pair_ptr->vflag_atom || system->pair_ptr->evflag) { - + // acquire vectors rvec_ScaledSum( delil, 1., system->my_atoms[l].x, -1., system->my_atoms[i].x ); @@ -430,29 +430,29 @@ void Torsion_AnglesOMP( reax_system *system, control_params *control, rvec_Scale( fi_tmp, CEtors7 + CEconj4, p_ijk->dcos_dk ); rvec_Scale( fj_tmp, CEtors7 + CEconj4, p_ijk->dcos_dj ); rvec_Scale( fk_tmp, CEtors7 + CEconj4, p_ijk->dcos_di ); - + // dcos_theta_jkl rvec_ScaledAdd( fj_tmp, CEtors8 + CEconj5, p_jkl->dcos_di ); rvec_ScaledAdd( fk_tmp, CEtors8 + CEconj5, p_jkl->dcos_dj ); - + // dcos_omega rvec_ScaledAdd( fi_tmp, CEtors9 + CEconj6, dcos_omega_di ); rvec_ScaledAdd( fj_tmp, CEtors9 + CEconj6, dcos_omega_dj ); rvec_ScaledAdd( fk_tmp, CEtors9 + CEconj6, dcos_omega_dk ); - + // tally eng_tmp = e_tor + e_con; - + if (system->pair_ptr->evflag) - pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, j, k, system->n, 1, - eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); + pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, j, k, system->n, 1, + eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); - // NEED TO MAKE AN OMP VERSION OF THIS CALL! + // NEED TO MAKE AN OMP VERSION OF THIS CALL! if (system->pair_ptr->vflag_atom) - system->pair_ptr->v_tally4(i, j, k, l, fi_tmp, fj_tmp, fk_tmp, - delil, deljl, delkl ); + system->pair_ptr->v_tally4(i, j, k, l, fi_tmp, fj_tmp, fk_tmp, + delil, deljl, delkl ); } - + } // pl check ends } // pl loop ends } // pi check ends diff --git a/src/USER-OMP/reaxc_torsion_angles_omp.h b/src/USER-OMP/reaxc_torsion_angles_omp.h index 39f8691877..62cb760f41 100644 --- a/src/USER-OMP/reaxc_torsion_angles_omp.h +++ b/src/USER-OMP/reaxc_torsion_angles_omp.h @@ -33,6 +33,6 @@ #include "reaxc_torsion_angles.h" void Torsion_AnglesOMP( reax_system*, control_params*, simulation_data*, - storage*, reax_list**, output_controls* ); + storage*, reax_list**, output_controls* ); #endif diff --git a/src/USER-OMP/reaxc_valence_angles_omp.cpp b/src/USER-OMP/reaxc_valence_angles_omp.cpp index 6c15a529d3..5366a84878 100644 --- a/src/USER-OMP/reaxc_valence_angles_omp.cpp +++ b/src/USER-OMP/reaxc_valence_angles_omp.cpp @@ -45,9 +45,9 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ void Calculate_dCos_ThetaOMP( rvec dvec_ji, double d_ji, rvec dvec_jk, double d_jk, - rvec* dcos_theta_di, - rvec* dcos_theta_dj, - rvec* dcos_theta_dk ) + rvec* dcos_theta_di, + rvec* dcos_theta_dj, + rvec* dcos_theta_dk ) { double sqr_d_ji = SQR(d_ji); double sqr_d_jk = SQR(d_jk); @@ -198,21 +198,21 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, BOA_ij = bo_ij->BO - control->thb_cut; if (BOA_ij > 0.0) { - i = pbond_ij->nbr; - + i = pbond_ij->nbr; + /* first copy 3-body intrs from previously computed ones where i>k. in the second for-loop below, we compute only new 3-body intrs where i < k */ for (pk = start_j; pk < pi; ++pk) { start_pk = Start_Index( pk, thb_intrs ); end_pk = End_Index( pk, thb_intrs ); - + for (t = start_pk; t < end_pk; ++t) if (thb_intrs->select.three_body_list[t].thb == i) { p_ijk = &(thb_intrs->select.three_body_list[my_offset] ); p_ijk->thb = bonds->select.bond_list[pk].nbr; - + ++my_offset; break; } @@ -227,7 +227,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, p_ijk = &( thb_intrs->select.three_body_list[my_offset] ); p_ijk->thb = k; - + ++my_offset; // add this to the list of 3-body interactions } // for(pk) } // if() @@ -345,34 +345,34 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, if (BOA_ij > 0.0) { i = pbond_ij->nbr; type_i = system->my_atoms[i].type; - - + + /* first copy 3-body intrs from previously computed ones where i>k. in the second for-loop below, we compute only new 3-body intrs where i < k */ for (pk = start_j; pk < pi; ++pk) { start_pk = Start_Index( pk, thb_intrs ); end_pk = End_Index( pk, thb_intrs ); - + for (t = start_pk; t < end_pk; ++t) if (thb_intrs->select.three_body_list[t].thb == i) { p_ijk = &(thb_intrs->select.three_body_list[my_offset] ); p_kji = &(thb_intrs->select.three_body_list[t]); - + p_ijk->thb = bonds->select.bond_list[pk].nbr; p_ijk->pthb = pk; p_ijk->theta = p_kji->theta; rvec_Copy( p_ijk->dcos_di, p_kji->dcos_dk ); rvec_Copy( p_ijk->dcos_dj, p_kji->dcos_dj ); rvec_Copy( p_ijk->dcos_dk, p_kji->dcos_di ); - + ++my_offset; ++num_thb_intrs; break; } } // for(pk) - - + + /* and this is the second for loop mentioned above */ for (pk = pi+1; pk < end_j; ++pk) { pbond_jk = &(bonds->select.bond_list[pk]); @@ -381,15 +381,15 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, k = pbond_jk->nbr; type_k = system->my_atoms[k].type; p_ijk = &( thb_intrs->select.three_body_list[my_offset] ); - + // Fix by Sudhir // if (BOA_jk <= 0) continue; if (j >= system->n && i >= system->n && k >= system->n) continue; - + Calculate_Theta( pbond_ij->dvec, pbond_ij->d, pbond_jk->dvec, pbond_jk->d, &theta, &cos_theta ); - + Calculate_dCos_ThetaOMP( pbond_ij->dvec, pbond_ij->d, pbond_jk->dvec, pbond_jk->d, &(p_ijk->dcos_di), &(p_ijk->dcos_dj), @@ -397,66 +397,66 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, p_ijk->thb = k; p_ijk->pthb = pk; p_ijk->theta = theta; - + sin_theta = sin( theta ); if( sin_theta < 1.0e-5 ) sin_theta = 1.0e-5; - + ++my_offset; // add this to the list of 3-body interactions ++num_thb_intrs; - + if ((j < system->n) && (BOA_jk > 0.0) && (bo_ij->BO > control->thb_cut) && (bo_jk->BO > control->thb_cut) && (bo_ij->BO * bo_jk->BO > control->thb_cutsq)) { thbh = &( system->reax_param.thbp[ type_i ][ type_j ][ type_k ] ); - + for (cnt = 0; cnt < thbh->cnt; ++cnt) { - + if( fabs(thbh->prm[cnt].p_val1) > 0.001 ) { thbp = &( thbh->prm[cnt] ); - + /* ANGLE ENERGY */ p_val1 = thbp->p_val1; p_val2 = thbp->p_val2; p_val4 = thbp->p_val4; p_val7 = thbp->p_val7; theta_00 = thbp->theta_00; - + exp3ij = exp( -p_val3 * pow( BOA_ij, p_val4 ) ); f7_ij = 1.0 - exp3ij; Cf7ij = p_val3 * p_val4 * pow( BOA_ij, p_val4 - 1.0 ) * exp3ij; - + exp3jk = exp( -p_val3 * pow( BOA_jk, p_val4 ) ); f7_jk = 1.0 - exp3jk; Cf7jk = p_val3 * p_val4 * pow( BOA_jk, p_val4 - 1.0 ) * exp3jk; - + expval7 = exp( -p_val7 * workspace->Delta_boc[j] ); trm8 = 1.0 + expval6 + expval7; f8_Dj = p_val5 - ( (p_val5 - 1.0) * (2.0 + expval6) / trm8 ); Cf8j = ( (1.0 - p_val5) / SQR(trm8) ) * ( p_val6 * expval6 * trm8 - (2.0 + expval6) * ( p_val6*expval6 - p_val7*expval7 ) ); - + theta_0 = 180.0 - theta_00 * (1.0 - exp(-p_val10 * (2.0 - SBO2))); theta_0 = DEG2RAD( theta_0 ); - + expval2theta = exp( -p_val2 * SQR(theta_0 - theta) ); if (p_val1 >= 0) expval12theta = p_val1 * (1.0 - expval2theta); else // To avoid linear Me-H-Me angles (6/6/06) expval12theta = p_val1 * -expval2theta; - + CEval1 = Cf7ij * f7_jk * f8_Dj * expval12theta; CEval2 = Cf7jk * f7_ij * f8_Dj * expval12theta; CEval3 = Cf8j * f7_ij * f7_jk * expval12theta; CEval4 = -2.0 * p_val1 * p_val2 * f7_ij * f7_jk * f8_Dj * expval2theta * (theta_0 - theta); - + Ctheta_0 = p_val10 * DEG2RAD(theta_00) * exp( -p_val10 * (2.0 - SBO2) ); - + CEval5 = -CEval4 * Ctheta_0 * CSBO2; CEval6 = CEval5 * dSBO1; CEval7 = CEval5 * dSBO2; @@ -465,8 +465,8 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, total_Eang += e_ang = f7_ij * f7_jk * f8_Dj * expval12theta; /* END ANGLE ENERGY*/ - - + + /* PENALTY ENERGY */ p_pen1 = thbp->p_pen1; p_pen2 = system->reax_param.gp.l[19]; @@ -486,20 +486,20 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, total_Epen += e_pen = p_pen1 * f9_Dj * exp_pen2ij * exp_pen2jk; - + CEpen1 = e_pen * Cf9j / f9_Dj; temp = -2.0 * p_pen2 * e_pen; CEpen2 = temp * (BOA_ij - 2.0); CEpen3 = temp * (BOA_jk - 2.0); /* END PENALTY ENERGY */ - - + + /* COALITION ENERGY */ p_coa1 = thbp->p_coa1; p_coa2 = system->reax_param.gp.l[2]; p_coa3 = system->reax_param.gp.l[38]; p_coa4 = system->reax_param.gp.l[30]; - + exp_coa2 = exp( p_coa2 * workspace->Delta_val[j] ); total_Ecoa += e_coa = p_coa1 / (1. + exp_coa2) * @@ -507,7 +507,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, exp( -p_coa3 * SQR(workspace->total_bond_order[k]-BOA_jk) ) * exp( -p_coa4 * SQR(BOA_ij - 1.5) ) * exp( -p_coa4 * SQR(BOA_jk - 1.5) ); - + CEcoa1 = -2 * p_coa4 * (BOA_ij - 1.5) * e_coa; CEcoa2 = -2 * p_coa4 * (BOA_jk - 1.5) * e_coa; CEcoa3 = -p_coa2 * exp_coa2 * e_coa / (1 + exp_coa2); @@ -516,15 +516,15 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, CEcoa5 = -2 * p_coa3 * (workspace->total_bond_order[k]-BOA_jk) * e_coa; /* END COALITION ENERGY */ - - + + /* FORCES */ bo_ij->Cdbo += (CEval1 + CEpen2 + (CEcoa1 - CEcoa4)); bo_jk->Cdbo += (CEval2 + CEpen3 + (CEcoa2 - CEcoa5)); workspace->CdDelta[j] += ((CEval3 + CEval7) + CEpen1 + CEcoa3); workspace->CdDeltaReduction[reductionOffset+i] += CEcoa4; workspace->CdDeltaReduction[reductionOffset+k] += CEcoa5; - + for (t = start_j; t < end_j; ++t) { pbond_jt = &( bonds->select.bond_list[t] ); bo_jt = &(pbond_jt->bo_data); @@ -536,7 +536,7 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, bo_jt->Cdbopi += CEval5; bo_jt->Cdbopi2 += CEval5; } - + if( control->virial == 0 ) { rvec_ScaledAdd( workspace->f[j], CEval8, p_ijk->dcos_dj ); rvec_ScaledAdd( workspace->forceReduction[reductionOffset+i], @@ -549,34 +549,34 @@ void Valence_AnglesOMP( reax_system *system, control_params *control, added directly into forces and pressure vector/tensor */ rvec_Scale( force, CEval8, p_ijk->dcos_di ); rvec_Add( workspace->forceReduction[reductionOffset+i], force ); - + rvec_iMultiply( ext_press, pbond_ij->rel_box, force ); rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); - + rvec_ScaledAdd( workspace->f[j], CEval8, p_ijk->dcos_dj ); - + rvec_Scale( force, CEval8, p_ijk->dcos_dk ); rvec_Add( workspace->forceReduction[reductionOffset+k], force ); rvec_iMultiply( ext_press, pbond_jk->rel_box, force ); rvec_Add( workspace->my_ext_pressReduction[tid], ext_press ); } - + /* tally into per-atom virials */ if( system->pair_ptr->vflag_atom || system->pair_ptr->evflag) { - + /* Acquire vectors */ rvec_ScaledSum( delij, 1., system->my_atoms[i].x, -1., system->my_atoms[j].x ); rvec_ScaledSum( delkj, 1., system->my_atoms[k].x, -1., system->my_atoms[j].x ); - + rvec_Scale( fi_tmp, -CEval8, p_ijk->dcos_di ); rvec_Scale( fj_tmp, -CEval8, p_ijk->dcos_dj ); rvec_Scale( fk_tmp, -CEval8, p_ijk->dcos_dk ); - + eng_tmp = e_ang + e_pen + e_coa; - + if( system->pair_ptr->evflag) pair_reax_ptr->ev_tally_thr_proxy(system->pair_ptr, j, j, system->N, 1, eng_tmp, 0.0, 0.0, 0.0, 0.0, 0.0, thr); diff --git a/src/USER-OMP/respa_omp.cpp b/src/USER-OMP/respa_omp.cpp index e596caab81..d4fa529b1c 100644 --- a/src/USER-OMP/respa_omp.cpp +++ b/src/USER-OMP/respa_omp.cpp @@ -155,11 +155,11 @@ void RespaOMP::setup(int flag) #endif { #if defined(_OPENMP) - int tid = omp_get_thread_num(); + int tid = omp_get_thread_num(); #else - int tid = 0; + int tid = 0; #endif - data_reduce_thr(atom->f[0], nall, nthreads, 3, tid); + data_reduce_thr(atom->f[0], nall, nthreads, 3, tid); } fix->did_reduce(); } @@ -250,11 +250,11 @@ void RespaOMP::setup_minimal(int flag) #endif { #if defined(_OPENMP) - int tid = omp_get_thread_num(); + int tid = omp_get_thread_num(); #else - int tid = 0; + int tid = 0; #endif - data_reduce_thr(atom->f[0], nall, nthreads, 3, tid); + data_reduce_thr(atom->f[0], nall, nthreads, 3, tid); } fix->did_reduce(); } @@ -403,11 +403,11 @@ void RespaOMP::recurse(int ilevel) #endif { #if defined(_OPENMP) - int tid = omp_get_thread_num(); + int tid = omp_get_thread_num(); #else - int tid = 0; + int tid = 0; #endif - data_reduce_thr(atom->f[0], nall, nthreads, 3, tid); + data_reduce_thr(atom->f[0], nall, nthreads, 3, tid); } fix->did_reduce(); } diff --git a/src/USER-QTB/fix_qbmsst.cpp b/src/USER-QTB/fix_qbmsst.cpp index 417e7ac87d..21ae464e10 100644 --- a/src/USER-QTB/fix_qbmsst.cpp +++ b/src/USER-QTB/fix_qbmsst.cpp @@ -174,13 +174,13 @@ FixQBMSST::FixQBMSST(LAMMPS *lmp, int narg, char **arg) : fprintf(screen," Artificial viscosity (units of mass/length/time) = %12.5e\n", mu); if (p0_set) - fprintf(screen," Initial pressure specified to be %12.5e\n", p0); + fprintf(screen," Initial pressure specified to be %12.5e\n", p0); else fprintf(screen," Initial pressure calculated on first step\n"); if (v0_set) - fprintf(screen," Initial volume specified to be %12.5e\n", v0); + fprintf(screen," Initial volume specified to be %12.5e\n", v0); else fprintf(screen," Initial volume calculated on first step\n"); if (e0_set) - fprintf(screen," Initial energy specified to be %12.5e\n", e0); + fprintf(screen," Initial energy specified to be %12.5e\n", e0); else fprintf(screen," Initial energy calculated on first step\n"); } if (logfile) { @@ -194,13 +194,13 @@ FixQBMSST::FixQBMSST(LAMMPS *lmp, int narg, char **arg) : fprintf(logfile," Artificial viscosity (units of mass/length/time) = %12.5e\n", mu); if (p0_set) - fprintf(logfile," Initial pressure specified to be %12.5e\n", p0); + fprintf(logfile," Initial pressure specified to be %12.5e\n", p0); else fprintf(logfile," Initial pressure calculated on first step\n"); if (v0_set) - fprintf(logfile," Initial volume specified to be %12.5e\n", v0); + fprintf(logfile," Initial volume specified to be %12.5e\n", v0); else fprintf(logfile," Initial volume calculated on first step\n"); if (e0_set) - fprintf(logfile," Initial energy specified to be %12.5e\n", e0); + fprintf(logfile," Initial energy specified to be %12.5e\n", e0); else fprintf(logfile," Initial energy calculated on first step\n"); } } @@ -361,7 +361,7 @@ void FixQBMSST::init() // initiate qtb temperature if (!qtb_set) { - t_current = t_init; qtb_set=1; + t_current = t_init; qtb_set=1; } old_eavg = e0; @@ -411,13 +411,13 @@ void FixQBMSST::init() nrigid = 0; for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"rigid") == 0 || - strcmp(modify->fix[i]->style,"poems") == 0) nrigid++; + strcmp(modify->fix[i]->style,"poems") == 0) nrigid++; if (nrigid) { rfix = new int[nrigid]; nrigid = 0; for (int i = 0; i < modify->nfix; i++) if (strcmp(modify->fix[i]->style,"rigid") == 0 || - strcmp(modify->fix[i]->style,"poems") == 0) rfix[nrigid++] = i; + strcmp(modify->fix[i]->style,"poems") == 0) rfix[nrigid++] = i; } } @@ -482,19 +482,19 @@ void FixQBMSST::setup(int vflag) if ( comm->me == 0 && tscale != 1.0) { if ( screen ) - fprintf(screen,"Fix QBMSST initial strain rate of %12.5e established " - "by reducing temperature by factor of %12.5e\n", - fac2,tscale); + fprintf(screen,"Fix QBMSST initial strain rate of %12.5e established " + "by reducing temperature by factor of %12.5e\n", + fac2,tscale); if ( logfile ) - fprintf(logfile,"Fix QBMSST initial strain rate of %12.5e established " - "by reducing temperature by factor of %12.5e\n", - fac2,tscale); + fprintf(logfile,"Fix QBMSST initial strain rate of %12.5e established " + "by reducing temperature by factor of %12.5e\n", + fac2,tscale); } for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { for (int k = 0; k < 3; k++ ) { v[i][k]*=sqrt_initial_temperature_scaling; - } + } } } } @@ -569,9 +569,9 @@ void FixQBMSST::initial_integrate(int vflag) //update random array for (int m = 0; m < 2*N_f-1; m++) { - random_array_0[j][m] = random_array_0[j][m+1]; - random_array_1[j][m] = random_array_1[j][m+1]; - random_array_2[j][m] = random_array_2[j][m+1]; + random_array_0[j][m] = random_array_0[j][m+1]; + random_array_1[j][m] = random_array_1[j][m+1]; + random_array_2[j][m] = random_array_2[j][m+1]; } random_array_0[j][2*N_f-1] = random->uniform()-0.5; random_array_1[j][2*N_f-1] = random->uniform()-0.5; @@ -629,20 +629,20 @@ void FixQBMSST::initial_integrate(int vflag) for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { for ( k = 0; k < 3; k++ ) { - double C = (f[i][k] + fran[i][k])* force->ftm2v / mass[type[i]];// this term now has a random force part - double D = mu * omega[sd] * omega[sd] / - (velocity_sum * mass[type[i]] * vol ) - fric_coef; - old_velocity[i][k] = v[i][k]; - if ( k == direction ) { - D = D - 2.0 * omega[sd] / vol; - } - if ( fabs(dthalf * D) > 1.0e-06 ) { - double expd = exp(D * dthalf); - v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; - } else { - v[i][k] = v[i][k] + ( C + D * v[i][k] ) * dthalf + - 0.5 * (D * D * v[i][k] + C * D ) * dthalf * dthalf; - } + double C = (f[i][k] + fran[i][k])* force->ftm2v / mass[type[i]];// this term now has a random force part + double D = mu * omega[sd] * omega[sd] / + (velocity_sum * mass[type[i]] * vol ) - fric_coef; + old_velocity[i][k] = v[i][k]; + if ( k == direction ) { + D = D - 2.0 * omega[sd] / vol; + } + if ( fabs(dthalf * D) > 1.0e-06 ) { + double expd = exp(D * dthalf); + v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; + } else { + v[i][k] = v[i][k] + ( C + D * v[i][k] ) * dthalf + + 0.5 * (D * D * v[i][k] + C * D ) * dthalf * dthalf; + } } } } @@ -653,7 +653,7 @@ void FixQBMSST::initial_integrate(int vflag) for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { for ( k = 0; k < 3; k++ ) { - v[i][k] = old_velocity[i][k]; + v[i][k] = old_velocity[i][k]; } } } @@ -662,20 +662,20 @@ void FixQBMSST::initial_integrate(int vflag) for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { for ( k = 0; k < 3; k++ ) { - double C = (f[i][k] + fran[i][k])* force->ftm2v / mass[type[i]];// this term now has a random force part - double D = mu * omega[sd] * omega[sd] / - (velocity_sum * mass[type[i]] * vol ) - fric_coef; - - if ( k == direction ) { - D = D - 2.0 * omega[sd] / vol; - } - if ( fabs(dthalf * D) > 1.0e-06 ) { - double expd = exp(D * dthalf); - v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; - } else { - v[i][k] = v[i][k] + ( C + D * v[i][k] ) * dthalf + - 0.5 * (D * D * v[i][k] + C * D ) * dthalf * dthalf; - } + double C = (f[i][k] + fran[i][k])* force->ftm2v / mass[type[i]];// this term now has a random force part + double D = mu * omega[sd] * omega[sd] / + (velocity_sum * mass[type[i]] * vol ) - fric_coef; + + if ( k == direction ) { + D = D - 2.0 * omega[sd] / vol; + } + if ( fabs(dthalf * D) > 1.0e-06 ) { + double expd = exp(D * dthalf); + v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; + } else { + v[i][k] = v[i][k] + ( C + D * v[i][k] ) * dthalf + + 0.5 * (D * D * v[i][k] + C * D ) * dthalf * dthalf; + } } } } @@ -730,20 +730,20 @@ void FixQBMSST::final_integrate() for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { for ( int k = 0; k < 3; k++ ) { - double C = (f[i][k] + fran[i][k]) * force->ftm2v / mass[type[i]];// this term now has a random force part - double D = mu * omega[sd] * omega[sd] / - (velocity_sum * mass[type[i]] * vol ) - fric_coef; - - if ( k == direction ) { - D = D - 2.0 * omega[sd] / vol; - } - if ( fabs(dthalf * D) > 1.0e-06 ) { - double expd = exp(D * dthalf); - v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; - } else { - v[i][k] = v[i][k] + ( C + D * v[i][k] ) * dthalf + - 0.5 * (D * D * v[i][k] + C * D ) * dthalf * dthalf; - } + double C = (f[i][k] + fran[i][k]) * force->ftm2v / mass[type[i]];// this term now has a random force part + double D = mu * omega[sd] * omega[sd] / + (velocity_sum * mass[type[i]] * vol ) - fric_coef; + + if ( k == direction ) { + D = D - 2.0 * omega[sd] / vol; + } + if ( fabs(dthalf * D) > 1.0e-06 ) { + double expd = exp(D * dthalf); + v[i][k] = expd * ( C + D * v[i][k] - C / expd ) / D; + } else { + v[i][k] = v[i][k] + ( C + D * v[i][k] ) * dthalf + + 0.5 * (D * D * v[i][k] + C * D ) * dthalf * dthalf; + } } } } @@ -775,7 +775,7 @@ void FixQBMSST::final_integrate() if ( B * dthalf > 1.0e-06 ) { omega[sd] = ( omega[sd] + A * - ( exp(B * dthalf) - 1.0 ) / B ) * exp(-B * dthalf); + ( exp(B * dthalf) - 1.0 ) / B ) * exp(-B * dthalf); } else { omega[sd] = omega[sd] + (A - B * omega[sd]) * dthalf + 0.5 * (B * B * omega[sd] - A * B ) * dthalf * dthalf; diff --git a/src/USER-QTB/fix_qtb.cpp b/src/USER-QTB/fix_qtb.cpp index ed9bc75574..98dd498088 100644 --- a/src/USER-QTB/fix_qtb.cpp +++ b/src/USER-QTB/fix_qtb.cpp @@ -257,9 +257,9 @@ void FixQTB::post_force(int vflag) //update random array for (int m = 0; m < 2*N_f-1; m++) { - random_array_0[j][m] = random_array_0[j][m+1]; - random_array_1[j][m] = random_array_1[j][m+1]; - random_array_2[j][m] = random_array_2[j][m+1]; + random_array_0[j][m] = random_array_0[j][m+1]; + random_array_1[j][m] = random_array_1[j][m+1]; + random_array_2[j][m] = random_array_2[j][m+1]; } random_array_0[j][2*N_f-1] = random->uniform()-0.5; random_array_1[j][2*N_f-1] = random->uniform()-0.5; diff --git a/src/USER-REAXC/fix_qeq_reax.cpp b/src/USER-REAXC/fix_qeq_reax.cpp index a79c5edd07..326af7505a 100644 --- a/src/USER-REAXC/fix_qeq_reax.cpp +++ b/src/USER-REAXC/fix_qeq_reax.cpp @@ -504,7 +504,7 @@ void FixQEqReax::pre_force(int vflag) init_matvec(); - matvecs_s = CG(b_s, s); // CG on s - parallel + matvecs_s = CG(b_s, s); // CG on s - parallel matvecs_t = CG(b_t, t); // CG on t - parallel matvecs = matvecs_s + matvecs_t; @@ -631,9 +631,9 @@ void FixQEqReax::compute_H() if (dy > SMALL) flag = 1; else if (fabs(dy) < SMALL && dx > SMALL) flag = 1; - } - } - } + } + } + } if (flag) { H.jlist[m_fill] = j; diff --git a/src/USER-REAXC/pair_reaxc.cpp b/src/USER-REAXC/pair_reaxc.cpp index 626e965667..6081563e18 100644 --- a/src/USER-REAXC/pair_reaxc.cpp +++ b/src/USER-REAXC/pair_reaxc.cpp @@ -16,7 +16,7 @@ (now at Lawrence Berkeley National Laboratory, hmaktulga@lbl.gov) Per-atom energy/virial added by Ray Shan (Sandia) Fix reax/c/bonds and fix reax/c/species for pair_style reax/c added by - Ray Shan (Sandia) + Ray Shan (Sandia) Hybrid and hybrid/overlay compatibility added by Ray Shan (Sandia) ------------------------------------------------------------------------- */ @@ -261,14 +261,14 @@ void PairReaxC::settings(int narg, char **arg) if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reax/c command"); system->safezone = force->numeric(FLERR,arg[iarg+1]); if (system->safezone < 0.0) - error->all(FLERR,"Illegal pair_style reax/c safezone command"); + error->all(FLERR,"Illegal pair_style reax/c safezone command"); system->saferzone = system->safezone*1.2 + 0.2; iarg += 2; } else if (strcmp(arg[iarg],"mincap") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reax/c command"); system->mincap = force->inumeric(FLERR,arg[iarg+1]); if (system->mincap < 0) - error->all(FLERR,"Illegal pair_style reax/c mincap command"); + error->all(FLERR,"Illegal pair_style reax/c mincap command"); iarg += 2; } else error->all(FLERR,"Illegal pair_style reax/c command"); } @@ -325,7 +325,7 @@ void PairReaxC::coeff( int nargs, char **args ) for (int j = 0; j < nreax_types; j++) if (strcasecmp(args[i],system->reax_param.sbp[j].name) == 0) { map[i-2] = j; - itmp ++; + itmp ++; } // error check @@ -390,8 +390,8 @@ void PairReaxC::init_style( ) cutmax = MAX3(control->nonb_cut, control->hbond_cut, control->bond_cut); if ((cutmax < 2.0*control->bond_cut) && (comm->me == 0)) error->warning(FLERR,"Total cutoff < 2*bond cutoff. May need to use an " - "increased neighbor list skin."); - + "increased neighbor list skin."); + for( int i = 0; i < LIST_N; ++i ) lists[i].allocated = 0; @@ -597,7 +597,7 @@ void PairReaxC::compute(int eflag, int vflag) for (i = 0; i < system->N; i ++) for (j = 0; j < MAXSPECBOND; j ++) { tmpbo[i][j] = 0.0; - tmpid[i][j] = 0; + tmpid[i][j] = 0; } FindBond(); } @@ -841,10 +841,10 @@ void PairReaxC::FindBond() bo_tmp = bo_ij->bo_data.BO; if (bo_tmp >= bo_cut ) { - tmpid[i][nj] = j; - tmpbo[i][nj] = bo_tmp; - nj ++; - if (nj > MAXSPECBOND) error->all(FLERR,"Increase MAXSPECBOND in reaxc_defs.h"); + tmpid[i][nj] = j; + tmpbo[i][nj] = bo_tmp; + nj ++; + if (nj > MAXSPECBOND) error->all(FLERR,"Increase MAXSPECBOND in reaxc_defs.h"); } } } diff --git a/src/USER-REAXC/reaxc_allocate.cpp b/src/USER-REAXC/reaxc_allocate.cpp index e46fe8ba9f..a07f090f92 100644 --- a/src/USER-REAXC/reaxc_allocate.cpp +++ b/src/USER-REAXC/reaxc_allocate.cpp @@ -300,10 +300,10 @@ int Allocate_Workspace( reax_system *system, control_params *control, // storage for reductions with multiple threads #ifdef LMP_USER_OMP workspace->CdDeltaReduction = (double *) scalloc(sizeof(double), total_cap*control->nthreads, - "cddelta_reduce", comm); + "cddelta_reduce", comm); workspace->forceReduction = (rvec *) scalloc(sizeof(rvec), total_cap*control->nthreads, - "forceReduction", comm); + "forceReduction", comm); workspace->valence_angle_atom_myoffset = (int *) scalloc(sizeof(int), total_cap, "valence_angle_atom_myoffset", comm); workspace->my_ext_pressReduction = (rvec *) calloc(sizeof(rvec), control->nthreads); diff --git a/src/USER-REAXC/reaxc_bonds.cpp b/src/USER-REAXC/reaxc_bonds.cpp index cf536fe606..9678addd6b 100644 --- a/src/USER-REAXC/reaxc_bonds.cpp +++ b/src/USER-REAXC/reaxc_bonds.cpp @@ -63,14 +63,14 @@ void Bonds( reax_system *system, control_params *control, j = bonds->select.bond_list[pj].nbr; if( system->my_atoms[i].orig_id > system->my_atoms[j].orig_id ) - continue; + continue; if( system->my_atoms[i].orig_id == system->my_atoms[j].orig_id ) { if (system->my_atoms[j].x[2] < system->my_atoms[i].x[2]) continue; - if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && - system->my_atoms[j].x[1] < system->my_atoms[i].x[1]) continue; if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && - system->my_atoms[j].x[1] == system->my_atoms[i].x[1] && - system->my_atoms[j].x[0] < system->my_atoms[i].x[0]) continue; + system->my_atoms[j].x[1] < system->my_atoms[i].x[1]) continue; + if (system->my_atoms[j].x[2] == system->my_atoms[i].x[2] && + system->my_atoms[j].x[1] == system->my_atoms[i].x[1] && + system->my_atoms[j].x[0] < system->my_atoms[i].x[0]) continue; } /* set the pointers */ @@ -86,17 +86,17 @@ void Bonds( reax_system *system, control_params *control, else pow_BOs_be2 = pow( bo_ij->BO_s, twbp->p_be2 ); exp_be12 = exp( twbp->p_be1 * ( 1.0 - pow_BOs_be2 ) ); CEbo = -twbp->De_s * exp_be12 * - ( 1.0 - twbp->p_be1 * twbp->p_be2 * pow_BOs_be2 ); + ( 1.0 - twbp->p_be1 * twbp->p_be2 * pow_BOs_be2 ); /* calculate the Bond Energy */ data->my_en.e_bond += ebond = - -twbp->De_s * bo_ij->BO_s * exp_be12 - -twbp->De_p * bo_ij->BO_pi - -twbp->De_pp * bo_ij->BO_pi2; + -twbp->De_s * bo_ij->BO_s * exp_be12 + -twbp->De_p * bo_ij->BO_pi + -twbp->De_pp * bo_ij->BO_pi2; /* tally into per-atom energy */ if( system->pair_ptr->evflag) - system->pair_ptr->ev_tally(i,j,natoms,1,ebond,0.0,0.0,0.0,0.0,0.0); + system->pair_ptr->ev_tally(i,j,natoms,1,ebond,0.0,0.0,0.0,0.0,0.0); /* calculate derivatives of Bond Orders */ bo_ij->Cdbo += CEbo; @@ -105,33 +105,33 @@ void Bonds( reax_system *system, control_params *control, /* Stabilisation terminal triple bond */ if( bo_ij->BO >= 1.00 ) { - if( gp37 == 2 || - (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || - (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990) ) { - exphu = exp( -gp7 * SQR(bo_ij->BO - 2.50) ); - exphua1 = exp(-gp3 * (workspace->total_bond_order[i]-bo_ij->BO)); - exphub1 = exp(-gp3 * (workspace->total_bond_order[j]-bo_ij->BO)); - exphuov = exp(gp4 * (workspace->Delta[i] + workspace->Delta[j])); - hulpov = 1.0 / (1.0 + 25.0 * exphuov); - - estriph = gp10 * exphu * hulpov * (exphua1 + exphub1); - data->my_en.e_bond += estriph; - - decobdbo = gp10 * exphu * hulpov * (exphua1 + exphub1) * - ( gp3 - 2.0 * gp7 * (bo_ij->BO-2.50) ); - decobdboua = -gp10 * exphu * hulpov * - (gp3*exphua1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); - decobdboub = -gp10 * exphu * hulpov * - (gp3*exphub1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); - - /* tally into per-atom energy */ - if( system->pair_ptr->evflag) - system->pair_ptr->ev_tally(i,j,natoms,1,estriph,0.0,0.0,0.0,0.0,0.0); - - bo_ij->Cdbo += decobdbo; - workspace->CdDelta[i] += decobdboua; - workspace->CdDelta[j] += decobdboub; - } + if( gp37 == 2 || + (sbp_i->mass == 12.0000 && sbp_j->mass == 15.9990) || + (sbp_j->mass == 12.0000 && sbp_i->mass == 15.9990) ) { + exphu = exp( -gp7 * SQR(bo_ij->BO - 2.50) ); + exphua1 = exp(-gp3 * (workspace->total_bond_order[i]-bo_ij->BO)); + exphub1 = exp(-gp3 * (workspace->total_bond_order[j]-bo_ij->BO)); + exphuov = exp(gp4 * (workspace->Delta[i] + workspace->Delta[j])); + hulpov = 1.0 / (1.0 + 25.0 * exphuov); + + estriph = gp10 * exphu * hulpov * (exphua1 + exphub1); + data->my_en.e_bond += estriph; + + decobdbo = gp10 * exphu * hulpov * (exphua1 + exphub1) * + ( gp3 - 2.0 * gp7 * (bo_ij->BO-2.50) ); + decobdboua = -gp10 * exphu * hulpov * + (gp3*exphua1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); + decobdboub = -gp10 * exphu * hulpov * + (gp3*exphub1 + 25.0*gp4*exphuov*hulpov*(exphua1+exphub1)); + + /* tally into per-atom energy */ + if( system->pair_ptr->evflag) + system->pair_ptr->ev_tally(i,j,natoms,1,estriph,0.0,0.0,0.0,0.0,0.0); + + bo_ij->Cdbo += decobdbo; + workspace->CdDelta[i] += decobdboua; + workspace->CdDelta[j] += decobdboub; + } } } } diff --git a/src/USER-REAXC/reaxc_forces.cpp b/src/USER-REAXC/reaxc_forces.cpp index fe3cc07a70..00b29824ea 100644 --- a/src/USER-REAXC/reaxc_forces.cpp +++ b/src/USER-REAXC/reaxc_forces.cpp @@ -257,7 +257,7 @@ void Init_Forces_noQEq( reax_system *system, control_params *control, if( flag ) { type_j = atom_j->type; - if (type_j < 0) continue; + if (type_j < 0) continue; sbp_j = &(system->reax_param.sbp[type_j]); twbp = &(system->reax_param.tbp[type_i][type_j]); diff --git a/src/USER-REAXC/reaxc_hydrogen_bonds.cpp b/src/USER-REAXC/reaxc_hydrogen_bonds.cpp index ff771ad65b..cb516b24f7 100644 --- a/src/USER-REAXC/reaxc_hydrogen_bonds.cpp +++ b/src/USER-REAXC/reaxc_hydrogen_bonds.cpp @@ -76,7 +76,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, pbond_ij = &( bond_list[pi] ); i = pbond_ij->nbr; type_i = system->my_atoms[i].type; - if (type_i < 0) continue; + if (type_i < 0) continue; bo_ij = &(pbond_ij->bo_data); if( system->reax_param.sbp[type_i].p_hbond == 2 && @@ -88,7 +88,7 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, /* set k's varibles */ k = hbond_list[pk].nbr; type_k = system->my_atoms[k].type; - if (type_k < 0) continue; + if (type_k < 0) continue; nbr_jk = hbond_list[pk].ptr; r_jk = nbr_jk->d; rvec_Scale( dvec_jk, hbond_list[pk].scl, nbr_jk->dvec ); @@ -101,9 +101,9 @@ void Hydrogen_Bonds( reax_system *system, control_params *control, if( system->my_atoms[i].orig_id != system->my_atoms[k].orig_id ) { bo_ij = &(pbond_ij->bo_data); type_i = system->my_atoms[i].type; - if (type_i < 0) continue; + if (type_i < 0) continue; hbp = &(system->reax_param.hbp[ type_i ][ type_j ][ type_k ]); - if (hbp->r0_hb <= 0.0) continue; + if (hbp->r0_hb <= 0.0) continue; ++num_hb_intrs; Calculate_Theta( pbond_ij->dvec, pbond_ij->d, dvec_jk, r_jk, diff --git a/src/USER-REAXC/reaxc_multi_body.cpp b/src/USER-REAXC/reaxc_multi_body.cpp index ecfd3ad04d..ce5b966529 100644 --- a/src/USER-REAXC/reaxc_multi_body.cpp +++ b/src/USER-REAXC/reaxc_multi_body.cpp @@ -99,7 +99,7 @@ void Atom_Energy( reax_system *system, control_params *control, for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if (type_j < 0) continue; + if (type_j < 0) continue; if( !strcmp( system->reax_param.sbp[type_j].name, "C" ) ) { twbp = &( system->reax_param.tbp[type_i][type_j]); @@ -141,7 +141,7 @@ void Atom_Energy( reax_system *system, control_params *control, for( pj = Start_Index(i, bonds); pj < End_Index(i, bonds); ++pj ) { j = bonds->select.bond_list[pj].nbr; type_j = system->my_atoms[j].type; - if (type_j < 0) continue; + if (type_j < 0) continue; bo_ij = &(bonds->select.bond_list[pj].bo_data); twbp = &(system->reax_param.tbp[ type_i ][ type_j ]); diff --git a/src/USER-REAXC/reaxc_torsion_angles.cpp b/src/USER-REAXC/reaxc_torsion_angles.cpp index 74d5b04f20..c5a7f23b30 100644 --- a/src/USER-REAXC/reaxc_torsion_angles.cpp +++ b/src/USER-REAXC/reaxc_torsion_angles.cpp @@ -182,14 +182,14 @@ void Torsion_Angles( reax_system *system, control_params *control, BOA_jk = bo_jk->BO - control->thb_cut; if( system->my_atoms[j].orig_id > system->my_atoms[k].orig_id ) - continue; + continue; if( system->my_atoms[j].orig_id == system->my_atoms[k].orig_id ) { if (system->my_atoms[k].x[2] < system->my_atoms[j].x[2]) continue; - if (system->my_atoms[k].x[2] == system->my_atoms[j].x[2] && - system->my_atoms[k].x[1] < system->my_atoms[j].x[1]) continue; if (system->my_atoms[k].x[2] == system->my_atoms[j].x[2] && - system->my_atoms[k].x[1] == system->my_atoms[j].x[1] && - system->my_atoms[k].x[0] < system->my_atoms[j].x[0]) continue; + system->my_atoms[k].x[1] < system->my_atoms[j].x[1]) continue; + if (system->my_atoms[k].x[2] == system->my_atoms[j].x[2] && + system->my_atoms[k].x[1] == system->my_atoms[j].x[1] && + system->my_atoms[k].x[0] < system->my_atoms[j].x[0]) continue; } if( bo_jk->BO > control->thb_cut/*0*/ && Num_Entries(pk, thb_intrs) ) { diff --git a/src/USER-SMD/atom_vec_smd.cpp b/src/USER-SMD/atom_vec_smd.cpp index d2d72a855a..84fbfd93ef 100644 --- a/src/USER-SMD/atom_vec_smd.cpp +++ b/src/USER-SMD/atom_vec_smd.cpp @@ -45,44 +45,44 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ AtomVecSMD::AtomVecSMD(LAMMPS *lmp) : - AtomVec(lmp) { - molecular = 0; - - comm_x_only = 0; - comm_f_only = 0; - size_forward = 6; // variables that are changed by time integration - size_reverse = 4; // f[3] + de - size_border = 31; - size_velocity = 6; // v + vest - size_data_atom = 13; // 7 + 3 x0 + 3 x - size_data_vel = 4; - xcol_data = 11; - - atom->radius_flag = 1; - atom->rmass_flag = 1; - atom->vfrac_flag = 1; - atom->contact_radius_flag = 1; - atom->molecule_flag = 1; - atom->smd_data_9_flag = 1; - atom->e_flag = 1; - atom->vest_flag = 1; - atom->smd_stress_flag = 1; - atom->eff_plastic_strain_flag = 1; - atom->x0_flag = 1; - atom->damage_flag = 1; - atom->eff_plastic_strain_rate_flag = 1; - - forceclearflag = 1; - - atom->smd_flag = 1; + AtomVec(lmp) { + molecular = 0; + + comm_x_only = 0; + comm_f_only = 0; + size_forward = 6; // variables that are changed by time integration + size_reverse = 4; // f[3] + de + size_border = 31; + size_velocity = 6; // v + vest + size_data_atom = 13; // 7 + 3 x0 + 3 x + size_data_vel = 4; + xcol_data = 11; + + atom->radius_flag = 1; + atom->rmass_flag = 1; + atom->vfrac_flag = 1; + atom->contact_radius_flag = 1; + atom->molecule_flag = 1; + atom->smd_data_9_flag = 1; + atom->e_flag = 1; + atom->vest_flag = 1; + atom->smd_stress_flag = 1; + atom->eff_plastic_strain_flag = 1; + atom->x0_flag = 1; + atom->damage_flag = 1; + atom->eff_plastic_strain_rate_flag = 1; + + forceclearflag = 1; + + atom->smd_flag = 1; } /* ---------------------------------------------------------------------- */ void AtomVecSMD::init() { - AtomVec::init(); + AtomVec::init(); - // do nothing here + // do nothing here } /* ---------------------------------------------------------------------- @@ -92,43 +92,43 @@ void AtomVecSMD::init() { ------------------------------------------------------------------------- */ void AtomVecSMD::grow(int n) { - if (n == 0) - grow_nmax(); - else - nmax = n; - atom->nmax = nmax; - if (nmax < 0 || nmax > MAXSMALLINT) - error->one(FLERR, "Per-processor system is too big"); - - //printf("in grow, nmax is now %d\n", nmax); - - tag = memory->grow(atom->tag, nmax, "atom:tag"); - type = memory->grow(atom->type, nmax, "atom:type"); - mask = memory->grow(atom->mask, nmax, "atom:mask"); - image = memory->grow(atom->image, nmax, "atom:image"); - x = memory->grow(atom->x, nmax, 3, "atom:x"); - v = memory->grow(atom->v, nmax, 3, "atom:v"); - - f = memory->grow(atom->f, nmax * comm->nthreads, 3, "atom:f"); - de = memory->grow(atom->de, nmax * comm->nthreads, "atom:de"); - - vfrac = memory->grow(atom->vfrac, nmax, "atom:vfrac"); - rmass = memory->grow(atom->rmass, nmax, "atom:rmass"); - x0 = memory->grow(atom->x0, nmax, 3, "atom:x0"); - radius = memory->grow(atom->radius, nmax, "atom:radius"); - contact_radius = memory->grow(atom->contact_radius, nmax, "atom:contact_radius"); - molecule = memory->grow(atom->molecule, nmax, "atom:molecule"); - smd_data_9 = memory->grow(atom->smd_data_9, nmax, NMAT_FULL, "atom:defgrad_old"); - e = memory->grow(atom->e, nmax, "atom:e"); - vest = memory->grow(atom->vest, nmax, 3, "atom:vest"); - tlsph_stress = memory->grow(atom->smd_stress, nmax, NMAT_SYMM, "atom:tlsph_stress"); - eff_plastic_strain = memory->grow(atom->eff_plastic_strain, nmax, "atom:eff_plastic_strain"); - eff_plastic_strain_rate = memory->grow(atom->eff_plastic_strain_rate, nmax, "atom:eff_plastic_strain_rate"); - damage = memory->grow(atom->damage, nmax, "atom:damage"); - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); + if (n == 0) + grow_nmax(); + else + nmax = n; + atom->nmax = nmax; + if (nmax < 0 || nmax > MAXSMALLINT) + error->one(FLERR, "Per-processor system is too big"); + + //printf("in grow, nmax is now %d\n", nmax); + + tag = memory->grow(atom->tag, nmax, "atom:tag"); + type = memory->grow(atom->type, nmax, "atom:type"); + mask = memory->grow(atom->mask, nmax, "atom:mask"); + image = memory->grow(atom->image, nmax, "atom:image"); + x = memory->grow(atom->x, nmax, 3, "atom:x"); + v = memory->grow(atom->v, nmax, 3, "atom:v"); + + f = memory->grow(atom->f, nmax * comm->nthreads, 3, "atom:f"); + de = memory->grow(atom->de, nmax * comm->nthreads, "atom:de"); + + vfrac = memory->grow(atom->vfrac, nmax, "atom:vfrac"); + rmass = memory->grow(atom->rmass, nmax, "atom:rmass"); + x0 = memory->grow(atom->x0, nmax, 3, "atom:x0"); + radius = memory->grow(atom->radius, nmax, "atom:radius"); + contact_radius = memory->grow(atom->contact_radius, nmax, "atom:contact_radius"); + molecule = memory->grow(atom->molecule, nmax, "atom:molecule"); + smd_data_9 = memory->grow(atom->smd_data_9, nmax, NMAT_FULL, "atom:defgrad_old"); + e = memory->grow(atom->e, nmax, "atom:e"); + vest = memory->grow(atom->vest, nmax, 3, "atom:vest"); + tlsph_stress = memory->grow(atom->smd_stress, nmax, NMAT_SYMM, "atom:tlsph_stress"); + eff_plastic_strain = memory->grow(atom->eff_plastic_strain, nmax, "atom:eff_plastic_strain"); + eff_plastic_strain_rate = memory->grow(atom->eff_plastic_strain_rate, nmax, "atom:eff_plastic_strain_rate"); + damage = memory->grow(atom->damage, nmax, "atom:damage"); + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); } /* ---------------------------------------------------------------------- @@ -136,28 +136,28 @@ void AtomVecSMD::grow(int n) { ------------------------------------------------------------------------- */ void AtomVecSMD::grow_reset() { - tag = atom->tag; - type = atom->type; - mask = atom->mask; - image = atom->image; - x = atom->x; - v = atom->v; - f = atom->f; - radius = atom->radius; - rmass = atom->rmass; - - vfrac = atom->vfrac; - x0 = atom->x0; - contact_radius = atom->contact_radius; - molecule = atom->molecule; - smd_data_9 = atom->smd_data_9; - e = atom->e; - de = atom->de; - tlsph_stress = atom->smd_stress; - eff_plastic_strain = atom->eff_plastic_strain; - eff_plastic_strain_rate = atom->eff_plastic_strain_rate; - damage = atom->damage; - vest = atom->vest; + tag = atom->tag; + type = atom->type; + mask = atom->mask; + image = atom->image; + x = atom->x; + v = atom->v; + f = atom->f; + radius = atom->radius; + rmass = atom->rmass; + + vfrac = atom->vfrac; + x0 = atom->x0; + contact_radius = atom->contact_radius; + molecule = atom->molecule; + smd_data_9 = atom->smd_data_9; + e = atom->e; + de = atom->de; + tlsph_stress = atom->smd_stress; + eff_plastic_strain = atom->eff_plastic_strain; + eff_plastic_strain_rate = atom->eff_plastic_strain_rate; + damage = atom->damage; + vest = atom->vest; } /* ---------------------------------------------------------------------- @@ -165,555 +165,555 @@ void AtomVecSMD::grow_reset() { ------------------------------------------------------------------------- */ void AtomVecSMD::copy(int i, int j, int delflag) { - tag[j] = tag[i]; - type[j] = type[i]; - mask[j] = mask[i]; - image[j] = image[i]; - x[j][0] = x[i][0]; - x[j][1] = x[i][1]; - x[j][2] = x[i][2]; - v[j][0] = v[i][0]; - v[j][1] = v[i][1]; - v[j][2] = v[i][2]; - - vfrac[j] = vfrac[i]; - rmass[j] = rmass[i]; - x0[j][0] = x0[i][0]; - x0[j][1] = x0[i][1]; - x0[j][2] = x0[i][2]; - radius[j] = radius[i]; - contact_radius[j] = contact_radius[i]; - molecule[j] = molecule[i]; - e[j] = e[i]; - eff_plastic_strain[j] = eff_plastic_strain[i]; - eff_plastic_strain_rate[j] = eff_plastic_strain_rate[i]; - vest[j][0] = vest[i][0]; - vest[j][1] = vest[i][1]; - vest[j][2] = vest[i][2]; - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[j][k] = smd_data_9[i][k]; - } - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[j][k] = tlsph_stress[i][k]; - } - - damage[j] = damage[i]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - modify->fix[atom->extra_grow[iextra]]->copy_arrays(i, j, delflag); + tag[j] = tag[i]; + type[j] = type[i]; + mask[j] = mask[i]; + image[j] = image[i]; + x[j][0] = x[i][0]; + x[j][1] = x[i][1]; + x[j][2] = x[i][2]; + v[j][0] = v[i][0]; + v[j][1] = v[i][1]; + v[j][2] = v[i][2]; + + vfrac[j] = vfrac[i]; + rmass[j] = rmass[i]; + x0[j][0] = x0[i][0]; + x0[j][1] = x0[i][1]; + x0[j][2] = x0[i][2]; + radius[j] = radius[i]; + contact_radius[j] = contact_radius[i]; + molecule[j] = molecule[i]; + e[j] = e[i]; + eff_plastic_strain[j] = eff_plastic_strain[i]; + eff_plastic_strain_rate[j] = eff_plastic_strain_rate[i]; + vest[j][0] = vest[i][0]; + vest[j][1] = vest[i][1]; + vest[j][2] = vest[i][2]; + + for (int k = 0; k < NMAT_FULL; k++) { + smd_data_9[j][k] = smd_data_9[i][k]; + } + + for (int k = 0; k < NMAT_SYMM; k++) { + tlsph_stress[j][k] = tlsph_stress[i][k]; + } + + damage[j] = damage[i]; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + modify->fix[atom->extra_grow[iextra]]->copy_arrays(i, j, delflag); } /* ---------------------------------------------------------------------- */ int AtomVecSMD::pack_comm(int n, int *list, double *buf, int pbc_flag, int *pbc) { - error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); - return -1; + error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); + return -1; } /* ---------------------------------------------------------------------- */ int AtomVecSMD::pack_comm_vel(int n, int *list, double *buf, int pbc_flag, int *pbc) { - // communicate quantities to ghosts, which are changed by time-integration AND are required on ghost atoms. - - //no need to pack stress or defgrad information here, as these quantities are not required for ghost atoms. - // Inside pair_style tlsph, these quantities are computed and communicated to ghosts. - - // no need to communicate x0 here, as it is not changed by time integration - // if x0 is changed when the ref config is updated, this communication is performed in the fix_integrate/tlsph - // similarily, rmass could be removed here. - // radius should be communicated here for future time-integration of the radius with ulsph (not implemented yet) - int i, j, m; - double dx, dy, dz, dvx, dvy, dvz; - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; //3 - buf[m++] = radius[j]; - buf[m++] = vfrac[j]; // 5 - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 8 - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 11 - buf[m++] = e[j]; // 12 - - } - } else { - if (domain->triclinic == 0) { - dx = pbc[0] * domain->xprd; - dy = pbc[1] * domain->yprd; - dz = pbc[2] * domain->zprd; - } else { - dx = pbc[0] * domain->xprd + pbc[5] * domain->xy + pbc[4] * domain->xz; - dy = pbc[1] * domain->yprd + pbc[3] * domain->yz; - dz = pbc[2] * domain->zprd; - } - if (!deform_vremap) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = radius[j]; - buf[m++] = vfrac[j]; - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 8 - - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 11 - buf[m++] = e[j]; // 12 - - } - } else { - dvx = pbc[0] * h_rate[0] + pbc[5] * h_rate[5] + pbc[4] * h_rate[4]; - dvy = pbc[1] * h_rate[1] + pbc[3] * h_rate[3]; - dvz = pbc[2] * h_rate[2]; -// printf("\ndvx = %f, dvy=%f, dvz=%f\n", dvx, dvy, dvz); -// printf("dx = %f, dy=%f, dz=%f\n", dx, dy, dz); - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; - buf[m++] = radius[j]; - buf[m++] = vfrac[j]; - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; - buf[m++] = vest[j][0] + dvx; - buf[m++] = vest[j][1] + dvy; - buf[m++] = vest[j][2] + dvz; - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 8 - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 11 - } - - buf[m++] = e[j]; // 12 - - } - } - } - - return m; + // communicate quantities to ghosts, which are changed by time-integration AND are required on ghost atoms. + + //no need to pack stress or defgrad information here, as these quantities are not required for ghost atoms. + // Inside pair_style tlsph, these quantities are computed and communicated to ghosts. + + // no need to communicate x0 here, as it is not changed by time integration + // if x0 is changed when the ref config is updated, this communication is performed in the fix_integrate/tlsph + // similarily, rmass could be removed here. + // radius should be communicated here for future time-integration of the radius with ulsph (not implemented yet) + int i, j, m; + double dx, dy, dz, dvx, dvy, dvz; + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; //3 + buf[m++] = radius[j]; + buf[m++] = vfrac[j]; // 5 + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; // 8 + + buf[m++] = vest[j][0]; + buf[m++] = vest[j][1]; + buf[m++] = vest[j][2]; // 11 + buf[m++] = e[j]; // 12 + + } + } else { + if (domain->triclinic == 0) { + dx = pbc[0] * domain->xprd; + dy = pbc[1] * domain->yprd; + dz = pbc[2] * domain->zprd; + } else { + dx = pbc[0] * domain->xprd + pbc[5] * domain->xy + pbc[4] * domain->xz; + dy = pbc[1] * domain->yprd + pbc[3] * domain->yz; + dz = pbc[2] * domain->zprd; + } + if (!deform_vremap) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = radius[j]; + buf[m++] = vfrac[j]; + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; // 8 + + buf[m++] = vest[j][0]; + buf[m++] = vest[j][1]; + buf[m++] = vest[j][2]; // 11 + buf[m++] = e[j]; // 12 + + } + } else { + dvx = pbc[0] * h_rate[0] + pbc[5] * h_rate[5] + pbc[4] * h_rate[4]; + dvy = pbc[1] * h_rate[1] + pbc[3] * h_rate[3]; + dvz = pbc[2] * h_rate[2]; +// printf("\ndvx = %f, dvy=%f, dvz=%f\n", dvx, dvy, dvz); +// printf("dx = %f, dy=%f, dz=%f\n", dx, dy, dz); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; + buf[m++] = radius[j]; + buf[m++] = vfrac[j]; + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; + buf[m++] = vest[j][0] + dvx; + buf[m++] = vest[j][1] + dvy; + buf[m++] = vest[j][2] + dvz; + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; // 8 + buf[m++] = vest[j][0]; + buf[m++] = vest[j][1]; + buf[m++] = vest[j][2]; // 11 + } + + buf[m++] = e[j]; // 12 + + } + } + } + + return m; } /* ---------------------------------------------------------------------- */ int AtomVecSMD::pack_comm_hybrid(int n, int *list, double *buf) { - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = radius[j]; - buf[m++] = vfrac[j]; - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; - buf[m++] = e[j]; - } - return m; + int i, j, m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = radius[j]; + buf[m++] = vfrac[j]; + buf[m++] = vest[j][0]; + buf[m++] = vest[j][1]; + buf[m++] = vest[j][2]; + buf[m++] = e[j]; + } + return m; } /* ---------------------------------------------------------------------- */ void AtomVecSMD::unpack_comm(int n, int first, double *buf) { - error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); + error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); } /* ---------------------------------------------------------------------- */ void AtomVecSMD::unpack_comm_vel(int n, int first, double *buf) { - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; //3 - radius[i] = buf[m++]; - vfrac[i] = buf[m++]; // 5 - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; // 8 - - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; // 11 - e[i] = buf[m++]; - - } + int i, m, last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; //3 + radius[i] = buf[m++]; + vfrac[i] = buf[m++]; // 5 + v[i][0] = buf[m++]; + v[i][1] = buf[m++]; + v[i][2] = buf[m++]; // 8 + + vest[i][0] = buf[m++]; + vest[i][1] = buf[m++]; + vest[i][2] = buf[m++]; // 11 + e[i] = buf[m++]; + + } } /* ---------------------------------------------------------------------- */ int AtomVecSMD::unpack_comm_hybrid(int n, int first, double *buf) { - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - radius[i] = buf[m++]; - vfrac[i] = buf[m++]; - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; - e[i] = buf[m++]; - } - return m; + int i, m, last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + radius[i] = buf[m++]; + vfrac[i] = buf[m++]; + vest[i][0] = buf[m++]; + vest[i][1] = buf[m++]; + vest[i][2] = buf[m++]; + e[i] = buf[m++]; + } + return m; } /* ---------------------------------------------------------------------- */ int AtomVecSMD::pack_reverse(int n, int first, double *buf) { - int i, m, last; - - printf("in pack_reverse\n"); - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = f[i][0]; - buf[m++] = f[i][1]; - buf[m++] = f[i][2]; - buf[m++] = de[i]; - } - return m; + int i, m, last; + + printf("in pack_reverse\n"); + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + buf[m++] = f[i][0]; + buf[m++] = f[i][1]; + buf[m++] = f[i][2]; + buf[m++] = de[i]; + } + return m; } /* ---------------------------------------------------------------------- */ int AtomVecSMD::pack_reverse_hybrid(int n, int first, double *buf) { - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = de[i]; - } - return m; + int i, m, last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + buf[m++] = de[i]; + } + return m; } /* ---------------------------------------------------------------------- */ void AtomVecSMD::unpack_reverse(int n, int *list, double *buf) { - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - f[j][0] += buf[m++]; - f[j][1] += buf[m++]; - f[j][2] += buf[m++]; - de[j] += buf[m++]; - } + int i, j, m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + f[j][0] += buf[m++]; + f[j][1] += buf[m++]; + f[j][2] += buf[m++]; + de[j] += buf[m++]; + } } /* ---------------------------------------------------------------------- */ int AtomVecSMD::unpack_reverse_hybrid(int n, int *list, double *buf) { - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - de[j] += buf[m++]; - } - return m; + int i, j, m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + de[j] += buf[m++]; + } + return m; } /* ---------------------------------------------------------------------- */ int AtomVecSMD::pack_border(int n, int *list, double *buf, int pbc_flag, int *pbc) { - error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); - return -1; + error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); + return -1; } /* ---------------------------------------------------------------------- */ int AtomVecSMD::pack_border_vel(int n, int *list, double *buf, int pbc_flag, int *pbc) { - int i, j, m; - double dx, dy, dz, dvx, dvy, dvz; - - //printf("AtomVecSMD::pack_border_vel\n"); - - m = 0; - if (pbc_flag == 0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0]; - buf[m++] = x[j][1]; - buf[m++] = x[j][2]; // 3 - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; // 6 - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; // 10 - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - buf[m++] = vfrac[j]; - buf[m++] = contact_radius[j]; - buf[m++] = e[j]; - buf[m++] = eff_plastic_strain[j]; // 16 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[j][k]; - } // 25 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[j][k]; - } // 31 - - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 34 - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 37 - } - } else { - - if (domain->triclinic == 0) { - dx = pbc[0] * domain->xprd; - dy = pbc[1] * domain->yprd; - dz = pbc[2] * domain->zprd; - } else { - dx = pbc[0]; - dy = pbc[1]; - dz = pbc[2]; - } - if (!deform_vremap) { - //printf("dx = %f\n", dx); - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; // 3 - buf[m++] = x0[j][0]; // this is correct - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; // 6 - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; // 10 - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - buf[m++] = vfrac[j]; - buf[m++] = contact_radius[j]; - buf[m++] = e[j]; - buf[m++] = eff_plastic_strain[j]; // 17 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[j][k]; - } // 26 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[j][k]; - } // 32 - - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 35 - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 38 - - } - } else { - dvx = pbc[0] * h_rate[0] + pbc[5] * h_rate[5] + pbc[4] * h_rate[4]; - dvy = pbc[1] * h_rate[1] + pbc[3] * h_rate[3]; - dvz = pbc[2] * h_rate[2]; -// printf("\ndvx = %f, dvy=%f, dvz=%f\n", dvx, dvy, dvz); -// printf("dx = %f, dy=%f, dz=%f\n", dx, dy, dz); - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x[j][0] + dx; - buf[m++] = x[j][1] + dy; - buf[m++] = x[j][2] + dz; // 3 - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; // 6 - buf[m++] = ubuf(tag[j]).d; - buf[m++] = ubuf(type[j]).d; - buf[m++] = ubuf(mask[j]).d; - buf[m++] = ubuf(molecule[j]).d; // 10 - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - buf[m++] = vfrac[j]; - buf[m++] = contact_radius[j]; - buf[m++] = e[j]; - buf[m++] = eff_plastic_strain[j]; // 16 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[j][k]; - } // 25 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[j][k]; - } // 31 - - if (mask[i] & deform_groupbit) { - buf[m++] = v[j][0] + dvx; - buf[m++] = v[j][1] + dvy; - buf[m++] = v[j][2] + dvz; // 34 - buf[m++] = vest[j][0] + dvx; - buf[m++] = vest[j][1] + dvy; - buf[m++] = vest[j][2] + dvz; // 37 - - } else { - buf[m++] = v[j][0]; - buf[m++] = v[j][1]; - buf[m++] = v[j][2]; // 34 - buf[m++] = vest[j][0]; - buf[m++] = vest[j][1]; - buf[m++] = vest[j][2]; // 37 - } - - } - } - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->pack_border(n, list, &buf[m]); - - return m; + int i, j, m; + double dx, dy, dz, dvx, dvy, dvz; + + //printf("AtomVecSMD::pack_border_vel\n"); + + m = 0; + if (pbc_flag == 0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; // 3 + buf[m++] = x0[j][0]; + buf[m++] = x0[j][1]; + buf[m++] = x0[j][2]; // 6 + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = ubuf(molecule[j]).d; // 10 + buf[m++] = radius[j]; + buf[m++] = rmass[j]; + buf[m++] = vfrac[j]; + buf[m++] = contact_radius[j]; + buf[m++] = e[j]; + buf[m++] = eff_plastic_strain[j]; // 16 + + for (int k = 0; k < NMAT_FULL; k++) { + buf[m++] = smd_data_9[j][k]; + } // 25 + + for (int k = 0; k < NMAT_SYMM; k++) { + buf[m++] = tlsph_stress[j][k]; + } // 31 + + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; // 34 + buf[m++] = vest[j][0]; + buf[m++] = vest[j][1]; + buf[m++] = vest[j][2]; // 37 + } + } else { + + if (domain->triclinic == 0) { + dx = pbc[0] * domain->xprd; + dy = pbc[1] * domain->yprd; + dz = pbc[2] * domain->zprd; + } else { + dx = pbc[0]; + dy = pbc[1]; + dz = pbc[2]; + } + if (!deform_vremap) { + //printf("dx = %f\n", dx); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; // 3 + buf[m++] = x0[j][0]; // this is correct + buf[m++] = x0[j][1]; + buf[m++] = x0[j][2]; // 6 + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = ubuf(molecule[j]).d; // 10 + buf[m++] = radius[j]; + buf[m++] = rmass[j]; + buf[m++] = vfrac[j]; + buf[m++] = contact_radius[j]; + buf[m++] = e[j]; + buf[m++] = eff_plastic_strain[j]; // 17 + + for (int k = 0; k < NMAT_FULL; k++) { + buf[m++] = smd_data_9[j][k]; + } // 26 + + for (int k = 0; k < NMAT_SYMM; k++) { + buf[m++] = tlsph_stress[j][k]; + } // 32 + + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; // 35 + buf[m++] = vest[j][0]; + buf[m++] = vest[j][1]; + buf[m++] = vest[j][2]; // 38 + + } + } else { + dvx = pbc[0] * h_rate[0] + pbc[5] * h_rate[5] + pbc[4] * h_rate[4]; + dvy = pbc[1] * h_rate[1] + pbc[3] * h_rate[3]; + dvz = pbc[2] * h_rate[2]; +// printf("\ndvx = %f, dvy=%f, dvz=%f\n", dvx, dvy, dvz); +// printf("dx = %f, dy=%f, dz=%f\n", dx, dy, dz); + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0] + dx; + buf[m++] = x[j][1] + dy; + buf[m++] = x[j][2] + dz; // 3 + buf[m++] = x0[j][0]; + buf[m++] = x0[j][1]; + buf[m++] = x0[j][2]; // 6 + buf[m++] = ubuf(tag[j]).d; + buf[m++] = ubuf(type[j]).d; + buf[m++] = ubuf(mask[j]).d; + buf[m++] = ubuf(molecule[j]).d; // 10 + buf[m++] = radius[j]; + buf[m++] = rmass[j]; + buf[m++] = vfrac[j]; + buf[m++] = contact_radius[j]; + buf[m++] = e[j]; + buf[m++] = eff_plastic_strain[j]; // 16 + + for (int k = 0; k < NMAT_FULL; k++) { + buf[m++] = smd_data_9[j][k]; + } // 25 + + for (int k = 0; k < NMAT_SYMM; k++) { + buf[m++] = tlsph_stress[j][k]; + } // 31 + + if (mask[i] & deform_groupbit) { + buf[m++] = v[j][0] + dvx; + buf[m++] = v[j][1] + dvy; + buf[m++] = v[j][2] + dvz; // 34 + buf[m++] = vest[j][0] + dvx; + buf[m++] = vest[j][1] + dvy; + buf[m++] = vest[j][2] + dvz; // 37 + + } else { + buf[m++] = v[j][0]; + buf[m++] = v[j][1]; + buf[m++] = v[j][2]; // 34 + buf[m++] = vest[j][0]; + buf[m++] = vest[j][1]; + buf[m++] = vest[j][2]; // 37 + } + + } + } + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]->pack_border(n, list, &buf[m]); + + return m; } /* ---------------------------------------------------------------------- */ int AtomVecSMD::pack_border_hybrid(int n, int *list, double *buf) { - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; // 3 - buf[m++] = ubuf(molecule[j]).d; // 4 - buf[m++] = radius[j]; - buf[m++] = rmass[j]; - buf[m++] = vfrac[j]; - buf[m++] = contact_radius[j]; - buf[m++] = e[j]; - buf[m++] = eff_plastic_strain[j]; // 11 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[j][k]; - } // 20 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[j][k]; - } // 26 - - } - return m; + int i, j, m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + + buf[m++] = x0[j][0]; + buf[m++] = x0[j][1]; + buf[m++] = x0[j][2]; // 3 + buf[m++] = ubuf(molecule[j]).d; // 4 + buf[m++] = radius[j]; + buf[m++] = rmass[j]; + buf[m++] = vfrac[j]; + buf[m++] = contact_radius[j]; + buf[m++] = e[j]; + buf[m++] = eff_plastic_strain[j]; // 11 + + for (int k = 0; k < NMAT_FULL; k++) { + buf[m++] = smd_data_9[j][k]; + } // 20 + + for (int k = 0; k < NMAT_SYMM; k++) { + buf[m++] = tlsph_stress[j][k]; + } // 26 + + } + return m; } /* ---------------------------------------------------------------------- */ void AtomVecSMD::unpack_border(int n, int first, double *buf) { - error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); + error->one(FLERR, "atom vec tlsph can only be used with ghost velocities turned on"); } /* ---------------------------------------------------------------------- */ void AtomVecSMD::unpack_border_vel(int n, int first, double *buf) { - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (i == nmax) - grow(0); - x[i][0] = buf[m++]; - x[i][1] = buf[m++]; - x[i][2] = buf[m++]; // 3 - x0[i][0] = buf[m++]; - x0[i][1] = buf[m++]; - x0[i][2] = buf[m++]; // 6 - tag[i] = (tagint) ubuf(buf[m++]).i; - type[i] = (int) ubuf(buf[m++]).i; - mask[i] = (int) ubuf(buf[m++]).i; - molecule[i] = (tagint) ubuf(buf[m++]).i; // 10 - - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - vfrac[i] = buf[m++]; - contact_radius[i] = buf[m++]; - e[i] = buf[m++]; - eff_plastic_strain[i] = buf[m++]; // 16 - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[i][k] = buf[m++]; - } // 25 - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[i][k] = buf[m++]; - } // 31 - - v[i][0] = buf[m++]; - v[i][1] = buf[m++]; - v[i][2] = buf[m++]; // 34 - vest[i][0] = buf[m++]; - vest[i][1] = buf[m++]; - vest[i][2] = buf[m++]; // 37 - } - - if (atom->nextra_border) - for (int iextra = 0; iextra < atom->nextra_border; iextra++) - m += modify->fix[atom->extra_border[iextra]]->unpack_border(n, first, &buf[m]); + int i, m, last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (i == nmax) + grow(0); + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; // 3 + x0[i][0] = buf[m++]; + x0[i][1] = buf[m++]; + x0[i][2] = buf[m++]; // 6 + tag[i] = (tagint) ubuf(buf[m++]).i; + type[i] = (int) ubuf(buf[m++]).i; + mask[i] = (int) ubuf(buf[m++]).i; + molecule[i] = (tagint) ubuf(buf[m++]).i; // 10 + + radius[i] = buf[m++]; + rmass[i] = buf[m++]; + vfrac[i] = buf[m++]; + contact_radius[i] = buf[m++]; + e[i] = buf[m++]; + eff_plastic_strain[i] = buf[m++]; // 16 + + for (int k = 0; k < NMAT_FULL; k++) { + smd_data_9[i][k] = buf[m++]; + } // 25 + + for (int k = 0; k < NMAT_SYMM; k++) { + tlsph_stress[i][k] = buf[m++]; + } // 31 + + v[i][0] = buf[m++]; + v[i][1] = buf[m++]; + v[i][2] = buf[m++]; // 34 + vest[i][0] = buf[m++]; + vest[i][1] = buf[m++]; + vest[i][2] = buf[m++]; // 37 + } + + if (atom->nextra_border) + for (int iextra = 0; iextra < atom->nextra_border; iextra++) + m += modify->fix[atom->extra_border[iextra]]->unpack_border(n, first, &buf[m]); } /* ---------------------------------------------------------------------- */ int AtomVecSMD::unpack_border_hybrid(int n, int first, double *buf) { - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x0[i][0] = buf[m++]; - x0[i][1] = buf[m++]; - x0[i][2] = buf[m++]; // 3 - molecule[i] = (tagint) ubuf(buf[m++]).i; // 4 - radius[i] = buf[m++]; - rmass[i] = buf[m++]; - vfrac[i] = buf[m++]; - contact_radius[i] = buf[m++]; - e[i] = buf[m++]; - eff_plastic_strain[i] = buf[m++]; // 11 - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[i][k] = buf[m++]; - } // 20 - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[i][k] = buf[m++]; - } // 26 - } - return m; + int i, m, last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x0[i][0] = buf[m++]; + x0[i][1] = buf[m++]; + x0[i][2] = buf[m++]; // 3 + molecule[i] = (tagint) ubuf(buf[m++]).i; // 4 + radius[i] = buf[m++]; + rmass[i] = buf[m++]; + vfrac[i] = buf[m++]; + contact_radius[i] = buf[m++]; + e[i] = buf[m++]; + eff_plastic_strain[i] = buf[m++]; // 11 + + for (int k = 0; k < NMAT_FULL; k++) { + smd_data_9[i][k] = buf[m++]; + } // 20 + + for (int k = 0; k < NMAT_SYMM; k++) { + tlsph_stress[i][k] = buf[m++]; + } // 26 + } + return m; } /* ---------------------------------------------------------------------- @@ -722,106 +722,106 @@ int AtomVecSMD::unpack_border_hybrid(int n, int first, double *buf) { ------------------------------------------------------------------------- */ int AtomVecSMD::pack_exchange(int i, double *buf) { - int m = 1; - - //printf("in AtomVecSMD::pack_exchange tag %d\n", tag[i]); - - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; // 3 - buf[m++] = x0[i][0]; - buf[m++] = x0[i][1]; - buf[m++] = x0[i][2]; // 6 - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; - buf[m++] = ubuf(image[i]).d; - buf[m++] = ubuf(molecule[i]).d; // 11 - buf[m++] = radius[i]; - buf[m++] = rmass[i]; - buf[m++] = vfrac[i]; - buf[m++] = contact_radius[i]; - buf[m++] = e[i]; - buf[m++] = eff_plastic_strain[i]; // 18 - buf[m++] = eff_plastic_strain_rate[i]; // 19 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[i][k]; - } // 27 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[i][k]; - } // 33 - - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; // 36 - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][2]; // 39 - - buf[m++] = damage[i]; - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i, &buf[m]); - - buf[0] = m; - return m; + int m = 1; + + //printf("in AtomVecSMD::pack_exchange tag %d\n", tag[i]); + + buf[m++] = x[i][0]; + buf[m++] = x[i][1]; + buf[m++] = x[i][2]; // 3 + buf[m++] = x0[i][0]; + buf[m++] = x0[i][1]; + buf[m++] = x0[i][2]; // 6 + buf[m++] = ubuf(tag[i]).d; + buf[m++] = ubuf(type[i]).d; + buf[m++] = ubuf(mask[i]).d; + buf[m++] = ubuf(image[i]).d; + buf[m++] = ubuf(molecule[i]).d; // 11 + buf[m++] = radius[i]; + buf[m++] = rmass[i]; + buf[m++] = vfrac[i]; + buf[m++] = contact_radius[i]; + buf[m++] = e[i]; + buf[m++] = eff_plastic_strain[i]; // 18 + buf[m++] = eff_plastic_strain_rate[i]; // 19 + + for (int k = 0; k < NMAT_FULL; k++) { + buf[m++] = smd_data_9[i][k]; + } // 27 + + for (int k = 0; k < NMAT_SYMM; k++) { + buf[m++] = tlsph_stress[i][k]; + } // 33 + + buf[m++] = v[i][0]; + buf[m++] = v[i][1]; + buf[m++] = v[i][2]; // 36 + buf[m++] = vest[i][0]; + buf[m++] = vest[i][1]; + buf[m++] = vest[i][2]; // 39 + + buf[m++] = damage[i]; + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i, &buf[m]); + + buf[0] = m; + return m; } /* ---------------------------------------------------------------------- */ int AtomVecSMD::unpack_exchange(double *buf) { - int nlocal = atom->nlocal; - if (nlocal == nmax) - grow(0); - - int m = 1; - - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; // 3 - x0[nlocal][0] = buf[m++]; - x0[nlocal][1] = buf[m++]; - x0[nlocal][2] = buf[m++]; // 6 - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; // 11 - - radius[nlocal] = buf[m++]; - rmass[nlocal] = buf[m++]; - vfrac[nlocal] = buf[m++]; - contact_radius[nlocal] = buf[m++]; - e[nlocal] = buf[m++]; - eff_plastic_strain[nlocal] = buf[m++]; // 18 - eff_plastic_strain_rate[nlocal] = buf[m++]; // 19 - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[nlocal][k] = buf[m++]; - } // 27 - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[nlocal][k] = buf[m++]; - } // 33 - - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; // 36 - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = buf[m++]; // 39 - - damage[nlocal] = buf[m++]; //40 - - if (atom->nextra_grow) - for (int iextra = 0; iextra < atom->nextra_grow; iextra++) - m += modify->fix[atom->extra_grow[iextra]]->unpack_exchange(nlocal, &buf[m]); - - atom->nlocal++; - return m; + int nlocal = atom->nlocal; + if (nlocal == nmax) + grow(0); + + int m = 1; + + x[nlocal][0] = buf[m++]; + x[nlocal][1] = buf[m++]; + x[nlocal][2] = buf[m++]; // 3 + x0[nlocal][0] = buf[m++]; + x0[nlocal][1] = buf[m++]; + x0[nlocal][2] = buf[m++]; // 6 + tag[nlocal] = (tagint) ubuf(buf[m++]).i; + type[nlocal] = (int) ubuf(buf[m++]).i; + mask[nlocal] = (int) ubuf(buf[m++]).i; + image[nlocal] = (imageint) ubuf(buf[m++]).i; + molecule[nlocal] = (tagint) ubuf(buf[m++]).i; // 11 + + radius[nlocal] = buf[m++]; + rmass[nlocal] = buf[m++]; + vfrac[nlocal] = buf[m++]; + contact_radius[nlocal] = buf[m++]; + e[nlocal] = buf[m++]; + eff_plastic_strain[nlocal] = buf[m++]; // 18 + eff_plastic_strain_rate[nlocal] = buf[m++]; // 19 + + for (int k = 0; k < NMAT_FULL; k++) { + smd_data_9[nlocal][k] = buf[m++]; + } // 27 + + for (int k = 0; k < NMAT_SYMM; k++) { + tlsph_stress[nlocal][k] = buf[m++]; + } // 33 + + v[nlocal][0] = buf[m++]; + v[nlocal][1] = buf[m++]; + v[nlocal][2] = buf[m++]; // 36 + vest[nlocal][0] = buf[m++]; + vest[nlocal][1] = buf[m++]; + vest[nlocal][2] = buf[m++]; // 39 + + damage[nlocal] = buf[m++]; //40 + + if (atom->nextra_grow) + for (int iextra = 0; iextra < atom->nextra_grow; iextra++) + m += modify->fix[atom->extra_grow[iextra]]->unpack_exchange(nlocal, &buf[m]); + + atom->nlocal++; + return m; } /* ---------------------------------------------------------------------- @@ -830,17 +830,17 @@ int AtomVecSMD::unpack_exchange(double *buf) { ------------------------------------------------------------------------- */ int AtomVecSMD::size_restart() { - int i; + int i; - int nlocal = atom->nlocal; - int n = 43 * nlocal; // count pack_restart + 1 (size of buffer) + int nlocal = atom->nlocal; + int n = 43 * nlocal; // count pack_restart + 1 (size of buffer) - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - for (i = 0; i < nlocal; i++) - n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); + if (atom->nextra_restart) + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) + for (i = 0; i < nlocal; i++) + n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); - return n; + return n; } /* ---------------------------------------------------------------------- @@ -849,50 +849,50 @@ int AtomVecSMD::size_restart() { molecular types may be negative, but write as positive ------------------------------------------------------------------------- */ int AtomVecSMD::pack_restart(int i, double *buf) { - int m = 1; // 1 - - buf[m++] = x[i][0]; - buf[m++] = x[i][1]; - buf[m++] = x[i][2]; // 4 - buf[m++] = x0[i][0]; - buf[m++] = x0[i][1]; - buf[m++] = x0[i][2]; // 7 - buf[m++] = ubuf(tag[i]).d; - buf[m++] = ubuf(type[i]).d; - buf[m++] = ubuf(mask[i]).d; // 10 - buf[m++] = ubuf(image[i]).d; - buf[m++] = ubuf(molecule[i]).d; - buf[m++] = radius[i]; - buf[m++] = rmass[i]; - buf[m++] = vfrac[i]; // 15 - buf[m++] = contact_radius[i]; - buf[m++] = e[i]; - buf[m++] = eff_plastic_strain[i]; - buf[m++] = eff_plastic_strain_rate[i]; // 19 - - for (int k = 0; k < NMAT_FULL; k++) { - buf[m++] = smd_data_9[i][k]; - } // 28 - - for (int k = 0; k < NMAT_SYMM; k++) { - buf[m++] = tlsph_stress[i][k]; - } // 34 - - buf[m++] = v[i][0]; - buf[m++] = v[i][1]; - buf[m++] = v[i][2]; // 37 - buf[m++] = vest[i][0]; - buf[m++] = vest[i][1]; - buf[m++] = vest[i][2]; // 40 - - buf[m++] = damage[i]; // 41 - - if (atom->nextra_restart) - for (int iextra = 0; iextra < atom->nextra_restart; iextra++) - m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i, &buf[m]); - - buf[0] = m; - return m; + int m = 1; // 1 + + buf[m++] = x[i][0]; + buf[m++] = x[i][1]; + buf[m++] = x[i][2]; // 4 + buf[m++] = x0[i][0]; + buf[m++] = x0[i][1]; + buf[m++] = x0[i][2]; // 7 + buf[m++] = ubuf(tag[i]).d; + buf[m++] = ubuf(type[i]).d; + buf[m++] = ubuf(mask[i]).d; // 10 + buf[m++] = ubuf(image[i]).d; + buf[m++] = ubuf(molecule[i]).d; + buf[m++] = radius[i]; + buf[m++] = rmass[i]; + buf[m++] = vfrac[i]; // 15 + buf[m++] = contact_radius[i]; + buf[m++] = e[i]; + buf[m++] = eff_plastic_strain[i]; + buf[m++] = eff_plastic_strain_rate[i]; // 19 + + for (int k = 0; k < NMAT_FULL; k++) { + buf[m++] = smd_data_9[i][k]; + } // 28 + + for (int k = 0; k < NMAT_SYMM; k++) { + buf[m++] = tlsph_stress[i][k]; + } // 34 + + buf[m++] = v[i][0]; + buf[m++] = v[i][1]; + buf[m++] = v[i][2]; // 37 + buf[m++] = vest[i][0]; + buf[m++] = vest[i][1]; + buf[m++] = vest[i][2]; // 40 + + buf[m++] = damage[i]; // 41 + + if (atom->nextra_restart) + for (int iextra = 0; iextra < atom->nextra_restart; iextra++) + m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i, &buf[m]); + + buf[0] = m; + return m; } /* ---------------------------------------------------------------------- @@ -900,66 +900,66 @@ int AtomVecSMD::pack_restart(int i, double *buf) { ------------------------------------------------------------------------- */ int AtomVecSMD::unpack_restart(double *buf) { - int nlocal = atom->nlocal; - if (nlocal == nmax) { - grow(0); - if (atom->nextra_store) - memory->grow(atom->extra, nmax, atom->nextra_store, "atom:extra"); - } - - int m = 1; - - x[nlocal][0] = buf[m++]; - x[nlocal][1] = buf[m++]; - x[nlocal][2] = buf[m++]; // 3 - x0[nlocal][0] = buf[m++]; - x0[nlocal][1] = buf[m++]; - x0[nlocal][2] = buf[m++]; // 6 - tag[nlocal] = (tagint) ubuf(buf[m++]).i; - type[nlocal] = (int) ubuf(buf[m++]).i; - mask[nlocal] = (int) ubuf(buf[m++]).i; - image[nlocal] = (imageint) ubuf(buf[m++]).i; - molecule[nlocal] = (tagint) ubuf(buf[m++]).i; // 11 - - radius[nlocal] = buf[m++]; - rmass[nlocal] = buf[m++]; - vfrac[nlocal] = buf[m++]; //14 - contact_radius[nlocal] = buf[m++]; //15 - e[nlocal] = buf[m++]; - eff_plastic_strain[nlocal] = buf[m++]; // 18 - eff_plastic_strain_rate[nlocal] = buf[m++]; // 29 - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[nlocal][k] = buf[m++]; - } // 28 - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[nlocal][k] = buf[m++]; - } // 34 - - v[nlocal][0] = buf[m++]; - v[nlocal][1] = buf[m++]; - v[nlocal][2] = buf[m++]; // 37 - vest[nlocal][0] = buf[m++]; - vest[nlocal][1] = buf[m++]; - vest[nlocal][2] = buf[m++]; // 40 - - damage[nlocal] = buf[m++]; //41 - - //printf("nlocal in restart is %d\n", nlocal); - - double **extra = atom->extra; - if (atom->nextra_store) { - int size = static_cast<int>(buf[0]) - m; - for (int i = 0; i < size; i++) - extra[nlocal][i] = buf[m++]; - } - - atom->nlocal++; - - //printf("returning m=%d in unpack_restart\n", m); - - return m; + int nlocal = atom->nlocal; + if (nlocal == nmax) { + grow(0); + if (atom->nextra_store) + memory->grow(atom->extra, nmax, atom->nextra_store, "atom:extra"); + } + + int m = 1; + + x[nlocal][0] = buf[m++]; + x[nlocal][1] = buf[m++]; + x[nlocal][2] = buf[m++]; // 3 + x0[nlocal][0] = buf[m++]; + x0[nlocal][1] = buf[m++]; + x0[nlocal][2] = buf[m++]; // 6 + tag[nlocal] = (tagint) ubuf(buf[m++]).i; + type[nlocal] = (int) ubuf(buf[m++]).i; + mask[nlocal] = (int) ubuf(buf[m++]).i; + image[nlocal] = (imageint) ubuf(buf[m++]).i; + molecule[nlocal] = (tagint) ubuf(buf[m++]).i; // 11 + + radius[nlocal] = buf[m++]; + rmass[nlocal] = buf[m++]; + vfrac[nlocal] = buf[m++]; //14 + contact_radius[nlocal] = buf[m++]; //15 + e[nlocal] = buf[m++]; + eff_plastic_strain[nlocal] = buf[m++]; // 18 + eff_plastic_strain_rate[nlocal] = buf[m++]; // 29 + + for (int k = 0; k < NMAT_FULL; k++) { + smd_data_9[nlocal][k] = buf[m++]; + } // 28 + + for (int k = 0; k < NMAT_SYMM; k++) { + tlsph_stress[nlocal][k] = buf[m++]; + } // 34 + + v[nlocal][0] = buf[m++]; + v[nlocal][1] = buf[m++]; + v[nlocal][2] = buf[m++]; // 37 + vest[nlocal][0] = buf[m++]; + vest[nlocal][1] = buf[m++]; + vest[nlocal][2] = buf[m++]; // 40 + + damage[nlocal] = buf[m++]; //41 + + //printf("nlocal in restart is %d\n", nlocal); + + double **extra = atom->extra; + if (atom->nextra_store) { + int size = static_cast<int>(buf[0]) - m; + for (int i = 0; i < size; i++) + extra[nlocal][i] = buf[m++]; + } + + atom->nlocal++; + + //printf("returning m=%d in unpack_restart\n", m); + + return m; } /* ---------------------------------------------------------------------- @@ -968,53 +968,53 @@ int AtomVecSMD::unpack_restart(double *buf) { ------------------------------------------------------------------------- */ void AtomVecSMD::create_atom(int itype, double *coord) { - int nlocal = atom->nlocal; - if (nlocal == nmax) { - printf("nlocal = %d, nmax = %d, calling grow\n", nlocal, nmax); - grow(0); - printf("... finished growing\n"); - } - - tag[nlocal] = 0; - type[nlocal] = itype; - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; - x0[nlocal][0] = coord[0]; - x0[nlocal][1] = coord[1]; - x0[nlocal][2] = coord[2]; - mask[nlocal] = 1; - image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | ((imageint) IMGMAX << IMGBITS) | IMGMAX; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - vest[nlocal][0] = 0.0; - vest[nlocal][1] = 0.0; - vest[nlocal][2] = 0.0; - - vfrac[nlocal] = 1.0; - rmass[nlocal] = 1.0; - radius[nlocal] = 0.5; - contact_radius[nlocal] = 0.5; - molecule[nlocal] = 1; - e[nlocal] = 0.0; - eff_plastic_strain[nlocal] = 0.0; - eff_plastic_strain_rate[nlocal] = 0.0; - - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[nlocal][k] = 0.0; - } - smd_data_9[nlocal][0] = 1.0; // xx - smd_data_9[nlocal][4] = 1.0; // yy - smd_data_9[nlocal][8] = 1.0; // zz - - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[nlocal][k] = 0.0; - } - - damage[nlocal] = 0.0; - - atom->nlocal++; + int nlocal = atom->nlocal; + if (nlocal == nmax) { + printf("nlocal = %d, nmax = %d, calling grow\n", nlocal, nmax); + grow(0); + printf("... finished growing\n"); + } + + tag[nlocal] = 0; + type[nlocal] = itype; + x[nlocal][0] = coord[0]; + x[nlocal][1] = coord[1]; + x[nlocal][2] = coord[2]; + x0[nlocal][0] = coord[0]; + x0[nlocal][1] = coord[1]; + x0[nlocal][2] = coord[2]; + mask[nlocal] = 1; + image[nlocal] = ((imageint) IMGMAX << IMG2BITS) | ((imageint) IMGMAX << IMGBITS) | IMGMAX; + v[nlocal][0] = 0.0; + v[nlocal][1] = 0.0; + v[nlocal][2] = 0.0; + vest[nlocal][0] = 0.0; + vest[nlocal][1] = 0.0; + vest[nlocal][2] = 0.0; + + vfrac[nlocal] = 1.0; + rmass[nlocal] = 1.0; + radius[nlocal] = 0.5; + contact_radius[nlocal] = 0.5; + molecule[nlocal] = 1; + e[nlocal] = 0.0; + eff_plastic_strain[nlocal] = 0.0; + eff_plastic_strain_rate[nlocal] = 0.0; + + for (int k = 0; k < NMAT_FULL; k++) { + smd_data_9[nlocal][k] = 0.0; + } + smd_data_9[nlocal][0] = 1.0; // xx + smd_data_9[nlocal][4] = 1.0; // yy + smd_data_9[nlocal][8] = 1.0; // zz + + for (int k = 0; k < NMAT_SYMM; k++) { + tlsph_stress[nlocal][k] = 0.0; + } + + damage[nlocal] = 0.0; + + atom->nlocal++; } /* ---------------------------------------------------------------------- @@ -1023,74 +1023,74 @@ void AtomVecSMD::create_atom(int itype, double *coord) { ------------------------------------------------------------------------- */ void AtomVecSMD::data_atom(double *coord, imageint imagetmp, char **values) { - int nlocal = atom->nlocal; - if (nlocal == nmax) - grow(0); + int nlocal = atom->nlocal; + if (nlocal == nmax) + grow(0); - tag[nlocal] = ATOTAGINT(values[0]); + tag[nlocal] = ATOTAGINT(values[0]); - type[nlocal] = atoi(values[1]); - if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) - error->one(FLERR, "Invalid atom type in Atoms section of data file"); + type[nlocal] = atoi(values[1]); + if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) + error->one(FLERR, "Invalid atom type in Atoms section of data file"); - molecule[nlocal] = ATOTAGINT(values[2]); - if (molecule[nlocal] <= 0) - error->one(FLERR, "Invalid molecule in Atoms section of data file"); + molecule[nlocal] = ATOTAGINT(values[2]); + if (molecule[nlocal] <= 0) + error->one(FLERR, "Invalid molecule in Atoms section of data file"); - vfrac[nlocal] = atof(values[3]); - if (vfrac[nlocal] < 0.0) - error->one(FLERR, "Invalid volume in Atoms section of data file"); + vfrac[nlocal] = atof(values[3]); + if (vfrac[nlocal] < 0.0) + error->one(FLERR, "Invalid volume in Atoms section of data file"); - rmass[nlocal] = atof(values[4]); - if (rmass[nlocal] == 0.0) - error->one(FLERR, "Invalid mass in Atoms section of data file"); + rmass[nlocal] = atof(values[4]); + if (rmass[nlocal] == 0.0) + error->one(FLERR, "Invalid mass in Atoms section of data file"); - radius[nlocal] = atof(values[5]); - if (radius[nlocal] < 0.0) - error->one(FLERR, "Invalid radius in Atoms section of data file"); + radius[nlocal] = atof(values[5]); + if (radius[nlocal] < 0.0) + error->one(FLERR, "Invalid radius in Atoms section of data file"); - contact_radius[nlocal] = atof(values[6]); - if (contact_radius[nlocal] < 0.0) - error->one(FLERR, "Invalid contact radius in Atoms section of data file"); + contact_radius[nlocal] = atof(values[6]); + if (contact_radius[nlocal] < 0.0) + error->one(FLERR, "Invalid contact radius in Atoms section of data file"); - e[nlocal] = 0.0; + e[nlocal] = 0.0; - x0[nlocal][0] = atof(values[7]); - x0[nlocal][1] = atof(values[8]); - x0[nlocal][2] = atof(values[9]); + x0[nlocal][0] = atof(values[7]); + x0[nlocal][1] = atof(values[8]); + x0[nlocal][2] = atof(values[9]); - x[nlocal][0] = coord[0]; - x[nlocal][1] = coord[1]; - x[nlocal][2] = coord[2]; + x[nlocal][0] = coord[0]; + x[nlocal][1] = coord[1]; + x[nlocal][2] = coord[2]; - image[nlocal] = imagetmp; + image[nlocal] = imagetmp; - mask[nlocal] = 1; - v[nlocal][0] = 0.0; - v[nlocal][1] = 0.0; - v[nlocal][2] = 0.0; - vest[nlocal][0] = 0.0; - vest[nlocal][1] = 0.0; - vest[nlocal][2] = 0.0; + mask[nlocal] = 1; + v[nlocal][0] = 0.0; + v[nlocal][1] = 0.0; + v[nlocal][2] = 0.0; + vest[nlocal][0] = 0.0; + vest[nlocal][1] = 0.0; + vest[nlocal][2] = 0.0; - damage[nlocal] = 0.0; + damage[nlocal] = 0.0; - eff_plastic_strain[nlocal] = 0.0; - eff_plastic_strain_rate[nlocal] = 0.0; + eff_plastic_strain[nlocal] = 0.0; + eff_plastic_strain_rate[nlocal] = 0.0; - for (int k = 0; k < NMAT_FULL; k++) { - smd_data_9[nlocal][k] = 0.0; - } + for (int k = 0; k < NMAT_FULL; k++) { + smd_data_9[nlocal][k] = 0.0; + } - for (int k = 0; k < NMAT_SYMM; k++) { - tlsph_stress[nlocal][k] = 0.0; - } + for (int k = 0; k < NMAT_SYMM; k++) { + tlsph_stress[nlocal][k] = 0.0; + } - smd_data_9[nlocal][0] = 1.0; // xx - smd_data_9[nlocal][4] = 1.0; // yy - smd_data_9[nlocal][8] = 1.0; // zz + smd_data_9[nlocal][0] = 1.0; // xx + smd_data_9[nlocal][4] = 1.0; // yy + smd_data_9[nlocal][8] = 1.0; // zz - atom->nlocal++; + atom->nlocal++; } /* ---------------------------------------------------------------------- @@ -1099,8 +1099,8 @@ void AtomVecSMD::data_atom(double *coord, imageint imagetmp, char **values) { ------------------------------------------------------------------------- */ int AtomVecSMD::data_atom_hybrid(int nlocal, char **values) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return -1; + error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); + return -1; } /* ---------------------------------------------------------------------- @@ -1108,12 +1108,12 @@ int AtomVecSMD::data_atom_hybrid(int nlocal, char **values) { ------------------------------------------------------------------------- */ void AtomVecSMD::data_vel(int m, char **values) { - v[m][0] = atof(values[0]); - v[m][1] = atof(values[1]); - v[m][2] = atof(values[2]); - vest[m][0] = atof(values[0]); - vest[m][1] = atof(values[1]); - vest[m][2] = atof(values[2]); + v[m][0] = atof(values[0]); + v[m][1] = atof(values[1]); + v[m][2] = atof(values[2]); + vest[m][0] = atof(values[0]); + vest[m][1] = atof(values[1]); + vest[m][2] = atof(values[2]); } /* ---------------------------------------------------------------------- @@ -1121,8 +1121,8 @@ void AtomVecSMD::data_vel(int m, char **values) { ------------------------------------------------------------------------- */ int AtomVecSMD::data_vel_hybrid(int m, char **values) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return 0; + error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); + return 0; } /* ---------------------------------------------------------------------- @@ -1130,28 +1130,28 @@ int AtomVecSMD::data_vel_hybrid(int m, char **values) { ------------------------------------------------------------------------- */ void AtomVecSMD::pack_data(double **buf) { - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = ubuf(type[i]).d; - buf[i][2] = ubuf(molecule[i]).d; - buf[i][3] = vfrac[i]; - buf[i][4] = rmass[i]; - buf[i][5] = radius[i]; - buf[i][6] = contact_radius[i]; - - buf[i][7] = x[i][0]; - buf[i][8] = x[i][1]; - buf[i][9] = x[i][2]; - + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + buf[i][0] = ubuf(tag[i]).d; + buf[i][1] = ubuf(type[i]).d; + buf[i][2] = ubuf(molecule[i]).d; + buf[i][3] = vfrac[i]; + buf[i][4] = rmass[i]; + buf[i][5] = radius[i]; + buf[i][6] = contact_radius[i]; + + buf[i][7] = x[i][0]; + buf[i][8] = x[i][1]; + buf[i][9] = x[i][2]; + buf[i][10] = x0[i][0]; buf[i][11] = x0[i][1]; buf[i][12] = x0[i][2]; - buf[i][13] = ubuf((image[i] & IMGMASK) - IMGMAX).d; - buf[i][14] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; - buf[i][15] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; - } + buf[i][13] = ubuf((image[i] & IMGMASK) - IMGMAX).d; + buf[i][14] = ubuf((image[i] >> IMGBITS & IMGMASK) - IMGMAX).d; + buf[i][15] = ubuf((image[i] >> IMG2BITS) - IMGMAX).d; + } } /* ---------------------------------------------------------------------- @@ -1159,8 +1159,8 @@ void AtomVecSMD::pack_data(double **buf) { ------------------------------------------------------------------------- */ int AtomVecSMD::pack_data_hybrid(int i, double *buf) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return -1; + error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); + return -1; } /* ---------------------------------------------------------------------- @@ -1168,12 +1168,12 @@ int AtomVecSMD::pack_data_hybrid(int i, double *buf) { ------------------------------------------------------------------------- */ void AtomVecSMD::write_data(FILE *fp, int n, double **buf) { - for (int i = 0; i < n; i++) - fprintf(fp, - TAGINT_FORMAT - " %d %d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e\n", (tagint) ubuf(buf[i][0]).i, - (int) ubuf(buf[i][1]).i, (int) ubuf(buf[i][2]).i, buf[i][3], buf[i][4], buf[i][5], buf[i][6], buf[i][7], buf[i][8], - buf[i][9], buf[i][10], buf[i][11], buf[i][12]); + for (int i = 0; i < n; i++) + fprintf(fp, + TAGINT_FORMAT + " %d %d %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e %-1.16e\n", (tagint) ubuf(buf[i][0]).i, + (int) ubuf(buf[i][1]).i, (int) ubuf(buf[i][2]).i, buf[i][3], buf[i][4], buf[i][5], buf[i][6], buf[i][7], buf[i][8], + buf[i][9], buf[i][10], buf[i][11], buf[i][12]); } /* ---------------------------------------------------------------------- @@ -1181,8 +1181,8 @@ void AtomVecSMD::write_data(FILE *fp, int n, double **buf) { ------------------------------------------------------------------------- */ int AtomVecSMD::write_data_hybrid(FILE *fp, double *buf) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return -1; + error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); + return -1; } /* ---------------------------------------------------------------------- @@ -1190,13 +1190,13 @@ int AtomVecSMD::write_data_hybrid(FILE *fp, double *buf) { ------------------------------------------------------------------------- */ void AtomVecSMD::pack_vel(double **buf) { - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - buf[i][0] = ubuf(tag[i]).d; - buf[i][1] = v[i][0]; - buf[i][2] = v[i][1]; - buf[i][3] = v[i][2]; - } + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + buf[i][0] = ubuf(tag[i]).d; + buf[i][1] = v[i][0]; + buf[i][2] = v[i][1]; + buf[i][3] = v[i][2]; + } } /* ---------------------------------------------------------------------- @@ -1204,8 +1204,8 @@ void AtomVecSMD::pack_vel(double **buf) { ------------------------------------------------------------------------- */ int AtomVecSMD::pack_vel_hybrid(int i, double *buf) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return 0; + error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); + return 0; } /* ---------------------------------------------------------------------- @@ -1213,9 +1213,9 @@ int AtomVecSMD::pack_vel_hybrid(int i, double *buf) { ------------------------------------------------------------------------- */ void AtomVecSMD::write_vel(FILE *fp, int n, double **buf) { - for (int i = 0; i < n; i++) - fprintf(fp, TAGINT_FORMAT - " %-1.16e %-1.16e %-1.16e\n", (tagint) ubuf(buf[i][0]).i, buf[i][1], buf[i][2], buf[i][3]); + for (int i = 0; i < n; i++) + fprintf(fp, TAGINT_FORMAT + " %-1.16e %-1.16e %-1.16e\n", (tagint) ubuf(buf[i][0]).i, buf[i][1], buf[i][2], buf[i][3]); } /* ---------------------------------------------------------------------- @@ -1223,8 +1223,8 @@ void AtomVecSMD::write_vel(FILE *fp, int n, double **buf) { ------------------------------------------------------------------------- */ int AtomVecSMD::write_vel_hybrid(FILE *fp, double *buf) { - error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); - return 3; + error->one(FLERR, "hybrid atom style functionality not yet implemented for atom style smd"); + return 3; } /* ---------------------------------------------------------------------- @@ -1232,59 +1232,59 @@ int AtomVecSMD::write_vel_hybrid(FILE *fp, double *buf) { ------------------------------------------------------------------------- */ bigint AtomVecSMD::memory_usage() { - bigint bytes = 0; - - if (atom->memcheck("tag")) - bytes += memory->usage(tag, nmax); - if (atom->memcheck("type")) - bytes += memory->usage(type, nmax); - if (atom->memcheck("molecule")) - bytes += memory->usage(molecule, nmax); - if (atom->memcheck("mask")) - bytes += memory->usage(mask, nmax); - if (atom->memcheck("image")) - bytes += memory->usage(image, nmax); - if (atom->memcheck("x")) - bytes += memory->usage(x, nmax, 3); - if (atom->memcheck("v")) - bytes += memory->usage(v, nmax, 3); - if (atom->memcheck("vest")) - bytes += memory->usage(vest, nmax, 3); - if (atom->memcheck("f")) - bytes += memory->usage(f, nmax * comm->nthreads, 3); - - if (atom->memcheck("radius")) - bytes += memory->usage(radius, nmax); - if (atom->memcheck("contact_radius")) - bytes += memory->usage(contact_radius, nmax); - if (atom->memcheck("vfrac")) - bytes += memory->usage(vfrac, nmax); - if (atom->memcheck("rmass")) - bytes += memory->usage(rmass, nmax); - if (atom->memcheck("eff_plastic_strain")) - bytes += memory->usage(eff_plastic_strain, nmax); - if (atom->memcheck("eff_plastic_strain_rate")) - bytes += memory->usage(eff_plastic_strain_rate, nmax); - if (atom->memcheck("e")) - bytes += memory->usage(e, nmax); - if (atom->memcheck("de")) - bytes += memory->usage(de, nmax); - - if (atom->memcheck("smd_data_9")) - bytes += memory->usage(smd_data_9, nmax, NMAT_FULL); - if (atom->memcheck("tlsph_stress")) - bytes += memory->usage(tlsph_stress, nmax, NMAT_SYMM); - - if (atom->memcheck("damage")) - bytes += memory->usage(damage, nmax); - - return bytes; + bigint bytes = 0; + + if (atom->memcheck("tag")) + bytes += memory->usage(tag, nmax); + if (atom->memcheck("type")) + bytes += memory->usage(type, nmax); + if (atom->memcheck("molecule")) + bytes += memory->usage(molecule, nmax); + if (atom->memcheck("mask")) + bytes += memory->usage(mask, nmax); + if (atom->memcheck("image")) + bytes += memory->usage(image, nmax); + if (atom->memcheck("x")) + bytes += memory->usage(x, nmax, 3); + if (atom->memcheck("v")) + bytes += memory->usage(v, nmax, 3); + if (atom->memcheck("vest")) + bytes += memory->usage(vest, nmax, 3); + if (atom->memcheck("f")) + bytes += memory->usage(f, nmax * comm->nthreads, 3); + + if (atom->memcheck("radius")) + bytes += memory->usage(radius, nmax); + if (atom->memcheck("contact_radius")) + bytes += memory->usage(contact_radius, nmax); + if (atom->memcheck("vfrac")) + bytes += memory->usage(vfrac, nmax); + if (atom->memcheck("rmass")) + bytes += memory->usage(rmass, nmax); + if (atom->memcheck("eff_plastic_strain")) + bytes += memory->usage(eff_plastic_strain, nmax); + if (atom->memcheck("eff_plastic_strain_rate")) + bytes += memory->usage(eff_plastic_strain_rate, nmax); + if (atom->memcheck("e")) + bytes += memory->usage(e, nmax); + if (atom->memcheck("de")) + bytes += memory->usage(de, nmax); + + if (atom->memcheck("smd_data_9")) + bytes += memory->usage(smd_data_9, nmax, NMAT_FULL); + if (atom->memcheck("tlsph_stress")) + bytes += memory->usage(tlsph_stress, nmax, NMAT_SYMM); + + if (atom->memcheck("damage")) + bytes += memory->usage(damage, nmax); + + return bytes; } /* ---------------------------------------------------------------------- */ void AtomVecSMD::force_clear(int n, size_t nbytes) { - //printf("clearing force on atom %d", n); - memset(&de[n], 0, nbytes); - memset(&f[0][0], 0, 3 * nbytes); + //printf("clearing force on atom %d", n); + memset(&de[n], 0, nbytes); + memset(&f[0][0], 0, 3 * nbytes); } diff --git a/src/USER-SMD/compute_smd_hourglass_error.cpp b/src/USER-SMD/compute_smd_hourglass_error.cpp index cf0f67bfbb..1502f7ccb5 100644 --- a/src/USER-SMD/compute_smd_hourglass_error.cpp +++ b/src/USER-SMD/compute_smd_hourglass_error.cpp @@ -39,67 +39,67 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSMDHourglassError::ComputeSMDHourglassError(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/hourglass_error command"); - if (atom->smd_flag != 1) - error->all(FLERR, "compute smd/hourglass_error command requires atom_style with hourglass_error (e.g. smd)"); + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/hourglass_error command"); + if (atom->smd_flag != 1) + error->all(FLERR, "compute smd/hourglass_error command requires atom_style with hourglass_error (e.g. smd)"); - peratom_flag = 1; - size_peratom_cols = 0; + peratom_flag = 1; + size_peratom_cols = 0; - nmax = 0; - hourglass_error_vector = NULL; + nmax = 0; + hourglass_error_vector = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDHourglassError::~ComputeSMDHourglassError() { - memory->sfree(hourglass_error_vector); + memory->sfree(hourglass_error_vector); } /* ---------------------------------------------------------------------- */ void ComputeSMDHourglassError::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/hourglass_error") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/hourglass_error"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/hourglass_error") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/hourglass_error"); } /* ---------------------------------------------------------------------- */ void ComputeSMDHourglassError::compute_peratom() { - invoked_peratom = update->ntimestep; - - // grow output Vector array if necessary - - if (atom->nmax > nmax) { - memory->sfree(hourglass_error_vector); - nmax = atom->nmax; - hourglass_error_vector = (double *) memory->smalloc(nmax * sizeof(double), "atom:hourglass_error_vector"); - vector_atom = hourglass_error_vector; - } - - int itmp = 0; - double *hourglass_error = (double *) force->pair->extract("smd/tlsph/hourglass_error_ptr", itmp); - if (hourglass_error == NULL) { - error->all(FLERR, "compute smd/hourglass_error failed to access hourglass_error array"); - } - - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - hourglass_error_vector[i] = hourglass_error[i]; - } else { - hourglass_error_vector[i] = 0.0; - } - } + invoked_peratom = update->ntimestep; + + // grow output Vector array if necessary + + if (atom->nmax > nmax) { + memory->sfree(hourglass_error_vector); + nmax = atom->nmax; + hourglass_error_vector = (double *) memory->smalloc(nmax * sizeof(double), "atom:hourglass_error_vector"); + vector_atom = hourglass_error_vector; + } + + int itmp = 0; + double *hourglass_error = (double *) force->pair->extract("smd/tlsph/hourglass_error_ptr", itmp); + if (hourglass_error == NULL) { + error->all(FLERR, "compute smd/hourglass_error failed to access hourglass_error array"); + } + + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + hourglass_error_vector[i] = hourglass_error[i]; + } else { + hourglass_error_vector[i] = 0.0; + } + } } /* ---------------------------------------------------------------------- @@ -107,6 +107,6 @@ void ComputeSMDHourglassError::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMDHourglassError::memory_usage() { - double bytes = nmax * sizeof(double); - return bytes; + double bytes = nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_rho.cpp b/src/USER-SMD/compute_smd_rho.cpp index 91b75d9003..cb97755aca 100644 --- a/src/USER-SMD/compute_smd_rho.cpp +++ b/src/USER-SMD/compute_smd_rho.cpp @@ -37,63 +37,63 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSMDRho::ComputeSMDRho(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/rho command"); - if (atom->vfrac_flag != 1) - error->all(FLERR, "compute smd/rho command requires atom_style with volume (e.g. smd)"); + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/rho command"); + if (atom->vfrac_flag != 1) + error->all(FLERR, "compute smd/rho command requires atom_style with volume (e.g. smd)"); - peratom_flag = 1; - size_peratom_cols = 0; + peratom_flag = 1; + size_peratom_cols = 0; - nmax = 0; - rhoVector = NULL; + nmax = 0; + rhoVector = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDRho::~ComputeSMDRho() { - memory->sfree(rhoVector); + memory->sfree(rhoVector); } /* ---------------------------------------------------------------------- */ void ComputeSMDRho::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/rho") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/rho"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/rho") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/rho"); } /* ---------------------------------------------------------------------- */ void ComputeSMDRho::compute_peratom() { - invoked_peratom = update->ntimestep; - - // grow rhoVector array if necessary - - if (atom->nmax > nmax) { - memory->sfree(rhoVector); - nmax = atom->nmax; - rhoVector = (double *) memory->smalloc(nmax * sizeof(double), "atom:rhoVector"); - vector_atom = rhoVector; - } - - double *vfrac = atom->vfrac; - double *rmass = atom->rmass; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - rhoVector[i] = rmass[i] / vfrac[i]; - } else { - rhoVector[i] = 0.0; - } - } + invoked_peratom = update->ntimestep; + + // grow rhoVector array if necessary + + if (atom->nmax > nmax) { + memory->sfree(rhoVector); + nmax = atom->nmax; + rhoVector = (double *) memory->smalloc(nmax * sizeof(double), "atom:rhoVector"); + vector_atom = rhoVector; + } + + double *vfrac = atom->vfrac; + double *rmass = atom->rmass; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + rhoVector[i] = rmass[i] / vfrac[i]; + } else { + rhoVector[i] = 0.0; + } + } } @@ -102,6 +102,6 @@ void ComputeSMDRho::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMDRho::memory_usage() { - double bytes = nmax * sizeof(double); - return bytes; + double bytes = nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_tlsph_defgrad.cpp b/src/USER-SMD/compute_smd_tlsph_defgrad.cpp index c2ed667ef6..3ba66a656c 100644 --- a/src/USER-SMD/compute_smd_tlsph_defgrad.cpp +++ b/src/USER-SMD/compute_smd_tlsph_defgrad.cpp @@ -44,88 +44,88 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSMDTLSPHDefgrad::ComputeSMDTLSPHDefgrad(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/tlsph_defgrad command"); + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/tlsph_defgrad command"); - peratom_flag = 1; - size_peratom_cols = 10; + peratom_flag = 1; + size_peratom_cols = 10; - nmax = 0; - defgradVector = NULL; + nmax = 0; + defgradVector = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDTLSPHDefgrad::~ComputeSMDTLSPHDefgrad() { - memory->sfree(defgradVector); + memory->sfree(defgradVector); } /* ---------------------------------------------------------------------- */ void ComputeSMDTLSPHDefgrad::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/tlsph_defgrad") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/tlsph_defgrad"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/tlsph_defgrad") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/tlsph_defgrad"); } /* ---------------------------------------------------------------------- */ void ComputeSMDTLSPHDefgrad::compute_peratom() { - double **defgrad = atom->smd_data_9; - Matrix3d F; - invoked_peratom = update->ntimestep; - - // grow vector array if necessary - if (atom->nmax > nmax) { - memory->destroy(defgradVector); - nmax = atom->nmax; - memory->create(defgradVector, nmax, size_peratom_cols, "defgradVector"); - array_atom = defgradVector; - } - - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - F(0, 0) = defgrad[i][0]; - F(0, 1) = defgrad[i][1]; - F(0, 2) = defgrad[i][2]; - F(1, 0) = defgrad[i][3]; - F(1, 1) = defgrad[i][4]; - F(1, 2) = defgrad[i][5]; - F(2, 0) = defgrad[i][6]; - F(2, 1) = defgrad[i][7]; - F(2, 2) = defgrad[i][8]; - - defgradVector[i][0] = F(0, 0); - defgradVector[i][1] = F(0, 1); - defgradVector[i][2] = F(0, 2); - defgradVector[i][3] = F(1, 0); - defgradVector[i][4] = F(1, 1); - defgradVector[i][5] = F(1, 2); - defgradVector[i][6] = F(2, 0); - defgradVector[i][7] = F(2, 1); - defgradVector[i][8] = F(2, 2); - defgradVector[i][9] = F.determinant(); - } else { - defgradVector[i][0] = 1.0; - defgradVector[i][1] = 0.0; - defgradVector[i][2] = 0.0; - defgradVector[i][3] = 0.0; - defgradVector[i][4] = 1.0; - defgradVector[i][5] = 0.0; - defgradVector[i][6] = 0.0; - defgradVector[i][7] = 0.0; - defgradVector[i][8] = 1.0; - defgradVector[i][9] = 1.0; - } - } + double **defgrad = atom->smd_data_9; + Matrix3d F; + invoked_peratom = update->ntimestep; + + // grow vector array if necessary + if (atom->nmax > nmax) { + memory->destroy(defgradVector); + nmax = atom->nmax; + memory->create(defgradVector, nmax, size_peratom_cols, "defgradVector"); + array_atom = defgradVector; + } + + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + F(0, 0) = defgrad[i][0]; + F(0, 1) = defgrad[i][1]; + F(0, 2) = defgrad[i][2]; + F(1, 0) = defgrad[i][3]; + F(1, 1) = defgrad[i][4]; + F(1, 2) = defgrad[i][5]; + F(2, 0) = defgrad[i][6]; + F(2, 1) = defgrad[i][7]; + F(2, 2) = defgrad[i][8]; + + defgradVector[i][0] = F(0, 0); + defgradVector[i][1] = F(0, 1); + defgradVector[i][2] = F(0, 2); + defgradVector[i][3] = F(1, 0); + defgradVector[i][4] = F(1, 1); + defgradVector[i][5] = F(1, 2); + defgradVector[i][6] = F(2, 0); + defgradVector[i][7] = F(2, 1); + defgradVector[i][8] = F(2, 2); + defgradVector[i][9] = F.determinant(); + } else { + defgradVector[i][0] = 1.0; + defgradVector[i][1] = 0.0; + defgradVector[i][2] = 0.0; + defgradVector[i][3] = 0.0; + defgradVector[i][4] = 1.0; + defgradVector[i][5] = 0.0; + defgradVector[i][6] = 0.0; + defgradVector[i][7] = 0.0; + defgradVector[i][8] = 1.0; + defgradVector[i][9] = 1.0; + } + } } /* ---------------------------------------------------------------------- @@ -133,6 +133,6 @@ void ComputeSMDTLSPHDefgrad::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMDTLSPHDefgrad::memory_usage() { - double bytes = size_peratom_cols * nmax * sizeof(double); - return bytes; + double bytes = size_peratom_cols * nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_tlsph_dt.cpp b/src/USER-SMD/compute_smd_tlsph_dt.cpp index 54b4f497fb..6d573775fa 100644 --- a/src/USER-SMD/compute_smd_tlsph_dt.cpp +++ b/src/USER-SMD/compute_smd_tlsph_dt.cpp @@ -38,71 +38,71 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSMDTlsphDt::ComputeSMDTlsphDt(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/tlsph_dt command"); - if (atom->contact_radius_flag != 1) - error->all(FLERR, - "compute smd/tlsph_dt command requires atom_style with contact_radius (e.g. smd)"); - - peratom_flag = 1; - size_peratom_cols = 0; - - nmax = 0; - dt_vector = NULL; + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/tlsph_dt command"); + if (atom->contact_radius_flag != 1) + error->all(FLERR, + "compute smd/tlsph_dt command requires atom_style with contact_radius (e.g. smd)"); + + peratom_flag = 1; + size_peratom_cols = 0; + + nmax = 0; + dt_vector = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDTlsphDt::~ComputeSMDTlsphDt() { - memory->sfree(dt_vector); + memory->sfree(dt_vector); } /* ---------------------------------------------------------------------- */ void ComputeSMDTlsphDt::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/tlsph_dt") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/tlsph_dt"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/tlsph_dt") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/tlsph_dt"); } /* ---------------------------------------------------------------------- */ void ComputeSMDTlsphDt::compute_peratom() { - invoked_peratom = update->ntimestep; - - // grow rhoVector array if necessary - - if (atom->nmax > nmax) { - memory->sfree(dt_vector); - nmax = atom->nmax; - dt_vector = (double *) memory->smalloc(nmax * sizeof(double), - "atom:tlsph_dt_vector"); - vector_atom = dt_vector; - } - - int itmp = 0; - double *particle_dt = (double *) force->pair->extract("smd/tlsph/particle_dt_ptr", - itmp); - if (particle_dt == NULL) { - error->all(FLERR, - "compute smd/tlsph_dt failed to access particle_dt array"); - } - - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - dt_vector[i] = particle_dt[i]; - } else { - dt_vector[i] = 0.0; - } - } + invoked_peratom = update->ntimestep; + + // grow rhoVector array if necessary + + if (atom->nmax > nmax) { + memory->sfree(dt_vector); + nmax = atom->nmax; + dt_vector = (double *) memory->smalloc(nmax * sizeof(double), + "atom:tlsph_dt_vector"); + vector_atom = dt_vector; + } + + int itmp = 0; + double *particle_dt = (double *) force->pair->extract("smd/tlsph/particle_dt_ptr", + itmp); + if (particle_dt == NULL) { + error->all(FLERR, + "compute smd/tlsph_dt failed to access particle_dt array"); + } + + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + dt_vector[i] = particle_dt[i]; + } else { + dt_vector[i] = 0.0; + } + } } /* ---------------------------------------------------------------------- @@ -110,6 +110,6 @@ void ComputeSMDTlsphDt::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMDTlsphDt::memory_usage() { - double bytes = nmax * sizeof(double); - return bytes; + double bytes = nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_tlsph_shape.cpp b/src/USER-SMD/compute_smd_tlsph_shape.cpp index cec773b5c3..d9dc070f6b 100644 --- a/src/USER-SMD/compute_smd_tlsph_shape.cpp +++ b/src/USER-SMD/compute_smd_tlsph_shape.cpp @@ -45,86 +45,86 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSmdTlsphShape::ComputeSmdTlsphShape(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/tlsph_strain command"); + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/tlsph_strain command"); - peratom_flag = 1; - size_peratom_cols = 7; + peratom_flag = 1; + size_peratom_cols = 7; - nmax = 0; - strainVector = NULL; + nmax = 0; + strainVector = NULL; } /* ---------------------------------------------------------------------- */ ComputeSmdTlsphShape::~ComputeSmdTlsphShape() { - memory->sfree(strainVector); + memory->sfree(strainVector); } /* ---------------------------------------------------------------------- */ void ComputeSmdTlsphShape::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/tlsph_strain") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/tlsph_strain"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/tlsph_strain") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/tlsph_strain"); } /* ---------------------------------------------------------------------- */ void ComputeSmdTlsphShape::compute_peratom() { - double *contact_radius = atom->contact_radius; - invoked_peratom = update->ntimestep; - - // grow vector array if necessary - - if (atom->nmax > nmax) { - memory->destroy(strainVector); - nmax = atom->nmax; - memory->create(strainVector, nmax, size_peratom_cols, "strainVector"); - array_atom = strainVector; - } - - int itmp = 0; - Matrix3d *R = (Matrix3d *) force->pair->extract("smd/tlsph/rotation_ptr", itmp); - if (R == NULL) { - error->all(FLERR, "compute smd/tlsph_shape failed to access rotation array"); - } - - Matrix3d *F = (Matrix3d *) force->pair->extract("smd/tlsph/Fincr_ptr", itmp); - if (F == NULL) { - error->all(FLERR, "compute smd/tlsph_shape failed to access deformation gradient array"); - } - - int *mask = atom->mask; - int nlocal = atom->nlocal; - Matrix3d E, eye; - eye.setIdentity(); - Quaterniond q; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - - E = 0.5 * (F[i].transpose() * F[i] - eye); // Green-Lagrange strain - strainVector[i][0] = contact_radius[i] * (1.0 + E(0, 0)); - strainVector[i][1] = contact_radius[i] * (1.0 + E(1, 1)); - strainVector[i][2] = contact_radius[i] * (1.0 + E(2, 2)); - - q = R[i]; // convert pure rotation matrix to quaternion - strainVector[i][3] = q.w(); - strainVector[i][4] = q.x(); - strainVector[i][5] = q.y(); - strainVector[i][6] = q.z(); - } else { - for (int j = 0; j < size_peratom_cols; j++) { - strainVector[i][j] = 0.0; - } - } - } + double *contact_radius = atom->contact_radius; + invoked_peratom = update->ntimestep; + + // grow vector array if necessary + + if (atom->nmax > nmax) { + memory->destroy(strainVector); + nmax = atom->nmax; + memory->create(strainVector, nmax, size_peratom_cols, "strainVector"); + array_atom = strainVector; + } + + int itmp = 0; + Matrix3d *R = (Matrix3d *) force->pair->extract("smd/tlsph/rotation_ptr", itmp); + if (R == NULL) { + error->all(FLERR, "compute smd/tlsph_shape failed to access rotation array"); + } + + Matrix3d *F = (Matrix3d *) force->pair->extract("smd/tlsph/Fincr_ptr", itmp); + if (F == NULL) { + error->all(FLERR, "compute smd/tlsph_shape failed to access deformation gradient array"); + } + + int *mask = atom->mask; + int nlocal = atom->nlocal; + Matrix3d E, eye; + eye.setIdentity(); + Quaterniond q; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + + E = 0.5 * (F[i].transpose() * F[i] - eye); // Green-Lagrange strain + strainVector[i][0] = contact_radius[i] * (1.0 + E(0, 0)); + strainVector[i][1] = contact_radius[i] * (1.0 + E(1, 1)); + strainVector[i][2] = contact_radius[i] * (1.0 + E(2, 2)); + + q = R[i]; // convert pure rotation matrix to quaternion + strainVector[i][3] = q.w(); + strainVector[i][4] = q.x(); + strainVector[i][5] = q.y(); + strainVector[i][6] = q.z(); + } else { + for (int j = 0; j < size_peratom_cols; j++) { + strainVector[i][j] = 0.0; + } + } + } } /* ---------------------------------------------------------------------- @@ -132,6 +132,6 @@ void ComputeSmdTlsphShape::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSmdTlsphShape::memory_usage() { - double bytes = size_peratom_cols * nmax * sizeof(double); - return bytes; + double bytes = size_peratom_cols * nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_tlsph_strain.cpp b/src/USER-SMD/compute_smd_tlsph_strain.cpp index 2037d6c354..ea137d5b2a 100644 --- a/src/USER-SMD/compute_smd_tlsph_strain.cpp +++ b/src/USER-SMD/compute_smd_tlsph_strain.cpp @@ -45,94 +45,94 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSMDTLSPHstrain::ComputeSMDTLSPHstrain(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/tlsph_strain command"); + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/tlsph_strain command"); - peratom_flag = 1; - size_peratom_cols = 6; + peratom_flag = 1; + size_peratom_cols = 6; - nmax = 0; - strainVector = NULL; + nmax = 0; + strainVector = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDTLSPHstrain::~ComputeSMDTLSPHstrain() { - memory->sfree(strainVector); + memory->sfree(strainVector); } /* ---------------------------------------------------------------------- */ void ComputeSMDTLSPHstrain::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/tlsph_strain") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/tlsph_strain"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/tlsph_strain") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/tlsph_strain"); } /* ---------------------------------------------------------------------- */ void ComputeSMDTLSPHstrain::compute_peratom() { - double **defgrad0 = atom->smd_data_9; - - invoked_peratom = update->ntimestep; - - // grow vector array if necessary - - if (atom->nmax > nmax) { - memory->destroy(strainVector); - nmax = atom->nmax; - memory->create(strainVector, nmax, size_peratom_cols, "strainVector"); - array_atom = strainVector; - } - - // copy data to output array - int itmp = 0; - Matrix3d *Fincr = (Matrix3d *) force->pair->extract("smd/tlsph/Fincr_ptr", itmp); - if (Fincr == NULL) { - error->all(FLERR, "compute smd/tlsph_strain failed to access Fincr array"); - } - - int *mask = atom->mask; - int nlocal = atom->nlocal; - Matrix3d E, eye, Ftotal, F0; - eye.setIdentity(); - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - - // old deformation gradient - F0(0, 0) = defgrad0[i][0]; - F0(0, 1) = defgrad0[i][1]; - F0(0, 2) = defgrad0[i][2]; - F0(1, 0) = defgrad0[i][3]; - F0(1, 1) = defgrad0[i][4]; - F0(1, 2) = defgrad0[i][5]; - F0(2, 0) = defgrad0[i][6]; - F0(2, 1) = defgrad0[i][7]; - F0(2, 2) = defgrad0[i][8]; - - // compute current total deformation gradient - Ftotal = F0 * Fincr[i]; // this is the total deformation gradient: reference deformation times incremental deformation - - - E = 0.5 * (Ftotal.transpose() * Ftotal - eye); // Green-Lagrange strain - strainVector[i][0] = E(0, 0); - strainVector[i][1] = E(1, 1); - strainVector[i][2] = E(2, 2); - strainVector[i][3] = E(0, 1); - strainVector[i][4] = E(0, 2); - strainVector[i][5] = E(1, 2); - } else { - for (int j = 0; j < size_peratom_cols; j++) { - strainVector[i][j] = 0.0; - } - } - } + double **defgrad0 = atom->smd_data_9; + + invoked_peratom = update->ntimestep; + + // grow vector array if necessary + + if (atom->nmax > nmax) { + memory->destroy(strainVector); + nmax = atom->nmax; + memory->create(strainVector, nmax, size_peratom_cols, "strainVector"); + array_atom = strainVector; + } + + // copy data to output array + int itmp = 0; + Matrix3d *Fincr = (Matrix3d *) force->pair->extract("smd/tlsph/Fincr_ptr", itmp); + if (Fincr == NULL) { + error->all(FLERR, "compute smd/tlsph_strain failed to access Fincr array"); + } + + int *mask = atom->mask; + int nlocal = atom->nlocal; + Matrix3d E, eye, Ftotal, F0; + eye.setIdentity(); + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + + // old deformation gradient + F0(0, 0) = defgrad0[i][0]; + F0(0, 1) = defgrad0[i][1]; + F0(0, 2) = defgrad0[i][2]; + F0(1, 0) = defgrad0[i][3]; + F0(1, 1) = defgrad0[i][4]; + F0(1, 2) = defgrad0[i][5]; + F0(2, 0) = defgrad0[i][6]; + F0(2, 1) = defgrad0[i][7]; + F0(2, 2) = defgrad0[i][8]; + + // compute current total deformation gradient + Ftotal = F0 * Fincr[i]; // this is the total deformation gradient: reference deformation times incremental deformation + + + E = 0.5 * (Ftotal.transpose() * Ftotal - eye); // Green-Lagrange strain + strainVector[i][0] = E(0, 0); + strainVector[i][1] = E(1, 1); + strainVector[i][2] = E(2, 2); + strainVector[i][3] = E(0, 1); + strainVector[i][4] = E(0, 2); + strainVector[i][5] = E(1, 2); + } else { + for (int j = 0; j < size_peratom_cols; j++) { + strainVector[i][j] = 0.0; + } + } + } } /* ---------------------------------------------------------------------- @@ -140,6 +140,6 @@ void ComputeSMDTLSPHstrain::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMDTLSPHstrain::memory_usage() { - double bytes = size_peratom_cols * nmax * sizeof(double); - return bytes; + double bytes = size_peratom_cols * nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_tlsph_strain_rate.cpp b/src/USER-SMD/compute_smd_tlsph_strain_rate.cpp index db91b080ba..ed3525f4ad 100644 --- a/src/USER-SMD/compute_smd_tlsph_strain_rate.cpp +++ b/src/USER-SMD/compute_smd_tlsph_strain_rate.cpp @@ -41,67 +41,67 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSMDTLSPHStrainRate::ComputeSMDTLSPHStrainRate(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/ulsph_strain_rate command"); + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/ulsph_strain_rate command"); - peratom_flag = 1; - size_peratom_cols = 6; + peratom_flag = 1; + size_peratom_cols = 6; - nmax = 0; - strain_rate_array = NULL; + nmax = 0; + strain_rate_array = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDTLSPHStrainRate::~ComputeSMDTLSPHStrainRate() { - memory->sfree(strain_rate_array); + memory->sfree(strain_rate_array); } /* ---------------------------------------------------------------------- */ void ComputeSMDTLSPHStrainRate::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/ulsph_strain_rate") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/ulsph_strain_rate"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/ulsph_strain_rate") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/ulsph_strain_rate"); } /* ---------------------------------------------------------------------- */ void ComputeSMDTLSPHStrainRate::compute_peratom() { - invoked_peratom = update->ntimestep; - - // grow vector array if necessary - - if (atom->nmax > nmax) { - memory->destroy(strain_rate_array); - nmax = atom->nmax; - memory->create(strain_rate_array, nmax, size_peratom_cols, "stresstensorVector"); - array_atom = strain_rate_array; - } - - int itmp = 0; - Matrix3d *D = (Matrix3d *) force->pair->extract("smd/tlsph/strain_rate_ptr", itmp); - if (D == NULL) { - error->all(FLERR, - "compute smd/tlsph_strain_rate could not access strain rate. Are the matching pair styles present?"); - } - - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - - strain_rate_array[i][0] = D[i](0, 0); // xx - strain_rate_array[i][1] = D[i](1, 1); // yy - strain_rate_array[i][2] = D[i](2, 2); // zz - strain_rate_array[i][3] = D[i](0, 1); // xy - strain_rate_array[i][4] = D[i](0, 2); // xz - strain_rate_array[i][5] = D[i](1, 2); // yz - } + invoked_peratom = update->ntimestep; + + // grow vector array if necessary + + if (atom->nmax > nmax) { + memory->destroy(strain_rate_array); + nmax = atom->nmax; + memory->create(strain_rate_array, nmax, size_peratom_cols, "stresstensorVector"); + array_atom = strain_rate_array; + } + + int itmp = 0; + Matrix3d *D = (Matrix3d *) force->pair->extract("smd/tlsph/strain_rate_ptr", itmp); + if (D == NULL) { + error->all(FLERR, + "compute smd/tlsph_strain_rate could not access strain rate. Are the matching pair styles present?"); + } + + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + + strain_rate_array[i][0] = D[i](0, 0); // xx + strain_rate_array[i][1] = D[i](1, 1); // yy + strain_rate_array[i][2] = D[i](2, 2); // zz + strain_rate_array[i][3] = D[i](0, 1); // xy + strain_rate_array[i][4] = D[i](0, 2); // xz + strain_rate_array[i][5] = D[i](1, 2); // yz + } } /* ---------------------------------------------------------------------- @@ -109,6 +109,6 @@ void ComputeSMDTLSPHStrainRate::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMDTLSPHStrainRate::memory_usage() { - double bytes = size_peratom_cols * nmax * sizeof(double); - return bytes; + double bytes = size_peratom_cols * nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_tlsph_stress.cpp b/src/USER-SMD/compute_smd_tlsph_stress.cpp index d1fce57f92..cbcb4c45af 100644 --- a/src/USER-SMD/compute_smd_tlsph_stress.cpp +++ b/src/USER-SMD/compute_smd_tlsph_stress.cpp @@ -41,85 +41,85 @@ using namespace LAMMPS_NS; * deviator of a tensor */ static Matrix3d Deviator(Matrix3d M) { - Matrix3d eye; - eye.setIdentity(); - eye *= M.trace() / 3.0; - return M - eye; + Matrix3d eye; + eye.setIdentity(); + eye *= M.trace() / 3.0; + return M - eye; } /* ---------------------------------------------------------------------- */ ComputeSMDTLSPHStress::ComputeSMDTLSPHStress(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/tlsph_stress command"); + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/tlsph_stress command"); - peratom_flag = 1; - size_peratom_cols = 7; + peratom_flag = 1; + size_peratom_cols = 7; - nmax = 0; - stress_array = NULL; + nmax = 0; + stress_array = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDTLSPHStress::~ComputeSMDTLSPHStress() { - memory->sfree(stress_array); + memory->sfree(stress_array); } /* ---------------------------------------------------------------------- */ void ComputeSMDTLSPHStress::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/tlsph_stress") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/tlsph_stress"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/tlsph_stress") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/tlsph_stress"); } /* ---------------------------------------------------------------------- */ void ComputeSMDTLSPHStress::compute_peratom() { - invoked_peratom = update->ntimestep; - Matrix3d stress_deviator; - double von_mises_stress; - - // grow vector array if necessary - - if (atom->nmax > nmax) { - memory->destroy(stress_array); - nmax = atom->nmax; - memory->create(stress_array, nmax, size_peratom_cols, "stresstensorVector"); - array_atom = stress_array; - } - - int itmp = 0; - Matrix3d *T = (Matrix3d *) force->pair->extract("smd/tlsph/stressTensor_ptr", itmp); - if (T == NULL) { - error->all(FLERR, "compute smd/tlsph_stress could not access stress tensors. Are the matching pair styles present?"); - } - int nlocal = atom->nlocal; - int *mask = atom->mask; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - stress_deviator = Deviator(T[i]); - von_mises_stress = sqrt(3. / 2.) * stress_deviator.norm(); - stress_array[i][0] = T[i](0, 0); // xx - stress_array[i][1] = T[i](1, 1); // yy - stress_array[i][2] = T[i](2, 2); // zz - stress_array[i][3] = T[i](0, 1); // xy - stress_array[i][4] = T[i](0, 2); // xz - stress_array[i][5] = T[i](1, 2); // yz - stress_array[i][6] = von_mises_stress; - } else { - for (int j = 0; j < size_peratom_cols; j++) { - stress_array[i][j] = 0.0; - } - } - } + invoked_peratom = update->ntimestep; + Matrix3d stress_deviator; + double von_mises_stress; + + // grow vector array if necessary + + if (atom->nmax > nmax) { + memory->destroy(stress_array); + nmax = atom->nmax; + memory->create(stress_array, nmax, size_peratom_cols, "stresstensorVector"); + array_atom = stress_array; + } + + int itmp = 0; + Matrix3d *T = (Matrix3d *) force->pair->extract("smd/tlsph/stressTensor_ptr", itmp); + if (T == NULL) { + error->all(FLERR, "compute smd/tlsph_stress could not access stress tensors. Are the matching pair styles present?"); + } + int nlocal = atom->nlocal; + int *mask = atom->mask; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + stress_deviator = Deviator(T[i]); + von_mises_stress = sqrt(3. / 2.) * stress_deviator.norm(); + stress_array[i][0] = T[i](0, 0); // xx + stress_array[i][1] = T[i](1, 1); // yy + stress_array[i][2] = T[i](2, 2); // zz + stress_array[i][3] = T[i](0, 1); // xy + stress_array[i][4] = T[i](0, 2); // xz + stress_array[i][5] = T[i](1, 2); // yz + stress_array[i][6] = von_mises_stress; + } else { + for (int j = 0; j < size_peratom_cols; j++) { + stress_array[i][j] = 0.0; + } + } + } } /* ---------------------------------------------------------------------- @@ -127,6 +127,6 @@ void ComputeSMDTLSPHStress::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMDTLSPHStress::memory_usage() { - double bytes = size_peratom_cols * nmax * sizeof(double); - return bytes; + double bytes = size_peratom_cols * nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_triangle_mesh_vertices.cpp b/src/USER-SMD/compute_smd_triangle_mesh_vertices.cpp index 822d62d6db..e43dadb47a 100644 --- a/src/USER-SMD/compute_smd_triangle_mesh_vertices.cpp +++ b/src/USER-SMD/compute_smd_triangle_mesh_vertices.cpp @@ -78,8 +78,8 @@ void ComputeSMDTriangleVertices::init() { void ComputeSMDTriangleVertices::compute_peratom() { - double **smd_data_9 = atom->smd_data_9; - tagint *mol = atom->molecule; + double **smd_data_9 = atom->smd_data_9; + tagint *mol = atom->molecule; invoked_peratom = update->ntimestep; diff --git a/src/USER-SMD/compute_smd_ulsph_effm.cpp b/src/USER-SMD/compute_smd_ulsph_effm.cpp index 87de3df256..9453d8cfa6 100644 --- a/src/USER-SMD/compute_smd_ulsph_effm.cpp +++ b/src/USER-SMD/compute_smd_ulsph_effm.cpp @@ -38,71 +38,71 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSMD_Ulsph_Effm::ComputeSMD_Ulsph_Effm(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/ulsph_effm command"); - if (atom->contact_radius_flag != 1) - error->all(FLERR, - "compute smd/ulsph_effm command requires atom_style with contact_radius (e.g. smd)"); - - peratom_flag = 1; - size_peratom_cols = 0; - - nmax = 0; - dt_vector = NULL; + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/ulsph_effm command"); + if (atom->contact_radius_flag != 1) + error->all(FLERR, + "compute smd/ulsph_effm command requires atom_style with contact_radius (e.g. smd)"); + + peratom_flag = 1; + size_peratom_cols = 0; + + nmax = 0; + dt_vector = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMD_Ulsph_Effm::~ComputeSMD_Ulsph_Effm() { - memory->sfree(dt_vector); + memory->sfree(dt_vector); } /* ---------------------------------------------------------------------- */ void ComputeSMD_Ulsph_Effm::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/ulsph_effm") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/ulsph_effm"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/ulsph_effm") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/ulsph_effm"); } /* ---------------------------------------------------------------------- */ void ComputeSMD_Ulsph_Effm::compute_peratom() { - invoked_peratom = update->ntimestep; - - // grow rhoVector array if necessary - - if (atom->nmax > nmax) { - memory->sfree(dt_vector); - nmax = atom->nmax; - dt_vector = (double *) memory->smalloc(nmax * sizeof(double), - "atom:tlsph_dt_vector"); - vector_atom = dt_vector; - } - - int itmp = 0; - double *particle_dt = (double *) force->pair->extract("smd/ulsph/effective_modulus_ptr", - itmp); - if (particle_dt == NULL) { - error->all(FLERR, - "compute smd/ulsph_effm failed to access particle_dt array"); - } - - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - dt_vector[i] = particle_dt[i]; - } else { - dt_vector[i] = 0.0; - } - } + invoked_peratom = update->ntimestep; + + // grow rhoVector array if necessary + + if (atom->nmax > nmax) { + memory->sfree(dt_vector); + nmax = atom->nmax; + dt_vector = (double *) memory->smalloc(nmax * sizeof(double), + "atom:tlsph_dt_vector"); + vector_atom = dt_vector; + } + + int itmp = 0; + double *particle_dt = (double *) force->pair->extract("smd/ulsph/effective_modulus_ptr", + itmp); + if (particle_dt == NULL) { + error->all(FLERR, + "compute smd/ulsph_effm failed to access particle_dt array"); + } + + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + dt_vector[i] = particle_dt[i]; + } else { + dt_vector[i] = 0.0; + } + } } /* ---------------------------------------------------------------------- @@ -110,6 +110,6 @@ void ComputeSMD_Ulsph_Effm::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMD_Ulsph_Effm::memory_usage() { - double bytes = nmax * sizeof(double); - return bytes; + double bytes = nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_ulsph_strain.cpp b/src/USER-SMD/compute_smd_ulsph_strain.cpp index 2ecb79e670..c7fcc909f3 100644 --- a/src/USER-SMD/compute_smd_ulsph_strain.cpp +++ b/src/USER-SMD/compute_smd_ulsph_strain.cpp @@ -45,69 +45,69 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSMDULSPHstrain::ComputeSMDULSPHstrain(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/tlsph_strain command"); + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/tlsph_strain command"); - peratom_flag = 1; - size_peratom_cols = 6; + peratom_flag = 1; + size_peratom_cols = 6; - nmax = 0; - strainVector = NULL; + nmax = 0; + strainVector = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDULSPHstrain::~ComputeSMDULSPHstrain() { - memory->sfree(strainVector); + memory->sfree(strainVector); } /* ---------------------------------------------------------------------- */ void ComputeSMDULSPHstrain::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/tlsph_strain") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/tlsph_strain"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/tlsph_strain") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/tlsph_strain"); } /* ---------------------------------------------------------------------- */ void ComputeSMDULSPHstrain::compute_peratom() { - double **atom_data9 = atom->smd_data_9; // ULSPH strain is stored in the first 6 entries of this data field - - invoked_peratom = update->ntimestep; - - // grow vector array if necessary - - if (atom->nmax > nmax) { - memory->destroy(strainVector); - nmax = atom->nmax; - memory->create(strainVector, nmax, size_peratom_cols, "strainVector"); - array_atom = strainVector; - } - - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - - strainVector[i][0] = atom_data9[i][0]; - strainVector[i][1] = atom_data9[i][1]; - strainVector[i][2] = atom_data9[i][2]; - strainVector[i][3] = atom_data9[i][3]; - strainVector[i][4] = atom_data9[i][4]; - strainVector[i][5] = atom_data9[i][5]; - } else { - for (int j = 0; j < size_peratom_cols; j++) { - strainVector[i][j] = 0.0; - } - } - } + double **atom_data9 = atom->smd_data_9; // ULSPH strain is stored in the first 6 entries of this data field + + invoked_peratom = update->ntimestep; + + // grow vector array if necessary + + if (atom->nmax > nmax) { + memory->destroy(strainVector); + nmax = atom->nmax; + memory->create(strainVector, nmax, size_peratom_cols, "strainVector"); + array_atom = strainVector; + } + + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + + strainVector[i][0] = atom_data9[i][0]; + strainVector[i][1] = atom_data9[i][1]; + strainVector[i][2] = atom_data9[i][2]; + strainVector[i][3] = atom_data9[i][3]; + strainVector[i][4] = atom_data9[i][4]; + strainVector[i][5] = atom_data9[i][5]; + } else { + for (int j = 0; j < size_peratom_cols; j++) { + strainVector[i][j] = 0.0; + } + } + } } /* ---------------------------------------------------------------------- @@ -115,6 +115,6 @@ void ComputeSMDULSPHstrain::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMDULSPHstrain::memory_usage() { - double bytes = size_peratom_cols * nmax * sizeof(double); - return bytes; + double bytes = size_peratom_cols * nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_ulsph_strain_rate.cpp b/src/USER-SMD/compute_smd_ulsph_strain_rate.cpp index 4ba4c6c520..0d472a368a 100644 --- a/src/USER-SMD/compute_smd_ulsph_strain_rate.cpp +++ b/src/USER-SMD/compute_smd_ulsph_strain_rate.cpp @@ -40,77 +40,77 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSMDULSPHStrainRate::ComputeSMDULSPHStrainRate(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/ulsph_strain_rate command"); + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/ulsph_strain_rate command"); - peratom_flag = 1; - size_peratom_cols = 6; + peratom_flag = 1; + size_peratom_cols = 6; - nmax = 0; - strain_rate_array = NULL; + nmax = 0; + strain_rate_array = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDULSPHStrainRate::~ComputeSMDULSPHStrainRate() { - memory->sfree(strain_rate_array); + memory->sfree(strain_rate_array); } /* ---------------------------------------------------------------------- */ void ComputeSMDULSPHStrainRate::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/ulsph_strain_rate") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/ulsph_strain_rate"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/ulsph_strain_rate") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/ulsph_strain_rate"); } /* ---------------------------------------------------------------------- */ void ComputeSMDULSPHStrainRate::compute_peratom() { - invoked_peratom = update->ntimestep; - int *mask = atom->mask; - - // grow vector array if necessary - - if (atom->nmax > nmax) { - memory->destroy(strain_rate_array); - nmax = atom->nmax; - memory->create(strain_rate_array, nmax, size_peratom_cols, "stresstensorVector"); - array_atom = strain_rate_array; - } - - int itmp = 0; - Matrix3d *L = (Matrix3d *) force->pair->extract("smd/ulsph/velocityGradient_ptr", itmp); - if (L == NULL) { - error->all(FLERR, - "compute smd/ulsph_strain_rate could not access any velocity gradients. Are the matching pair styles present?"); - } - int nlocal = atom->nlocal; - Matrix3d D; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - D = 0.5 * (L[i] + L[i].transpose()); - strain_rate_array[i][0] = D(0, 0); // xx - strain_rate_array[i][1] = D(1, 1); // yy - strain_rate_array[i][2] = D(2, 2); // zz - strain_rate_array[i][3] = D(0, 1); // xy - strain_rate_array[i][4] = D(0, 2); // xz - strain_rate_array[i][5] = D(1, 2); // yz - } else { - strain_rate_array[i][0] = 0.0; - strain_rate_array[i][1] = 0.0; - strain_rate_array[i][2] = 0.0; - strain_rate_array[i][3] = 0.0; - strain_rate_array[i][4] = 0.0; - strain_rate_array[i][5] = 0.0; - } - } + invoked_peratom = update->ntimestep; + int *mask = atom->mask; + + // grow vector array if necessary + + if (atom->nmax > nmax) { + memory->destroy(strain_rate_array); + nmax = atom->nmax; + memory->create(strain_rate_array, nmax, size_peratom_cols, "stresstensorVector"); + array_atom = strain_rate_array; + } + + int itmp = 0; + Matrix3d *L = (Matrix3d *) force->pair->extract("smd/ulsph/velocityGradient_ptr", itmp); + if (L == NULL) { + error->all(FLERR, + "compute smd/ulsph_strain_rate could not access any velocity gradients. Are the matching pair styles present?"); + } + int nlocal = atom->nlocal; + Matrix3d D; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + D = 0.5 * (L[i] + L[i].transpose()); + strain_rate_array[i][0] = D(0, 0); // xx + strain_rate_array[i][1] = D(1, 1); // yy + strain_rate_array[i][2] = D(2, 2); // zz + strain_rate_array[i][3] = D(0, 1); // xy + strain_rate_array[i][4] = D(0, 2); // xz + strain_rate_array[i][5] = D(1, 2); // yz + } else { + strain_rate_array[i][0] = 0.0; + strain_rate_array[i][1] = 0.0; + strain_rate_array[i][2] = 0.0; + strain_rate_array[i][3] = 0.0; + strain_rate_array[i][4] = 0.0; + strain_rate_array[i][5] = 0.0; + } + } } /* ---------------------------------------------------------------------- @@ -118,6 +118,6 @@ void ComputeSMDULSPHStrainRate::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMDULSPHStrainRate::memory_usage() { - double bytes = size_peratom_cols * nmax * sizeof(double); - return bytes; + double bytes = size_peratom_cols * nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_ulsph_stress.cpp b/src/USER-SMD/compute_smd_ulsph_stress.cpp index e26e0c12f2..7069feced3 100644 --- a/src/USER-SMD/compute_smd_ulsph_stress.cpp +++ b/src/USER-SMD/compute_smd_ulsph_stress.cpp @@ -40,87 +40,87 @@ using namespace LAMMPS_NS; * deviator of a tensor */ static Matrix3d Deviator(Matrix3d M) { - Matrix3d eye; - eye.setIdentity(); - eye *= M.trace() / 3.0; - return M - eye; + Matrix3d eye; + eye.setIdentity(); + eye *= M.trace() / 3.0; + return M - eye; } /* ---------------------------------------------------------------------- */ ComputeSMDULSPHStress::ComputeSMDULSPHStress(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/ulsph_stress command"); + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/ulsph_stress command"); - peratom_flag = 1; - size_peratom_cols = 7; + peratom_flag = 1; + size_peratom_cols = 7; - nmax = 0; - stress_array = NULL; + nmax = 0; + stress_array = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDULSPHStress::~ComputeSMDULSPHStress() { - memory->sfree(stress_array); + memory->sfree(stress_array); } /* ---------------------------------------------------------------------- */ void ComputeSMDULSPHStress::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/ulsph_stress") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/ulsph_stress"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/ulsph_stress") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/ulsph_stress"); } /* ---------------------------------------------------------------------- */ void ComputeSMDULSPHStress::compute_peratom() { - invoked_peratom = update->ntimestep; - int *mask = atom->mask; - Matrix3d stress_deviator; - double von_mises_stress; - - // grow vector array if necessary - - if (atom->nmax > nmax) { - memory->destroy(stress_array); - nmax = atom->nmax; - memory->create(stress_array, nmax, size_peratom_cols, "stresstensorVector"); - array_atom = stress_array; - } - - int itmp = 0; - Matrix3d *T = (Matrix3d *) force->pair->extract("smd/ulsph/stressTensor_ptr", itmp); - if (T == NULL) { - error->all(FLERR, "compute smd/ulsph_stress could not access stress tensors. Are the matching pair styles present?"); - } - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - - if (mask[i] & groupbit) { - stress_deviator = Deviator(T[i]); - von_mises_stress = sqrt(3. / 2.) * stress_deviator.norm(); - stress_array[i][0] = T[i](0, 0); // xx - stress_array[i][1] = T[i](1, 1); // yy - stress_array[i][2] = T[i](2, 2); // zz - stress_array[i][3] = T[i](0, 1); // xy - stress_array[i][4] = T[i](0, 2); // xz - stress_array[i][5] = T[i](1, 2); // yz - stress_array[i][6] = von_mises_stress; - - } else { - for (int j = 0; j < size_peratom_cols; j++) { - stress_array[i][j] = 0.0; - } - } - } + invoked_peratom = update->ntimestep; + int *mask = atom->mask; + Matrix3d stress_deviator; + double von_mises_stress; + + // grow vector array if necessary + + if (atom->nmax > nmax) { + memory->destroy(stress_array); + nmax = atom->nmax; + memory->create(stress_array, nmax, size_peratom_cols, "stresstensorVector"); + array_atom = stress_array; + } + + int itmp = 0; + Matrix3d *T = (Matrix3d *) force->pair->extract("smd/ulsph/stressTensor_ptr", itmp); + if (T == NULL) { + error->all(FLERR, "compute smd/ulsph_stress could not access stress tensors. Are the matching pair styles present?"); + } + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + + if (mask[i] & groupbit) { + stress_deviator = Deviator(T[i]); + von_mises_stress = sqrt(3. / 2.) * stress_deviator.norm(); + stress_array[i][0] = T[i](0, 0); // xx + stress_array[i][1] = T[i](1, 1); // yy + stress_array[i][2] = T[i](2, 2); // zz + stress_array[i][3] = T[i](0, 1); // xy + stress_array[i][4] = T[i](0, 2); // xz + stress_array[i][5] = T[i](1, 2); // yz + stress_array[i][6] = von_mises_stress; + + } else { + for (int j = 0; j < size_peratom_cols; j++) { + stress_array[i][j] = 0.0; + } + } + } } /* ---------------------------------------------------------------------- @@ -128,7 +128,7 @@ void ComputeSMDULSPHStress::compute_peratom() { ------------------------------------------------------------------------- */ double ComputeSMDULSPHStress::memory_usage() { - double bytes = size_peratom_cols * nmax * sizeof(double); - return bytes; + double bytes = size_peratom_cols * nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/compute_smd_vol.cpp b/src/USER-SMD/compute_smd_vol.cpp index a12164d9e2..3573ee6a6c 100644 --- a/src/USER-SMD/compute_smd_vol.cpp +++ b/src/USER-SMD/compute_smd_vol.cpp @@ -37,86 +37,86 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeSMDVol::ComputeSMDVol(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) { - if (narg != 3) - error->all(FLERR, "Illegal compute smd/volume command"); - if (atom->vfrac_flag != 1) - error->all(FLERR, "compute smd/volume command requires atom_style with density (e.g. smd)"); - - scalar_flag = 1; - peratom_flag = 1; - size_peratom_cols = 0; - - nmax = 0; - volVector = NULL; + Compute(lmp, narg, arg) { + if (narg != 3) + error->all(FLERR, "Illegal compute smd/volume command"); + if (atom->vfrac_flag != 1) + error->all(FLERR, "compute smd/volume command requires atom_style with density (e.g. smd)"); + + scalar_flag = 1; + peratom_flag = 1; + size_peratom_cols = 0; + + nmax = 0; + volVector = NULL; } /* ---------------------------------------------------------------------- */ ComputeSMDVol::~ComputeSMDVol() { - memory->sfree(volVector); + memory->sfree(volVector); } /* ---------------------------------------------------------------------- */ void ComputeSMDVol::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "smd/volume") == 0) - count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR, "More than one compute smd/volume"); + int count = 0; + for (int i = 0; i < modify->ncompute; i++) + if (strcmp(modify->compute[i]->style, "smd/volume") == 0) + count++; + if (count > 1 && comm->me == 0) + error->warning(FLERR, "More than one compute smd/volume"); } /* ---------------------------------------------------------------------- */ void ComputeSMDVol::compute_peratom() { - invoked_peratom = update->ntimestep; - - // grow volVector array if necessary - - if (atom->nmax > nmax) { - memory->sfree(volVector); - nmax = atom->nmax; - volVector = (double *) memory->smalloc(nmax * sizeof(double), "atom:volVector"); - vector_atom = volVector; - } - - double *vfrac = atom->vfrac; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - volVector[i] = vfrac[i]; - } else { - volVector[i] = 0.0; - } - } + invoked_peratom = update->ntimestep; + + // grow volVector array if necessary + + if (atom->nmax > nmax) { + memory->sfree(volVector); + nmax = atom->nmax; + volVector = (double *) memory->smalloc(nmax * sizeof(double), "atom:volVector"); + vector_atom = volVector; + } + + double *vfrac = atom->vfrac; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + volVector[i] = vfrac[i]; + } else { + volVector[i] = 0.0; + } + } } /* ---------------------------------------------------------------------- */ double ComputeSMDVol::compute_scalar() { - invoked_scalar = update->ntimestep; - double *vfrac = atom->vfrac; - int *mask = atom->mask; - int nlocal = atom->nlocal; + invoked_scalar = update->ntimestep; + double *vfrac = atom->vfrac; + int *mask = atom->mask; + int nlocal = atom->nlocal; - double this_proc_sum_volumes = 0.0; - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - this_proc_sum_volumes += vfrac[i]; - } - } + double this_proc_sum_volumes = 0.0; + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + this_proc_sum_volumes += vfrac[i]; + } + } - //printf("this_proc_sum_volumes = %g\n", this_proc_sum_volumes); - MPI_Allreduce(&this_proc_sum_volumes, &scalar, 1, MPI_DOUBLE, MPI_SUM, world); - //if (comm->me == 0) printf("global sum_volumes = %g\n", scalar); + //printf("this_proc_sum_volumes = %g\n", this_proc_sum_volumes); + MPI_Allreduce(&this_proc_sum_volumes, &scalar, 1, MPI_DOUBLE, MPI_SUM, world); + //if (comm->me == 0) printf("global sum_volumes = %g\n", scalar); - return scalar; + return scalar; } @@ -125,6 +125,6 @@ double ComputeSMDVol::compute_scalar() { ------------------------------------------------------------------------- */ double ComputeSMDVol::memory_usage() { - double bytes = nmax * sizeof(double); - return bytes; + double bytes = nmax * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/fix_smd_adjust_dt.cpp b/src/USER-SMD/fix_smd_adjust_dt.cpp index 4920160a30..d2570b6bdc 100644 --- a/src/USER-SMD/fix_smd_adjust_dt.cpp +++ b/src/USER-SMD/fix_smd_adjust_dt.cpp @@ -48,161 +48,161 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixSMDTlsphDtReset::FixSMDTlsphDtReset(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) { - if (narg != 4) - error->all(FLERR, "Illegal fix smd/adjust_dt command"); + Fix(lmp, narg, arg) { + if (narg != 4) + error->all(FLERR, "Illegal fix smd/adjust_dt command"); - // set time_depend, else elapsed time accumulation can be messed up + // set time_depend, else elapsed time accumulation can be messed up - time_depend = 1; - scalar_flag = 1; - vector_flag = 1; - size_vector = 2; - global_freq = 1; - extscalar = 0; - extvector = 0; - restart_global = 1; // this fix stores global (i.e., not per-atom) info: elaspsed time + time_depend = 1; + scalar_flag = 1; + vector_flag = 1; + size_vector = 2; + global_freq = 1; + extscalar = 0; + extvector = 0; + restart_global = 1; // this fix stores global (i.e., not per-atom) info: elaspsed time - safety_factor = atof(arg[3]); + safety_factor = atof(arg[3]); - // initializations - t_elapsed = 0.0; + // initializations + t_elapsed = 0.0; } /* ---------------------------------------------------------------------- */ int FixSMDTlsphDtReset::setmask() { - int mask = 0; - mask |= INITIAL_INTEGRATE; - mask |= END_OF_STEP; - return mask; + int mask = 0; + mask |= INITIAL_INTEGRATE; + mask |= END_OF_STEP; + return mask; } /* ---------------------------------------------------------------------- */ void FixSMDTlsphDtReset::init() { - dt = update->dt; + dt = update->dt; } /* ---------------------------------------------------------------------- */ void FixSMDTlsphDtReset::setup(int vflag) { - end_of_step(); + end_of_step(); } /* ---------------------------------------------------------------------- */ void FixSMDTlsphDtReset::initial_integrate(int vflag) { - //printf("in adjust_dt: dt = %20.10f\n", update->dt); + //printf("in adjust_dt: dt = %20.10f\n", update->dt); - t_elapsed += update->dt; + t_elapsed += update->dt; } /* ---------------------------------------------------------------------- */ void FixSMDTlsphDtReset::end_of_step() { - double dtmin = BIG; - int itmp = 0; - - /* - * extract minimum CFL timestep from TLSPH and ULSPH pair styles - */ - - double *dtCFL_TLSPH = (double *) force->pair->extract("smd/tlsph/dtCFL_ptr", itmp); - double *dtCFL_ULSPH = (double *) force->pair->extract("smd/ulsph/dtCFL_ptr", itmp); - double *dt_TRI = (double *) force->pair->extract("smd/tri_surface/stable_time_increment_ptr", itmp); - double *dt_HERTZ = (double *) force->pair->extract("smd/hertz/stable_time_increment_ptr", itmp); - double *dt_PERI_IPMB = (double *) force->pair->extract("smd/peri_ipmb/stable_time_increment_ptr", itmp); - - if ((dtCFL_TLSPH == NULL) && (dtCFL_ULSPH == NULL) && (dt_TRI == NULL) && (dt_HERTZ == NULL) - && (dt_PERI_IPMB == NULL)) { - error->all(FLERR, "fix smd/adjust_dt failed to access a valid dtCFL"); - } - - if (dtCFL_TLSPH != NULL) { - dtmin = MIN(dtmin, *dtCFL_TLSPH); - } - - if (dtCFL_ULSPH != NULL) { - dtmin = MIN(dtmin, *dtCFL_ULSPH); - } - - if (dt_TRI != NULL) { - dtmin = MIN(dtmin, *dt_TRI); - } - - if (dt_HERTZ != NULL) { - dtmin = MIN(dtmin, *dt_HERTZ); - } - - if (dt_PERI_IPMB != NULL) { - dtmin = MIN(dtmin, *dt_PERI_IPMB); - } - -// double **v = atom->v; -// double **f = atom->f; -// double *rmass = atom->rmass; -// double *radius = atom->radius; -// int *mask = atom->mask; -// int nlocal = atom->nlocal; -// double dtv, dtf, dtsq; -// double vsq, fsq, massinv, xmax; -// double delx, dely, delz, delr; - -// for (int i = 0; i < nlocal; i++) { -// if (mask[i] & groupbit) { -// xmax = 0.005 * radius[i]; -// massinv = 1.0 / rmass[i]; -// vsq = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]; -// fsq = f[i][0] * f[i][0] + f[i][1] * f[i][1] + f[i][2] * f[i][2]; -// dtv = dtf = BIG; -// if (vsq > 0.0) -// dtv = xmax / sqrt(vsq); -// if (fsq > 0.0) -// dtf = sqrt(2.0 * xmax / (sqrt(fsq) * massinv)); -// dt = MIN(dtv, dtf); -// dtmin = MIN(dtmin, dt); -// dtsq = dt * dt; -// delx = dt * v[i][0] + 0.5 * dtsq * massinv * f[i][0]; -// dely = dt * v[i][1] + 0.5 * dtsq * massinv * f[i][1]; -// delz = dt * v[i][2] + 0.5 * dtsq * massinv * f[i][2]; -// delr = sqrt(delx * delx + dely * dely + delz * delz); -// if (delr > xmax) -// dt *= xmax / delr; -// dtmin = MIN(dtmin, dt); + double dtmin = BIG; + int itmp = 0; + + /* + * extract minimum CFL timestep from TLSPH and ULSPH pair styles + */ + + double *dtCFL_TLSPH = (double *) force->pair->extract("smd/tlsph/dtCFL_ptr", itmp); + double *dtCFL_ULSPH = (double *) force->pair->extract("smd/ulsph/dtCFL_ptr", itmp); + double *dt_TRI = (double *) force->pair->extract("smd/tri_surface/stable_time_increment_ptr", itmp); + double *dt_HERTZ = (double *) force->pair->extract("smd/hertz/stable_time_increment_ptr", itmp); + double *dt_PERI_IPMB = (double *) force->pair->extract("smd/peri_ipmb/stable_time_increment_ptr", itmp); + + if ((dtCFL_TLSPH == NULL) && (dtCFL_ULSPH == NULL) && (dt_TRI == NULL) && (dt_HERTZ == NULL) + && (dt_PERI_IPMB == NULL)) { + error->all(FLERR, "fix smd/adjust_dt failed to access a valid dtCFL"); + } + + if (dtCFL_TLSPH != NULL) { + dtmin = MIN(dtmin, *dtCFL_TLSPH); + } + + if (dtCFL_ULSPH != NULL) { + dtmin = MIN(dtmin, *dtCFL_ULSPH); + } + + if (dt_TRI != NULL) { + dtmin = MIN(dtmin, *dt_TRI); + } + + if (dt_HERTZ != NULL) { + dtmin = MIN(dtmin, *dt_HERTZ); + } + + if (dt_PERI_IPMB != NULL) { + dtmin = MIN(dtmin, *dt_PERI_IPMB); + } + +// double **v = atom->v; +// double **f = atom->f; +// double *rmass = atom->rmass; +// double *radius = atom->radius; +// int *mask = atom->mask; +// int nlocal = atom->nlocal; +// double dtv, dtf, dtsq; +// double vsq, fsq, massinv, xmax; +// double delx, dely, delz, delr; + +// for (int i = 0; i < nlocal; i++) { +// if (mask[i] & groupbit) { +// xmax = 0.005 * radius[i]; +// massinv = 1.0 / rmass[i]; +// vsq = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]; +// fsq = f[i][0] * f[i][0] + f[i][1] * f[i][1] + f[i][2] * f[i][2]; +// dtv = dtf = BIG; +// if (vsq > 0.0) +// dtv = xmax / sqrt(vsq); +// if (fsq > 0.0) +// dtf = sqrt(2.0 * xmax / (sqrt(fsq) * massinv)); +// dt = MIN(dtv, dtf); +// dtmin = MIN(dtmin, dt); +// dtsq = dt * dt; +// delx = dt * v[i][0] + 0.5 * dtsq * massinv * f[i][0]; +// dely = dt * v[i][1] + 0.5 * dtsq * massinv * f[i][1]; +// delz = dt * v[i][2] + 0.5 * dtsq * massinv * f[i][2]; +// delr = sqrt(delx * delx + dely * dely + delz * delz); +// if (delr > xmax) +// dt *= xmax / delr; +// dtmin = MIN(dtmin, dt); // -//// xmax = 0.05 * radius[i]; -//// massinv = 1.0 / rmass[i]; -//// fsq = f[i][0] * f[i][0] + f[i][1] * f[i][1] + f[i][2] * f[i][2]; -//// dtf = BIG; -//// if (fsq > 0.0) -//// dtf = sqrt(2.0 * xmax / (sqrt(fsq) * massinv)); -//// dtmin = MIN(dtmin, dtf); -// } -// } - - dtmin *= safety_factor; // apply safety factor - MPI_Allreduce(&dtmin, &dt, 1, MPI_DOUBLE, MPI_MIN, world); - - if (update->ntimestep == 0) { - dt = 1.0e-16; - } - - //printf("dtmin is now: %f, dt is now%f\n", dtmin, dt); - - - update->dt = dt; - if (force->pair) - force->pair->reset_dt(); - for (int i = 0; i < modify->nfix; i++) - modify->fix[i]->reset_dt(); +//// xmax = 0.05 * radius[i]; +//// massinv = 1.0 / rmass[i]; +//// fsq = f[i][0] * f[i][0] + f[i][1] * f[i][1] + f[i][2] * f[i][2]; +//// dtf = BIG; +//// if (fsq > 0.0) +//// dtf = sqrt(2.0 * xmax / (sqrt(fsq) * massinv)); +//// dtmin = MIN(dtmin, dtf); +// } +// } + + dtmin *= safety_factor; // apply safety factor + MPI_Allreduce(&dtmin, &dt, 1, MPI_DOUBLE, MPI_MIN, world); + + if (update->ntimestep == 0) { + dt = 1.0e-16; + } + + //printf("dtmin is now: %f, dt is now%f\n", dtmin, dt); + + + update->dt = dt; + if (force->pair) + force->pair->reset_dt(); + for (int i = 0; i < modify->nfix; i++) + modify->fix[i]->reset_dt(); } /* ---------------------------------------------------------------------- */ double FixSMDTlsphDtReset::compute_scalar() { - return t_elapsed; + return t_elapsed; } /* ---------------------------------------------------------------------- @@ -210,15 +210,15 @@ double FixSMDTlsphDtReset::compute_scalar() { ------------------------------------------------------------------------- */ void FixSMDTlsphDtReset::write_restart(FILE *fp) { - int n = 0; - double list[1]; - list[n++] = t_elapsed; - - if (comm->me == 0) { - int size = n * sizeof(double); - fwrite(&size, sizeof(int), 1, fp); - fwrite(list, sizeof(double), n, fp); - } + int n = 0; + double list[1]; + list[n++] = t_elapsed; + + if (comm->me == 0) { + int size = n * sizeof(double); + fwrite(&size, sizeof(int), 1, fp); + fwrite(list, sizeof(double), n, fp); + } } /* ---------------------------------------------------------------------- @@ -226,8 +226,8 @@ void FixSMDTlsphDtReset::write_restart(FILE *fp) { ------------------------------------------------------------------------- */ void FixSMDTlsphDtReset::restart(char *buf) { - int n = 0; - double *list = (double *) buf; - t_elapsed = list[n++]; + int n = 0; + double *list = (double *) buf; + t_elapsed = list[n++]; } diff --git a/src/USER-SMD/fix_smd_adjust_dt.h b/src/USER-SMD/fix_smd_adjust_dt.h index d7d8c922f2..b89c136082 100644 --- a/src/USER-SMD/fix_smd_adjust_dt.h +++ b/src/USER-SMD/fix_smd_adjust_dt.h @@ -37,21 +37,21 @@ namespace LAMMPS_NS { class FixSMDTlsphDtReset: public Fix { public: - FixSMDTlsphDtReset(class LAMMPS *, int, char **); - ~FixSMDTlsphDtReset() { - } - int setmask(); - void init(); - void setup(int); - void initial_integrate(int); - void end_of_step(); - double compute_scalar(); - void write_restart(FILE *); - void restart(char *); + FixSMDTlsphDtReset(class LAMMPS *, int, char **); + ~FixSMDTlsphDtReset() { + } + int setmask(); + void init(); + void setup(int); + void initial_integrate(int); + void end_of_step(); + double compute_scalar(); + void write_restart(FILE *); + void restart(char *); private: - double safety_factor; - double dt, t_elapsed; + double safety_factor; + double dt, t_elapsed; }; } diff --git a/src/USER-SMD/fix_smd_integrate_tlsph.cpp b/src/USER-SMD/fix_smd_integrate_tlsph.cpp index b364c4813d..2744211d87 100644 --- a/src/USER-SMD/fix_smd_integrate_tlsph.cpp +++ b/src/USER-SMD/fix_smd_integrate_tlsph.cpp @@ -48,207 +48,207 @@ using namespace std; /* ---------------------------------------------------------------------- */ FixSMDIntegrateTlsph::FixSMDIntegrateTlsph(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) { - if (narg < 3) { - printf("narg=%d\n", narg); - error->all(FLERR, "Illegal fix smd/integrate_tlsph command"); - } - - xsphFlag = false; - vlimit = -1.0; - int iarg = 3; - - if (comm->me == 0) { - printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); - printf("fix smd/integrate_tlsph is active for group: %s \n", arg[1]); - } - - while (true) { - - if (iarg >= narg) { - break; - } - - if (strcmp(arg[iarg], "xsph") == 0) { - xsphFlag = true; - if (comm->me == 0) { - error->one(FLERR, "XSPH is currently not available"); - printf("... will use XSPH time integration\n"); - } - } else if (strcmp(arg[iarg], "limit_velocity") == 0) { - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected number following limit_velocity"); - } - - vlimit = force->numeric(FLERR, arg[iarg]); - if (comm->me == 0) { - printf("... will limit velocities to <= %g\n", vlimit); - } - } else { - char msg[128]; - sprintf(msg, "Illegal keyword for smd/integrate_tlsph: %s\n", arg[iarg]); - error->all(FLERR, msg); - } - - iarg++; - } - - if (comm->me == 0) { - printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); - } - - time_integrate = 1; - - // set comm sizes needed by this fix - - atom->add_callback(0); + Fix(lmp, narg, arg) { + if (narg < 3) { + printf("narg=%d\n", narg); + error->all(FLERR, "Illegal fix smd/integrate_tlsph command"); + } + + xsphFlag = false; + vlimit = -1.0; + int iarg = 3; + + if (comm->me == 0) { + printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); + printf("fix smd/integrate_tlsph is active for group: %s \n", arg[1]); + } + + while (true) { + + if (iarg >= narg) { + break; + } + + if (strcmp(arg[iarg], "xsph") == 0) { + xsphFlag = true; + if (comm->me == 0) { + error->one(FLERR, "XSPH is currently not available"); + printf("... will use XSPH time integration\n"); + } + } else if (strcmp(arg[iarg], "limit_velocity") == 0) { + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected number following limit_velocity"); + } + + vlimit = force->numeric(FLERR, arg[iarg]); + if (comm->me == 0) { + printf("... will limit velocities to <= %g\n", vlimit); + } + } else { + char msg[128]; + sprintf(msg, "Illegal keyword for smd/integrate_tlsph: %s\n", arg[iarg]); + error->all(FLERR, msg); + } + + iarg++; + } + + if (comm->me == 0) { + printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); + } + + time_integrate = 1; + + // set comm sizes needed by this fix + + atom->add_callback(0); } /* ---------------------------------------------------------------------- */ int FixSMDIntegrateTlsph::setmask() { - int mask = 0; - mask |= INITIAL_INTEGRATE; - mask |= FINAL_INTEGRATE; - return mask; + int mask = 0; + mask |= INITIAL_INTEGRATE; + mask |= FINAL_INTEGRATE; + return mask; } /* ---------------------------------------------------------------------- */ void FixSMDIntegrateTlsph::init() { - dtv = update->dt; - dtf = 0.5 * update->dt * force->ftm2v; - vlimitsq = vlimit * vlimit; + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + vlimitsq = vlimit * vlimit; } /* ---------------------------------------------------------------------- ------------------------------------------------------------------------- */ void FixSMDIntegrateTlsph::initial_integrate(int vflag) { - double dtfm, vsq, scale; - - // update v and x of atoms in group - - double **x = atom->x; - double **v = atom->v; - double **vest = atom->vest; - double **f = atom->f; - double *rmass = atom->rmass; - int *mask = atom->mask; - int nlocal = atom->nlocal; - int itmp; - double vxsph_x, vxsph_y, vxsph_z; - if (igroup == atom->firstgroup) - nlocal = atom->nfirst; - - Vector3d *smoothVelDifference = (Vector3d *) force->pair->extract("smd/tlsph/smoothVel_ptr", itmp); - - if (xsphFlag) { - if (smoothVelDifference == NULL) { - error->one(FLERR, - "fix smd/integrate_tlsph failed to access smoothVel array. Check if a pair style exist which calculates this quantity."); - } - } - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - dtfm = dtf / rmass[i]; - - // 1st part of Velocity_Verlet: push velocties 1/2 time increment ahead - v[i][0] += dtfm * f[i][0]; - v[i][1] += dtfm * f[i][1]; - v[i][2] += dtfm * f[i][2]; - - if (vlimit > 0.0) { - vsq = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]; - if (vsq > vlimitsq) { - scale = sqrt(vlimitsq / vsq); - v[i][0] *= scale; - v[i][1] *= scale; - v[i][2] *= scale; - } - } - - if (xsphFlag) { - - // construct XSPH velocity - vxsph_x = v[i][0] + 0.5 * smoothVelDifference[i](0); - vxsph_y = v[i][1] + 0.5 * smoothVelDifference[i](1); - vxsph_z = v[i][2] + 0.5 * smoothVelDifference[i](2); - - vest[i][0] = vxsph_x + dtfm * f[i][0]; - vest[i][1] = vxsph_y + dtfm * f[i][1]; - vest[i][2] = vxsph_z + dtfm * f[i][2]; - - x[i][0] += dtv * vxsph_x; - x[i][1] += dtv * vxsph_y; - x[i][2] += dtv * vxsph_z; - } else { - - // extrapolate velocity from half- to full-step - vest[i][0] = v[i][0] + dtfm * f[i][0]; - vest[i][1] = v[i][1] + dtfm * f[i][1]; - vest[i][2] = v[i][2] + dtfm * f[i][2]; - - x[i][0] += dtv * v[i][0]; // 2nd part of Velocity-Verlet: push positions one full time increment ahead - x[i][1] += dtv * v[i][1]; - x[i][2] += dtv * v[i][2]; - } - } - } + double dtfm, vsq, scale; + + // update v and x of atoms in group + + double **x = atom->x; + double **v = atom->v; + double **vest = atom->vest; + double **f = atom->f; + double *rmass = atom->rmass; + int *mask = atom->mask; + int nlocal = atom->nlocal; + int itmp; + double vxsph_x, vxsph_y, vxsph_z; + if (igroup == atom->firstgroup) + nlocal = atom->nfirst; + + Vector3d *smoothVelDifference = (Vector3d *) force->pair->extract("smd/tlsph/smoothVel_ptr", itmp); + + if (xsphFlag) { + if (smoothVelDifference == NULL) { + error->one(FLERR, + "fix smd/integrate_tlsph failed to access smoothVel array. Check if a pair style exist which calculates this quantity."); + } + } + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + dtfm = dtf / rmass[i]; + + // 1st part of Velocity_Verlet: push velocties 1/2 time increment ahead + v[i][0] += dtfm * f[i][0]; + v[i][1] += dtfm * f[i][1]; + v[i][2] += dtfm * f[i][2]; + + if (vlimit > 0.0) { + vsq = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]; + if (vsq > vlimitsq) { + scale = sqrt(vlimitsq / vsq); + v[i][0] *= scale; + v[i][1] *= scale; + v[i][2] *= scale; + } + } + + if (xsphFlag) { + + // construct XSPH velocity + vxsph_x = v[i][0] + 0.5 * smoothVelDifference[i](0); + vxsph_y = v[i][1] + 0.5 * smoothVelDifference[i](1); + vxsph_z = v[i][2] + 0.5 * smoothVelDifference[i](2); + + vest[i][0] = vxsph_x + dtfm * f[i][0]; + vest[i][1] = vxsph_y + dtfm * f[i][1]; + vest[i][2] = vxsph_z + dtfm * f[i][2]; + + x[i][0] += dtv * vxsph_x; + x[i][1] += dtv * vxsph_y; + x[i][2] += dtv * vxsph_z; + } else { + + // extrapolate velocity from half- to full-step + vest[i][0] = v[i][0] + dtfm * f[i][0]; + vest[i][1] = v[i][1] + dtfm * f[i][1]; + vest[i][2] = v[i][2] + dtfm * f[i][2]; + + x[i][0] += dtv * v[i][0]; // 2nd part of Velocity-Verlet: push positions one full time increment ahead + x[i][1] += dtv * v[i][1]; + x[i][2] += dtv * v[i][2]; + } + } + } } /* ---------------------------------------------------------------------- */ void FixSMDIntegrateTlsph::final_integrate() { - double dtfm, vsq, scale; + double dtfm, vsq, scale; // update v of atoms in group - double **v = atom->v; - double **f = atom->f; - double *e = atom->e; - double *de = atom->de; - double *rmass = atom->rmass; - int *mask = atom->mask; - int nlocal = atom->nlocal; - if (igroup == atom->firstgroup) - nlocal = atom->nfirst; - int i; - - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - dtfm = dtf / rmass[i]; - - v[i][0] += dtfm * f[i][0]; // 3rd part of Velocity-Verlet: push velocities another half time increment ahead - v[i][1] += dtfm * f[i][1]; // both positions and velocities are now defined at full time-steps. - v[i][2] += dtfm * f[i][2]; - - // limit velocity - if (vlimit > 0.0) { - vsq = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]; - if (vsq > vlimitsq) { - scale = sqrt(vlimitsq / vsq); - v[i][0] *= scale; - v[i][1] *= scale; - v[i][2] *= scale; - } - } - - e[i] += dtv * de[i]; - } - } + double **v = atom->v; + double **f = atom->f; + double *e = atom->e; + double *de = atom->de; + double *rmass = atom->rmass; + int *mask = atom->mask; + int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) + nlocal = atom->nfirst; + int i; + + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + dtfm = dtf / rmass[i]; + + v[i][0] += dtfm * f[i][0]; // 3rd part of Velocity-Verlet: push velocities another half time increment ahead + v[i][1] += dtfm * f[i][1]; // both positions and velocities are now defined at full time-steps. + v[i][2] += dtfm * f[i][2]; + + // limit velocity + if (vlimit > 0.0) { + vsq = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]; + if (vsq > vlimitsq) { + scale = sqrt(vlimitsq / vsq); + v[i][0] *= scale; + v[i][1] *= scale; + v[i][2] *= scale; + } + } + + e[i] += dtv * de[i]; + } + } } /* ---------------------------------------------------------------------- */ void FixSMDIntegrateTlsph::reset_dt() { - dtv = update->dt; - dtf = 0.5 * update->dt * force->ftm2v; - vlimitsq = vlimit * vlimit; + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + vlimitsq = vlimit * vlimit; } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-SMD/fix_smd_integrate_tlsph.h b/src/USER-SMD/fix_smd_integrate_tlsph.h index ca047f2dfd..6c152e6fe3 100644 --- a/src/USER-SMD/fix_smd_integrate_tlsph.h +++ b/src/USER-SMD/fix_smd_integrate_tlsph.h @@ -37,8 +37,8 @@ FixStyle(smd/integrate_tlsph,FixSMDIntegrateTlsph) namespace LAMMPS_NS { class FixSMDIntegrateTlsph: public Fix { - friend class Neighbor; - friend class PairTlsph; + friend class Neighbor; + friend class PairTlsph; public: FixSMDIntegrateTlsph(class LAMMPS *, int, char **); virtual ~FixSMDIntegrateTlsph() { diff --git a/src/USER-SMD/fix_smd_integrate_ulsph.cpp b/src/USER-SMD/fix_smd_integrate_ulsph.cpp index 3dbf453349..9b892bf259 100644 --- a/src/USER-SMD/fix_smd_integrate_ulsph.cpp +++ b/src/USER-SMD/fix_smd_integrate_ulsph.cpp @@ -50,109 +50,109 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixSMDIntegrateUlsph::FixSMDIntegrateUlsph(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) { - - if ((atom->e_flag != 1) || (atom->vfrac_flag != 1)) - error->all(FLERR, "fix smd/integrate_ulsph command requires atom_style with both energy and volume"); - - if (narg < 3) - error->all(FLERR, "Illegal number of arguments for fix smd/integrate_ulsph command"); - - adjust_radius_flag = false; - xsphFlag = false; - vlimit = -1.0; - int iarg = 3; - - if (comm->me == 0) { - printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); - printf("fix smd/integrate_ulsph is active for group: %s \n", arg[1]); - } - while (true) { - - if (iarg >= narg) { - break; - } - - if (strcmp(arg[iarg], "xsph") == 0) { - xsphFlag = true; - if (comm->me == 0) { - error->one(FLERR, "XSPH is currently not available"); - printf("... will use XSPH time integration\n"); - } - } else if (strcmp(arg[iarg], "adjust_radius") == 0) { - adjust_radius_flag = true; - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected three numbers following adjust_radius: factor, min, max"); - } - - adjust_radius_factor = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected three numbers following adjust_radius: factor, min, max"); - } - - min_nn = force->inumeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected three numbers following adjust_radius: factor, min, max"); - } - - max_nn = force->inumeric(FLERR, arg[iarg]); - - if (comm->me == 0) { - printf("... will adjust smoothing length dynamically with factor %g to achieve %d to %d neighbors per particle.\n ", - adjust_radius_factor, min_nn, max_nn); - } - - } else if (strcmp(arg[iarg], "limit_velocity") == 0) { - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected number following limit_velocity"); - } - vlimit = force->numeric(FLERR, arg[iarg]); - - if (comm->me == 0) { - printf("... will limit velocities to <= %g\n", vlimit); - } - } else { - char msg[128]; - sprintf(msg, "Illegal keyword for smd/integrate_ulsph: %s\n", arg[iarg]); - error->all(FLERR, msg); - } - - iarg++; - - } - - if (comm->me == 0) { - printf(">>========>>========>>========>>========>>========>>========>>========>>========\n\n"); - } - - // set comm sizes needed by this fix - atom->add_callback(0); - - time_integrate = 1; + Fix(lmp, narg, arg) { + + if ((atom->e_flag != 1) || (atom->vfrac_flag != 1)) + error->all(FLERR, "fix smd/integrate_ulsph command requires atom_style with both energy and volume"); + + if (narg < 3) + error->all(FLERR, "Illegal number of arguments for fix smd/integrate_ulsph command"); + + adjust_radius_flag = false; + xsphFlag = false; + vlimit = -1.0; + int iarg = 3; + + if (comm->me == 0) { + printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); + printf("fix smd/integrate_ulsph is active for group: %s \n", arg[1]); + } + while (true) { + + if (iarg >= narg) { + break; + } + + if (strcmp(arg[iarg], "xsph") == 0) { + xsphFlag = true; + if (comm->me == 0) { + error->one(FLERR, "XSPH is currently not available"); + printf("... will use XSPH time integration\n"); + } + } else if (strcmp(arg[iarg], "adjust_radius") == 0) { + adjust_radius_flag = true; + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected three numbers following adjust_radius: factor, min, max"); + } + + adjust_radius_factor = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected three numbers following adjust_radius: factor, min, max"); + } + + min_nn = force->inumeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected three numbers following adjust_radius: factor, min, max"); + } + + max_nn = force->inumeric(FLERR, arg[iarg]); + + if (comm->me == 0) { + printf("... will adjust smoothing length dynamically with factor %g to achieve %d to %d neighbors per particle.\n ", + adjust_radius_factor, min_nn, max_nn); + } + + } else if (strcmp(arg[iarg], "limit_velocity") == 0) { + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected number following limit_velocity"); + } + vlimit = force->numeric(FLERR, arg[iarg]); + + if (comm->me == 0) { + printf("... will limit velocities to <= %g\n", vlimit); + } + } else { + char msg[128]; + sprintf(msg, "Illegal keyword for smd/integrate_ulsph: %s\n", arg[iarg]); + error->all(FLERR, msg); + } + + iarg++; + + } + + if (comm->me == 0) { + printf(">>========>>========>>========>>========>>========>>========>>========>>========\n\n"); + } + + // set comm sizes needed by this fix + atom->add_callback(0); + + time_integrate = 1; } /* ---------------------------------------------------------------------- */ int FixSMDIntegrateUlsph::setmask() { - int mask = 0; - mask |= INITIAL_INTEGRATE; - mask |= FINAL_INTEGRATE; - return mask; + int mask = 0; + mask |= INITIAL_INTEGRATE; + mask |= FINAL_INTEGRATE; + return mask; } /* ---------------------------------------------------------------------- */ void FixSMDIntegrateUlsph::init() { - dtv = update->dt; - dtf = 0.5 * update->dt * force->ftm2v; - vlimitsq = vlimit * vlimit; + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + vlimitsq = vlimit * vlimit; } /* ---------------------------------------------------------------------- @@ -160,166 +160,166 @@ void FixSMDIntegrateUlsph::init() { ------------------------------------------------------------------------- */ void FixSMDIntegrateUlsph::initial_integrate(int vflag) { - double **x = atom->x; - double **v = atom->v; - double **f = atom->f; - double **vest = atom->vest; - double *rmass = atom->rmass; + double **x = atom->x; + double **v = atom->v; + double **f = atom->f; + double **vest = atom->vest; + double *rmass = atom->rmass; - int *mask = atom->mask; - int nlocal = atom->nlocal; - int i, itmp; - double dtfm, vsq, scale; - double vxsph_x, vxsph_y, vxsph_z; + int *mask = atom->mask; + int nlocal = atom->nlocal; + int i, itmp; + double dtfm, vsq, scale; + double vxsph_x, vxsph_y, vxsph_z; - //printf("initial_integrate at timestep %d\n", update->ntimestep); + //printf("initial_integrate at timestep %d\n", update->ntimestep); - /* - * get smoothed velocities from ULSPH pair style - */ + /* + * get smoothed velocities from ULSPH pair style + */ - Vector3d *smoothVel = (Vector3d *) force->pair->extract("smd/ulsph/smoothVel_ptr", itmp); + Vector3d *smoothVel = (Vector3d *) force->pair->extract("smd/ulsph/smoothVel_ptr", itmp); - if (xsphFlag) { - if (smoothVel == NULL) { - error->one(FLERR, "fix smd/integrate_ulsph failed to access smoothVel array"); - } - } + if (xsphFlag) { + if (smoothVel == NULL) { + error->one(FLERR, "fix smd/integrate_ulsph failed to access smoothVel array"); + } + } - if (igroup == atom->firstgroup) - nlocal = atom->nfirst; + if (igroup == atom->firstgroup) + nlocal = atom->nfirst; - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - dtfm = dtf / rmass[i]; + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + dtfm = dtf / rmass[i]; - v[i][0] += dtfm * f[i][0]; - v[i][1] += dtfm * f[i][1]; - v[i][2] += dtfm * f[i][2]; + v[i][0] += dtfm * f[i][0]; + v[i][1] += dtfm * f[i][1]; + v[i][2] += dtfm * f[i][2]; - if (vlimit > 0.0) { - vsq = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]; - if (vsq > vlimitsq) { - scale = sqrt(vlimitsq / vsq); - v[i][0] *= scale; - v[i][1] *= scale; - v[i][2] *= scale; + if (vlimit > 0.0) { + vsq = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]; + if (vsq > vlimitsq) { + scale = sqrt(vlimitsq / vsq); + v[i][0] *= scale; + v[i][1] *= scale; + v[i][2] *= scale; - vest[i][0] = v[i][0]; - vest[i][1] = v[i][1]; - vest[i][2] = v[i][2]; - } - } + vest[i][0] = v[i][0]; + vest[i][1] = v[i][1]; + vest[i][2] = v[i][2]; + } + } - if (xsphFlag) { + if (xsphFlag) { - // construct XSPH velocity - vxsph_x = v[i][0] - 0.5 * smoothVel[i](0); - vxsph_y = v[i][1] - 0.5 * smoothVel[i](1); - vxsph_z = v[i][2] - 0.5 * smoothVel[i](2); + // construct XSPH velocity + vxsph_x = v[i][0] - 0.5 * smoothVel[i](0); + vxsph_y = v[i][1] - 0.5 * smoothVel[i](1); + vxsph_z = v[i][2] - 0.5 * smoothVel[i](2); - vest[i][0] = vxsph_x + dtfm * f[i][0]; - vest[i][1] = vxsph_y + dtfm * f[i][1]; - vest[i][2] = vxsph_z + dtfm * f[i][2]; + vest[i][0] = vxsph_x + dtfm * f[i][0]; + vest[i][1] = vxsph_y + dtfm * f[i][1]; + vest[i][2] = vxsph_z + dtfm * f[i][2]; - x[i][0] += dtv * vxsph_x; - x[i][1] += dtv * vxsph_y; - x[i][2] += dtv * vxsph_z; + x[i][0] += dtv * vxsph_x; + x[i][1] += dtv * vxsph_y; + x[i][2] += dtv * vxsph_z; - } else { + } else { - // extrapolate velocity from half- to full-step - vest[i][0] = v[i][0] + dtfm * f[i][0]; - vest[i][1] = v[i][1] + dtfm * f[i][1]; - vest[i][2] = v[i][2] + dtfm * f[i][2]; + // extrapolate velocity from half- to full-step + vest[i][0] = v[i][0] + dtfm * f[i][0]; + vest[i][1] = v[i][1] + dtfm * f[i][1]; + vest[i][2] = v[i][2] + dtfm * f[i][2]; - x[i][0] += dtv * v[i][0]; - x[i][1] += dtv * v[i][1]; - x[i][2] += dtv * v[i][2]; - } - } - } + x[i][0] += dtv * v[i][0]; + x[i][1] += dtv * v[i][1]; + x[i][2] += dtv * v[i][2]; + } + } + } } /* ---------------------------------------------------------------------- */ void FixSMDIntegrateUlsph::final_integrate() { - double **v = atom->v; - double **f = atom->f; - double *e = atom->e; - double *de = atom->de; - double *vfrac = atom->vfrac; - double *radius = atom->radius; - double *contact_radius = atom->contact_radius; - int *mask = atom->mask; - int nlocal = atom->nlocal; - if (igroup == atom->firstgroup) - nlocal = atom->nfirst; - double dtfm, vsq, scale; - double *rmass = atom->rmass; - double vol_increment; - Matrix3d D; - - /* - * get current number of SPH neighbors from ULSPH pair style - */ - - int itmp; - int *nn = (int *) force->pair->extract("smd/ulsph/numNeighs_ptr", itmp); - if (nn == NULL) { - error->one(FLERR, "fix smd/integrate_ulsph failed to accesss num_neighs array"); - } - - Matrix3d *L = (Matrix3d *) force->pair->extract("smd/ulsph/velocityGradient_ptr", itmp); - if (L == NULL) { - error->one(FLERR, "fix smd/integrate_ulsph failed to accesss velocityGradient array"); - } - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - - dtfm = dtf / rmass[i]; - v[i][0] += dtfm * f[i][0]; - v[i][1] += dtfm * f[i][1]; - v[i][2] += dtfm * f[i][2]; - - if (vlimit > 0.0) { - vsq = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]; - if (vsq > vlimitsq) { - scale = sqrt(vlimitsq / vsq); - v[i][0] *= scale; - v[i][1] *= scale; - v[i][2] *= scale; - } - } - - e[i] += dtf * de[i]; - - if (adjust_radius_flag) { - if (nn[i] < min_nn) { - radius[i] *= adjust_radius_factor; - } else if (nn[i] > max_nn) { - radius[i] /= adjust_radius_factor; - } - radius[i] = MAX(radius[i], 1.25 * contact_radius[i]); - radius[i] = MIN(radius[i], 4.0 * contact_radius[i]); - - } - - D = 0.5 * (L[i] + L[i].transpose()); - vol_increment = vfrac[i] * update->dt * D.trace(); // Jacobian of deformation - vfrac[i] += vol_increment; - } - } + double **v = atom->v; + double **f = atom->f; + double *e = atom->e; + double *de = atom->de; + double *vfrac = atom->vfrac; + double *radius = atom->radius; + double *contact_radius = atom->contact_radius; + int *mask = atom->mask; + int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) + nlocal = atom->nfirst; + double dtfm, vsq, scale; + double *rmass = atom->rmass; + double vol_increment; + Matrix3d D; + + /* + * get current number of SPH neighbors from ULSPH pair style + */ + + int itmp; + int *nn = (int *) force->pair->extract("smd/ulsph/numNeighs_ptr", itmp); + if (nn == NULL) { + error->one(FLERR, "fix smd/integrate_ulsph failed to accesss num_neighs array"); + } + + Matrix3d *L = (Matrix3d *) force->pair->extract("smd/ulsph/velocityGradient_ptr", itmp); + if (L == NULL) { + error->one(FLERR, "fix smd/integrate_ulsph failed to accesss velocityGradient array"); + } + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + + dtfm = dtf / rmass[i]; + v[i][0] += dtfm * f[i][0]; + v[i][1] += dtfm * f[i][1]; + v[i][2] += dtfm * f[i][2]; + + if (vlimit > 0.0) { + vsq = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]; + if (vsq > vlimitsq) { + scale = sqrt(vlimitsq / vsq); + v[i][0] *= scale; + v[i][1] *= scale; + v[i][2] *= scale; + } + } + + e[i] += dtf * de[i]; + + if (adjust_radius_flag) { + if (nn[i] < min_nn) { + radius[i] *= adjust_radius_factor; + } else if (nn[i] > max_nn) { + radius[i] /= adjust_radius_factor; + } + radius[i] = MAX(radius[i], 1.25 * contact_radius[i]); + radius[i] = MIN(radius[i], 4.0 * contact_radius[i]); + + } + + D = 0.5 * (L[i] + L[i].transpose()); + vol_increment = vfrac[i] * update->dt * D.trace(); // Jacobian of deformation + vfrac[i] += vol_increment; + } + } } /* ---------------------------------------------------------------------- */ void FixSMDIntegrateUlsph::reset_dt() { - dtv = update->dt; - dtf = 0.5 * update->dt * force->ftm2v; + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; } diff --git a/src/USER-SMD/fix_smd_move_triangulated_surface.cpp b/src/USER-SMD/fix_smd_move_triangulated_surface.cpp index e452923bd4..d8a0bda4d0 100644 --- a/src/USER-SMD/fix_smd_move_triangulated_surface.cpp +++ b/src/USER-SMD/fix_smd_move_triangulated_surface.cpp @@ -53,173 +53,173 @@ using namespace std; /* ---------------------------------------------------------------------- */ FixSMDMoveTriSurf::FixSMDMoveTriSurf(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) { - - if (atom->smd_flag != 1) { - error->all(FLERR, "fix fix smd/move_tri_surf command requires atom_style smd"); - } - - if (narg < 3) - error->all(FLERR, "Illegal number of arguments for fix fix smd/move_tri_surf command"); - - rotateFlag = linearFlag = wiggleFlag = false; - wiggle_direction = 1.0; - wiggle_max_travel = 0.0; - - int iarg = 3; - - if (comm->me == 0) { - printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); - printf("fix fix smd/move_tri_surf is active for group: %s \n", arg[1]); - } - while (true) { - - if (iarg >= narg) { - break; - } - - if (strcmp(arg[iarg], "*LINEAR") == 0) { - linearFlag = true; - if (comm->me == 0) { - printf("... will move surface in a linear fashion\n"); - } - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected three floats for velocity following *LINEAR"); - } - vx = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected three floats for velocity following *LINEAR"); - } - vy = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected three floats for velocity following *LINEAR"); - } - vz = force->numeric(FLERR, arg[iarg]); - - } else if (strcmp(arg[iarg], "*WIGGLE") == 0) { - wiggleFlag = true; - if (comm->me == 0) { - printf("... will move surface in wiggle fashion\n"); - } - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 4 floats following *WIGGLE : vx vy vz max_travel"); - } - vx = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 4 floats following *WIGGLE : vx vy vz max_travel"); - } - vy = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 4 floats following *WIGGLE : vx vy vz max_travel"); - } - vz = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 4 floats following *WIGGLE : vx vy vz max_travel"); - } - wiggle_max_travel = force->numeric(FLERR, arg[iarg]); - - } else if (strcmp(arg[iarg], "*ROTATE") == 0) { - rotateFlag = true; - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); - } - origin(0) = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); - } - origin(1) = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); - } - origin(2) = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); - } - rotation_axis(0) = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); - } - rotation_axis(1) = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); - } - rotation_axis(2) = force->numeric(FLERR, arg[iarg]); - - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); - } - rotation_period = force->numeric(FLERR, arg[iarg]); - - /* - * construct rotation matrix - */ - - u_cross(0, 0) = 0.0; - u_cross(0, 1) = -rotation_axis(2); - u_cross(0, 2) = rotation_axis(1); - - u_cross(1, 0) = rotation_axis(2); - u_cross(1, 1) = 0.0; - u_cross(1, 2) = -rotation_axis(0); - - u_cross(2, 0) = -rotation_axis(1); - u_cross(2, 1) = rotation_axis(0); - u_cross(2, 2) = 0.0; - - uxu = rotation_axis * rotation_axis.transpose(); - - if (comm->me == 0) { - printf("will rotate with period %f\n", rotation_period); - } - - } else { - char msg[128]; - sprintf(msg, "Illegal keyword for fix smd/move_tri_surf: %s\n", arg[iarg]); - error->all(FLERR, msg); - } - - iarg++; - - } - - if (comm->me == 0) { - printf(">>========>>========>>========>>========>>========>>========>>========>>========\n\n"); - } - - // set comm sizes needed by this fix - comm_forward = 12; - - //atom->add_callback(0); - //atom->add_callback(1); - - time_integrate = 1; + Fix(lmp, narg, arg) { + + if (atom->smd_flag != 1) { + error->all(FLERR, "fix fix smd/move_tri_surf command requires atom_style smd"); + } + + if (narg < 3) + error->all(FLERR, "Illegal number of arguments for fix fix smd/move_tri_surf command"); + + rotateFlag = linearFlag = wiggleFlag = false; + wiggle_direction = 1.0; + wiggle_max_travel = 0.0; + + int iarg = 3; + + if (comm->me == 0) { + printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); + printf("fix fix smd/move_tri_surf is active for group: %s \n", arg[1]); + } + while (true) { + + if (iarg >= narg) { + break; + } + + if (strcmp(arg[iarg], "*LINEAR") == 0) { + linearFlag = true; + if (comm->me == 0) { + printf("... will move surface in a linear fashion\n"); + } + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected three floats for velocity following *LINEAR"); + } + vx = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected three floats for velocity following *LINEAR"); + } + vy = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected three floats for velocity following *LINEAR"); + } + vz = force->numeric(FLERR, arg[iarg]); + + } else if (strcmp(arg[iarg], "*WIGGLE") == 0) { + wiggleFlag = true; + if (comm->me == 0) { + printf("... will move surface in wiggle fashion\n"); + } + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 4 floats following *WIGGLE : vx vy vz max_travel"); + } + vx = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 4 floats following *WIGGLE : vx vy vz max_travel"); + } + vy = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 4 floats following *WIGGLE : vx vy vz max_travel"); + } + vz = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 4 floats following *WIGGLE : vx vy vz max_travel"); + } + wiggle_max_travel = force->numeric(FLERR, arg[iarg]); + + } else if (strcmp(arg[iarg], "*ROTATE") == 0) { + rotateFlag = true; + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); + } + origin(0) = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); + } + origin(1) = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); + } + origin(2) = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); + } + rotation_axis(0) = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); + } + rotation_axis(1) = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); + } + rotation_axis(2) = force->numeric(FLERR, arg[iarg]); + + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected 7 floats following *ROTATE: origin, rotation axis, and rotation period"); + } + rotation_period = force->numeric(FLERR, arg[iarg]); + + /* + * construct rotation matrix + */ + + u_cross(0, 0) = 0.0; + u_cross(0, 1) = -rotation_axis(2); + u_cross(0, 2) = rotation_axis(1); + + u_cross(1, 0) = rotation_axis(2); + u_cross(1, 1) = 0.0; + u_cross(1, 2) = -rotation_axis(0); + + u_cross(2, 0) = -rotation_axis(1); + u_cross(2, 1) = rotation_axis(0); + u_cross(2, 2) = 0.0; + + uxu = rotation_axis * rotation_axis.transpose(); + + if (comm->me == 0) { + printf("will rotate with period %f\n", rotation_period); + } + + } else { + char msg[128]; + sprintf(msg, "Illegal keyword for fix smd/move_tri_surf: %s\n", arg[iarg]); + error->all(FLERR, msg); + } + + iarg++; + + } + + if (comm->me == 0) { + printf(">>========>>========>>========>>========>>========>>========>>========>>========\n\n"); + } + + // set comm sizes needed by this fix + comm_forward = 12; + + //atom->add_callback(0); + //atom->add_callback(1); + + time_integrate = 1; } /* ---------------------------------------------------------------------- */ @@ -234,284 +234,284 @@ FixSMDMoveTriSurf::~FixSMDMoveTriSurf() /* ---------------------------------------------------------------------- */ int FixSMDMoveTriSurf::setmask() { - int mask = 0; - mask |= INITIAL_INTEGRATE; - //mask |= PRE_EXCHANGE; - return mask; + int mask = 0; + mask |= INITIAL_INTEGRATE; + //mask |= PRE_EXCHANGE; + return mask; } /* ---------------------------------------------------------------------- */ void FixSMDMoveTriSurf::init() { - dtv = update->dt; + dtv = update->dt; } /* ---------------------------------------------------------------------- ------------------------------------------------------------------------- */ void FixSMDMoveTriSurf::initial_integrate(int vflag) { - double **x = atom->x; - double **x0 = atom->x0; - double **v = atom->v; - double **vest = atom->vest; - double **smd_data_9 = atom->smd_data_9; - tagint *mol = atom->molecule; - - int *mask = atom->mask; - int nlocal = atom->nlocal; - double phi; - int i; - Matrix3d eye, Rot; - eye.setIdentity(); - - Vector3d v1, v2, v3, n, point, rotated_point, R, vel; - - if (igroup == atom->firstgroup) - nlocal = atom->nfirst; + double **x = atom->x; + double **x0 = atom->x0; + double **v = atom->v; + double **vest = atom->vest; + double **smd_data_9 = atom->smd_data_9; + tagint *mol = atom->molecule; + + int *mask = atom->mask; + int nlocal = atom->nlocal; + double phi; + int i; + Matrix3d eye, Rot; + eye.setIdentity(); + + Vector3d v1, v2, v3, n, point, rotated_point, R, vel; + + if (igroup == atom->firstgroup) + nlocal = atom->nfirst; - if (linearFlag) { // translate particles - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { + if (linearFlag) { // translate particles + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { - v[i][0] = vx; - v[i][1] = vy; - v[i][2] = vz; - - vest[i][0] = vx; - vest[i][1] = vy; - vest[i][2] = vz; - - x[i][0] += dtv * vx; - x[i][1] += dtv * vy; - x[i][2] += dtv * vz; - - /* - * if this is a triangle, move the vertices as well - */ - - if (mol[i] >= 65535) { - smd_data_9[i][0] += dtv * vx; - smd_data_9[i][1] += dtv * vy; - smd_data_9[i][2] += dtv * vz; - - smd_data_9[i][3] += dtv * vx; - smd_data_9[i][4] += dtv * vy; - smd_data_9[i][5] += dtv * vz; - - smd_data_9[i][6] += dtv * vx; - smd_data_9[i][7] += dtv * vy; - smd_data_9[i][8] += dtv * vz; - } - - } - } - } - - if (wiggleFlag) { // wiggle particles forward and backward - - wiggle_travel += sqrt(vx * vx + vy * vy + vz * vz ) * dtv; - double wiggle_vx = wiggle_direction * vx; - double wiggle_vy = wiggle_direction * vy; - double wiggle_vz = wiggle_direction * vz; - - //printf("wiggle vz is %f, wiggle_max_travel is %f, dir=%f\n", wiggle_vz, wiggle_max_travel, wiggle_direction); - - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - - v[i][0] = wiggle_vx; - v[i][1] = wiggle_vy; - v[i][2] = wiggle_vz; - - vest[i][0] = wiggle_vx; - vest[i][1] = wiggle_vy; - vest[i][2] = wiggle_vz; - - x[i][0] += dtv * wiggle_vx; - x[i][1] += dtv * wiggle_vy; - x[i][2] += dtv * wiggle_vz; - - /* - * if this is a triangle, move the vertices as well - */ - - if (mol[i] >= 65535) { - smd_data_9[i][0] += dtv * wiggle_vx; - smd_data_9[i][1] += dtv * wiggle_vy; - smd_data_9[i][2] += dtv * wiggle_vz; - - smd_data_9[i][3] += dtv * wiggle_vx; - smd_data_9[i][4] += dtv * wiggle_vy; - smd_data_9[i][5] += dtv * wiggle_vz; - - smd_data_9[i][6] += dtv * wiggle_vx; - smd_data_9[i][7] += dtv * wiggle_vy; - smd_data_9[i][8] += dtv * wiggle_vz; - } - - } - } - - if (wiggle_travel >= wiggle_max_travel) { - wiggle_direction *= -1.0; - wiggle_travel = 0.0; - } - } - - if (rotateFlag) { // rotate particles - Vector3d xnew, R_new, x_correct; - - /* - * rotation angle and matrix form of Rodrigues' rotation formula - */ - - phi = MY_2PI * dtv / rotation_period; - //printf("dt=%f, phi =%f, T=%f\n", dtv, phi, rotation_period); - Rot = cos(phi) * eye + sin(phi) * u_cross + (1.0 - cos(phi)) * uxu; - - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - - /* - * generate vector R from origin to point which is to be rotated - */ - point << x[i][0], x[i][1], x[i][2]; - R = point - origin; - - /* - * rotate vector and shift away from origin - */ - rotated_point = Rot * R + origin; - - /* - * determine velocity - */ - vel = (rotated_point - point) / update->dt; - - /* - * assign new velocities and coordinates - */ - v[i][0] = vel(0); - v[i][1] = vel(1); - v[i][2] = vel(2); - - vest[i][0] = vel(0); - vest[i][1] = vel(1); - vest[i][2] = vel(2); - - x[i][0] = rotated_point(0); - x[i][1] = rotated_point(1); - x[i][2] = rotated_point(2); - - /* - * if this is a triangle, rotate the vertices as well - */ - - if (mol[i] >= 65535) { - - v1 << smd_data_9[i][0], smd_data_9[i][1], smd_data_9[i][2]; - R = v1 - origin; - rotated_point = Rot * R + origin; - vel = (rotated_point - v1) / update->dt; - smd_data_9[i][0] = rotated_point(0); - smd_data_9[i][1] = rotated_point(1); - smd_data_9[i][2] = rotated_point(2); - v1 = rotated_point; - - v2 << smd_data_9[i][3], smd_data_9[i][4], smd_data_9[i][5]; - R = v2 - origin; - rotated_point = Rot * R + origin; - vel = (rotated_point - v2) / update->dt; - smd_data_9[i][3] = rotated_point(0); - smd_data_9[i][4] = rotated_point(1); - smd_data_9[i][5] = rotated_point(2); - v2 = rotated_point; - - v3 << smd_data_9[i][6], smd_data_9[i][7], smd_data_9[i][8]; - R = v3 - origin; - rotated_point = Rot * R + origin; - vel = (rotated_point - v3) / update->dt; - smd_data_9[i][6] = rotated_point(0); - smd_data_9[i][7] = rotated_point(1); - smd_data_9[i][8] = rotated_point(2); - v3 = rotated_point; - - // recalculate triangle normal - n = (v2 - v1).cross(v2 - v3); - n /= n.norm(); - x0[i][0] = n(0); - x0[i][1] = n(1); - x0[i][2] = n(2); - - } - - } - } - } - - // we changed smd_data_9, x0. perform communication to ghosts - comm->forward_comm_fix(this); + v[i][0] = vx; + v[i][1] = vy; + v[i][2] = vz; + + vest[i][0] = vx; + vest[i][1] = vy; + vest[i][2] = vz; + + x[i][0] += dtv * vx; + x[i][1] += dtv * vy; + x[i][2] += dtv * vz; + + /* + * if this is a triangle, move the vertices as well + */ + + if (mol[i] >= 65535) { + smd_data_9[i][0] += dtv * vx; + smd_data_9[i][1] += dtv * vy; + smd_data_9[i][2] += dtv * vz; + + smd_data_9[i][3] += dtv * vx; + smd_data_9[i][4] += dtv * vy; + smd_data_9[i][5] += dtv * vz; + + smd_data_9[i][6] += dtv * vx; + smd_data_9[i][7] += dtv * vy; + smd_data_9[i][8] += dtv * vz; + } + + } + } + } + + if (wiggleFlag) { // wiggle particles forward and backward + + wiggle_travel += sqrt(vx * vx + vy * vy + vz * vz ) * dtv; + double wiggle_vx = wiggle_direction * vx; + double wiggle_vy = wiggle_direction * vy; + double wiggle_vz = wiggle_direction * vz; + + //printf("wiggle vz is %f, wiggle_max_travel is %f, dir=%f\n", wiggle_vz, wiggle_max_travel, wiggle_direction); + + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + + v[i][0] = wiggle_vx; + v[i][1] = wiggle_vy; + v[i][2] = wiggle_vz; + + vest[i][0] = wiggle_vx; + vest[i][1] = wiggle_vy; + vest[i][2] = wiggle_vz; + + x[i][0] += dtv * wiggle_vx; + x[i][1] += dtv * wiggle_vy; + x[i][2] += dtv * wiggle_vz; + + /* + * if this is a triangle, move the vertices as well + */ + + if (mol[i] >= 65535) { + smd_data_9[i][0] += dtv * wiggle_vx; + smd_data_9[i][1] += dtv * wiggle_vy; + smd_data_9[i][2] += dtv * wiggle_vz; + + smd_data_9[i][3] += dtv * wiggle_vx; + smd_data_9[i][4] += dtv * wiggle_vy; + smd_data_9[i][5] += dtv * wiggle_vz; + + smd_data_9[i][6] += dtv * wiggle_vx; + smd_data_9[i][7] += dtv * wiggle_vy; + smd_data_9[i][8] += dtv * wiggle_vz; + } + + } + } + + if (wiggle_travel >= wiggle_max_travel) { + wiggle_direction *= -1.0; + wiggle_travel = 0.0; + } + } + + if (rotateFlag) { // rotate particles + Vector3d xnew, R_new, x_correct; + + /* + * rotation angle and matrix form of Rodrigues' rotation formula + */ + + phi = MY_2PI * dtv / rotation_period; + //printf("dt=%f, phi =%f, T=%f\n", dtv, phi, rotation_period); + Rot = cos(phi) * eye + sin(phi) * u_cross + (1.0 - cos(phi)) * uxu; + + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + + /* + * generate vector R from origin to point which is to be rotated + */ + point << x[i][0], x[i][1], x[i][2]; + R = point - origin; + + /* + * rotate vector and shift away from origin + */ + rotated_point = Rot * R + origin; + + /* + * determine velocity + */ + vel = (rotated_point - point) / update->dt; + + /* + * assign new velocities and coordinates + */ + v[i][0] = vel(0); + v[i][1] = vel(1); + v[i][2] = vel(2); + + vest[i][0] = vel(0); + vest[i][1] = vel(1); + vest[i][2] = vel(2); + + x[i][0] = rotated_point(0); + x[i][1] = rotated_point(1); + x[i][2] = rotated_point(2); + + /* + * if this is a triangle, rotate the vertices as well + */ + + if (mol[i] >= 65535) { + + v1 << smd_data_9[i][0], smd_data_9[i][1], smd_data_9[i][2]; + R = v1 - origin; + rotated_point = Rot * R + origin; + vel = (rotated_point - v1) / update->dt; + smd_data_9[i][0] = rotated_point(0); + smd_data_9[i][1] = rotated_point(1); + smd_data_9[i][2] = rotated_point(2); + v1 = rotated_point; + + v2 << smd_data_9[i][3], smd_data_9[i][4], smd_data_9[i][5]; + R = v2 - origin; + rotated_point = Rot * R + origin; + vel = (rotated_point - v2) / update->dt; + smd_data_9[i][3] = rotated_point(0); + smd_data_9[i][4] = rotated_point(1); + smd_data_9[i][5] = rotated_point(2); + v2 = rotated_point; + + v3 << smd_data_9[i][6], smd_data_9[i][7], smd_data_9[i][8]; + R = v3 - origin; + rotated_point = Rot * R + origin; + vel = (rotated_point - v3) / update->dt; + smd_data_9[i][6] = rotated_point(0); + smd_data_9[i][7] = rotated_point(1); + smd_data_9[i][8] = rotated_point(2); + v3 = rotated_point; + + // recalculate triangle normal + n = (v2 - v1).cross(v2 - v3); + n /= n.norm(); + x0[i][0] = n(0); + x0[i][1] = n(1); + x0[i][2] = n(2); + + } + + } + } + } + + // we changed smd_data_9, x0. perform communication to ghosts + comm->forward_comm_fix(this); } /* ---------------------------------------------------------------------- */ void FixSMDMoveTriSurf::reset_dt() { - dtv = update->dt; + dtv = update->dt; } /* ---------------------------------------------------------------------- */ int FixSMDMoveTriSurf::pack_forward_comm(int n, int *list, double *buf, int pbc_flag, int *pbc) { - int i, j, m; - double **x0 = atom->x0; - double **smd_data_9 = atom->smd_data_9; - - //printf("in FixSMDIntegrateTlsph::pack_forward_comm\n"); - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; - - buf[m++] = smd_data_9[j][0]; - buf[m++] = smd_data_9[j][1]; - buf[m++] = smd_data_9[j][2]; - buf[m++] = smd_data_9[j][3]; - buf[m++] = smd_data_9[j][4]; - buf[m++] = smd_data_9[j][5]; - buf[m++] = smd_data_9[j][6]; - buf[m++] = smd_data_9[j][7]; - buf[m++] = smd_data_9[j][8]; - - } - return m; + int i, j, m; + double **x0 = atom->x0; + double **smd_data_9 = atom->smd_data_9; + + //printf("in FixSMDIntegrateTlsph::pack_forward_comm\n"); + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x0[j][0]; + buf[m++] = x0[j][1]; + buf[m++] = x0[j][2]; + + buf[m++] = smd_data_9[j][0]; + buf[m++] = smd_data_9[j][1]; + buf[m++] = smd_data_9[j][2]; + buf[m++] = smd_data_9[j][3]; + buf[m++] = smd_data_9[j][4]; + buf[m++] = smd_data_9[j][5]; + buf[m++] = smd_data_9[j][6]; + buf[m++] = smd_data_9[j][7]; + buf[m++] = smd_data_9[j][8]; + + } + return m; } /* ---------------------------------------------------------------------- */ void FixSMDMoveTriSurf::unpack_forward_comm(int n, int first, double *buf) { - int i, m, last; - double **x0 = atom->x0; - double **smd_data_9 = atom->smd_data_9; - - //printf("in FixSMDMoveTriSurf::unpack_forward_comm\n"); - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x0[i][0] = buf[m++]; - x0[i][1] = buf[m++]; - x0[i][2] = buf[m++]; - - smd_data_9[i][0] = buf[m++]; - smd_data_9[i][1] = buf[m++]; - smd_data_9[i][2] = buf[m++]; - smd_data_9[i][3] = buf[m++]; - smd_data_9[i][4] = buf[m++]; - smd_data_9[i][5] = buf[m++]; - smd_data_9[i][6] = buf[m++]; - smd_data_9[i][7] = buf[m++]; - smd_data_9[i][8] = buf[m++]; - } + int i, m, last; + double **x0 = atom->x0; + double **smd_data_9 = atom->smd_data_9; + + //printf("in FixSMDMoveTriSurf::unpack_forward_comm\n"); + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x0[i][0] = buf[m++]; + x0[i][1] = buf[m++]; + x0[i][2] = buf[m++]; + + smd_data_9[i][0] = buf[m++]; + smd_data_9[i][1] = buf[m++]; + smd_data_9[i][2] = buf[m++]; + smd_data_9[i][3] = buf[m++]; + smd_data_9[i][4] = buf[m++]; + smd_data_9[i][5] = buf[m++]; + smd_data_9[i][6] = buf[m++]; + smd_data_9[i][7] = buf[m++]; + smd_data_9[i][8] = buf[m++]; + } } diff --git a/src/USER-SMD/fix_smd_move_triangulated_surface.h b/src/USER-SMD/fix_smd_move_triangulated_surface.h index c851d490c5..ec58a8bac1 100644 --- a/src/USER-SMD/fix_smd_move_triangulated_surface.h +++ b/src/USER-SMD/fix_smd_move_triangulated_surface.h @@ -38,23 +38,23 @@ namespace LAMMPS_NS { class FixSMDMoveTriSurf: public Fix { public: - FixSMDMoveTriSurf(class LAMMPS *, int, char **); - ~FixSMDMoveTriSurf(); - int setmask(); - virtual void init(); - virtual void initial_integrate(int); - void reset_dt(); - int pack_forward_comm(int, int *, double *, int, int *); - void unpack_forward_comm(int, int, double *); + FixSMDMoveTriSurf(class LAMMPS *, int, char **); + ~FixSMDMoveTriSurf(); + int setmask(); + virtual void init(); + virtual void initial_integrate(int); + void reset_dt(); + int pack_forward_comm(int, int *, double *, int, int *); + void unpack_forward_comm(int, int, double *); protected: - double dtv; - bool linearFlag, wiggleFlag, rotateFlag; - double vx, vy, vz; - Eigen::Vector3d rotation_axis, origin; - double rotation_period; - Eigen::Matrix3d u_cross, uxu; - double wiggle_travel, wiggle_max_travel, wiggle_direction; + double dtv; + bool linearFlag, wiggleFlag, rotateFlag; + double vx, vy, vz; + Eigen::Vector3d rotation_axis, origin; + double rotation_period; + Eigen::Matrix3d u_cross, uxu; + double wiggle_travel, wiggle_max_travel, wiggle_direction; }; } diff --git a/src/USER-SMD/fix_smd_setvel.cpp b/src/USER-SMD/fix_smd_setvel.cpp index 92c4a00581..0c2dc31f45 100644 --- a/src/USER-SMD/fix_smd_setvel.cpp +++ b/src/USER-SMD/fix_smd_setvel.cpp @@ -41,304 +41,304 @@ using namespace LAMMPS_NS; using namespace FixConst; enum { - NONE, CONSTANT, EQUAL, ATOM + NONE, CONSTANT, EQUAL, ATOM }; /* ---------------------------------------------------------------------- */ FixSMDSetVel::FixSMDSetVel(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) { - if (narg < 6) - error->all(FLERR, "Illegal fix setvelocity command"); - - dynamic_group_allow = 1; - vector_flag = 1; - size_vector = 3; - global_freq = 1; - extvector = 1; - - xstr = ystr = zstr = NULL; - - if (strstr(arg[3], "v_") == arg[3]) { - int n = strlen(&arg[3][2]) + 1; - xstr = new char[n]; - strcpy(xstr, &arg[3][2]); - } else if (strcmp(arg[3], "NULL") == 0) { - xstyle = NONE; - } else { - xvalue = force->numeric(FLERR, arg[3]); - xstyle = CONSTANT; - } - if (strstr(arg[4], "v_") == arg[4]) { - int n = strlen(&arg[4][2]) + 1; - ystr = new char[n]; - strcpy(ystr, &arg[4][2]); - } else if (strcmp(arg[4], "NULL") == 0) { - ystyle = NONE; - } else { - yvalue = force->numeric(FLERR, arg[4]); - ystyle = CONSTANT; - } - if (strstr(arg[5], "v_") == arg[5]) { - int n = strlen(&arg[5][2]) + 1; - zstr = new char[n]; - strcpy(zstr, &arg[5][2]); - } else if (strcmp(arg[5], "NULL") == 0) { - zstyle = NONE; - } else { - zvalue = force->numeric(FLERR, arg[5]); - zstyle = CONSTANT; - } - - // optional args - - iregion = -1; - idregion = NULL; - - int iarg = 6; - while (iarg < narg) { - if (strcmp(arg[iarg], "region") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix setvelocity command"); - iregion = domain->find_region(arg[iarg + 1]); - if (iregion == -1) - error->all(FLERR, "Region ID for fix setvelocity does not exist"); - int n = strlen(arg[iarg + 1]) + 1; - idregion = new char[n]; - strcpy(idregion, arg[iarg + 1]); - iarg += 2; - } else - error->all(FLERR, "Illegal fix setvelocity command"); - } - - force_flag = 0; - foriginal[0] = foriginal[1] = foriginal[2] = 0.0; - - maxatom = atom->nmax; - memory->create(sforce, maxatom, 3, "setvelocity:sforce"); + Fix(lmp, narg, arg) { + if (narg < 6) + error->all(FLERR, "Illegal fix setvelocity command"); + + dynamic_group_allow = 1; + vector_flag = 1; + size_vector = 3; + global_freq = 1; + extvector = 1; + + xstr = ystr = zstr = NULL; + + if (strstr(arg[3], "v_") == arg[3]) { + int n = strlen(&arg[3][2]) + 1; + xstr = new char[n]; + strcpy(xstr, &arg[3][2]); + } else if (strcmp(arg[3], "NULL") == 0) { + xstyle = NONE; + } else { + xvalue = force->numeric(FLERR, arg[3]); + xstyle = CONSTANT; + } + if (strstr(arg[4], "v_") == arg[4]) { + int n = strlen(&arg[4][2]) + 1; + ystr = new char[n]; + strcpy(ystr, &arg[4][2]); + } else if (strcmp(arg[4], "NULL") == 0) { + ystyle = NONE; + } else { + yvalue = force->numeric(FLERR, arg[4]); + ystyle = CONSTANT; + } + if (strstr(arg[5], "v_") == arg[5]) { + int n = strlen(&arg[5][2]) + 1; + zstr = new char[n]; + strcpy(zstr, &arg[5][2]); + } else if (strcmp(arg[5], "NULL") == 0) { + zstyle = NONE; + } else { + zvalue = force->numeric(FLERR, arg[5]); + zstyle = CONSTANT; + } + + // optional args + + iregion = -1; + idregion = NULL; + + int iarg = 6; + while (iarg < narg) { + if (strcmp(arg[iarg], "region") == 0) { + if (iarg + 2 > narg) + error->all(FLERR, "Illegal fix setvelocity command"); + iregion = domain->find_region(arg[iarg + 1]); + if (iregion == -1) + error->all(FLERR, "Region ID for fix setvelocity does not exist"); + int n = strlen(arg[iarg + 1]) + 1; + idregion = new char[n]; + strcpy(idregion, arg[iarg + 1]); + iarg += 2; + } else + error->all(FLERR, "Illegal fix setvelocity command"); + } + + force_flag = 0; + foriginal[0] = foriginal[1] = foriginal[2] = 0.0; + + maxatom = atom->nmax; + memory->create(sforce, maxatom, 3, "setvelocity:sforce"); } /* ---------------------------------------------------------------------- */ FixSMDSetVel::~FixSMDSetVel() { - delete[] xstr; - delete[] ystr; - delete[] zstr; - delete[] idregion; - memory->destroy(sforce); + delete[] xstr; + delete[] ystr; + delete[] zstr; + delete[] idregion; + memory->destroy(sforce); } /* ---------------------------------------------------------------------- */ int FixSMDSetVel::setmask() { - int mask = 0; - //mask |= INITIAL_INTEGRATE; - mask |= POST_FORCE; - return mask; + int mask = 0; + //mask |= INITIAL_INTEGRATE; + mask |= POST_FORCE; + return mask; } /* ---------------------------------------------------------------------- */ void FixSMDSetVel::init() { - // check variables - - if (xstr) { - xvar = input->variable->find(xstr); - if (xvar < 0) - error->all(FLERR, "Variable name for fix setvelocity does not exist"); - if (input->variable->equalstyle(xvar)) - xstyle = EQUAL; - else if (input->variable->atomstyle(xvar)) - xstyle = ATOM; - else - error->all(FLERR, "Variable for fix setvelocity is invalid style"); - } - if (ystr) { - yvar = input->variable->find(ystr); - if (yvar < 0) - error->all(FLERR, "Variable name for fix setvelocity does not exist"); - if (input->variable->equalstyle(yvar)) - ystyle = EQUAL; - else if (input->variable->atomstyle(yvar)) - ystyle = ATOM; - else - error->all(FLERR, "Variable for fix setvelocity is invalid style"); - } - if (zstr) { - zvar = input->variable->find(zstr); - if (zvar < 0) - error->all(FLERR, "Variable name for fix setvelocity does not exist"); - if (input->variable->equalstyle(zvar)) - zstyle = EQUAL; - else if (input->variable->atomstyle(zvar)) - zstyle = ATOM; - else - error->all(FLERR, "Variable for fix setvelocity is invalid style"); - } - - // set index and check validity of region - - if (iregion >= 0) { - iregion = domain->find_region(idregion); - if (iregion == -1) - error->all(FLERR, "Region ID for fix setvelocity does not exist"); - } - - if (xstyle == ATOM || ystyle == ATOM || zstyle == ATOM) - varflag = ATOM; - else if (xstyle == EQUAL || ystyle == EQUAL || zstyle == EQUAL) - varflag = EQUAL; - else - varflag = CONSTANT; - - // cannot use non-zero forces for a minimization since no energy is integrated - // use fix addforce instead - - int flag = 0; - if (update->whichflag == 2) { - if (xstyle == EQUAL || xstyle == ATOM) - flag = 1; - if (ystyle == EQUAL || ystyle == ATOM) - flag = 1; - if (zstyle == EQUAL || zstyle == ATOM) - flag = 1; - if (xstyle == CONSTANT && xvalue != 0.0) - flag = 1; - if (ystyle == CONSTANT && yvalue != 0.0) - flag = 1; - if (zstyle == CONSTANT && zvalue != 0.0) - flag = 1; - } - if (flag) - error->all(FLERR, "Cannot use non-zero forces in an energy minimization"); + // check variables + + if (xstr) { + xvar = input->variable->find(xstr); + if (xvar < 0) + error->all(FLERR, "Variable name for fix setvelocity does not exist"); + if (input->variable->equalstyle(xvar)) + xstyle = EQUAL; + else if (input->variable->atomstyle(xvar)) + xstyle = ATOM; + else + error->all(FLERR, "Variable for fix setvelocity is invalid style"); + } + if (ystr) { + yvar = input->variable->find(ystr); + if (yvar < 0) + error->all(FLERR, "Variable name for fix setvelocity does not exist"); + if (input->variable->equalstyle(yvar)) + ystyle = EQUAL; + else if (input->variable->atomstyle(yvar)) + ystyle = ATOM; + else + error->all(FLERR, "Variable for fix setvelocity is invalid style"); + } + if (zstr) { + zvar = input->variable->find(zstr); + if (zvar < 0) + error->all(FLERR, "Variable name for fix setvelocity does not exist"); + if (input->variable->equalstyle(zvar)) + zstyle = EQUAL; + else if (input->variable->atomstyle(zvar)) + zstyle = ATOM; + else + error->all(FLERR, "Variable for fix setvelocity is invalid style"); + } + + // set index and check validity of region + + if (iregion >= 0) { + iregion = domain->find_region(idregion); + if (iregion == -1) + error->all(FLERR, "Region ID for fix setvelocity does not exist"); + } + + if (xstyle == ATOM || ystyle == ATOM || zstyle == ATOM) + varflag = ATOM; + else if (xstyle == EQUAL || ystyle == EQUAL || zstyle == EQUAL) + varflag = EQUAL; + else + varflag = CONSTANT; + + // cannot use non-zero forces for a minimization since no energy is integrated + // use fix addforce instead + + int flag = 0; + if (update->whichflag == 2) { + if (xstyle == EQUAL || xstyle == ATOM) + flag = 1; + if (ystyle == EQUAL || ystyle == ATOM) + flag = 1; + if (zstyle == EQUAL || zstyle == ATOM) + flag = 1; + if (xstyle == CONSTANT && xvalue != 0.0) + flag = 1; + if (ystyle == CONSTANT && yvalue != 0.0) + flag = 1; + if (zstyle == CONSTANT && zvalue != 0.0) + flag = 1; + } + if (flag) + error->all(FLERR, "Cannot use non-zero forces in an energy minimization"); } /* ---------------------------------------------------------------------- */ void FixSMDSetVel::setup(int vflag) { - if (strstr(update->integrate_style, "verlet")) - post_force(vflag); - else + if (strstr(update->integrate_style, "verlet")) + post_force(vflag); + else error->all(FLERR,"Fix smd/setvel does not support RESPA"); } /* ---------------------------------------------------------------------- */ void FixSMDSetVel::min_setup(int vflag) { - post_force(vflag); + post_force(vflag); } /* ---------------------------------------------------------------------- */ //void FixSMDSetVel::initial_integrate(int vflag) { void FixSMDSetVel::post_force(int vflag) { - double **x = atom->x; - double **f = atom->f; - double **v = atom->v; - double **vest = atom->vest; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - // update region if necessary - - Region *region = NULL; - if (iregion >= 0) { - region = domain->regions[iregion]; - region->prematch(); - } - - // reallocate sforce array if necessary - - if (varflag == ATOM && atom->nmax > maxatom) { - maxatom = atom->nmax; - memory->destroy(sforce); - memory->create(sforce, maxatom, 3, "setvelocity:sforce"); - } - - foriginal[0] = foriginal[1] = foriginal[2] = 0.0; - force_flag = 0; - - if (varflag == CONSTANT) { - for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit) { - if (region && !region->match(x[i][0], x[i][1], x[i][2])) - continue; - foriginal[0] += f[i][0]; - foriginal[1] += f[i][1]; - foriginal[2] += f[i][2]; - if (xstyle) { - v[i][0] = xvalue; - vest[i][0] = xvalue; - f[i][0] = 0.0; - } - if (ystyle) { - v[i][1] = yvalue; - vest[i][1] = yvalue; - f[i][1] = 0.0; - } - if (zstyle) { - v[i][2] = zvalue; - vest[i][2] = zvalue; - f[i][2] = 0.0; - } - } - - // variable force, wrap with clear/add - - } else { - - modify->clearstep_compute(); - - if (xstyle == EQUAL) - xvalue = input->variable->compute_equal(xvar); - else if (xstyle == ATOM) - input->variable->compute_atom(xvar, igroup, &sforce[0][0], 3, 0); - if (ystyle == EQUAL) - yvalue = input->variable->compute_equal(yvar); - else if (ystyle == ATOM) - input->variable->compute_atom(yvar, igroup, &sforce[0][1], 3, 0); - if (zstyle == EQUAL) - zvalue = input->variable->compute_equal(zvar); - else if (zstyle == ATOM) - input->variable->compute_atom(zvar, igroup, &sforce[0][2], 3, 0); - - modify->addstep_compute(update->ntimestep + 1); - - //printf("setting velocity at timestep %d\n", update->ntimestep); - - for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit) { - if (region && !region->match(x[i][0], x[i][1], x[i][2])) - continue; - foriginal[0] += f[i][0]; - foriginal[1] += f[i][1]; - foriginal[2] += f[i][2]; - if (xstyle == ATOM) { - vest[i][0] = v[i][0] = sforce[i][0]; - f[i][0] = 0.0; - } else if (xstyle) { - vest[i][0] = v[i][0] = xvalue; - f[i][0] = 0.0; - } - - if (ystyle == ATOM) { - vest[i][1] = v[i][1] = sforce[i][1]; - f[i][1] = 0.0; - } else if (ystyle) { - vest[i][1] = v[i][1] = yvalue; - f[i][1] = 0.0; - } - - if (zstyle == ATOM) { - vest[i][2] = v[i][2] = sforce[i][2]; - f[i][2] = 0.0; - } else if (zstyle) { - vest[i][2] = v[i][2] = zvalue; - f[i][2] = 0.0; - } - - } - } + double **x = atom->x; + double **f = atom->f; + double **v = atom->v; + double **vest = atom->vest; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + // update region if necessary + + Region *region = NULL; + if (iregion >= 0) { + region = domain->regions[iregion]; + region->prematch(); + } + + // reallocate sforce array if necessary + + if (varflag == ATOM && atom->nmax > maxatom) { + maxatom = atom->nmax; + memory->destroy(sforce); + memory->create(sforce, maxatom, 3, "setvelocity:sforce"); + } + + foriginal[0] = foriginal[1] = foriginal[2] = 0.0; + force_flag = 0; + + if (varflag == CONSTANT) { + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) { + if (region && !region->match(x[i][0], x[i][1], x[i][2])) + continue; + foriginal[0] += f[i][0]; + foriginal[1] += f[i][1]; + foriginal[2] += f[i][2]; + if (xstyle) { + v[i][0] = xvalue; + vest[i][0] = xvalue; + f[i][0] = 0.0; + } + if (ystyle) { + v[i][1] = yvalue; + vest[i][1] = yvalue; + f[i][1] = 0.0; + } + if (zstyle) { + v[i][2] = zvalue; + vest[i][2] = zvalue; + f[i][2] = 0.0; + } + } + + // variable force, wrap with clear/add + + } else { + + modify->clearstep_compute(); + + if (xstyle == EQUAL) + xvalue = input->variable->compute_equal(xvar); + else if (xstyle == ATOM) + input->variable->compute_atom(xvar, igroup, &sforce[0][0], 3, 0); + if (ystyle == EQUAL) + yvalue = input->variable->compute_equal(yvar); + else if (ystyle == ATOM) + input->variable->compute_atom(yvar, igroup, &sforce[0][1], 3, 0); + if (zstyle == EQUAL) + zvalue = input->variable->compute_equal(zvar); + else if (zstyle == ATOM) + input->variable->compute_atom(zvar, igroup, &sforce[0][2], 3, 0); + + modify->addstep_compute(update->ntimestep + 1); + + //printf("setting velocity at timestep %d\n", update->ntimestep); + + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) { + if (region && !region->match(x[i][0], x[i][1], x[i][2])) + continue; + foriginal[0] += f[i][0]; + foriginal[1] += f[i][1]; + foriginal[2] += f[i][2]; + if (xstyle == ATOM) { + vest[i][0] = v[i][0] = sforce[i][0]; + f[i][0] = 0.0; + } else if (xstyle) { + vest[i][0] = v[i][0] = xvalue; + f[i][0] = 0.0; + } + + if (ystyle == ATOM) { + vest[i][1] = v[i][1] = sforce[i][1]; + f[i][1] = 0.0; + } else if (ystyle) { + vest[i][1] = v[i][1] = yvalue; + f[i][1] = 0.0; + } + + if (zstyle == ATOM) { + vest[i][2] = v[i][2] = sforce[i][2]; + f[i][2] = 0.0; + } else if (zstyle) { + vest[i][2] = v[i][2] = zvalue; + f[i][2] = 0.0; + } + + } + } } /* ---------------------------------------------------------------------- @@ -348,11 +348,11 @@ void FixSMDSetVel::post_force(int vflag) { double FixSMDSetVel::compute_vector(int n) { // only sum across procs one time - if (force_flag == 0) { - MPI_Allreduce(foriginal, foriginal_all, 3, MPI_DOUBLE, MPI_SUM, world); - force_flag = 1; - } - return foriginal_all[n]; + if (force_flag == 0) { + MPI_Allreduce(foriginal, foriginal_all, 3, MPI_DOUBLE, MPI_SUM, world); + force_flag = 1; + } + return foriginal_all[n]; } /* ---------------------------------------------------------------------- @@ -360,8 +360,8 @@ double FixSMDSetVel::compute_vector(int n) { ------------------------------------------------------------------------- */ double FixSMDSetVel::memory_usage() { - double bytes = 0.0; - if (varflag == ATOM) - bytes = atom->nmax * 3 * sizeof(double); - return bytes; + double bytes = 0.0; + if (varflag == ATOM) + bytes = atom->nmax * 3 * sizeof(double); + return bytes; } diff --git a/src/USER-SMD/fix_smd_tlsph_reference_configuration.cpp b/src/USER-SMD/fix_smd_tlsph_reference_configuration.cpp index 76fd8021b6..da0533c88b 100644 --- a/src/USER-SMD/fix_smd_tlsph_reference_configuration.cpp +++ b/src/USER-SMD/fix_smd_tlsph_reference_configuration.cpp @@ -57,141 +57,141 @@ using namespace SMD_Math; /* ---------------------------------------------------------------------- */ FixSMD_TLSPH_ReferenceConfiguration::FixSMD_TLSPH_ReferenceConfiguration(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) { - - if (atom->map_style == 0) - error->all(FLERR, "Pair tlsph with partner list requires an atom map, see atom_modify"); - - maxpartner = 1; - npartner = NULL; - partner = NULL; - wfd_list = NULL; - wf_list = NULL; - energy_per_bond = NULL; - degradation_ij = NULL; - grow_arrays(atom->nmax); - atom->add_callback(0); - - // initialize npartner to 0 so neighbor list creation is OK the 1st time - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - npartner[i] = 0; - } - - comm_forward = 14; - updateFlag = 1; + Fix(lmp, narg, arg) { + + if (atom->map_style == 0) + error->all(FLERR, "Pair tlsph with partner list requires an atom map, see atom_modify"); + + maxpartner = 1; + npartner = NULL; + partner = NULL; + wfd_list = NULL; + wf_list = NULL; + energy_per_bond = NULL; + degradation_ij = NULL; + grow_arrays(atom->nmax); + atom->add_callback(0); + + // initialize npartner to 0 so neighbor list creation is OK the 1st time + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + npartner[i] = 0; + } + + comm_forward = 14; + updateFlag = 1; } /* ---------------------------------------------------------------------- */ FixSMD_TLSPH_ReferenceConfiguration::~FixSMD_TLSPH_ReferenceConfiguration() { - // unregister this fix so atom class doesn't invoke it any more + // unregister this fix so atom class doesn't invoke it any more - atom->delete_callback(id, 0); + atom->delete_callback(id, 0); // delete locally stored arrays - memory->destroy(npartner); - memory->destroy(partner); - memory->destroy(wfd_list); - memory->destroy(wf_list); - memory->destroy(degradation_ij); - memory->destroy(energy_per_bond); + memory->destroy(npartner); + memory->destroy(partner); + memory->destroy(wfd_list); + memory->destroy(wf_list); + memory->destroy(degradation_ij); + memory->destroy(energy_per_bond); } /* ---------------------------------------------------------------------- */ int FixSMD_TLSPH_ReferenceConfiguration::setmask() { - int mask = 0; - mask |= PRE_EXCHANGE; - return mask; + int mask = 0; + mask |= PRE_EXCHANGE; + return mask; } /* ---------------------------------------------------------------------- */ void FixSMD_TLSPH_ReferenceConfiguration::init() { - if (atom->tag_enable == 0) - error->all(FLERR, "Pair style tlsph requires atoms have IDs"); + if (atom->tag_enable == 0) + error->all(FLERR, "Pair style tlsph requires atoms have IDs"); } /* ---------------------------------------------------------------------- */ void FixSMD_TLSPH_ReferenceConfiguration::pre_exchange() { - //return; - - //printf("in FixSMD_TLSPH_ReferenceConfiguration::pre_exchange()\n"); - double **defgrad = atom->smd_data_9; - double *radius = atom->radius; - double *rho = atom->rho; - double *vfrac = atom->vfrac; - double **x = atom->x; - double **x0 = atom->x0; - double *rmass = atom->rmass; - int nlocal = atom->nlocal; - int i, itmp; - int *mask = atom->mask; - if (igroup == atom->firstgroup) { - nlocal = atom->nfirst; - } - - int *updateFlag_ptr = (int *) force->pair->extract("smd/tlsph/updateFlag_ptr", itmp); - if (updateFlag_ptr == NULL) { - error->one(FLERR, - "fix FixSMD_TLSPH_ReferenceConfiguration failed to access updateFlag pointer. Check if a pair style exist which calculates this quantity."); - } - - int *nn = (int *) force->pair->extract("smd/tlsph/numNeighsRefConfig_ptr", itmp); - if (nn == NULL) { - error->all(FLERR, "FixSMDIntegrateTlsph::updateReferenceConfiguration() failed to access numNeighsRefConfig_ptr array"); - } - - // sum all update flag across processors - MPI_Allreduce(updateFlag_ptr, &updateFlag, 1, MPI_INT, MPI_MAX, world); - - if (updateFlag > 0) { - if (comm->me == 0) { - printf("**** updating ref config at step: %ld\n", update->ntimestep); - } - - for (i = 0; i < nlocal; i++) { - - if (mask[i] & groupbit) { - - // re-set x0 coordinates - x0[i][0] = x[i][0]; - x0[i][1] = x[i][1]; - x0[i][2] = x[i][2]; - - // re-set deformation gradient - defgrad[i][0] = 1.0; - defgrad[i][1] = 0.0; - defgrad[i][2] = 0.0; - defgrad[i][3] = 0.0; - defgrad[i][4] = 1.0; - defgrad[i][5] = 0.0; - defgrad[i][6] = 0.0; - defgrad[i][7] = 0.0; - defgrad[i][8] = 1.0; - /* - * Adjust particle volume as the reference configuration is changed. - * We safeguard against excessive deformations by limiting the adjustment range - * to the intervale J \in [0.9..1.1] - */ - vfrac[i] = rmass[i] / rho[i]; + //return; + + //printf("in FixSMD_TLSPH_ReferenceConfiguration::pre_exchange()\n"); + double **defgrad = atom->smd_data_9; + double *radius = atom->radius; + double *rho = atom->rho; + double *vfrac = atom->vfrac; + double **x = atom->x; + double **x0 = atom->x0; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + int i, itmp; + int *mask = atom->mask; + if (igroup == atom->firstgroup) { + nlocal = atom->nfirst; + } + + int *updateFlag_ptr = (int *) force->pair->extract("smd/tlsph/updateFlag_ptr", itmp); + if (updateFlag_ptr == NULL) { + error->one(FLERR, + "fix FixSMD_TLSPH_ReferenceConfiguration failed to access updateFlag pointer. Check if a pair style exist which calculates this quantity."); + } + + int *nn = (int *) force->pair->extract("smd/tlsph/numNeighsRefConfig_ptr", itmp); + if (nn == NULL) { + error->all(FLERR, "FixSMDIntegrateTlsph::updateReferenceConfiguration() failed to access numNeighsRefConfig_ptr array"); + } + + // sum all update flag across processors + MPI_Allreduce(updateFlag_ptr, &updateFlag, 1, MPI_INT, MPI_MAX, world); + + if (updateFlag > 0) { + if (comm->me == 0) { + printf("**** updating ref config at step: %ld\n", update->ntimestep); + } + + for (i = 0; i < nlocal; i++) { + + if (mask[i] & groupbit) { + + // re-set x0 coordinates + x0[i][0] = x[i][0]; + x0[i][1] = x[i][1]; + x0[i][2] = x[i][2]; + + // re-set deformation gradient + defgrad[i][0] = 1.0; + defgrad[i][1] = 0.0; + defgrad[i][2] = 0.0; + defgrad[i][3] = 0.0; + defgrad[i][4] = 1.0; + defgrad[i][5] = 0.0; + defgrad[i][6] = 0.0; + defgrad[i][7] = 0.0; + defgrad[i][8] = 1.0; + /* + * Adjust particle volume as the reference configuration is changed. + * We safeguard against excessive deformations by limiting the adjustment range + * to the intervale J \in [0.9..1.1] + */ + vfrac[i] = rmass[i] / rho[i]; // - if (nn[i] < 15) { - radius[i] *= 1.2; - } // else //{ - // radius[i] *= pow(J, 1.0 / domain->dimension); - //} - } - } - - // update of reference config could have changed x0, vfrac, radius - // communicate these quantities now to ghosts: x0, vfrac, radius - comm->forward_comm_fix(this); - - setup(0); - } + if (nn[i] < 15) { + radius[i] *= 1.2; + } // else //{ + // radius[i] *= pow(J, 1.0 / domain->dimension); + //} + } + } + + // update of reference config could have changed x0, vfrac, radius + // communicate these quantities now to ghosts: x0, vfrac, radius + comm->forward_comm_fix(this); + + setup(0); + } } /* ---------------------------------------------------------------------- @@ -200,155 +200,155 @@ void FixSMD_TLSPH_ReferenceConfiguration::pre_exchange() { ------------------------------------------------------------------------- */ void FixSMD_TLSPH_ReferenceConfiguration::setup(int vflag) { - int i, j, ii, jj, n, inum, jnum; - int *ilist, *jlist, *numneigh, **firstneigh; - double r, h, wf, wfd; - Vector3d dx; + int i, j, ii, jj, n, inum, jnum; + int *ilist, *jlist, *numneigh, **firstneigh; + double r, h, wf, wfd; + Vector3d dx; - if (updateFlag == 0) - return; + if (updateFlag == 0) + return; - int nlocal = atom->nlocal; - nmax = atom->nmax; - grow_arrays(nmax); + int nlocal = atom->nlocal; + nmax = atom->nmax; + grow_arrays(nmax); // 1st loop over neighbor list // calculate npartner for each owned atom // nlocal_neigh = nlocal when neigh list was built, may be smaller than nlocal - double **x0 = atom->x; - double *radius = atom->radius; - int *mask = atom->mask; - tagint *tag = atom->tag; - NeighList *list = pair->list; - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - // zero npartner for all current atoms - for (i = 0; i < nlocal; i++) - npartner[i] = 0; - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - if (INSERT_PREDEFINED_CRACKS) { - if (!crack_exclude(i, j)) - continue; - } - - dx(0) = x0[i][0] - x0[j][0]; - dx(1) = x0[i][1] - x0[j][1]; - dx(2) = x0[i][2] - x0[j][2]; - r = dx.norm(); - h = radius[i] + radius[j]; - - if (r <= h) { - npartner[i]++; - if (j < nlocal) { - npartner[j]++; - } - } - } - } - - maxpartner = 0; - for (i = 0; i < nlocal; i++) - maxpartner = MAX(maxpartner, npartner[i]); - int maxall; - MPI_Allreduce(&maxpartner, &maxall, 1, MPI_INT, MPI_MAX, world); - maxpartner = maxall; - - grow_arrays(nmax); - - for (i = 0; i < nlocal; i++) { - npartner[i] = 0; - for (jj = 0; jj < maxpartner; jj++) { - wfd_list[i][jj] = 0.0; - wf_list[i][jj] = 0.0; - degradation_ij[i][jj] = 0.0; - energy_per_bond[i][jj] = 0.0; - } - } - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - dx(0) = x0[i][0] - x0[j][0]; - dx(1) = x0[i][1] - x0[j][1]; - dx(2) = x0[i][2] - x0[j][2]; - r = dx.norm(); - h = radius[i] + radius[j]; - - if (INSERT_PREDEFINED_CRACKS) { - if (!crack_exclude(i, j)) - continue; - } - - if (r < h) { - spiky_kernel_and_derivative(h, r, domain->dimension, wf, wfd); - - partner[i][npartner[i]] = tag[j]; - wfd_list[i][npartner[i]] = wfd; - wf_list[i][npartner[i]] = wf; - npartner[i]++; - if (j < nlocal) { - partner[j][npartner[j]] = tag[i]; - wfd_list[j][npartner[j]] = wfd; - wf_list[j][npartner[j]] = wf; - npartner[j]++; - } - } - } - } - - // count number of particles for which this group is active - - // bond statistics - if (update->ntimestep > -1) { - n = 0; - int count = 0; - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - n += npartner[i]; - count += 1; - } - } - int nall, countall; - MPI_Allreduce(&n, &nall, 1, MPI_INT, MPI_SUM, world); - MPI_Allreduce(&count, &countall, 1, MPI_INT, MPI_SUM, world); + double **x0 = atom->x; + double *radius = atom->radius; + int *mask = atom->mask; + tagint *tag = atom->tag; + NeighList *list = pair->list; + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // zero npartner for all current atoms + for (i = 0; i < nlocal; i++) + npartner[i] = 0; + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + if (INSERT_PREDEFINED_CRACKS) { + if (!crack_exclude(i, j)) + continue; + } + + dx(0) = x0[i][0] - x0[j][0]; + dx(1) = x0[i][1] - x0[j][1]; + dx(2) = x0[i][2] - x0[j][2]; + r = dx.norm(); + h = radius[i] + radius[j]; + + if (r <= h) { + npartner[i]++; + if (j < nlocal) { + npartner[j]++; + } + } + } + } + + maxpartner = 0; + for (i = 0; i < nlocal; i++) + maxpartner = MAX(maxpartner, npartner[i]); + int maxall; + MPI_Allreduce(&maxpartner, &maxall, 1, MPI_INT, MPI_MAX, world); + maxpartner = maxall; + + grow_arrays(nmax); + + for (i = 0; i < nlocal; i++) { + npartner[i] = 0; + for (jj = 0; jj < maxpartner; jj++) { + wfd_list[i][jj] = 0.0; + wf_list[i][jj] = 0.0; + degradation_ij[i][jj] = 0.0; + energy_per_bond[i][jj] = 0.0; + } + } + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + dx(0) = x0[i][0] - x0[j][0]; + dx(1) = x0[i][1] - x0[j][1]; + dx(2) = x0[i][2] - x0[j][2]; + r = dx.norm(); + h = radius[i] + radius[j]; + + if (INSERT_PREDEFINED_CRACKS) { + if (!crack_exclude(i, j)) + continue; + } + + if (r < h) { + spiky_kernel_and_derivative(h, r, domain->dimension, wf, wfd); + + partner[i][npartner[i]] = tag[j]; + wfd_list[i][npartner[i]] = wfd; + wf_list[i][npartner[i]] = wf; + npartner[i]++; + if (j < nlocal) { + partner[j][npartner[j]] = tag[i]; + wfd_list[j][npartner[j]] = wfd; + wf_list[j][npartner[j]] = wf; + npartner[j]++; + } + } + } + } + + // count number of particles for which this group is active + + // bond statistics + if (update->ntimestep > -1) { + n = 0; + int count = 0; + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + n += npartner[i]; + count += 1; + } + } + int nall, countall; + MPI_Allreduce(&n, &nall, 1, MPI_INT, MPI_SUM, world); + MPI_Allreduce(&count, &countall, 1, MPI_INT, MPI_SUM, world); if (countall < 1) countall = 1; - if (comm->me == 0) { - if (screen) { - printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); - fprintf(screen, "TLSPH neighbors:\n"); - fprintf(screen, " max # of neighbors for a single particle = %d\n", maxpartner); - fprintf(screen, " average # of neighbors/particle in group tlsph = %g\n", (double) nall / countall); - printf(">>========>>========>>========>>========>>========>>========>>========>>========\n\n"); - } - if (logfile) { - fprintf(logfile, "\nTLSPH neighbors:\n"); - fprintf(logfile, " max # of neighbors for a single particle = %d\n", maxpartner); - fprintf(logfile, " average # of neighbors/particle in group tlsph = %g\n", (double) nall / countall); - } - } - } - - updateFlag = 0; // set update flag to zero after the update + if (comm->me == 0) { + if (screen) { + printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); + fprintf(screen, "TLSPH neighbors:\n"); + fprintf(screen, " max # of neighbors for a single particle = %d\n", maxpartner); + fprintf(screen, " average # of neighbors/particle in group tlsph = %g\n", (double) nall / countall); + printf(">>========>>========>>========>>========>>========>>========>>========>>========\n\n"); + } + if (logfile) { + fprintf(logfile, "\nTLSPH neighbors:\n"); + fprintf(logfile, " max # of neighbors for a single particle = %d\n", maxpartner); + fprintf(logfile, " average # of neighbors/particle in group tlsph = %g\n", (double) nall / countall); + } + } + } + + updateFlag = 0; // set update flag to zero after the update } @@ -357,14 +357,14 @@ void FixSMD_TLSPH_ReferenceConfiguration::setup(int vflag) { ------------------------------------------------------------------------- */ double FixSMD_TLSPH_ReferenceConfiguration::memory_usage() { - int nmax = atom->nmax; - int bytes = nmax * sizeof(int); - bytes += nmax * maxpartner * sizeof(tagint); // partner array - bytes += nmax * maxpartner * sizeof(float); // wf_list - bytes += nmax * maxpartner * sizeof(float); // wfd_list - bytes += nmax * maxpartner * sizeof(float); // damage_per_interaction array - bytes += nmax * sizeof(int); // npartner array - return bytes; + int nmax = atom->nmax; + int bytes = nmax * sizeof(int); + bytes += nmax * maxpartner * sizeof(tagint); // partner array + bytes += nmax * maxpartner * sizeof(float); // wf_list + bytes += nmax * maxpartner * sizeof(float); // wfd_list + bytes += nmax * maxpartner * sizeof(float); // damage_per_interaction array + bytes += nmax * sizeof(int); // npartner array + return bytes; } @@ -373,13 +373,13 @@ double FixSMD_TLSPH_ReferenceConfiguration::memory_usage() { ------------------------------------------------------------------------- */ void FixSMD_TLSPH_ReferenceConfiguration::grow_arrays(int nmax) { - //printf("in FixSMD_TLSPH_ReferenceConfiguration::grow_arrays\n"); - memory->grow(npartner, nmax, "tlsph_refconfig_neigh:npartner"); - memory->grow(partner, nmax, maxpartner, "tlsph_refconfig_neigh:partner"); - memory->grow(wfd_list, nmax, maxpartner, "tlsph_refconfig_neigh:wfd"); - memory->grow(wf_list, nmax, maxpartner, "tlsph_refconfig_neigh:wf"); - memory->grow(degradation_ij, nmax, maxpartner, "tlsph_refconfig_neigh:degradation_ij"); - memory->grow(energy_per_bond, nmax, maxpartner, "tlsph_refconfig_neigh:damage_onset_strain"); + //printf("in FixSMD_TLSPH_ReferenceConfiguration::grow_arrays\n"); + memory->grow(npartner, nmax, "tlsph_refconfig_neigh:npartner"); + memory->grow(partner, nmax, maxpartner, "tlsph_refconfig_neigh:partner"); + memory->grow(wfd_list, nmax, maxpartner, "tlsph_refconfig_neigh:wfd"); + memory->grow(wf_list, nmax, maxpartner, "tlsph_refconfig_neigh:wf"); + memory->grow(degradation_ij, nmax, maxpartner, "tlsph_refconfig_neigh:degradation_ij"); + memory->grow(energy_per_bond, nmax, maxpartner, "tlsph_refconfig_neigh:damage_onset_strain"); } /* ---------------------------------------------------------------------- @@ -387,14 +387,14 @@ void FixSMD_TLSPH_ReferenceConfiguration::grow_arrays(int nmax) { ------------------------------------------------------------------------- */ void FixSMD_TLSPH_ReferenceConfiguration::copy_arrays(int i, int j, int delflag) { - npartner[j] = npartner[i]; - for (int m = 0; m < npartner[j]; m++) { - partner[j][m] = partner[i][m]; - wfd_list[j][m] = wfd_list[i][m]; - wf_list[j][m] = wf_list[i][m]; - degradation_ij[j][m] = degradation_ij[i][m]; - energy_per_bond[j][m] = energy_per_bond[i][m]; - } + npartner[j] = npartner[i]; + for (int m = 0; m < npartner[j]; m++) { + partner[j][m] = partner[i][m]; + wfd_list[j][m] = wfd_list[i][m]; + wf_list[j][m] = wf_list[i][m]; + degradation_ij[j][m] = degradation_ij[i][m]; + energy_per_bond[j][m] = energy_per_bond[i][m]; + } } /* ---------------------------------------------------------------------- @@ -407,16 +407,16 @@ int FixSMD_TLSPH_ReferenceConfiguration::pack_exchange(int i, double *buf) { //printf("pack_exchange ...\n"); - int m = 0; - buf[m++] = npartner[i]; - for (int n = 0; n < npartner[i]; n++) { - buf[m++] = partner[i][n]; - buf[m++] = wfd_list[i][n]; - buf[m++] = wf_list[i][n]; - buf[m++] = degradation_ij[i][n]; - buf[m++] = energy_per_bond[i][n]; - } - return m; + int m = 0; + buf[m++] = npartner[i]; + for (int n = 0; n < npartner[i]; n++) { + buf[m++] = partner[i][n]; + buf[m++] = wfd_list[i][n]; + buf[m++] = wf_list[i][n]; + buf[m++] = degradation_ij[i][n]; + buf[m++] = energy_per_bond[i][n]; + } + return m; } @@ -425,27 +425,27 @@ int FixSMD_TLSPH_ReferenceConfiguration::pack_exchange(int i, double *buf) { ------------------------------------------------------------------------- */ int FixSMD_TLSPH_ReferenceConfiguration::unpack_exchange(int nlocal, double *buf) { - if (nlocal == nmax) { - //printf("nlocal=%d, nmax=%d\n", nlocal, nmax); - nmax = nmax / DELTA * DELTA; - nmax += DELTA; - grow_arrays(nmax); - - error->message(FLERR, - "in Fixtlsph_refconfigNeighGCG::unpack_exchange: local arrays too small for receiving partner information; growing arrays"); - } + if (nlocal == nmax) { + //printf("nlocal=%d, nmax=%d\n", nlocal, nmax); + nmax = nmax / DELTA * DELTA; + nmax += DELTA; + grow_arrays(nmax); + + error->message(FLERR, + "in Fixtlsph_refconfigNeighGCG::unpack_exchange: local arrays too small for receiving partner information; growing arrays"); + } //printf("nlocal=%d, nmax=%d\n", nlocal, nmax); - int m = 0; - npartner[nlocal] = static_cast<int>(buf[m++]); - for (int n = 0; n < npartner[nlocal]; n++) { - partner[nlocal][n] = static_cast<tagint>(buf[m++]); - wfd_list[nlocal][n] = static_cast<float>(buf[m++]); - wf_list[nlocal][n] = static_cast<float>(buf[m++]); - degradation_ij[nlocal][n] = static_cast<float>(buf[m++]); - energy_per_bond[nlocal][n] = static_cast<float>(buf[m++]); - } - return m; + int m = 0; + npartner[nlocal] = static_cast<int>(buf[m++]); + for (int n = 0; n < npartner[nlocal]; n++) { + partner[nlocal][n] = static_cast<tagint>(buf[m++]); + wfd_list[nlocal][n] = static_cast<float>(buf[m++]); + wf_list[nlocal][n] = static_cast<float>(buf[m++]); + degradation_ij[nlocal][n] = static_cast<float>(buf[m++]); + energy_per_bond[nlocal][n] = static_cast<float>(buf[m++]); + } + return m; } /* ---------------------------------------------------------------------- @@ -453,17 +453,17 @@ int FixSMD_TLSPH_ReferenceConfiguration::unpack_exchange(int nlocal, double *buf ------------------------------------------------------------------------- */ int FixSMD_TLSPH_ReferenceConfiguration::pack_restart(int i, double *buf) { - int m = 0; - buf[m++] = 4 * npartner[i] + 2; - buf[m++] = npartner[i]; - for (int n = 0; n < npartner[i]; n++) { - buf[m++] = partner[i][n]; - buf[m++] = wfd_list[i][n]; - buf[m++] = wf_list[i][n]; - buf[m++] = degradation_ij[i][n]; - buf[m++] = energy_per_bond[i][n]; - } - return m; + int m = 0; + buf[m++] = 4 * npartner[i] + 2; + buf[m++] = npartner[i]; + for (int n = 0; n < npartner[i]; n++) { + buf[m++] = partner[i][n]; + buf[m++] = wfd_list[i][n]; + buf[m++] = wf_list[i][n]; + buf[m++] = degradation_ij[i][n]; + buf[m++] = energy_per_bond[i][n]; + } + return m; } /* ---------------------------------------------------------------------- @@ -475,19 +475,19 @@ void FixSMD_TLSPH_ReferenceConfiguration::unpack_restart(int nlocal, int nth) { // skip to Nth set of extra values -// double **extra = atom->extra; +// double **extra = atom->extra; // -// int m = 0; -// for (int i = 0; i < nth; i++) -// m += static_cast<int>(extra[nlocal][m]); -// m++; +// int m = 0; +// for (int i = 0; i < nth; i++) +// m += static_cast<int>(extra[nlocal][m]); +// m++; // -// // allocate new chunks from ipage,dpage for incoming values +// // allocate new chunks from ipage,dpage for incoming values // -// npartner[nlocal] = static_cast<int>(extra[nlocal][m++]); -// for (int n = 0; n < npartner[nlocal]; n++) { -// partner[nlocal][n] = static_cast<tagint>(extra[nlocal][m++]); -// } +// npartner[nlocal] = static_cast<int>(extra[nlocal][m++]); +// for (int n = 0; n < npartner[nlocal]; n++) { +// partner[nlocal][n] = static_cast<tagint>(extra[nlocal][m++]); +// } } /* ---------------------------------------------------------------------- @@ -497,9 +497,9 @@ void FixSMD_TLSPH_ReferenceConfiguration::unpack_restart(int nlocal, int nth) { int FixSMD_TLSPH_ReferenceConfiguration::maxsize_restart() { // maxtouch_all = max # of touching partners across all procs - int maxtouch_all; - MPI_Allreduce(&maxpartner, &maxtouch_all, 1, MPI_INT, MPI_MAX, world); - return 4 * maxtouch_all + 2; + int maxtouch_all; + MPI_Allreduce(&maxpartner, &maxtouch_all, 1, MPI_INT, MPI_MAX, world); + return 4 * maxtouch_all + 2; } /* ---------------------------------------------------------------------- @@ -507,72 +507,72 @@ int FixSMD_TLSPH_ReferenceConfiguration::maxsize_restart() { ------------------------------------------------------------------------- */ int FixSMD_TLSPH_ReferenceConfiguration::size_restart(int nlocal) { - return 4 * npartner[nlocal] + 2; + return 4 * npartner[nlocal] + 2; } /* ---------------------------------------------------------------------- */ int FixSMD_TLSPH_ReferenceConfiguration::pack_forward_comm(int n, int *list, double *buf, int pbc_flag, int *pbc) { - int i, j, m; - double *radius = atom->radius; - double *vfrac = atom->vfrac; - double **x0 = atom->x0; - double **defgrad0 = atom->smd_data_9; - - //printf("FixSMD_TLSPH_ReferenceConfiguration:::pack_forward_comm\n"); - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = x0[j][0]; - buf[m++] = x0[j][1]; - buf[m++] = x0[j][2]; - - buf[m++] = vfrac[j]; - buf[m++] = radius[j]; - - buf[m++] = defgrad0[i][0]; - buf[m++] = defgrad0[i][1]; - buf[m++] = defgrad0[i][2]; - buf[m++] = defgrad0[i][3]; - buf[m++] = defgrad0[i][4]; - buf[m++] = defgrad0[i][5]; - buf[m++] = defgrad0[i][6]; - buf[m++] = defgrad0[i][7]; - buf[m++] = defgrad0[i][8]; - - } - return m; + int i, j, m; + double *radius = atom->radius; + double *vfrac = atom->vfrac; + double **x0 = atom->x0; + double **defgrad0 = atom->smd_data_9; + + //printf("FixSMD_TLSPH_ReferenceConfiguration:::pack_forward_comm\n"); + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x0[j][0]; + buf[m++] = x0[j][1]; + buf[m++] = x0[j][2]; + + buf[m++] = vfrac[j]; + buf[m++] = radius[j]; + + buf[m++] = defgrad0[i][0]; + buf[m++] = defgrad0[i][1]; + buf[m++] = defgrad0[i][2]; + buf[m++] = defgrad0[i][3]; + buf[m++] = defgrad0[i][4]; + buf[m++] = defgrad0[i][5]; + buf[m++] = defgrad0[i][6]; + buf[m++] = defgrad0[i][7]; + buf[m++] = defgrad0[i][8]; + + } + return m; } /* ---------------------------------------------------------------------- */ void FixSMD_TLSPH_ReferenceConfiguration::unpack_forward_comm(int n, int first, double *buf) { - int i, m, last; - double *radius = atom->radius; - double *vfrac = atom->vfrac; - double **x0 = atom->x0; - double **defgrad0 = atom->smd_data_9; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - x0[i][0] = buf[m++]; - x0[i][1] = buf[m++]; - x0[i][2] = buf[m++]; - - vfrac[i] = buf[m++]; - radius[i] = buf[m++]; - - defgrad0[i][0] = buf[m++]; - defgrad0[i][1] = buf[m++]; - defgrad0[i][2] = buf[m++]; - defgrad0[i][3] = buf[m++]; - defgrad0[i][4] = buf[m++]; - defgrad0[i][5] = buf[m++]; - defgrad0[i][6] = buf[m++]; - defgrad0[i][7] = buf[m++]; - defgrad0[i][8] = buf[m++]; - } + int i, m, last; + double *radius = atom->radius; + double *vfrac = atom->vfrac; + double **x0 = atom->x0; + double **defgrad0 = atom->smd_data_9; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x0[i][0] = buf[m++]; + x0[i][1] = buf[m++]; + x0[i][2] = buf[m++]; + + vfrac[i] = buf[m++]; + radius[i] = buf[m++]; + + defgrad0[i][0] = buf[m++]; + defgrad0[i][1] = buf[m++]; + defgrad0[i][2] = buf[m++]; + defgrad0[i][3] = buf[m++]; + defgrad0[i][4] = buf[m++]; + defgrad0[i][5] = buf[m++]; + defgrad0[i][6] = buf[m++]; + defgrad0[i][7] = buf[m++]; + defgrad0[i][8] = buf[m++]; + } } /* ---------------------------------------------------------------------- @@ -583,26 +583,26 @@ void FixSMD_TLSPH_ReferenceConfiguration::unpack_forward_comm(int n, int first, bool FixSMD_TLSPH_ReferenceConfiguration::crack_exclude(int i, int j) { - double **x = atom->x; - double l0 = domain->lattice->xlattice; + double **x = atom->x; + double l0 = domain->lattice->xlattice; - // line between pair of atoms i,j - double x1 = x[i][0] / l0; - double y1 = x[i][1] / l0; + // line between pair of atoms i,j + double x1 = x[i][0] / l0; + double y1 = x[i][1] / l0; - double x2 = x[j][0] / l0; - double y2 = x[j][1] / l0; + double x2 = x[j][0] / l0; + double y2 = x[j][1] / l0; - // hardcoded crack line - double x3 = -0.1 / l0; - double y3 = ((int) 1.0 / l0) + 0.5; - //printf("y3 = %f\n", y3); - double x4 = 0.1 / l0 - 1.0 + 0.1; - double y4 = y3; + // hardcoded crack line + double x3 = -0.1 / l0; + double y3 = ((int) 1.0 / l0) + 0.5; + //printf("y3 = %f\n", y3); + double x4 = 0.1 / l0 - 1.0 + 0.1; + double y4 = y3; - bool retVal = DoLineSegmentsIntersect(x1, y1, x2, y2, x3, y3, x4, y4); + bool retVal = DoLineSegmentsIntersect(x1, y1, x2, y2, x3, y3, x4, y4); - return !retVal; - //return 1; + return !retVal; + //return 1; } diff --git a/src/USER-SMD/fix_smd_tlsph_reference_configuration.h b/src/USER-SMD/fix_smd_tlsph_reference_configuration.h index 3ff693e9bb..8549621c2f 100644 --- a/src/USER-SMD/fix_smd_tlsph_reference_configuration.h +++ b/src/USER-SMD/fix_smd_tlsph_reference_configuration.h @@ -40,42 +40,42 @@ FixStyle(SMD_TLSPH_NEIGHBORS,FixSMD_TLSPH_ReferenceConfiguration) namespace LAMMPS_NS { class FixSMD_TLSPH_ReferenceConfiguration: public Fix { - friend class Neighbor; - friend class PairTlsph; + friend class Neighbor; + friend class PairTlsph; public: - FixSMD_TLSPH_ReferenceConfiguration(class LAMMPS *, int, char **); - ~FixSMD_TLSPH_ReferenceConfiguration(); - int setmask(); - void init(); - void setup(int); - void pre_exchange(); - int pack_forward_comm(int, int *, double *, int, int *); - void unpack_forward_comm(int, int, double *); - - double memory_usage(); - void grow_arrays(int); - void copy_arrays(int, int, int); - int pack_exchange(int, double *); - int unpack_exchange(int, double *); - int pack_restart(int, double *); - void unpack_restart(int, int); - int size_restart(int); - int maxsize_restart(); - - bool crack_exclude(int i, int j); - bool get_line_intersection(int i, int j); + FixSMD_TLSPH_ReferenceConfiguration(class LAMMPS *, int, char **); + ~FixSMD_TLSPH_ReferenceConfiguration(); + int setmask(); + void init(); + void setup(int); + void pre_exchange(); + int pack_forward_comm(int, int *, double *, int, int *); + void unpack_forward_comm(int, int, double *); + + double memory_usage(); + void grow_arrays(int); + void copy_arrays(int, int, int); + int pack_exchange(int, double *); + int unpack_exchange(int, double *); + int pack_restart(int, double *); + void unpack_restart(int, int); + int size_restart(int); + int maxsize_restart(); + + bool crack_exclude(int i, int j); + bool get_line_intersection(int i, int j); protected: - int updateFlag; // flag to update reference configuration - int nmax; - int maxpartner; - int *npartner; // # of touching partners of each atom - tagint **partner; // global atom IDs for the partners - float **wfd_list, **wf_list, **energy_per_bond; - float **degradation_ij; // per-pair interaction degradation status - - class Pair *pair; + int updateFlag; // flag to update reference configuration + int nmax; + int maxpartner; + int *npartner; // # of touching partners of each atom + tagint **partner; // global atom IDs for the partners + float **wfd_list, **wf_list, **energy_per_bond; + float **degradation_ij; // per-pair interaction degradation status + + class Pair *pair; }; diff --git a/src/USER-SMD/fix_smd_wall_surface.cpp b/src/USER-SMD/fix_smd_wall_surface.cpp index 94cac6e20c..53232af001 100644 --- a/src/USER-SMD/fix_smd_wall_surface.cpp +++ b/src/USER-SMD/fix_smd_wall_surface.cpp @@ -41,39 +41,39 @@ using namespace std; #define DELTA 16384 #define EPSILON 1.0e-6 enum { - LAYOUT_UNIFORM, LAYOUT_NONUNIFORM, LAYOUT_TILED + LAYOUT_UNIFORM, LAYOUT_NONUNIFORM, LAYOUT_TILED }; // several files /* ---------------------------------------------------------------------- */ FixSMDWallSurface::FixSMDWallSurface(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) { - - restart_global = 0; - restart_peratom = 0; - first = 1; - - //atom->add_callback(0); - //atom->add_callback(1); - - if (narg != 6) - error->all(FLERR, "Illegal number of arguments for fix smd/wall_surface"); - - filename = strdup(arg[3]); - wall_particle_type = force->inumeric(FLERR, arg[4]); - wall_molecule_id = force->inumeric(FLERR, arg[5]); - if (wall_molecule_id < 65535) { - error->one(FLERR, "wall molcule id must be >= 65535\n"); - } - - if (comm->me == 0) { - printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); - printf("fix smd/wall_surface reads trianglulated surface from file: %s\n", filename); - printf("fix smd/wall_surface has particle type %d \n", wall_particle_type); - printf("fix smd/wall_surface has molecule id %d \n", wall_molecule_id); - printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); - } + Fix(lmp, narg, arg) { + + restart_global = 0; + restart_peratom = 0; + first = 1; + + //atom->add_callback(0); + //atom->add_callback(1); + + if (narg != 6) + error->all(FLERR, "Illegal number of arguments for fix smd/wall_surface"); + + filename = strdup(arg[3]); + wall_particle_type = force->inumeric(FLERR, arg[4]); + wall_molecule_id = force->inumeric(FLERR, arg[5]); + if (wall_molecule_id < 65535) { + error->one(FLERR, "wall molcule id must be >= 65535\n"); + } + + if (comm->me == 0) { + printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); + printf("fix smd/wall_surface reads trianglulated surface from file: %s\n", filename); + printf("fix smd/wall_surface has particle type %d \n", wall_particle_type); + printf("fix smd/wall_surface has molecule id %d \n", wall_molecule_id); + printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); + } } /* ---------------------------------------------------------------------- */ @@ -81,24 +81,24 @@ FixSMDWallSurface::FixSMDWallSurface(LAMMPS *lmp, int narg, char **arg) : FixSMDWallSurface::~FixSMDWallSurface() { free(filename); filename = NULL; - // unregister this fix so atom class doesn't invoke it any more + // unregister this fix so atom class doesn't invoke it any more - //atom->delete_callback(id, 0); - //atom->delete_callback(id, 1); + //atom->delete_callback(id, 0); + //atom->delete_callback(id, 1); } /* ---------------------------------------------------------------------- */ int FixSMDWallSurface::setmask() { - int mask = 0; - return mask; + int mask = 0; + return mask; } /* ---------------------------------------------------------------------- */ void FixSMDWallSurface::init() { - if (!first) - return; + if (!first) + return; } /* ---------------------------------------------------------------------- @@ -106,7 +106,7 @@ void FixSMDWallSurface::init() { ------------------------------------------------------------------------- */ void FixSMDWallSurface::min_setup(int vflag) { - setup(vflag); + setup(vflag); } /* ---------------------------------------------------------------------- @@ -116,83 +116,83 @@ void FixSMDWallSurface::min_setup(int vflag) { void FixSMDWallSurface::setup(int vflag) { - if (!first) - return; - first = 0; - - // set bounds for my proc - // if periodic and I am lo/hi proc, adjust bounds by EPSILON - // insures all data atoms will be owned even with round-off - - int triclinic = domain->triclinic; - - double epsilon[3]; - if (triclinic) - epsilon[0] = epsilon[1] = epsilon[2] = EPSILON; - else { - epsilon[0] = domain->prd[0] * EPSILON; - epsilon[1] = domain->prd[1] * EPSILON; - epsilon[2] = domain->prd[2] * EPSILON; - } - - if (triclinic == 0) { - sublo[0] = domain->sublo[0]; - subhi[0] = domain->subhi[0]; - sublo[1] = domain->sublo[1]; - subhi[1] = domain->subhi[1]; - sublo[2] = domain->sublo[2]; - subhi[2] = domain->subhi[2]; - } else { - sublo[0] = domain->sublo_lamda[0]; - subhi[0] = domain->subhi_lamda[0]; - sublo[1] = domain->sublo_lamda[1]; - subhi[1] = domain->subhi_lamda[1]; - sublo[2] = domain->sublo_lamda[2]; - subhi[2] = domain->subhi_lamda[2]; - } - - if (comm->layout != LAYOUT_TILED) { - if (domain->xperiodic) { - if (comm->myloc[0] == 0) - sublo[0] -= epsilon[0]; - if (comm->myloc[0] == comm->procgrid[0] - 1) - subhi[0] += epsilon[0]; - } - if (domain->yperiodic) { - if (comm->myloc[1] == 0) - sublo[1] -= epsilon[1]; - if (comm->myloc[1] == comm->procgrid[1] - 1) - subhi[1] += epsilon[1]; - } - if (domain->zperiodic) { - if (comm->myloc[2] == 0) - sublo[2] -= epsilon[2]; - if (comm->myloc[2] == comm->procgrid[2] - 1) - subhi[2] += epsilon[2]; - } - - } else { - if (domain->xperiodic) { - if (comm->mysplit[0][0] == 0.0) - sublo[0] -= epsilon[0]; - if (comm->mysplit[0][1] == 1.0) - subhi[0] += epsilon[0]; - } - if (domain->yperiodic) { - if (comm->mysplit[1][0] == 0.0) - sublo[1] -= epsilon[1]; - if (comm->mysplit[1][1] == 1.0) - subhi[1] += epsilon[1]; - } - if (domain->zperiodic) { - if (comm->mysplit[2][0] == 0.0) - sublo[2] -= epsilon[2]; - if (comm->mysplit[2][1] == 1.0) - subhi[2] += epsilon[2]; - } - } - - read_triangles(0); + if (!first) + return; + first = 0; + + // set bounds for my proc + // if periodic and I am lo/hi proc, adjust bounds by EPSILON + // insures all data atoms will be owned even with round-off + + int triclinic = domain->triclinic; + + double epsilon[3]; + if (triclinic) + epsilon[0] = epsilon[1] = epsilon[2] = EPSILON; + else { + epsilon[0] = domain->prd[0] * EPSILON; + epsilon[1] = domain->prd[1] * EPSILON; + epsilon[2] = domain->prd[2] * EPSILON; + } + + if (triclinic == 0) { + sublo[0] = domain->sublo[0]; + subhi[0] = domain->subhi[0]; + sublo[1] = domain->sublo[1]; + subhi[1] = domain->subhi[1]; + sublo[2] = domain->sublo[2]; + subhi[2] = domain->subhi[2]; + } else { + sublo[0] = domain->sublo_lamda[0]; + subhi[0] = domain->subhi_lamda[0]; + sublo[1] = domain->sublo_lamda[1]; + subhi[1] = domain->subhi_lamda[1]; + sublo[2] = domain->sublo_lamda[2]; + subhi[2] = domain->subhi_lamda[2]; + } + + if (comm->layout != LAYOUT_TILED) { + if (domain->xperiodic) { + if (comm->myloc[0] == 0) + sublo[0] -= epsilon[0]; + if (comm->myloc[0] == comm->procgrid[0] - 1) + subhi[0] += epsilon[0]; + } + if (domain->yperiodic) { + if (comm->myloc[1] == 0) + sublo[1] -= epsilon[1]; + if (comm->myloc[1] == comm->procgrid[1] - 1) + subhi[1] += epsilon[1]; + } + if (domain->zperiodic) { + if (comm->myloc[2] == 0) + sublo[2] -= epsilon[2]; + if (comm->myloc[2] == comm->procgrid[2] - 1) + subhi[2] += epsilon[2]; + } + + } else { + if (domain->xperiodic) { + if (comm->mysplit[0][0] == 0.0) + sublo[0] -= epsilon[0]; + if (comm->mysplit[0][1] == 1.0) + subhi[0] += epsilon[0]; + } + if (domain->yperiodic) { + if (comm->mysplit[1][0] == 0.0) + sublo[1] -= epsilon[1]; + if (comm->mysplit[1][1] == 1.0) + subhi[1] += epsilon[1]; + } + if (domain->zperiodic) { + if (comm->mysplit[2][0] == 0.0) + sublo[2] -= epsilon[2]; + if (comm->mysplit[2][1] == 1.0) + subhi[2] += epsilon[2]; + } + } + + read_triangles(0); } /* ---------------------------------------------------------------------- @@ -200,25 +200,25 @@ void FixSMDWallSurface::setup(int vflag) { ------------------------------------------------------------------------- */ int FixSMDWallSurface::count_words(const char *line) { - int n = strlen(line) + 1; - char *copy; - memory->create(copy, n, "atom:copy"); - strcpy(copy, line); - - char *ptr; - if ((ptr = strchr(copy, '#'))) - *ptr = '\0'; - - if (strtok(copy, " \t\n\r\f") == NULL) { - memory->destroy(copy); - return 0; - } - n = 1; - while (strtok(NULL, " \t\n\r\f")) - n++; - - memory->destroy(copy); - return n; + int n = strlen(line) + 1; + char *copy; + memory->create(copy, n, "atom:copy"); + strcpy(copy, line); + + char *ptr; + if ((ptr = strchr(copy, '#'))) + *ptr = '\0'; + + if (strtok(copy, " \t\n\r\f") == NULL) { + memory->destroy(copy); + return 0; + } + n = 1; + while (strtok(NULL, " \t\n\r\f")) + n++; + + memory->destroy(copy); + return n; } /* ---------------------------------------------------------------------- @@ -227,283 +227,283 @@ int FixSMDWallSurface::count_words(const char *line) { void FixSMDWallSurface::read_triangles(int pass) { - double coord[3]; - - int nlocal_previous = atom->nlocal; - int ilocal = nlocal_previous; - int m; - int me; - - bigint natoms_previous = atom->natoms; - Vector3d *vert; - vert = new Vector3d[3]; - Vector3d normal, center; - - FILE *fp = fopen(filename, "r"); - if (fp == NULL) { - char str[128]; - sprintf(str, "Cannot open file %s", filename); - error->one(FLERR, str); - } - - MPI_Comm_rank(world, &me); - if (me == 0) { - if (screen) { - if (pass == 0) { - printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); - fprintf(screen, " scanning triangle pairs ...\n"); - } else { - fprintf(screen, " reading triangle pairs ...\n"); - } - } - if (logfile) { - if (pass == 0) { - fprintf(logfile, " scanning triangle pairs ...\n"); - } else { - fprintf(logfile, " reading triangle pairs ...\n"); - } - } - } - - char str[128]; - char line[256]; - char *retpointer; - char **values; - int nwords; - - // read STL solid name - retpointer = fgets(line, sizeof(line), fp); - if (retpointer == NULL) { - sprintf(str, "error reading number of triangle pairs"); - error->one(FLERR, str); - } - - nwords = count_words(line); - if (nwords < 1) { - sprintf(str, "first line of file is incorrect"); - error->one(FLERR, str); - } - -// values = new char*[nwords]; -// values[0] = strtok(line, " \t\n\r\f"); -// if (values[0] == NULL) -// error->all(FLERR, "Incorrect atom format in data file"); -// for (m = 1; m < nwords; m++) { -// values[m] = strtok(NULL, " \t\n\r\f"); -// if (values[m] == NULL) -// error->all(FLERR, "Incorrect atom format in data file"); -// } -// delete[] values; + double coord[3]; + + int nlocal_previous = atom->nlocal; + int ilocal = nlocal_previous; + int m; + int me; + + bigint natoms_previous = atom->natoms; + Vector3d *vert; + vert = new Vector3d[3]; + Vector3d normal, center; + + FILE *fp = fopen(filename, "r"); + if (fp == NULL) { + char str[128]; + sprintf(str, "Cannot open file %s", filename); + error->one(FLERR, str); + } + + MPI_Comm_rank(world, &me); + if (me == 0) { + if (screen) { + if (pass == 0) { + printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); + fprintf(screen, " scanning triangle pairs ...\n"); + } else { + fprintf(screen, " reading triangle pairs ...\n"); + } + } + if (logfile) { + if (pass == 0) { + fprintf(logfile, " scanning triangle pairs ...\n"); + } else { + fprintf(logfile, " reading triangle pairs ...\n"); + } + } + } + + char str[128]; + char line[256]; + char *retpointer; + char **values; + int nwords; + + // read STL solid name + retpointer = fgets(line, sizeof(line), fp); + if (retpointer == NULL) { + sprintf(str, "error reading number of triangle pairs"); + error->one(FLERR, str); + } + + nwords = count_words(line); + if (nwords < 1) { + sprintf(str, "first line of file is incorrect"); + error->one(FLERR, str); + } + +// values = new char*[nwords]; +// values[0] = strtok(line, " \t\n\r\f"); +// if (values[0] == NULL) +// error->all(FLERR, "Incorrect atom format in data file"); +// for (m = 1; m < nwords; m++) { +// values[m] = strtok(NULL, " \t\n\r\f"); +// if (values[m] == NULL) +// error->all(FLERR, "Incorrect atom format in data file"); +// } +// delete[] values; // -// if (comm->me == 0) { -// cout << "STL file contains solid body with name: " << values[1] << endl; -// } - - // iterate over STL facets util end of body is reached - - while (fgets(line, sizeof(line), fp)) { // read a line, should be the facet line - - // evaluate facet line - nwords = count_words(line); - if (nwords != 5) { - //sprintf(str, "found end solid line"); - //error->message(FLERR, str); - break; - } else { - // should be facet line - } - - values = new char*[nwords]; - values[0] = strtok(line, " \t\n\r\f"); - if (values[0] == NULL) - error->all(FLERR, "Incorrect atom format in data file"); - for (m = 1; m < nwords; m++) { - values[m] = strtok(NULL, " \t\n\r\f"); - if (values[m] == NULL) - error->all(FLERR, "Incorrect atom format in data file"); - } - - normal << force->numeric(FLERR, values[2]), force->numeric(FLERR, values[3]), force->numeric(FLERR, values[4]); - //cout << "normal is " << normal << endl; - - delete[] values; - - // read outer loop line - retpointer = fgets(line, sizeof(line), fp); - if (retpointer == NULL) { - sprintf(str, "error reading outer loop"); - error->one(FLERR, str); - } - - nwords = count_words(line); - if (nwords != 2) { - sprintf(str, "error reading outer loop"); - error->one(FLERR, str); - } - - // read vertex lines - - for (int k = 0; k < 3; k++) { - retpointer = fgets(line, sizeof(line), fp); - if (retpointer == NULL) { - sprintf(str, "error reading vertex line"); - error->one(FLERR, str); - } - - nwords = count_words(line); - if (nwords != 4) { - sprintf(str, "error reading vertex line"); - error->one(FLERR, str); - } - - values = new char*[nwords]; - values[0] = strtok(line, " \t\n\r\f"); - if (values[0] == NULL) - error->all(FLERR, "Incorrect vertex line"); - for (m = 1; m < nwords; m++) { - values[m] = strtok(NULL, " \t\n\r\f"); - if (values[m] == NULL) - error->all(FLERR, "Incorrect vertex line"); - } - - vert[k] << force->numeric(FLERR, values[1]), force->numeric(FLERR, values[2]), force->numeric(FLERR, values[3]); - //cout << "vertex is " << vert[k] << endl; - //printf("%s %s %s\n", values[1], values[2], values[3]); - delete[] values; - //exit(1); - - } - - // read end loop line - retpointer = fgets(line, sizeof(line), fp); - if (retpointer == NULL) { - sprintf(str, "error reading endloop"); - error->one(FLERR, str); - } - - nwords = count_words(line); - if (nwords != 1) { - sprintf(str, "error reading endloop"); - error->one(FLERR, str); - } - - // read end facet line - retpointer = fgets(line, sizeof(line), fp); - if (retpointer == NULL) { - sprintf(str, "error reading endfacet"); - error->one(FLERR, str); - } - - nwords = count_words(line); - if (nwords != 1) { - sprintf(str, "error reading endfacet"); - error->one(FLERR, str); - } - - // now we have a normal and three vertices ... proceed with adding triangle - - center = (vert[0] + vert[1] + vert[2]) / 3.0; - - // cout << "center is " << center << endl; - - double r1 = (center - vert[0]).norm(); - double r2 = (center - vert[1]).norm(); - double r3 = (center - vert[2]).norm(); - double r = MAX(r1, r2); - r = MAX(r, r3); - - /* - * if atom/molecule is in my subbox, create it - * ... use x0 to hold triangle normal. - * ... use smd_data_9 to hold the three vertices - * ... use x to hold triangle center - * ... radius is the mmaximal distance from triangle center to all vertices - */ - - // printf("coord: %f %f %f\n", coord[0], coord[1], coord[2]); - // printf("sublo: %f %f %f\n", sublo[0], sublo[1], sublo[2]); - // printf("subhi: %f %f %f\n", subhi[0], subhi[1], subhi[2]); - //printf("ilocal = %d\n", ilocal); - if (center(0) >= sublo[0] && center(0) < subhi[0] && center(1) >= sublo[1] && center(1) < subhi[1] && center(2) >= sublo[2] - && center(2) < subhi[2]) { - //printf("******* KERATIN nlocal=%d ***\n", nlocal); - coord[0] = center(0); - coord[1] = center(1); - coord[2] = center(2); - atom->avec->create_atom(wall_particle_type, coord); - - /* - * need to initialize pointers to atom vec arrays here, because they could have changed - * due to calling grow() in create_atoms() above; - */ - - tagint *mol = atom->molecule; - int *type = atom->type; - double *radius = atom->radius; - double *contact_radius = atom->contact_radius; - double **smd_data_9 = atom->smd_data_9; - double **x0 = atom->x0; - - radius[ilocal] = r; //ilocal; - contact_radius[ilocal] = r; //ilocal; - mol[ilocal] = wall_molecule_id; - type[ilocal] = wall_particle_type; - x0[ilocal][0] = normal(0); - x0[ilocal][1] = normal(1); - x0[ilocal][2] = normal(2); - smd_data_9[ilocal][0] = vert[0](0); - smd_data_9[ilocal][1] = vert[0](1); - smd_data_9[ilocal][2] = vert[0](2); - smd_data_9[ilocal][3] = vert[1](0); - smd_data_9[ilocal][4] = vert[1](1); - smd_data_9[ilocal][5] = vert[1](2); - smd_data_9[ilocal][6] = vert[2](0); - smd_data_9[ilocal][7] = vert[2](1); - smd_data_9[ilocal][8] = vert[2](2); - - ilocal++; - } - - } +// if (comm->me == 0) { +// cout << "STL file contains solid body with name: " << values[1] << endl; +// } + + // iterate over STL facets util end of body is reached + + while (fgets(line, sizeof(line), fp)) { // read a line, should be the facet line + + // evaluate facet line + nwords = count_words(line); + if (nwords != 5) { + //sprintf(str, "found end solid line"); + //error->message(FLERR, str); + break; + } else { + // should be facet line + } + + values = new char*[nwords]; + values[0] = strtok(line, " \t\n\r\f"); + if (values[0] == NULL) + error->all(FLERR, "Incorrect atom format in data file"); + for (m = 1; m < nwords; m++) { + values[m] = strtok(NULL, " \t\n\r\f"); + if (values[m] == NULL) + error->all(FLERR, "Incorrect atom format in data file"); + } + + normal << force->numeric(FLERR, values[2]), force->numeric(FLERR, values[3]), force->numeric(FLERR, values[4]); + //cout << "normal is " << normal << endl; + + delete[] values; + + // read outer loop line + retpointer = fgets(line, sizeof(line), fp); + if (retpointer == NULL) { + sprintf(str, "error reading outer loop"); + error->one(FLERR, str); + } + + nwords = count_words(line); + if (nwords != 2) { + sprintf(str, "error reading outer loop"); + error->one(FLERR, str); + } + + // read vertex lines + + for (int k = 0; k < 3; k++) { + retpointer = fgets(line, sizeof(line), fp); + if (retpointer == NULL) { + sprintf(str, "error reading vertex line"); + error->one(FLERR, str); + } + + nwords = count_words(line); + if (nwords != 4) { + sprintf(str, "error reading vertex line"); + error->one(FLERR, str); + } + + values = new char*[nwords]; + values[0] = strtok(line, " \t\n\r\f"); + if (values[0] == NULL) + error->all(FLERR, "Incorrect vertex line"); + for (m = 1; m < nwords; m++) { + values[m] = strtok(NULL, " \t\n\r\f"); + if (values[m] == NULL) + error->all(FLERR, "Incorrect vertex line"); + } + + vert[k] << force->numeric(FLERR, values[1]), force->numeric(FLERR, values[2]), force->numeric(FLERR, values[3]); + //cout << "vertex is " << vert[k] << endl; + //printf("%s %s %s\n", values[1], values[2], values[3]); + delete[] values; + //exit(1); + + } + + // read end loop line + retpointer = fgets(line, sizeof(line), fp); + if (retpointer == NULL) { + sprintf(str, "error reading endloop"); + error->one(FLERR, str); + } + + nwords = count_words(line); + if (nwords != 1) { + sprintf(str, "error reading endloop"); + error->one(FLERR, str); + } + + // read end facet line + retpointer = fgets(line, sizeof(line), fp); + if (retpointer == NULL) { + sprintf(str, "error reading endfacet"); + error->one(FLERR, str); + } + + nwords = count_words(line); + if (nwords != 1) { + sprintf(str, "error reading endfacet"); + error->one(FLERR, str); + } + + // now we have a normal and three vertices ... proceed with adding triangle + + center = (vert[0] + vert[1] + vert[2]) / 3.0; + + // cout << "center is " << center << endl; + + double r1 = (center - vert[0]).norm(); + double r2 = (center - vert[1]).norm(); + double r3 = (center - vert[2]).norm(); + double r = MAX(r1, r2); + r = MAX(r, r3); + + /* + * if atom/molecule is in my subbox, create it + * ... use x0 to hold triangle normal. + * ... use smd_data_9 to hold the three vertices + * ... use x to hold triangle center + * ... radius is the mmaximal distance from triangle center to all vertices + */ + + // printf("coord: %f %f %f\n", coord[0], coord[1], coord[2]); + // printf("sublo: %f %f %f\n", sublo[0], sublo[1], sublo[2]); + // printf("subhi: %f %f %f\n", subhi[0], subhi[1], subhi[2]); + //printf("ilocal = %d\n", ilocal); + if (center(0) >= sublo[0] && center(0) < subhi[0] && center(1) >= sublo[1] && center(1) < subhi[1] && center(2) >= sublo[2] + && center(2) < subhi[2]) { + //printf("******* KERATIN nlocal=%d ***\n", nlocal); + coord[0] = center(0); + coord[1] = center(1); + coord[2] = center(2); + atom->avec->create_atom(wall_particle_type, coord); + + /* + * need to initialize pointers to atom vec arrays here, because they could have changed + * due to calling grow() in create_atoms() above; + */ + + tagint *mol = atom->molecule; + int *type = atom->type; + double *radius = atom->radius; + double *contact_radius = atom->contact_radius; + double **smd_data_9 = atom->smd_data_9; + double **x0 = atom->x0; + + radius[ilocal] = r; //ilocal; + contact_radius[ilocal] = r; //ilocal; + mol[ilocal] = wall_molecule_id; + type[ilocal] = wall_particle_type; + x0[ilocal][0] = normal(0); + x0[ilocal][1] = normal(1); + x0[ilocal][2] = normal(2); + smd_data_9[ilocal][0] = vert[0](0); + smd_data_9[ilocal][1] = vert[0](1); + smd_data_9[ilocal][2] = vert[0](2); + smd_data_9[ilocal][3] = vert[1](0); + smd_data_9[ilocal][4] = vert[1](1); + smd_data_9[ilocal][5] = vert[1](2); + smd_data_9[ilocal][6] = vert[2](0); + smd_data_9[ilocal][7] = vert[2](1); + smd_data_9[ilocal][8] = vert[2](2); + + ilocal++; + } + + } // set new total # of atoms and error check - bigint nblocal = atom->nlocal; - MPI_Allreduce(&nblocal, &atom->natoms, 1, MPI_LMP_BIGINT, MPI_SUM, world); - if (atom->natoms < 0 || atom->natoms >= MAXBIGINT) - error->all(FLERR, "Too many total atoms"); + bigint nblocal = atom->nlocal; + MPI_Allreduce(&nblocal, &atom->natoms, 1, MPI_LMP_BIGINT, MPI_SUM, world); + if (atom->natoms < 0 || atom->natoms >= MAXBIGINT) + error->all(FLERR, "Too many total atoms"); // add IDs for newly created atoms // check that atom IDs are valid - if (atom->tag_enable) - atom->tag_extend(); - atom->tag_check(); + if (atom->tag_enable) + atom->tag_extend(); + atom->tag_check(); // create global mapping of atoms // zero nghost in case are adding new atoms to existing atoms - if (atom->map_style) { - atom->nghost = 0; - atom->map_init(); - atom->map_set(); - } + if (atom->map_style) { + atom->nghost = 0; + atom->map_init(); + atom->map_set(); + } // print status - if (comm->me == 0) { - if (screen) { - printf("... fix smd/wall_surface finished reading triangulated surface\n"); - fprintf(screen, "fix smd/wall_surface created " BIGINT_FORMAT " atoms\n", atom->natoms - natoms_previous); - printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); - } - if (logfile) { - fprintf(logfile, "... fix smd/wall_surface finished reading triangulated surface\n"); - fprintf(logfile, "fix smd/wall_surface created " BIGINT_FORMAT " atoms\n", atom->natoms - natoms_previous); - fprintf(logfile, ">>========>>========>>========>>========>>========>>========>>========>>========\n"); - } - } - - delete[] vert; - fclose(fp); + if (comm->me == 0) { + if (screen) { + printf("... fix smd/wall_surface finished reading triangulated surface\n"); + fprintf(screen, "fix smd/wall_surface created " BIGINT_FORMAT " atoms\n", atom->natoms - natoms_previous); + printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); + } + if (logfile) { + fprintf(logfile, "... fix smd/wall_surface finished reading triangulated surface\n"); + fprintf(logfile, "fix smd/wall_surface created " BIGINT_FORMAT " atoms\n", atom->natoms - natoms_previous); + fprintf(logfile, ">>========>>========>>========>>========>>========>>========>>========>>========\n"); + } + } + + delete[] vert; + fclose(fp); } diff --git a/src/USER-SMD/fix_smd_wall_surface.h b/src/USER-SMD/fix_smd_wall_surface.h index a32319f48f..10f80c4ca8 100644 --- a/src/USER-SMD/fix_smd_wall_surface.h +++ b/src/USER-SMD/fix_smd_wall_surface.h @@ -27,22 +27,22 @@ namespace LAMMPS_NS { class FixSMDWallSurface: public Fix { public: - FixSMDWallSurface(class LAMMPS *, int, char **); - virtual ~FixSMDWallSurface(); - int setmask(); - void init(); - void setup(int); - void min_setup(int); + FixSMDWallSurface(class LAMMPS *, int, char **); + virtual ~FixSMDWallSurface(); + int setmask(); + void init(); + void setup(int); + void min_setup(int); - int count_words(const char *line); - void read_triangles(int pass); + int count_words(const char *line); + void read_triangles(int pass); private: - int first; // flag for first time initialization - double sublo[3], subhi[3]; // epsilon-extended proc sub-box for adding atoms; - char *filename; - int wall_particle_type; - int wall_molecule_id; + int first; // flag for first time initialization + double sublo[3], subhi[3]; // epsilon-extended proc sub-box for adding atoms; + char *filename; + int wall_particle_type; + int wall_molecule_id; }; } diff --git a/src/USER-SMD/pair_smd_hertz.cpp b/src/USER-SMD/pair_smd_hertz.cpp index b5bae7ef47..9b26382965 100644 --- a/src/USER-SMD/pair_smd_hertz.cpp +++ b/src/USER-SMD/pair_smd_hertz.cpp @@ -51,166 +51,166 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ PairHertz::PairHertz(LAMMPS *lmp) : - Pair(lmp) { + Pair(lmp) { - onerad_dynamic = onerad_frozen = maxrad_dynamic = maxrad_frozen = NULL; - bulkmodulus = NULL; - kn = NULL; - scale = 1.0; + onerad_dynamic = onerad_frozen = maxrad_dynamic = maxrad_frozen = NULL; + bulkmodulus = NULL; + kn = NULL; + scale = 1.0; } /* ---------------------------------------------------------------------- */ PairHertz::~PairHertz() { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - memory->destroy(bulkmodulus); - memory->destroy(kn); - - delete[] onerad_dynamic; - delete[] onerad_frozen; - delete[] maxrad_dynamic; - delete[] maxrad_frozen; - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + memory->destroy(bulkmodulus); + memory->destroy(kn); + + delete[] onerad_dynamic; + delete[] onerad_frozen; + delete[] maxrad_dynamic; + delete[] maxrad_frozen; + } } /* ---------------------------------------------------------------------- */ void PairHertz::compute(int eflag, int vflag) { - int i, j, ii, jj, inum, jnum, itype, jtype; - double xtmp, ytmp, ztmp, delx, dely, delz; - double rsq, r, evdwl, fpair; - int *ilist, *jlist, *numneigh, **firstneigh; - double rcut, r_geom, delta, ri, rj, dt_crit; - double *rmass = atom->rmass; - - evdwl = 0.0; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; - - double **f = atom->f; - double **x = atom->x; - double **x0 = atom->x0; - int *type = atom->type; - int nlocal = atom->nlocal; - double *radius = atom->contact_radius; - double *sph_radius = atom->radius; - double rcutSq; - double delx0, dely0, delz0, rSq0, sphCut; - - int newton_pair = force->newton_pair; - int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - stable_time_increment = 1.0e22; - - // loop over neighbors of my atoms - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - ri = scale * radius[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - jtype = type[j]; - - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; - - rsq = delx * delx + dely * dely + delz * delz; - - rj = scale * radius[j]; - rcut = ri + rj; - rcutSq = rcut * rcut; - - if (rsq < rcutSq) { - - /* - * self contact option: - * if pair of particles was initially close enough to interact via a bulk continuum mechanism (e.g. SPH), exclude pair from contact forces. - * this approach should work well if no updates of the reference configuration are performed. - */ - - if (itype == jtype) { - delx0 = x0[j][0] - x0[i][0]; - dely0 = x0[j][1] - x0[i][1]; - delz0 = x0[j][2] - x0[i][2]; - if (periodic) { - domain->minimum_image(delx0, dely0, delz0); - } - rSq0 = delx0 * delx0 + dely0 * dely0 + delz0 * delz0; // initial distance - sphCut = sph_radius[i] + sph_radius[j]; - if (rSq0 < sphCut * sphCut) { - rcut = 0.5 * rcut; - rcutSq = rcut * rcut; - if (rsq > rcutSq) { - continue; - } - } - } - - r = sqrt(rsq); - //printf("hertz interaction, r=%f, cut=%f, h=%f\n", r, rcut, sqrt(rSq0)); - - // Hertzian short-range forces - delta = rcut - r; // overlap distance - r_geom = ri * rj / rcut; - //assuming poisson ratio = 1/4 for 3d - fpair = 1.066666667e0 * bulkmodulus[itype][jtype] * delta * sqrt(delta * r_geom); // units: N - evdwl = fpair * 0.4e0 * delta; // GCG 25 April: this expression conserves total energy - dt_crit = 3.14 * sqrt(0.5 * (rmass[i] + rmass[j]) / (fpair / delta)); - - stable_time_increment = MIN(stable_time_increment, dt_crit); - if (r > 2.0e-16) { - fpair /= r; // divide by r and multiply with non-normalized distance vector - } else { - fpair = 0.0; - } - - /* - * contact viscosity -- needs to be done, see GRANULAR package for normal & shear damping - * for now: no damping and thus no viscous energy deltaE - */ - - if (evflag) { - ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, delx, dely, delz); - } - - f[i][0] += delx * fpair; - f[i][1] += dely * fpair; - f[i][2] += delz * fpair; - - if (newton_pair || j < nlocal) { - f[j][0] -= delx * fpair; - f[j][1] -= dely * fpair; - f[j][2] -= delz * fpair; - } - - } - } - } - -// double stable_time_increment_all = 0.0; -// MPI_Allreduce(&stable_time_increment, &stable_time_increment_all, 1, MPI_DOUBLE, MPI_MIN, world); -// if (comm->me == 0) { -// printf("stable time step for pair smd/hertz is %f\n", stable_time_increment_all); -// } + int i, j, ii, jj, inum, jnum, itype, jtype; + double xtmp, ytmp, ztmp, delx, dely, delz; + double rsq, r, evdwl, fpair; + int *ilist, *jlist, *numneigh, **firstneigh; + double rcut, r_geom, delta, ri, rj, dt_crit; + double *rmass = atom->rmass; + + evdwl = 0.0; + if (eflag || vflag) + ev_setup(eflag, vflag); + else + evflag = vflag_fdotr = 0; + + double **f = atom->f; + double **x = atom->x; + double **x0 = atom->x0; + int *type = atom->type; + int nlocal = atom->nlocal; + double *radius = atom->contact_radius; + double *sph_radius = atom->radius; + double rcutSq; + double delx0, dely0, delz0, rSq0, sphCut; + + int newton_pair = force->newton_pair; + int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + stable_time_increment = 1.0e22; + + // loop over neighbors of my atoms + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + ri = scale * radius[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + jtype = type[j]; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + + rsq = delx * delx + dely * dely + delz * delz; + + rj = scale * radius[j]; + rcut = ri + rj; + rcutSq = rcut * rcut; + + if (rsq < rcutSq) { + + /* + * self contact option: + * if pair of particles was initially close enough to interact via a bulk continuum mechanism (e.g. SPH), exclude pair from contact forces. + * this approach should work well if no updates of the reference configuration are performed. + */ + + if (itype == jtype) { + delx0 = x0[j][0] - x0[i][0]; + dely0 = x0[j][1] - x0[i][1]; + delz0 = x0[j][2] - x0[i][2]; + if (periodic) { + domain->minimum_image(delx0, dely0, delz0); + } + rSq0 = delx0 * delx0 + dely0 * dely0 + delz0 * delz0; // initial distance + sphCut = sph_radius[i] + sph_radius[j]; + if (rSq0 < sphCut * sphCut) { + rcut = 0.5 * rcut; + rcutSq = rcut * rcut; + if (rsq > rcutSq) { + continue; + } + } + } + + r = sqrt(rsq); + //printf("hertz interaction, r=%f, cut=%f, h=%f\n", r, rcut, sqrt(rSq0)); + + // Hertzian short-range forces + delta = rcut - r; // overlap distance + r_geom = ri * rj / rcut; + //assuming poisson ratio = 1/4 for 3d + fpair = 1.066666667e0 * bulkmodulus[itype][jtype] * delta * sqrt(delta * r_geom); // units: N + evdwl = fpair * 0.4e0 * delta; // GCG 25 April: this expression conserves total energy + dt_crit = 3.14 * sqrt(0.5 * (rmass[i] + rmass[j]) / (fpair / delta)); + + stable_time_increment = MIN(stable_time_increment, dt_crit); + if (r > 2.0e-16) { + fpair /= r; // divide by r and multiply with non-normalized distance vector + } else { + fpair = 0.0; + } + + /* + * contact viscosity -- needs to be done, see GRANULAR package for normal & shear damping + * for now: no damping and thus no viscous energy deltaE + */ + + if (evflag) { + ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, delx, dely, delz); + } + + f[i][0] += delx * fpair; + f[i][1] += dely * fpair; + f[i][2] += delz * fpair; + + if (newton_pair || j < nlocal) { + f[j][0] -= delx * fpair; + f[j][1] -= dely * fpair; + f[j][2] -= delz * fpair; + } + + } + } + } + +// double stable_time_increment_all = 0.0; +// MPI_Allreduce(&stable_time_increment, &stable_time_increment_all, 1, MPI_DOUBLE, MPI_MIN, world); +// if (comm->me == 0) { +// printf("stable time step for pair smd/hertz is %f\n", stable_time_increment_all); +// } } /* ---------------------------------------------------------------------- @@ -218,23 +218,23 @@ void PairHertz::compute(int eflag, int vflag) { ------------------------------------------------------------------------- */ void PairHertz::allocate() { - allocated = 1; - int n = atom->ntypes; + allocated = 1; + int n = atom->ntypes; - memory->create(setflag, n + 1, n + 1, "pair:setflag"); - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; + memory->create(setflag, n + 1, n + 1, "pair:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; - memory->create(bulkmodulus, n + 1, n + 1, "pair:kspring"); - memory->create(kn, n + 1, n + 1, "pair:kn"); + memory->create(bulkmodulus, n + 1, n + 1, "pair:kspring"); + memory->create(kn, n + 1, n + 1, "pair:kn"); - memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); // always needs to be allocated, even with granular neighborlist + memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); // always needs to be allocated, even with granular neighborlist - onerad_dynamic = new double[n + 1]; - onerad_frozen = new double[n + 1]; - maxrad_dynamic = new double[n + 1]; - maxrad_frozen = new double[n + 1]; + onerad_dynamic = new double[n + 1]; + onerad_frozen = new double[n + 1]; + maxrad_dynamic = new double[n + 1]; + maxrad_frozen = new double[n + 1]; } /* ---------------------------------------------------------------------- @@ -242,16 +242,16 @@ void PairHertz::allocate() { ------------------------------------------------------------------------- */ void PairHertz::settings(int narg, char **arg) { - if (narg != 1) - error->all(FLERR, "Illegal number of args for pair_style hertz"); + if (narg != 1) + error->all(FLERR, "Illegal number of args for pair_style hertz"); - scale = force->numeric(FLERR, arg[0]); - if (comm->me == 0) { - printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); - printf("SMD/HERTZ CONTACT SETTINGS:\n"); - printf("... effective contact radius is scaled by %f\n", scale); - printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); - } + scale = force->numeric(FLERR, arg[0]); + if (comm->me == 0) { + printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); + printf("SMD/HERTZ CONTACT SETTINGS:\n"); + printf("... effective contact radius is scaled by %f\n", scale); + printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); + } } @@ -260,37 +260,37 @@ void PairHertz::settings(int narg, char **arg) { ------------------------------------------------------------------------- */ void PairHertz::coeff(int narg, char **arg) { - if (narg != 3) - error->all(FLERR, "Incorrect args for pair coefficients"); - if (!allocated) - allocate(); - - int ilo, ihi, jlo, jhi; - force->bounds(FLERR,arg[0], atom->ntypes, ilo, ihi); - force->bounds(FLERR,arg[1], atom->ntypes, jlo, jhi); - - double bulkmodulus_one = atof(arg[2]); - - // set short-range force constant - double kn_one = 0.0; - if (domain->dimension == 3) { - kn_one = (16. / 15.) * bulkmodulus_one; //assuming poisson ratio = 1/4 for 3d - } else { - kn_one = 0.251856195 * (2. / 3.) * bulkmodulus_one; //assuming poisson ratio = 1/3 for 2d - } - - int count = 0; - for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo, i); j <= jhi; j++) { - bulkmodulus[i][j] = bulkmodulus_one; - kn[i][j] = kn_one; - setflag[i][j] = 1; - count++; - } - } - - if (count == 0) - error->all(FLERR, "Incorrect args for pair coefficients"); + if (narg != 3) + error->all(FLERR, "Incorrect args for pair coefficients"); + if (!allocated) + allocate(); + + int ilo, ihi, jlo, jhi; + force->bounds(FLERR,arg[0], atom->ntypes, ilo, ihi); + force->bounds(FLERR,arg[1], atom->ntypes, jlo, jhi); + + double bulkmodulus_one = atof(arg[2]); + + // set short-range force constant + double kn_one = 0.0; + if (domain->dimension == 3) { + kn_one = (16. / 15.) * bulkmodulus_one; //assuming poisson ratio = 1/4 for 3d + } else { + kn_one = 0.251856195 * (2. / 3.) * bulkmodulus_one; //assuming poisson ratio = 1/3 for 2d + } + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo, i); j <= jhi; j++) { + bulkmodulus[i][j] = bulkmodulus_one; + kn[i][j] = kn_one; + setflag[i][j] = 1; + count++; + } + } + + if (count == 0) + error->all(FLERR, "Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -299,26 +299,26 @@ void PairHertz::coeff(int narg, char **arg) { double PairHertz::init_one(int i, int j) { - if (!allocated) - allocate(); + if (!allocated) + allocate(); - if (setflag[i][j] == 0) - error->all(FLERR, "All pair coeffs are not set"); + if (setflag[i][j] == 0) + error->all(FLERR, "All pair coeffs are not set"); - bulkmodulus[j][i] = bulkmodulus[i][j]; - kn[j][i] = kn[i][j]; + bulkmodulus[j][i] = bulkmodulus[i][j]; + kn[j][i] = kn[i][j]; - // cutoff = sum of max I,J radii for - // dynamic/dynamic & dynamic/frozen interactions, but not frozen/frozen + // cutoff = sum of max I,J radii for + // dynamic/dynamic & dynamic/frozen interactions, but not frozen/frozen - double cutoff = maxrad_dynamic[i] + maxrad_dynamic[j]; - cutoff = MAX(cutoff, maxrad_frozen[i] + maxrad_dynamic[j]); - cutoff = MAX(cutoff, maxrad_dynamic[i] + maxrad_frozen[j]); + double cutoff = maxrad_dynamic[i] + maxrad_dynamic[j]; + cutoff = MAX(cutoff, maxrad_frozen[i] + maxrad_dynamic[j]); + cutoff = MAX(cutoff, maxrad_dynamic[i] + maxrad_frozen[j]); - if (comm->me == 0) { - printf("cutoff for pair smd/hertz = %f\n", cutoff); - } - return cutoff; + if (comm->me == 0) { + printf("cutoff for pair smd/hertz = %f\n", cutoff); + } + return cutoff; } /* ---------------------------------------------------------------------- @@ -326,32 +326,32 @@ double PairHertz::init_one(int i, int j) { ------------------------------------------------------------------------- */ void PairHertz::init_style() { - int i; + int i; - // error checks + // error checks - if (!atom->contact_radius_flag) - error->all(FLERR, "Pair style smd/hertz requires atom style with contact_radius"); + if (!atom->contact_radius_flag) + error->all(FLERR, "Pair style smd/hertz requires atom style with contact_radius"); - int irequest = neighbor->request(this); - neighbor->requests[irequest]->size = 1; + int irequest = neighbor->request(this); + neighbor->requests[irequest]->size = 1; - // set maxrad_dynamic and maxrad_frozen for each type - // include future Fix pour particles as dynamic + // set maxrad_dynamic and maxrad_frozen for each type + // include future Fix pour particles as dynamic - for (i = 1; i <= atom->ntypes; i++) - onerad_dynamic[i] = onerad_frozen[i] = 0.0; + for (i = 1; i <= atom->ntypes; i++) + onerad_dynamic[i] = onerad_frozen[i] = 0.0; - double *radius = atom->radius; - int *type = atom->type; - int nlocal = atom->nlocal; + double *radius = atom->radius; + int *type = atom->type; + int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) { - onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]); - } + for (i = 0; i < nlocal; i++) { + onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]); + } - MPI_Allreduce(&onerad_dynamic[1], &maxrad_dynamic[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); - MPI_Allreduce(&onerad_frozen[1], &maxrad_frozen[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); + MPI_Allreduce(&onerad_dynamic[1], &maxrad_dynamic[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); + MPI_Allreduce(&onerad_frozen[1], &maxrad_frozen[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); } /* ---------------------------------------------------------------------- @@ -360,8 +360,8 @@ void PairHertz::init_style() { ------------------------------------------------------------------------- */ void PairHertz::init_list(int id, NeighList *ptr) { - if (id == 0) - list = ptr; + if (id == 0) + list = ptr; } /* ---------------------------------------------------------------------- @@ -370,15 +370,15 @@ void PairHertz::init_list(int id, NeighList *ptr) { double PairHertz::memory_usage() { - return 0.0; + return 0.0; } void *PairHertz::extract(const char *str, int &i) { - //printf("in PairTriSurf::extract\n"); - if (strcmp(str, "smd/hertz/stable_time_increment_ptr") == 0) { - return (void *) &stable_time_increment; - } + //printf("in PairTriSurf::extract\n"); + if (strcmp(str, "smd/hertz/stable_time_increment_ptr") == 0) { + return (void *) &stable_time_increment; + } - return NULL; + return NULL; } diff --git a/src/USER-SMD/pair_smd_tlsph.cpp b/src/USER-SMD/pair_smd_tlsph.cpp index 8dac846017..1a600b393e 100644 --- a/src/USER-SMD/pair_smd_tlsph.cpp +++ b/src/USER-SMD/pair_smd_tlsph.cpp @@ -65,68 +65,68 @@ using namespace SMD_Math; /* ---------------------------------------------------------------------- */ PairTlsph::PairTlsph(LAMMPS *lmp) : - Pair(lmp) { + Pair(lmp) { - onerad_dynamic = onerad_frozen = maxrad_dynamic = maxrad_frozen = NULL; + onerad_dynamic = onerad_frozen = maxrad_dynamic = maxrad_frozen = NULL; - failureModel = NULL; - strengthModel = eos = NULL; + failureModel = NULL; + strengthModel = eos = NULL; - nmax = 0; // make sure no atom on this proc such that initial memory allocation is correct - Fdot = Fincr = K = PK1 = NULL; - R = FincrInv = W = D = NULL; - detF = NULL; - smoothVelDifference = NULL; - numNeighsRefConfig = NULL; - CauchyStress = NULL; - hourglass_error = NULL; - Lookup = NULL; - particle_dt = NULL; + nmax = 0; // make sure no atom on this proc such that initial memory allocation is correct + Fdot = Fincr = K = PK1 = NULL; + R = FincrInv = W = D = NULL; + detF = NULL; + smoothVelDifference = NULL; + numNeighsRefConfig = NULL; + CauchyStress = NULL; + hourglass_error = NULL; + Lookup = NULL; + particle_dt = NULL; - updateFlag = 0; - first = true; - dtCFL = 0.0; // initialize dtCFL so it is set to safe value if extracted on zero-th timestep + updateFlag = 0; + first = true; + dtCFL = 0.0; // initialize dtCFL so it is set to safe value if extracted on zero-th timestep - comm_forward = 22; // this pair style communicates 20 doubles to ghost atoms : PK1 tensor + F tensor + shepardWeight - fix_tlsph_reference_configuration = NULL; + comm_forward = 22; // this pair style communicates 20 doubles to ghost atoms : PK1 tensor + F tensor + shepardWeight + fix_tlsph_reference_configuration = NULL; - cut_comm = MAX(neighbor->cutneighmax, comm->cutghostuser); // cutoff radius within which ghost atoms are communicated. + cut_comm = MAX(neighbor->cutneighmax, comm->cutghostuser); // cutoff radius within which ghost atoms are communicated. } /* ---------------------------------------------------------------------- */ PairTlsph::~PairTlsph() { - //printf("in PairTlsph::~PairTlsph()\n"); - - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - memory->destroy(strengthModel); - memory->destroy(eos); - memory->destroy(Lookup); - - delete[] onerad_dynamic; - delete[] onerad_frozen; - delete[] maxrad_dynamic; - delete[] maxrad_frozen; - - delete[] Fdot; - delete[] Fincr; - delete[] K; - delete[] detF; - delete[] PK1; - delete[] smoothVelDifference; - delete[] R; - delete[] FincrInv; - delete[] W; - delete[] D; - delete[] numNeighsRefConfig; - delete[] CauchyStress; - delete[] hourglass_error; - delete[] particle_dt; - - delete[] failureModel; - } + //printf("in PairTlsph::~PairTlsph()\n"); + + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + memory->destroy(strengthModel); + memory->destroy(eos); + memory->destroy(Lookup); + + delete[] onerad_dynamic; + delete[] onerad_frozen; + delete[] maxrad_dynamic; + delete[] maxrad_frozen; + + delete[] Fdot; + delete[] Fincr; + delete[] K; + delete[] detF; + delete[] PK1; + delete[] smoothVelDifference; + delete[] R; + delete[] FincrInv; + delete[] W; + delete[] D; + delete[] numNeighsRefConfig; + delete[] CauchyStress; + delete[] hourglass_error; + delete[] particle_dt; + + delete[] failureModel; + } } /* ---------------------------------------------------------------------- @@ -136,563 +136,563 @@ PairTlsph::~PairTlsph() { ---------------------------------------------------------------------- */ void PairTlsph::PreCompute() { - tagint *mol = atom->molecule; - double *vfrac = atom->vfrac; - double *radius = atom->radius; - double **x0 = atom->x0; - double **x = atom->x; - double **v = atom->vest; // extrapolated velocities corresponding to current positions - double **vint = atom->v; // Velocity-Verlet algorithm velocities - double *damage = atom->damage; - tagint *tag = atom->tag; - int *type = atom->type; - int nlocal = atom->nlocal; - int jnum, jj, i, j, itype, idim; - - tagint **partner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->partner; - int *npartner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->npartner; - float **wfd_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wfd_list; - float **wf_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wf_list; - float **degradation_ij = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->degradation_ij; - double r0, r0Sq, wf, wfd, h, irad, voli, volj, scale, shepardWeight; - Vector3d dx, dx0, dv, g; - Matrix3d Ktmp, Ftmp, Fdottmp, L, U, eye; - Vector3d vi, vj, vinti, vintj, xi, xj, x0i, x0j, dvint; - int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); - bool status; - Matrix3d F0; - - eye.setIdentity(); - - for (i = 0; i < nlocal; i++) { - - itype = type[i]; - if (setflag[itype][itype] == 1) { - - K[i].setZero(); - Fincr[i].setZero(); - Fdot[i].setZero(); - numNeighsRefConfig[i] = 0; - smoothVelDifference[i].setZero(); - hourglass_error[i] = 0.0; - - if (mol[i] < 0) { // valid SPH particle have mol > 0 - continue; - } - - // initialize aveage mass density - h = 2.0 * radius[i]; - r0 = 0.0; - spiky_kernel_and_derivative(h, r0, domain->dimension, wf, wfd); - shepardWeight = wf * voli; - - jnum = npartner[i]; - irad = radius[i]; - voli = vfrac[i]; - - // initialize Eigen data structures from LAMMPS data structures - for (idim = 0; idim < 3; idim++) { - xi(idim) = x[i][idim]; - x0i(idim) = x0[i][idim]; - vi(idim) = v[i][idim]; - vinti(idim) = vint[i][idim]; - } - - for (jj = 0; jj < jnum; jj++) { - - if (partner[i][jj] == 0) - continue; - j = atom->map(partner[i][jj]); - if (j < 0) { // // check if lost a partner without first breaking bond - partner[i][jj] = 0; - continue; - } - - if (mol[j] < 0) { // particle has failed. do not include it for computing any property - continue; - } - - if (mol[i] != mol[j]) { - continue; - } - - // initialize Eigen data structures from LAMMPS data structures - for (idim = 0; idim < 3; idim++) { - xj(idim) = x[j][idim]; - x0j(idim) = x0[j][idim]; - vj(idim) = v[j][idim]; - vintj(idim) = vint[j][idim]; - } - dx0 = x0j - x0i; - dx = xj - xi; - - if (periodic) - domain->minimum_image(dx0(0), dx0(1), dx0(2)); - - r0Sq = dx0.squaredNorm(); - h = irad + radius[j]; - - r0 = sqrt(r0Sq); - volj = vfrac[j]; - - // distance vectors in current and reference configuration, velocity difference - dv = vj - vi; - dvint = vintj - vinti; - - // scale the interaction according to the damage variable - scale = 1.0 - degradation_ij[i][jj]; - wf = wf_list[i][jj] * scale; - wfd = wfd_list[i][jj] * scale; - g = (wfd / r0) * dx0; - - /* build matrices */ - Ktmp = -g * dx0.transpose(); - Fdottmp = -dv * g.transpose(); - Ftmp = -(dx - dx0) * g.transpose(); - - K[i] += volj * Ktmp; - Fdot[i] += volj * Fdottmp; - Fincr[i] += volj * Ftmp; - shepardWeight += volj * wf; - smoothVelDifference[i] += volj * wf * dvint; - numNeighsRefConfig[i]++; - } // end loop over j - - // normalize average velocity field around an integration point - if (shepardWeight > 0.0) { - smoothVelDifference[i] /= shepardWeight; - } else { - smoothVelDifference[i].setZero(); - } - - pseudo_inverse_SVD(K[i]); - Fdot[i] *= K[i]; - Fincr[i] *= K[i]; - Fincr[i] += eye; - - if (JAUMANN) { - R[i].setIdentity(); // for Jaumann stress rate, we do not need a subsequent rotation back into the reference configuration - } else { - status = PolDec(Fincr[i], R[i], U, false); // polar decomposition of the deformation gradient, F = R * U - if (!status) { - error->message(FLERR, "Polar decomposition of deformation gradient failed.\n"); - mol[i] = -1; - } else { - Fincr[i] = R[i] * U; - } - } - - detF[i] = Fincr[i].determinant(); - FincrInv[i] = Fincr[i].inverse(); - - // velocity gradient - L = Fdot[i] * FincrInv[i]; - - // symmetric (D) and asymmetric (W) parts of L - D[i] = 0.5 * (L + L.transpose()); - W[i] = 0.5 * (L - L.transpose()); // spin tensor:: need this for Jaumann rate - - // unrotated rate-of-deformation tensor d, see right side of Pronto2d, eqn.(2.1.7) - // convention: unrotated frame is that one, where the true rotation of an integration point has been subtracted. - // stress in the unrotated frame of reference is denoted sigma (stress seen by an observer doing rigid body rotations along with the material) - // stress in the true frame of reference (a stationary observer) is denoted by T, "true stress" - D[i] = (R[i].transpose() * D[i] * R[i]).eval(); - - // limit strain rate - //double limit = 1.0e-3 * Lookup[SIGNAL_VELOCITY][itype] / radius[i]; - //D[i] = LimitEigenvalues(D[i], limit); - - /* - * make sure F stays within some limits - */ - - if ((detF[i] < DETF_MIN) || (detF[i] > DETF_MAX) || (numNeighsRefConfig[i] == 0)) { - printf("deleting particle [%d] because det(F)=%f is outside stable range %f -- %f \n", tag[i], - Fincr[i].determinant(), - DETF_MIN, DETF_MAX); - printf("nn = %d, damage=%f\n", numNeighsRefConfig[i], damage[i]); - cout << "Here is matrix F:" << endl << Fincr[i] << endl; - cout << "Here is matrix F-1:" << endl << FincrInv[i] << endl; - cout << "Here is matrix K-1:" << endl << K[i] << endl; - cout << "Here is matrix K:" << endl << K[i].inverse() << endl; - cout << "Here is det of K" << endl << (K[i].inverse()).determinant() << endl; - cout << "Here is matrix R:" << endl << R[i] << endl; - cout << "Here is det of R" << endl << R[i].determinant() << endl; - cout << "Here is matrix U:" << endl << U << endl; - mol[i] = -1; - //error->one(FLERR, ""); - } - - if (mol[i] < 0) { - D[i].setZero(); - Fdot[i].setZero(); - Fincr[i].setIdentity(); - smoothVelDifference[i].setZero(); - detF[i] = 1.0; - K[i].setIdentity(); - - vint[i][0] = 0.0; - vint[i][1] = 0.0; - vint[i][2] = 0.0; - } - } // end loop over i - } // end check setflag + tagint *mol = atom->molecule; + double *vfrac = atom->vfrac; + double *radius = atom->radius; + double **x0 = atom->x0; + double **x = atom->x; + double **v = atom->vest; // extrapolated velocities corresponding to current positions + double **vint = atom->v; // Velocity-Verlet algorithm velocities + double *damage = atom->damage; + tagint *tag = atom->tag; + int *type = atom->type; + int nlocal = atom->nlocal; + int jnum, jj, i, j, itype, idim; + + tagint **partner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->partner; + int *npartner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->npartner; + float **wfd_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wfd_list; + float **wf_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wf_list; + float **degradation_ij = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->degradation_ij; + double r0, r0Sq, wf, wfd, h, irad, voli, volj, scale, shepardWeight; + Vector3d dx, dx0, dv, g; + Matrix3d Ktmp, Ftmp, Fdottmp, L, U, eye; + Vector3d vi, vj, vinti, vintj, xi, xj, x0i, x0j, dvint; + int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); + bool status; + Matrix3d F0; + + eye.setIdentity(); + + for (i = 0; i < nlocal; i++) { + + itype = type[i]; + if (setflag[itype][itype] == 1) { + + K[i].setZero(); + Fincr[i].setZero(); + Fdot[i].setZero(); + numNeighsRefConfig[i] = 0; + smoothVelDifference[i].setZero(); + hourglass_error[i] = 0.0; + + if (mol[i] < 0) { // valid SPH particle have mol > 0 + continue; + } + + // initialize aveage mass density + h = 2.0 * radius[i]; + r0 = 0.0; + spiky_kernel_and_derivative(h, r0, domain->dimension, wf, wfd); + shepardWeight = wf * voli; + + jnum = npartner[i]; + irad = radius[i]; + voli = vfrac[i]; + + // initialize Eigen data structures from LAMMPS data structures + for (idim = 0; idim < 3; idim++) { + xi(idim) = x[i][idim]; + x0i(idim) = x0[i][idim]; + vi(idim) = v[i][idim]; + vinti(idim) = vint[i][idim]; + } + + for (jj = 0; jj < jnum; jj++) { + + if (partner[i][jj] == 0) + continue; + j = atom->map(partner[i][jj]); + if (j < 0) { // // check if lost a partner without first breaking bond + partner[i][jj] = 0; + continue; + } + + if (mol[j] < 0) { // particle has failed. do not include it for computing any property + continue; + } + + if (mol[i] != mol[j]) { + continue; + } + + // initialize Eigen data structures from LAMMPS data structures + for (idim = 0; idim < 3; idim++) { + xj(idim) = x[j][idim]; + x0j(idim) = x0[j][idim]; + vj(idim) = v[j][idim]; + vintj(idim) = vint[j][idim]; + } + dx0 = x0j - x0i; + dx = xj - xi; + + if (periodic) + domain->minimum_image(dx0(0), dx0(1), dx0(2)); + + r0Sq = dx0.squaredNorm(); + h = irad + radius[j]; + + r0 = sqrt(r0Sq); + volj = vfrac[j]; + + // distance vectors in current and reference configuration, velocity difference + dv = vj - vi; + dvint = vintj - vinti; + + // scale the interaction according to the damage variable + scale = 1.0 - degradation_ij[i][jj]; + wf = wf_list[i][jj] * scale; + wfd = wfd_list[i][jj] * scale; + g = (wfd / r0) * dx0; + + /* build matrices */ + Ktmp = -g * dx0.transpose(); + Fdottmp = -dv * g.transpose(); + Ftmp = -(dx - dx0) * g.transpose(); + + K[i] += volj * Ktmp; + Fdot[i] += volj * Fdottmp; + Fincr[i] += volj * Ftmp; + shepardWeight += volj * wf; + smoothVelDifference[i] += volj * wf * dvint; + numNeighsRefConfig[i]++; + } // end loop over j + + // normalize average velocity field around an integration point + if (shepardWeight > 0.0) { + smoothVelDifference[i] /= shepardWeight; + } else { + smoothVelDifference[i].setZero(); + } + + pseudo_inverse_SVD(K[i]); + Fdot[i] *= K[i]; + Fincr[i] *= K[i]; + Fincr[i] += eye; + + if (JAUMANN) { + R[i].setIdentity(); // for Jaumann stress rate, we do not need a subsequent rotation back into the reference configuration + } else { + status = PolDec(Fincr[i], R[i], U, false); // polar decomposition of the deformation gradient, F = R * U + if (!status) { + error->message(FLERR, "Polar decomposition of deformation gradient failed.\n"); + mol[i] = -1; + } else { + Fincr[i] = R[i] * U; + } + } + + detF[i] = Fincr[i].determinant(); + FincrInv[i] = Fincr[i].inverse(); + + // velocity gradient + L = Fdot[i] * FincrInv[i]; + + // symmetric (D) and asymmetric (W) parts of L + D[i] = 0.5 * (L + L.transpose()); + W[i] = 0.5 * (L - L.transpose()); // spin tensor:: need this for Jaumann rate + + // unrotated rate-of-deformation tensor d, see right side of Pronto2d, eqn.(2.1.7) + // convention: unrotated frame is that one, where the true rotation of an integration point has been subtracted. + // stress in the unrotated frame of reference is denoted sigma (stress seen by an observer doing rigid body rotations along with the material) + // stress in the true frame of reference (a stationary observer) is denoted by T, "true stress" + D[i] = (R[i].transpose() * D[i] * R[i]).eval(); + + // limit strain rate + //double limit = 1.0e-3 * Lookup[SIGNAL_VELOCITY][itype] / radius[i]; + //D[i] = LimitEigenvalues(D[i], limit); + + /* + * make sure F stays within some limits + */ + + if ((detF[i] < DETF_MIN) || (detF[i] > DETF_MAX) || (numNeighsRefConfig[i] == 0)) { + printf("deleting particle [%d] because det(F)=%f is outside stable range %f -- %f \n", tag[i], + Fincr[i].determinant(), + DETF_MIN, DETF_MAX); + printf("nn = %d, damage=%f\n", numNeighsRefConfig[i], damage[i]); + cout << "Here is matrix F:" << endl << Fincr[i] << endl; + cout << "Here is matrix F-1:" << endl << FincrInv[i] << endl; + cout << "Here is matrix K-1:" << endl << K[i] << endl; + cout << "Here is matrix K:" << endl << K[i].inverse() << endl; + cout << "Here is det of K" << endl << (K[i].inverse()).determinant() << endl; + cout << "Here is matrix R:" << endl << R[i] << endl; + cout << "Here is det of R" << endl << R[i].determinant() << endl; + cout << "Here is matrix U:" << endl << U << endl; + mol[i] = -1; + //error->one(FLERR, ""); + } + + if (mol[i] < 0) { + D[i].setZero(); + Fdot[i].setZero(); + Fincr[i].setIdentity(); + smoothVelDifference[i].setZero(); + detF[i] = 1.0; + K[i].setIdentity(); + + vint[i][0] = 0.0; + vint[i][1] = 0.0; + vint[i][2] = 0.0; + } + } // end loop over i + } // end check setflag } /* ---------------------------------------------------------------------- */ void PairTlsph::compute(int eflag, int vflag) { - if (atom->nmax > nmax) { - nmax = atom->nmax; - delete[] Fdot; - Fdot = new Matrix3d[nmax]; // memory usage: 9 doubles - delete[] Fincr; - Fincr = new Matrix3d[nmax]; // memory usage: 9 doubles - delete[] K; - K = new Matrix3d[nmax]; // memory usage: 9 doubles - delete[] PK1; - PK1 = new Matrix3d[nmax]; // memory usage: 9 doubles; total 5*9=45 doubles - delete[] detF; - detF = new double[nmax]; // memory usage: 1 double; total 46 doubles - delete[] smoothVelDifference; - smoothVelDifference = new Vector3d[nmax]; // memory usage: 3 doubles; total 49 doubles - delete[] R; - R = new Matrix3d[nmax]; // memory usage: 9 doubles; total 67 doubles - delete[] FincrInv; - FincrInv = new Matrix3d[nmax]; // memory usage: 9 doubles; total 85 doubles - delete[] W; - W = new Matrix3d[nmax]; // memory usage: 9 doubles; total 94 doubles - delete[] D; - D = new Matrix3d[nmax]; // memory usage: 9 doubles; total 103 doubles - delete[] numNeighsRefConfig; - numNeighsRefConfig = new int[nmax]; // memory usage: 1 int; total 108 doubles - delete[] CauchyStress; - CauchyStress = new Matrix3d[nmax]; // memory usage: 9 doubles; total 118 doubles - delete[] hourglass_error; - hourglass_error = new double[nmax]; - delete[] particle_dt; - particle_dt = new double[nmax]; - } - - if (first) { // return on first call, because reference connectivity lists still needs to be built. Also zero quantities which are otherwise undefined. - first = false; - - for (int i = 0; i < atom->nlocal; i++) { - Fincr[i].setZero(); - detF[i] = 0.0; - smoothVelDifference[i].setZero(); - D[i].setZero(); - numNeighsRefConfig[i] = 0; - CauchyStress[i].setZero(); - hourglass_error[i] = 0.0; - particle_dt[i] = 0.0; - } - - return; - } - - /* - * calculate deformations and rate-of-deformations - */ - PairTlsph::PreCompute(); - - /* - * calculate stresses from constitutive models - */ - PairTlsph::AssembleStress(); - - /* - * QUANTITIES ABOVE HAVE ONLY BEEN CALCULATED FOR NLOCAL PARTICLES. - * NEED TO DO A FORWARD COMMUNICATION TO GHOST ATOMS NOW - */ - comm->forward_comm_pair(this); - - /* - * compute forces between particles - */ - updateFlag = 0; - ComputeForces(eflag, vflag); + if (atom->nmax > nmax) { + nmax = atom->nmax; + delete[] Fdot; + Fdot = new Matrix3d[nmax]; // memory usage: 9 doubles + delete[] Fincr; + Fincr = new Matrix3d[nmax]; // memory usage: 9 doubles + delete[] K; + K = new Matrix3d[nmax]; // memory usage: 9 doubles + delete[] PK1; + PK1 = new Matrix3d[nmax]; // memory usage: 9 doubles; total 5*9=45 doubles + delete[] detF; + detF = new double[nmax]; // memory usage: 1 double; total 46 doubles + delete[] smoothVelDifference; + smoothVelDifference = new Vector3d[nmax]; // memory usage: 3 doubles; total 49 doubles + delete[] R; + R = new Matrix3d[nmax]; // memory usage: 9 doubles; total 67 doubles + delete[] FincrInv; + FincrInv = new Matrix3d[nmax]; // memory usage: 9 doubles; total 85 doubles + delete[] W; + W = new Matrix3d[nmax]; // memory usage: 9 doubles; total 94 doubles + delete[] D; + D = new Matrix3d[nmax]; // memory usage: 9 doubles; total 103 doubles + delete[] numNeighsRefConfig; + numNeighsRefConfig = new int[nmax]; // memory usage: 1 int; total 108 doubles + delete[] CauchyStress; + CauchyStress = new Matrix3d[nmax]; // memory usage: 9 doubles; total 118 doubles + delete[] hourglass_error; + hourglass_error = new double[nmax]; + delete[] particle_dt; + particle_dt = new double[nmax]; + } + + if (first) { // return on first call, because reference connectivity lists still needs to be built. Also zero quantities which are otherwise undefined. + first = false; + + for (int i = 0; i < atom->nlocal; i++) { + Fincr[i].setZero(); + detF[i] = 0.0; + smoothVelDifference[i].setZero(); + D[i].setZero(); + numNeighsRefConfig[i] = 0; + CauchyStress[i].setZero(); + hourglass_error[i] = 0.0; + particle_dt[i] = 0.0; + } + + return; + } + + /* + * calculate deformations and rate-of-deformations + */ + PairTlsph::PreCompute(); + + /* + * calculate stresses from constitutive models + */ + PairTlsph::AssembleStress(); + + /* + * QUANTITIES ABOVE HAVE ONLY BEEN CALCULATED FOR NLOCAL PARTICLES. + * NEED TO DO A FORWARD COMMUNICATION TO GHOST ATOMS NOW + */ + comm->forward_comm_pair(this); + + /* + * compute forces between particles + */ + updateFlag = 0; + ComputeForces(eflag, vflag); } void PairTlsph::ComputeForces(int eflag, int vflag) { - tagint *mol = atom->molecule; - double **x = atom->x; - double **v = atom->vest; - double **x0 = atom->x0; - double **f = atom->f; - double *vfrac = atom->vfrac; - double *de = atom->de; - double *rmass = atom->rmass; - double *radius = atom->radius; - double *damage = atom->damage; - double *plastic_strain = atom->eff_plastic_strain; - int *type = atom->type; - int nlocal = atom->nlocal; - int i, j, jj, jnum, itype, idim; - double r, hg_mag, wf, wfd, h, r0, r0Sq, voli, volj; - double delVdotDelR, visc_magnitude, deltaE, mu_ij, hg_err, gamma_dot_dx, delta, scale; - double strain1d, strain1d_max, softening_strain, shepardWeight; - char str[128]; - Vector3d fi, fj, dx0, dx, dv, f_stress, f_hg, dxp_i, dxp_j, gamma, g, gamma_i, gamma_j, x0i, x0j; - Vector3d xi, xj, vi, vj, f_visc, sumForces, f_spring; - int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); - - tagint **partner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->partner; - int *npartner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->npartner; - float **wfd_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wfd_list; - float **wf_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wf_list; - float **degradation_ij = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->degradation_ij; - float **energy_per_bond = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->energy_per_bond; - Matrix3d eye; - eye.setIdentity(); - - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; - - /* - * iterate over pairs of particles i, j and assign forces using PK1 stress tensor - */ - - //updateFlag = 0; - hMin = 1.0e22; - dtRelative = 1.0e22; - - for (i = 0; i < nlocal; i++) { - - if (mol[i] < 0) { - continue; // Particle i is not a valid SPH particle (anymore). Skip all interactions with this particle. - } - - itype = type[i]; - jnum = npartner[i]; - voli = vfrac[i]; - - // initialize aveage mass density - h = 2.0 * radius[i]; - r = 0.0; - spiky_kernel_and_derivative(h, r, domain->dimension, wf, wfd); - shepardWeight = wf * voli; - - for (idim = 0; idim < 3; idim++) { - x0i(idim) = x0[i][idim]; - xi(idim) = x[i][idim]; - vi(idim) = v[i][idim]; - } - - for (jj = 0; jj < jnum; jj++) { - if (partner[i][jj] == 0) - continue; - j = atom->map(partner[i][jj]); - if (j < 0) { // // check if lost a partner without first breaking bond - partner[i][jj] = 0; - continue; - } - - if (mol[j] < 0) { - continue; // Particle j is not a valid SPH particle (anymore). Skip all interactions with this particle. - } - - if (mol[i] != mol[j]) { - continue; - } - - if (type[j] != itype) { - sprintf(str, "particle pair is not of same type!"); - error->all(FLERR, str); - } - - for (idim = 0; idim < 3; idim++) { - x0j(idim) = x0[j][idim]; - xj(idim) = x[j][idim]; - vj(idim) = v[j][idim]; - } - - if (periodic) - domain->minimum_image(dx0(0), dx0(1), dx0(2)); - - // check that distance between i and j (in the reference config) is less than cutoff - dx0 = x0j - x0i; - r0Sq = dx0.squaredNorm(); - h = radius[i] + radius[j]; - hMin = MIN(hMin, h); - r0 = sqrt(r0Sq); - volj = vfrac[j]; - - // distance vectors in current and reference configuration, velocity difference - dx = xj - xi; - dv = vj - vi; - r = dx.norm(); // current distance - - // scale the interaction according to the damage variable - scale = 1.0 - degradation_ij[i][jj]; - wf = wf_list[i][jj] * scale; - wfd = wfd_list[i][jj] * scale; - - g = (wfd / r0) * dx0; // uncorrected kernel gradient - - /* - * force contribution -- note that the kernel gradient correction has been absorbed into PK1 - */ - - f_stress = -voli * volj * (PK1[i] + PK1[j]) * g; - - /* - * artificial viscosity - */ - delVdotDelR = dx.dot(dv) / (r + 0.1 * h); // project relative velocity onto unit particle distance vector [m/s] - LimitDoubleMagnitude(delVdotDelR, 0.01 * Lookup[SIGNAL_VELOCITY][itype]); - mu_ij = h * delVdotDelR / (r + 0.1 * h); // units: [m * m/s / m = m/s] - visc_magnitude = (-Lookup[VISCOSITY_Q1][itype] * Lookup[SIGNAL_VELOCITY][itype] * mu_ij - + Lookup[VISCOSITY_Q2][itype] * mu_ij * mu_ij) / Lookup[REFERENCE_DENSITY][itype]; // units: m^5/(s^2 kg)) - f_visc = rmass[i] * rmass[j] * visc_magnitude * wfd * dx / (r + 1.0e-2 * h); // units: kg^2 * m^5/(s^2 kg) * m^-4 = kg m / s^2 = N - - /* - * hourglass deviation of particles i and j - */ - - gamma = 0.5 * (Fincr[i] + Fincr[j]) * dx0 - dx; - hg_err = gamma.norm() / r0; - hourglass_error[i] += volj * wf * hg_err; - - /* SPH-like hourglass formulation */ - - if (MAX(plastic_strain[i], plastic_strain[j]) > 1.0e-3) { - /* - * viscous hourglass formulation for particles with plastic deformation - */ - delta = gamma.dot(dx); - if (delVdotDelR * delta < 0.0) { - hg_err = MAX(hg_err, 0.05); // limit hg_err to avoid numerical instabilities - hg_mag = -hg_err * Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype] * Lookup[SIGNAL_VELOCITY][itype] * mu_ij - / Lookup[REFERENCE_DENSITY][itype]; // this has units of pressure - } else { - hg_mag = 0.0; - } - f_hg = rmass[i] * rmass[j] * hg_mag * wfd * dx / (r + 1.0e-2 * h); - - } else { - /* - * stiffness hourglass formulation for particle in the elastic regime - */ - - gamma_dot_dx = gamma.dot(dx); // project hourglass error vector onto pair distance vector - LimitDoubleMagnitude(gamma_dot_dx, 0.1 * r); // limit projected vector to avoid numerical instabilities - delta = 0.5 * gamma_dot_dx / (r + 0.1 * h); // delta has dimensions of [m] - hg_mag = Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype] * delta / (r0Sq + 0.01 * h * h); // hg_mag has dimensions [m^(-1)] - hg_mag *= -voli * volj * wf * Lookup[YOUNGS_MODULUS][itype]; // hg_mag has dimensions [J*m^(-1)] = [N] - f_hg = (hg_mag / (r + 0.01 * h)) * dx; - } - - // scale hourglass force with damage - f_hg *= (1.0 - damage[i]) * (1.0 - damage[j]); - - // sum stress, viscous, and hourglass forces - sumForces = f_stress + f_visc + f_hg; // + f_spring; - - // energy rate -- project velocity onto force vector - deltaE = 0.5 * sumForces.dot(dv); - - // apply forces to pair of particles - f[i][0] += sumForces(0); - f[i][1] += sumForces(1); - f[i][2] += sumForces(2); - de[i] += deltaE; - - // tally atomistic stress tensor - if (evflag) { - ev_tally_xyz(i, j, nlocal, 0, 0.0, 0.0, sumForces(0), sumForces(1), sumForces(2), dx(0), dx(1), dx(2)); - } - - shepardWeight += wf * volj; - - // check if a particle has moved too much w.r.t another particle - if (r > r0) { - if (update_method == UPDATE_CONSTANT_THRESHOLD) { - if (r - r0 > update_threshold) { - updateFlag = 1; - } - } else if (update_method == UPDATE_PAIRWISE_RATIO) { - if ((r - r0) / h > update_threshold) { - updateFlag = 1; - } - } - } - - if (failureModel[itype].failure_max_pairwise_strain) { - - strain1d = (r - r0) / r0; - strain1d_max = Lookup[FAILURE_MAX_PAIRWISE_STRAIN_THRESHOLD][itype]; - softening_strain = 2.0 * strain1d_max; - - if (strain1d > strain1d_max) { - degradation_ij[i][jj] = (strain1d - strain1d_max) / softening_strain; - } else { - degradation_ij[i][jj] = 0.0; - } - - if (degradation_ij[i][jj] >= 1.0) { // delete interaction if fully damaged - partner[i][jj] = 0; - } - } - - if (failureModel[itype].failure_energy_release_rate) { - - // integration approach - energy_per_bond[i][jj] += update->dt * f_stress.dot(dv) / (voli * volj); - double Vic = (2.0 / 3.0) * h * h * h; // interaction volume for 2d plane strain - double critical_energy_per_bond = Lookup[CRITICAL_ENERGY_RELEASE_RATE][itype] / (2.0 * Vic); - - if (energy_per_bond[i][jj] > critical_energy_per_bond) { - //degradation_ij[i][jj] = 1.0; - partner[i][jj] = 0; - } - } - - if (failureModel[itype].integration_point_wise) { - - strain1d = (r - r0) / r0; - - if (strain1d > 0.0) { - - if ((damage[i] == 1.0) && (damage[j] == 1.0)) { - // check if damage_onset is already defined - if (energy_per_bond[i][jj] == 0.0) { // pair damage not defined yet - energy_per_bond[i][jj] = strain1d; - } else { // damage initiation strain already defined - strain1d_max = energy_per_bond[i][jj]; - softening_strain = 2.0 * strain1d_max; - - if (strain1d > strain1d_max) { - degradation_ij[i][jj] = (strain1d - strain1d_max) / softening_strain; - } else { - degradation_ij[i][jj] = 0.0; - } - } - } - - if (degradation_ij[i][jj] >= 1.0) { // delete interaction if fully damaged - partner[i][jj] = 0; - } - - } else { - degradation_ij[i][jj] = 0.0; - } // end failureModel[itype].integration_point_wise - - } - - } // end loop over jj neighbors of i - - if (shepardWeight != 0.0) { - hourglass_error[i] /= shepardWeight; - } - - } // end loop over i - - if (vflag_fdotr) - virial_fdotr_compute(); + tagint *mol = atom->molecule; + double **x = atom->x; + double **v = atom->vest; + double **x0 = atom->x0; + double **f = atom->f; + double *vfrac = atom->vfrac; + double *de = atom->de; + double *rmass = atom->rmass; + double *radius = atom->radius; + double *damage = atom->damage; + double *plastic_strain = atom->eff_plastic_strain; + int *type = atom->type; + int nlocal = atom->nlocal; + int i, j, jj, jnum, itype, idim; + double r, hg_mag, wf, wfd, h, r0, r0Sq, voli, volj; + double delVdotDelR, visc_magnitude, deltaE, mu_ij, hg_err, gamma_dot_dx, delta, scale; + double strain1d, strain1d_max, softening_strain, shepardWeight; + char str[128]; + Vector3d fi, fj, dx0, dx, dv, f_stress, f_hg, dxp_i, dxp_j, gamma, g, gamma_i, gamma_j, x0i, x0j; + Vector3d xi, xj, vi, vj, f_visc, sumForces, f_spring; + int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); + + tagint **partner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->partner; + int *npartner = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->npartner; + float **wfd_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wfd_list; + float **wf_list = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->wf_list; + float **degradation_ij = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->degradation_ij; + float **energy_per_bond = ((FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[ifix_tlsph])->energy_per_bond; + Matrix3d eye; + eye.setIdentity(); + + if (eflag || vflag) + ev_setup(eflag, vflag); + else + evflag = vflag_fdotr = 0; + + /* + * iterate over pairs of particles i, j and assign forces using PK1 stress tensor + */ + + //updateFlag = 0; + hMin = 1.0e22; + dtRelative = 1.0e22; + + for (i = 0; i < nlocal; i++) { + + if (mol[i] < 0) { + continue; // Particle i is not a valid SPH particle (anymore). Skip all interactions with this particle. + } + + itype = type[i]; + jnum = npartner[i]; + voli = vfrac[i]; + + // initialize aveage mass density + h = 2.0 * radius[i]; + r = 0.0; + spiky_kernel_and_derivative(h, r, domain->dimension, wf, wfd); + shepardWeight = wf * voli; + + for (idim = 0; idim < 3; idim++) { + x0i(idim) = x0[i][idim]; + xi(idim) = x[i][idim]; + vi(idim) = v[i][idim]; + } + + for (jj = 0; jj < jnum; jj++) { + if (partner[i][jj] == 0) + continue; + j = atom->map(partner[i][jj]); + if (j < 0) { // // check if lost a partner without first breaking bond + partner[i][jj] = 0; + continue; + } + + if (mol[j] < 0) { + continue; // Particle j is not a valid SPH particle (anymore). Skip all interactions with this particle. + } + + if (mol[i] != mol[j]) { + continue; + } + + if (type[j] != itype) { + sprintf(str, "particle pair is not of same type!"); + error->all(FLERR, str); + } + + for (idim = 0; idim < 3; idim++) { + x0j(idim) = x0[j][idim]; + xj(idim) = x[j][idim]; + vj(idim) = v[j][idim]; + } + + if (periodic) + domain->minimum_image(dx0(0), dx0(1), dx0(2)); + + // check that distance between i and j (in the reference config) is less than cutoff + dx0 = x0j - x0i; + r0Sq = dx0.squaredNorm(); + h = radius[i] + radius[j]; + hMin = MIN(hMin, h); + r0 = sqrt(r0Sq); + volj = vfrac[j]; + + // distance vectors in current and reference configuration, velocity difference + dx = xj - xi; + dv = vj - vi; + r = dx.norm(); // current distance + + // scale the interaction according to the damage variable + scale = 1.0 - degradation_ij[i][jj]; + wf = wf_list[i][jj] * scale; + wfd = wfd_list[i][jj] * scale; + + g = (wfd / r0) * dx0; // uncorrected kernel gradient + + /* + * force contribution -- note that the kernel gradient correction has been absorbed into PK1 + */ + + f_stress = -voli * volj * (PK1[i] + PK1[j]) * g; + + /* + * artificial viscosity + */ + delVdotDelR = dx.dot(dv) / (r + 0.1 * h); // project relative velocity onto unit particle distance vector [m/s] + LimitDoubleMagnitude(delVdotDelR, 0.01 * Lookup[SIGNAL_VELOCITY][itype]); + mu_ij = h * delVdotDelR / (r + 0.1 * h); // units: [m * m/s / m = m/s] + visc_magnitude = (-Lookup[VISCOSITY_Q1][itype] * Lookup[SIGNAL_VELOCITY][itype] * mu_ij + + Lookup[VISCOSITY_Q2][itype] * mu_ij * mu_ij) / Lookup[REFERENCE_DENSITY][itype]; // units: m^5/(s^2 kg)) + f_visc = rmass[i] * rmass[j] * visc_magnitude * wfd * dx / (r + 1.0e-2 * h); // units: kg^2 * m^5/(s^2 kg) * m^-4 = kg m / s^2 = N + + /* + * hourglass deviation of particles i and j + */ + + gamma = 0.5 * (Fincr[i] + Fincr[j]) * dx0 - dx; + hg_err = gamma.norm() / r0; + hourglass_error[i] += volj * wf * hg_err; + + /* SPH-like hourglass formulation */ + + if (MAX(plastic_strain[i], plastic_strain[j]) > 1.0e-3) { + /* + * viscous hourglass formulation for particles with plastic deformation + */ + delta = gamma.dot(dx); + if (delVdotDelR * delta < 0.0) { + hg_err = MAX(hg_err, 0.05); // limit hg_err to avoid numerical instabilities + hg_mag = -hg_err * Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype] * Lookup[SIGNAL_VELOCITY][itype] * mu_ij + / Lookup[REFERENCE_DENSITY][itype]; // this has units of pressure + } else { + hg_mag = 0.0; + } + f_hg = rmass[i] * rmass[j] * hg_mag * wfd * dx / (r + 1.0e-2 * h); + + } else { + /* + * stiffness hourglass formulation for particle in the elastic regime + */ + + gamma_dot_dx = gamma.dot(dx); // project hourglass error vector onto pair distance vector + LimitDoubleMagnitude(gamma_dot_dx, 0.1 * r); // limit projected vector to avoid numerical instabilities + delta = 0.5 * gamma_dot_dx / (r + 0.1 * h); // delta has dimensions of [m] + hg_mag = Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype] * delta / (r0Sq + 0.01 * h * h); // hg_mag has dimensions [m^(-1)] + hg_mag *= -voli * volj * wf * Lookup[YOUNGS_MODULUS][itype]; // hg_mag has dimensions [J*m^(-1)] = [N] + f_hg = (hg_mag / (r + 0.01 * h)) * dx; + } + + // scale hourglass force with damage + f_hg *= (1.0 - damage[i]) * (1.0 - damage[j]); + + // sum stress, viscous, and hourglass forces + sumForces = f_stress + f_visc + f_hg; // + f_spring; + + // energy rate -- project velocity onto force vector + deltaE = 0.5 * sumForces.dot(dv); + + // apply forces to pair of particles + f[i][0] += sumForces(0); + f[i][1] += sumForces(1); + f[i][2] += sumForces(2); + de[i] += deltaE; + + // tally atomistic stress tensor + if (evflag) { + ev_tally_xyz(i, j, nlocal, 0, 0.0, 0.0, sumForces(0), sumForces(1), sumForces(2), dx(0), dx(1), dx(2)); + } + + shepardWeight += wf * volj; + + // check if a particle has moved too much w.r.t another particle + if (r > r0) { + if (update_method == UPDATE_CONSTANT_THRESHOLD) { + if (r - r0 > update_threshold) { + updateFlag = 1; + } + } else if (update_method == UPDATE_PAIRWISE_RATIO) { + if ((r - r0) / h > update_threshold) { + updateFlag = 1; + } + } + } + + if (failureModel[itype].failure_max_pairwise_strain) { + + strain1d = (r - r0) / r0; + strain1d_max = Lookup[FAILURE_MAX_PAIRWISE_STRAIN_THRESHOLD][itype]; + softening_strain = 2.0 * strain1d_max; + + if (strain1d > strain1d_max) { + degradation_ij[i][jj] = (strain1d - strain1d_max) / softening_strain; + } else { + degradation_ij[i][jj] = 0.0; + } + + if (degradation_ij[i][jj] >= 1.0) { // delete interaction if fully damaged + partner[i][jj] = 0; + } + } + + if (failureModel[itype].failure_energy_release_rate) { + + // integration approach + energy_per_bond[i][jj] += update->dt * f_stress.dot(dv) / (voli * volj); + double Vic = (2.0 / 3.0) * h * h * h; // interaction volume for 2d plane strain + double critical_energy_per_bond = Lookup[CRITICAL_ENERGY_RELEASE_RATE][itype] / (2.0 * Vic); + + if (energy_per_bond[i][jj] > critical_energy_per_bond) { + //degradation_ij[i][jj] = 1.0; + partner[i][jj] = 0; + } + } + + if (failureModel[itype].integration_point_wise) { + + strain1d = (r - r0) / r0; + + if (strain1d > 0.0) { + + if ((damage[i] == 1.0) && (damage[j] == 1.0)) { + // check if damage_onset is already defined + if (energy_per_bond[i][jj] == 0.0) { // pair damage not defined yet + energy_per_bond[i][jj] = strain1d; + } else { // damage initiation strain already defined + strain1d_max = energy_per_bond[i][jj]; + softening_strain = 2.0 * strain1d_max; + + if (strain1d > strain1d_max) { + degradation_ij[i][jj] = (strain1d - strain1d_max) / softening_strain; + } else { + degradation_ij[i][jj] = 0.0; + } + } + } + + if (degradation_ij[i][jj] >= 1.0) { // delete interaction if fully damaged + partner[i][jj] = 0; + } + + } else { + degradation_ij[i][jj] = 0.0; + } // end failureModel[itype].integration_point_wise + + } + + } // end loop over jj neighbors of i + + if (shepardWeight != 0.0) { + hourglass_error[i] /= shepardWeight; + } + + } // end loop over i + + if (vflag_fdotr) + virial_fdotr_compute(); } /* ---------------------------------------------------------------------- @@ -701,181 +701,181 @@ void PairTlsph::ComputeForces(int eflag, int vflag) { shape matrix correction ------------------------------------------------------------------------- */ void PairTlsph::AssembleStress() { - tagint *mol = atom->molecule; - double *eff_plastic_strain = atom->eff_plastic_strain; - double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; - double **tlsph_stress = atom->smd_stress; - int *type = atom->type; - double *radius = atom->radius; - double *damage = atom->damage; - double *rmass = atom->rmass; - double *vfrac = atom->vfrac; - double *e = atom->e; - double pInitial, d_iso, pFinal, p_rate, plastic_strain_increment; - int i, itype; - int nlocal = atom->nlocal; - double dt = update->dt; - double M_eff, p_wave_speed, mass_specific_energy, vol_specific_energy, rho; - Matrix3d sigma_rate, eye, sigmaInitial, sigmaFinal, T, T_damaged, Jaumann_rate, sigma_rate_check; - Matrix3d d_dev, sigmaInitial_dev, sigmaFinal_dev, sigma_dev_rate, strain; - Vector3d x0i, xi, xp; - - eye.setIdentity(); - dtCFL = 1.0e22; - pFinal = 0.0; - - for (i = 0; i < nlocal; i++) { - particle_dt[i] = 0.0; - - itype = type[i]; - if (setflag[itype][itype] == 1) { - if (mol[i] > 0) { // only do the following if particle has not failed -- mol < 0 means particle has failed - - /* - * initial stress state: given by the unrotateted Cauchy stress. - * Assemble Eigen 3d matrix from stored stress state - */ - sigmaInitial(0, 0) = tlsph_stress[i][0]; - sigmaInitial(0, 1) = tlsph_stress[i][1]; - sigmaInitial(0, 2) = tlsph_stress[i][2]; - sigmaInitial(1, 1) = tlsph_stress[i][3]; - sigmaInitial(1, 2) = tlsph_stress[i][4]; - sigmaInitial(2, 2) = tlsph_stress[i][5]; - sigmaInitial(1, 0) = sigmaInitial(0, 1); - sigmaInitial(2, 0) = sigmaInitial(0, 2); - sigmaInitial(2, 1) = sigmaInitial(1, 2); - - //cout << "this is sigma initial" << endl << sigmaInitial << endl; - - pInitial = sigmaInitial.trace() / 3.0; // isotropic part of initial stress - sigmaInitial_dev = Deviator(sigmaInitial); - d_iso = D[i].trace(); // volumetric part of stretch rate - d_dev = Deviator(D[i]); // deviatoric part of stretch rate - strain = 0.5 * (Fincr[i].transpose() * Fincr[i] - eye); - mass_specific_energy = e[i] / rmass[i]; // energy per unit mass - rho = rmass[i] / (detF[i] * vfrac[i]); - vol_specific_energy = mass_specific_energy * rho; // energy per current volume - - /* - * pressure: compute pressure rate p_rate and final pressure pFinal - */ - - ComputePressure(i, rho, mass_specific_energy, vol_specific_energy, pInitial, d_iso, pFinal, p_rate); - - /* - * material strength - */ - - //cout << "this is the strain deviator rate" << endl << d_dev << endl; - ComputeStressDeviator(i, sigmaInitial_dev, d_dev, sigmaFinal_dev, sigma_dev_rate, plastic_strain_increment); - //cout << "this is the stress deviator rate" << endl << sigma_dev_rate << endl; - - // keep a rolling average of the plastic strain rate over the last 100 or so timesteps - eff_plastic_strain[i] += plastic_strain_increment; - - // compute a characteristic time over which to average the plastic strain - double tav = 1000 * radius[i] / (Lookup[SIGNAL_VELOCITY][itype]); - eff_plastic_strain_rate[i] -= eff_plastic_strain_rate[i] * dt / tav; + tagint *mol = atom->molecule; + double *eff_plastic_strain = atom->eff_plastic_strain; + double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; + double **tlsph_stress = atom->smd_stress; + int *type = atom->type; + double *radius = atom->radius; + double *damage = atom->damage; + double *rmass = atom->rmass; + double *vfrac = atom->vfrac; + double *e = atom->e; + double pInitial, d_iso, pFinal, p_rate, plastic_strain_increment; + int i, itype; + int nlocal = atom->nlocal; + double dt = update->dt; + double M_eff, p_wave_speed, mass_specific_energy, vol_specific_energy, rho; + Matrix3d sigma_rate, eye, sigmaInitial, sigmaFinal, T, T_damaged, Jaumann_rate, sigma_rate_check; + Matrix3d d_dev, sigmaInitial_dev, sigmaFinal_dev, sigma_dev_rate, strain; + Vector3d x0i, xi, xp; + + eye.setIdentity(); + dtCFL = 1.0e22; + pFinal = 0.0; + + for (i = 0; i < nlocal; i++) { + particle_dt[i] = 0.0; + + itype = type[i]; + if (setflag[itype][itype] == 1) { + if (mol[i] > 0) { // only do the following if particle has not failed -- mol < 0 means particle has failed + + /* + * initial stress state: given by the unrotateted Cauchy stress. + * Assemble Eigen 3d matrix from stored stress state + */ + sigmaInitial(0, 0) = tlsph_stress[i][0]; + sigmaInitial(0, 1) = tlsph_stress[i][1]; + sigmaInitial(0, 2) = tlsph_stress[i][2]; + sigmaInitial(1, 1) = tlsph_stress[i][3]; + sigmaInitial(1, 2) = tlsph_stress[i][4]; + sigmaInitial(2, 2) = tlsph_stress[i][5]; + sigmaInitial(1, 0) = sigmaInitial(0, 1); + sigmaInitial(2, 0) = sigmaInitial(0, 2); + sigmaInitial(2, 1) = sigmaInitial(1, 2); + + //cout << "this is sigma initial" << endl << sigmaInitial << endl; + + pInitial = sigmaInitial.trace() / 3.0; // isotropic part of initial stress + sigmaInitial_dev = Deviator(sigmaInitial); + d_iso = D[i].trace(); // volumetric part of stretch rate + d_dev = Deviator(D[i]); // deviatoric part of stretch rate + strain = 0.5 * (Fincr[i].transpose() * Fincr[i] - eye); + mass_specific_energy = e[i] / rmass[i]; // energy per unit mass + rho = rmass[i] / (detF[i] * vfrac[i]); + vol_specific_energy = mass_specific_energy * rho; // energy per current volume + + /* + * pressure: compute pressure rate p_rate and final pressure pFinal + */ + + ComputePressure(i, rho, mass_specific_energy, vol_specific_energy, pInitial, d_iso, pFinal, p_rate); + + /* + * material strength + */ + + //cout << "this is the strain deviator rate" << endl << d_dev << endl; + ComputeStressDeviator(i, sigmaInitial_dev, d_dev, sigmaFinal_dev, sigma_dev_rate, plastic_strain_increment); + //cout << "this is the stress deviator rate" << endl << sigma_dev_rate << endl; + + // keep a rolling average of the plastic strain rate over the last 100 or so timesteps + eff_plastic_strain[i] += plastic_strain_increment; + + // compute a characteristic time over which to average the plastic strain + double tav = 1000 * radius[i] / (Lookup[SIGNAL_VELOCITY][itype]); + eff_plastic_strain_rate[i] -= eff_plastic_strain_rate[i] * dt / tav; eff_plastic_strain_rate[i] += plastic_strain_increment / tav; eff_plastic_strain_rate[i] = MAX(0.0, eff_plastic_strain_rate[i]); - /* - * assemble total stress from pressure and deviatoric stress - */ - sigmaFinal = pFinal * eye + sigmaFinal_dev; // this is the stress that is kept - - if (JAUMANN) { - /* - * sigma is already the co-rotated Cauchy stress. - * The stress rate, however, needs to be made objective. - */ - - if (dt > 1.0e-16) { - sigma_rate = (1.0 / dt) * (sigmaFinal - sigmaInitial); - } else { - sigma_rate.setZero(); - } - - Jaumann_rate = sigma_rate + W[i] * sigmaInitial + sigmaInitial * W[i].transpose(); - sigmaFinal = sigmaInitial + dt * Jaumann_rate; - T = sigmaFinal; - } else { - /* - * sigma is the unrotated stress. - * need to do forward rotation of the unrotated stress sigma to the current configuration - */ - T = R[i] * sigmaFinal * R[i].transpose(); - } - - /* - * store unrotated stress in atom vector - * symmetry is exploited - */ - tlsph_stress[i][0] = sigmaFinal(0, 0); - tlsph_stress[i][1] = sigmaFinal(0, 1); - tlsph_stress[i][2] = sigmaFinal(0, 2); - tlsph_stress[i][3] = sigmaFinal(1, 1); - tlsph_stress[i][4] = sigmaFinal(1, 2); - tlsph_stress[i][5] = sigmaFinal(2, 2); - - /* - * Damage due to failure criteria. - */ - - if (failureModel[itype].integration_point_wise) { - ComputeDamage(i, strain, T, T_damaged); - //T = T_damaged; Do not do this, it is undefined as of now - } - - // store rotated, "true" Cauchy stress - CauchyStress[i] = T; - - /* - * We have the corotational Cauchy stress. - * Convert to PK1. Note that reference configuration used for computing the forces is linked via - * the incremental deformation gradient, not the full deformation gradient. - */ - PK1[i] = detF[i] * T * FincrInv[i].transpose(); - - /* - * pre-multiply stress tensor with shape matrix to save computation in force loop - */ - PK1[i] = PK1[i] * K[i]; - - /* - * compute stable time step according to Pronto 2d - */ - - Matrix3d deltaSigma; - deltaSigma = sigmaFinal - sigmaInitial; - p_rate = deltaSigma.trace() / (3.0 * dt + 1.0e-16); - sigma_dev_rate = Deviator(deltaSigma) / (dt + 1.0e-16); - - double K_eff, mu_eff; - effective_longitudinal_modulus(itype, dt, d_iso, p_rate, d_dev, sigma_dev_rate, damage[i], K_eff, mu_eff, M_eff); - p_wave_speed = sqrt(M_eff / rho); - - if (mol[i] < 0) { - error->one(FLERR, "this should not happen"); - } - - particle_dt[i] = 2.0 * radius[i] / p_wave_speed; - dtCFL = MIN(dtCFL, particle_dt[i]); - - } else { // end if mol > 0 - PK1[i].setZero(); - K[i].setIdentity(); - CauchyStress[i].setZero(); - sigma_rate.setZero(); - tlsph_stress[i][0] = 0.0; - tlsph_stress[i][1] = 0.0; - tlsph_stress[i][2] = 0.0; - tlsph_stress[i][3] = 0.0; - tlsph_stress[i][4] = 0.0; - tlsph_stress[i][5] = 0.0; - } // end if mol > 0 - } // end setflag - } // end for + /* + * assemble total stress from pressure and deviatoric stress + */ + sigmaFinal = pFinal * eye + sigmaFinal_dev; // this is the stress that is kept + + if (JAUMANN) { + /* + * sigma is already the co-rotated Cauchy stress. + * The stress rate, however, needs to be made objective. + */ + + if (dt > 1.0e-16) { + sigma_rate = (1.0 / dt) * (sigmaFinal - sigmaInitial); + } else { + sigma_rate.setZero(); + } + + Jaumann_rate = sigma_rate + W[i] * sigmaInitial + sigmaInitial * W[i].transpose(); + sigmaFinal = sigmaInitial + dt * Jaumann_rate; + T = sigmaFinal; + } else { + /* + * sigma is the unrotated stress. + * need to do forward rotation of the unrotated stress sigma to the current configuration + */ + T = R[i] * sigmaFinal * R[i].transpose(); + } + + /* + * store unrotated stress in atom vector + * symmetry is exploited + */ + tlsph_stress[i][0] = sigmaFinal(0, 0); + tlsph_stress[i][1] = sigmaFinal(0, 1); + tlsph_stress[i][2] = sigmaFinal(0, 2); + tlsph_stress[i][3] = sigmaFinal(1, 1); + tlsph_stress[i][4] = sigmaFinal(1, 2); + tlsph_stress[i][5] = sigmaFinal(2, 2); + + /* + * Damage due to failure criteria. + */ + + if (failureModel[itype].integration_point_wise) { + ComputeDamage(i, strain, T, T_damaged); + //T = T_damaged; Do not do this, it is undefined as of now + } + + // store rotated, "true" Cauchy stress + CauchyStress[i] = T; + + /* + * We have the corotational Cauchy stress. + * Convert to PK1. Note that reference configuration used for computing the forces is linked via + * the incremental deformation gradient, not the full deformation gradient. + */ + PK1[i] = detF[i] * T * FincrInv[i].transpose(); + + /* + * pre-multiply stress tensor with shape matrix to save computation in force loop + */ + PK1[i] = PK1[i] * K[i]; + + /* + * compute stable time step according to Pronto 2d + */ + + Matrix3d deltaSigma; + deltaSigma = sigmaFinal - sigmaInitial; + p_rate = deltaSigma.trace() / (3.0 * dt + 1.0e-16); + sigma_dev_rate = Deviator(deltaSigma) / (dt + 1.0e-16); + + double K_eff, mu_eff; + effective_longitudinal_modulus(itype, dt, d_iso, p_rate, d_dev, sigma_dev_rate, damage[i], K_eff, mu_eff, M_eff); + p_wave_speed = sqrt(M_eff / rho); + + if (mol[i] < 0) { + error->one(FLERR, "this should not happen"); + } + + particle_dt[i] = 2.0 * radius[i] / p_wave_speed; + dtCFL = MIN(dtCFL, particle_dt[i]); + + } else { // end if mol > 0 + PK1[i].setZero(); + K[i].setIdentity(); + CauchyStress[i].setZero(); + sigma_rate.setZero(); + tlsph_stress[i][0] = 0.0; + tlsph_stress[i][1] = 0.0; + tlsph_stress[i][2] = 0.0; + tlsph_stress[i][3] = 0.0; + tlsph_stress[i][4] = 0.0; + tlsph_stress[i][5] = 0.0; + } // end if mol > 0 + } // end setflag + } // end for } /* ---------------------------------------------------------------------- @@ -883,25 +883,25 @@ void PairTlsph::AssembleStress() { ------------------------------------------------------------------------- */ void PairTlsph::allocate() { - allocated = 1; - int n = atom->ntypes; + allocated = 1; + int n = atom->ntypes; - memory->create(setflag, n + 1, n + 1, "pair:setflag"); - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; + memory->create(setflag, n + 1, n + 1, "pair:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; - memory->create(strengthModel, n + 1, "pair:strengthmodel"); - memory->create(eos, n + 1, "pair:eosmodel"); - failureModel = new failure_types[n + 1]; - memory->create(Lookup, MAX_KEY_VALUE, n + 1, "pair:LookupTable"); + memory->create(strengthModel, n + 1, "pair:strengthmodel"); + memory->create(eos, n + 1, "pair:eosmodel"); + failureModel = new failure_types[n + 1]; + memory->create(Lookup, MAX_KEY_VALUE, n + 1, "pair:LookupTable"); - memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); // always needs to be allocated, even with granular neighborlist + memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); // always needs to be allocated, even with granular neighborlist - onerad_dynamic = new double[n + 1]; - onerad_frozen = new double[n + 1]; - maxrad_dynamic = new double[n + 1]; - maxrad_frozen = new double[n + 1]; + onerad_dynamic = new double[n + 1]; + onerad_frozen = new double[n + 1]; + maxrad_dynamic = new double[n + 1]; + maxrad_frozen = new double[n + 1]; } @@ -911,82 +911,82 @@ void PairTlsph::allocate() { void PairTlsph::settings(int narg, char **arg) { - if (comm->me == 0) { - printf( - "\n>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========\n"); - printf("TLSPH settings\n"); - } - - /* - * default value for update_threshold for updates of reference configuration: - * The maximum relative displacement which is tracked by the construction of LAMMPS' neighborlists - * is the folowing. - */ - - cut_comm = MAX(neighbor->cutneighmax, comm->cutghostuser); // cutoff radius within which ghost atoms are communicated. - update_threshold = cut_comm; - update_method = UPDATE_NONE; - - int iarg = 0; - - while (true) { - - if (iarg >= narg) { - break; - } - - if (strcmp(arg[iarg], "*UPDATE_CONSTANT") == 0) { - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected number following *UPDATE_CONSTANT keyword"); - } - - update_method = UPDATE_CONSTANT_THRESHOLD; - update_threshold = force->numeric(FLERR, arg[iarg]); - - } else if (strcmp(arg[iarg], "*UPDATE_PAIRWISE") == 0) { - iarg++; - if (iarg == narg) { - error->all(FLERR, "expected number following *UPDATE_PAIRWISE keyword"); - } - - update_method = UPDATE_PAIRWISE_RATIO; - update_threshold = force->numeric(FLERR, arg[iarg]); - - } else { - char msg[128]; - sprintf(msg, "Illegal keyword for smd/integrate_tlsph: %s\n", arg[iarg]); - error->all(FLERR, msg); - } - - iarg++; - } - - if ((update_threshold > cut_comm) && (update_method == UPDATE_CONSTANT_THRESHOLD)) { - if (comm->me == 0) { - printf("\n ***** WARNING ***\n"); - printf("requested reference configuration update threshold is %g length units\n", update_threshold); - printf("This value exceeds the maximum value %g beyond which TLSPH displacements can be tracked at current settings.\n", - cut_comm); - printf("Expect loss of neighbors!\n"); - } - } - - if (comm->me == 0) { - - if (update_method == UPDATE_CONSTANT_THRESHOLD) { - printf("... will update reference configuration if magnitude of relative displacement exceeds %g length units\n", - update_threshold); - } else if (update_method == UPDATE_PAIRWISE_RATIO) { - printf("... will update reference configuration if ratio pairwise distance / smoothing length exceeds %g\n", - update_threshold); - } else if (update_method == UPDATE_NONE) { - printf("... will never update reference configuration"); - } - printf( - ">>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========\n"); - - } + if (comm->me == 0) { + printf( + "\n>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========\n"); + printf("TLSPH settings\n"); + } + + /* + * default value for update_threshold for updates of reference configuration: + * The maximum relative displacement which is tracked by the construction of LAMMPS' neighborlists + * is the folowing. + */ + + cut_comm = MAX(neighbor->cutneighmax, comm->cutghostuser); // cutoff radius within which ghost atoms are communicated. + update_threshold = cut_comm; + update_method = UPDATE_NONE; + + int iarg = 0; + + while (true) { + + if (iarg >= narg) { + break; + } + + if (strcmp(arg[iarg], "*UPDATE_CONSTANT") == 0) { + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected number following *UPDATE_CONSTANT keyword"); + } + + update_method = UPDATE_CONSTANT_THRESHOLD; + update_threshold = force->numeric(FLERR, arg[iarg]); + + } else if (strcmp(arg[iarg], "*UPDATE_PAIRWISE") == 0) { + iarg++; + if (iarg == narg) { + error->all(FLERR, "expected number following *UPDATE_PAIRWISE keyword"); + } + + update_method = UPDATE_PAIRWISE_RATIO; + update_threshold = force->numeric(FLERR, arg[iarg]); + + } else { + char msg[128]; + sprintf(msg, "Illegal keyword for smd/integrate_tlsph: %s\n", arg[iarg]); + error->all(FLERR, msg); + } + + iarg++; + } + + if ((update_threshold > cut_comm) && (update_method == UPDATE_CONSTANT_THRESHOLD)) { + if (comm->me == 0) { + printf("\n ***** WARNING ***\n"); + printf("requested reference configuration update threshold is %g length units\n", update_threshold); + printf("This value exceeds the maximum value %g beyond which TLSPH displacements can be tracked at current settings.\n", + cut_comm); + printf("Expect loss of neighbors!\n"); + } + } + + if (comm->me == 0) { + + if (update_method == UPDATE_CONSTANT_THRESHOLD) { + printf("... will update reference configuration if magnitude of relative displacement exceeds %g length units\n", + update_threshold); + } else if (update_method == UPDATE_PAIRWISE_RATIO) { + printf("... will update reference configuration if ratio pairwise distance / smoothing length exceeds %g\n", + update_threshold); + } else if (update_method == UPDATE_NONE) { + printf("... will never update reference configuration"); + } + printf( + ">>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========\n"); + + } } @@ -995,701 +995,701 @@ void PairTlsph::settings(int narg, char **arg) { ------------------------------------------------------------------------- */ void PairTlsph::coeff(int narg, char **arg) { - int ioffset, iarg, iNextKwd, itype; - char str[128]; - std::string s, t; - - if (narg < 3) { - sprintf(str, "number of arguments for pair tlsph is too small!"); - error->all(FLERR, str); - } - if (!allocated) - allocate(); - - /* - * check that TLSPH parameters are given only in i,i form - */ - if (force->inumeric(FLERR, arg[0]) != force->inumeric(FLERR, arg[1])) { - sprintf(str, "TLSPH coefficients can only be specified between particles of same type!"); - error->all(FLERR, str); - } - itype = force->inumeric(FLERR, arg[0]); + int ioffset, iarg, iNextKwd, itype; + char str[128]; + std::string s, t; + + if (narg < 3) { + sprintf(str, "number of arguments for pair tlsph is too small!"); + error->all(FLERR, str); + } + if (!allocated) + allocate(); + + /* + * check that TLSPH parameters are given only in i,i form + */ + if (force->inumeric(FLERR, arg[0]) != force->inumeric(FLERR, arg[1])) { + sprintf(str, "TLSPH coefficients can only be specified between particles of same type!"); + error->all(FLERR, str); + } + itype = force->inumeric(FLERR, arg[0]); // set all eos, strength and failure models to inactive by default - eos[itype] = EOS_NONE; - strengthModel[itype] = STRENGTH_NONE; - - if (comm->me == 0) { - printf( - "\n>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========\n"); - printf("SMD / TLSPH PROPERTIES OF PARTICLE TYPE %d:\n", itype); - } - - /* - * read parameters which are common -- regardless of material / eos model - */ - - ioffset = 2; - if (strcmp(arg[ioffset], "*COMMON") != 0) { - sprintf(str, "common keyword missing!"); - error->all(FLERR, str); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } + eos[itype] = EOS_NONE; + strengthModel[itype] = STRENGTH_NONE; + + if (comm->me == 0) { + printf( + "\n>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========\n"); + printf("SMD / TLSPH PROPERTIES OF PARTICLE TYPE %d:\n", itype); + } + + /* + * read parameters which are common -- regardless of material / eos model + */ + + ioffset = 2; + if (strcmp(arg[ioffset], "*COMMON") != 0) { + sprintf(str, "common keyword missing!"); + error->all(FLERR, str); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } //printf("keyword following *COMMON is %s\n", arg[iNextKwd]); - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *COMMON"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 7 + 1) { - sprintf(str, "expected 7 arguments following *COMMON but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[REFERENCE_DENSITY][itype] = force->numeric(FLERR, arg[ioffset + 1]); - Lookup[YOUNGS_MODULUS][itype] = force->numeric(FLERR, arg[ioffset + 2]); - Lookup[POISSON_RATIO][itype] = force->numeric(FLERR, arg[ioffset + 3]); - Lookup[VISCOSITY_Q1][itype] = force->numeric(FLERR, arg[ioffset + 4]); - Lookup[VISCOSITY_Q2][itype] = force->numeric(FLERR, arg[ioffset + 5]); - Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype] = force->numeric(FLERR, arg[ioffset + 6]); - Lookup[HEAT_CAPACITY][itype] = force->numeric(FLERR, arg[ioffset + 7]); - - Lookup[LAME_LAMBDA][itype] = Lookup[YOUNGS_MODULUS][itype] * Lookup[POISSON_RATIO][itype] - / ((1.0 + Lookup[POISSON_RATIO][itype]) * (1.0 - 2.0 * Lookup[POISSON_RATIO][itype])); - Lookup[SHEAR_MODULUS][itype] = Lookup[YOUNGS_MODULUS][itype] / (2.0 * (1.0 + Lookup[POISSON_RATIO][itype])); - Lookup[M_MODULUS][itype] = Lookup[LAME_LAMBDA][itype] + 2.0 * Lookup[SHEAR_MODULUS][itype]; - Lookup[SIGNAL_VELOCITY][itype] = sqrt( - (Lookup[LAME_LAMBDA][itype] + 2.0 * Lookup[SHEAR_MODULUS][itype]) / Lookup[REFERENCE_DENSITY][itype]); - Lookup[BULK_MODULUS][itype] = Lookup[LAME_LAMBDA][itype] + 2.0 * Lookup[SHEAR_MODULUS][itype] / 3.0; - - if (comm->me == 0) { - printf("\n material unspecific properties for SMD/TLSPH definition of particle type %d:\n", itype); - printf("%60s : %g\n", "reference density", Lookup[REFERENCE_DENSITY][itype]); - printf("%60s : %g\n", "Young's modulus", Lookup[YOUNGS_MODULUS][itype]); - printf("%60s : %g\n", "Poisson ratio", Lookup[POISSON_RATIO][itype]); - printf("%60s : %g\n", "linear viscosity coefficient", Lookup[VISCOSITY_Q1][itype]); - printf("%60s : %g\n", "quadratic viscosity coefficient", Lookup[VISCOSITY_Q2][itype]); - printf("%60s : %g\n", "hourglass control coefficient", Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype]); - printf("%60s : %g\n", "heat capacity [energy / (mass * temperature)]", Lookup[HEAT_CAPACITY][itype]); - printf("%60s : %g\n", "Lame constant lambda", Lookup[LAME_LAMBDA][itype]); - printf("%60s : %g\n", "shear modulus", Lookup[SHEAR_MODULUS][itype]); - printf("%60s : %g\n", "bulk modulus", Lookup[BULK_MODULUS][itype]); - printf("%60s : %g\n", "signal velocity", Lookup[SIGNAL_VELOCITY][itype]); - - } - - /* - * read following material cards - */ + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *COMMON"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 7 + 1) { + sprintf(str, "expected 7 arguments following *COMMON but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[REFERENCE_DENSITY][itype] = force->numeric(FLERR, arg[ioffset + 1]); + Lookup[YOUNGS_MODULUS][itype] = force->numeric(FLERR, arg[ioffset + 2]); + Lookup[POISSON_RATIO][itype] = force->numeric(FLERR, arg[ioffset + 3]); + Lookup[VISCOSITY_Q1][itype] = force->numeric(FLERR, arg[ioffset + 4]); + Lookup[VISCOSITY_Q2][itype] = force->numeric(FLERR, arg[ioffset + 5]); + Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype] = force->numeric(FLERR, arg[ioffset + 6]); + Lookup[HEAT_CAPACITY][itype] = force->numeric(FLERR, arg[ioffset + 7]); + + Lookup[LAME_LAMBDA][itype] = Lookup[YOUNGS_MODULUS][itype] * Lookup[POISSON_RATIO][itype] + / ((1.0 + Lookup[POISSON_RATIO][itype]) * (1.0 - 2.0 * Lookup[POISSON_RATIO][itype])); + Lookup[SHEAR_MODULUS][itype] = Lookup[YOUNGS_MODULUS][itype] / (2.0 * (1.0 + Lookup[POISSON_RATIO][itype])); + Lookup[M_MODULUS][itype] = Lookup[LAME_LAMBDA][itype] + 2.0 * Lookup[SHEAR_MODULUS][itype]; + Lookup[SIGNAL_VELOCITY][itype] = sqrt( + (Lookup[LAME_LAMBDA][itype] + 2.0 * Lookup[SHEAR_MODULUS][itype]) / Lookup[REFERENCE_DENSITY][itype]); + Lookup[BULK_MODULUS][itype] = Lookup[LAME_LAMBDA][itype] + 2.0 * Lookup[SHEAR_MODULUS][itype] / 3.0; + + if (comm->me == 0) { + printf("\n material unspecific properties for SMD/TLSPH definition of particle type %d:\n", itype); + printf("%60s : %g\n", "reference density", Lookup[REFERENCE_DENSITY][itype]); + printf("%60s : %g\n", "Young's modulus", Lookup[YOUNGS_MODULUS][itype]); + printf("%60s : %g\n", "Poisson ratio", Lookup[POISSON_RATIO][itype]); + printf("%60s : %g\n", "linear viscosity coefficient", Lookup[VISCOSITY_Q1][itype]); + printf("%60s : %g\n", "quadratic viscosity coefficient", Lookup[VISCOSITY_Q2][itype]); + printf("%60s : %g\n", "hourglass control coefficient", Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype]); + printf("%60s : %g\n", "heat capacity [energy / (mass * temperature)]", Lookup[HEAT_CAPACITY][itype]); + printf("%60s : %g\n", "Lame constant lambda", Lookup[LAME_LAMBDA][itype]); + printf("%60s : %g\n", "shear modulus", Lookup[SHEAR_MODULUS][itype]); + printf("%60s : %g\n", "bulk modulus", Lookup[BULK_MODULUS][itype]); + printf("%60s : %g\n", "signal velocity", Lookup[SIGNAL_VELOCITY][itype]); + + } + + /* + * read following material cards + */ //printf("next kwd is %s\n", arg[iNextKwd]); - eos[itype] = EOS_NONE; - strengthModel[itype] = STRENGTH_NONE; - - while (true) { - if (strcmp(arg[iNextKwd], "*END") == 0) { - if (comm->me == 0) { - printf("found *END keyword"); - printf( - "\n>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========\n\n"); - } - break; - } - - /* - * Linear Elasticity model based on deformation gradient - */ - ioffset = iNextKwd; - if (strcmp(arg[ioffset], "*LINEAR_DEFGRAD") == 0) { - strengthModel[itype] = LINEAR_DEFGRAD; - - if (comm->me == 0) { - printf("reading *LINEAR_DEFGRAD\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *LINEAR_DEFGRAD"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1) { - sprintf(str, "expected 0 arguments following *LINEAR_DEFGRAD but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - if (comm->me == 0) { - printf("\n%60s\n", "Linear Elasticity model based on deformation gradient"); - } - } else if (strcmp(arg[ioffset], "*STRENGTH_LINEAR") == 0) { - - /* - * Linear Elasticity strength only model based on strain rate - */ - - strengthModel[itype] = STRENGTH_LINEAR; - if (comm->me == 0) { - printf("reading *STRENGTH_LINEAR\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *STRENGTH_LINEAR"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1) { - sprintf(str, "expected 0 arguments following *STRENGTH_LINEAR but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - if (comm->me == 0) { - printf("%60s\n", "Linear Elasticity strength based on strain rate"); - } - } // end Linear Elasticity strength only model based on strain rate - - else if (strcmp(arg[ioffset], "*STRENGTH_LINEAR_PLASTIC") == 0) { - - /* - * Linear Elastic / perfectly plastic strength only model based on strain rate - */ - - strengthModel[itype] = STRENGTH_LINEAR_PLASTIC; - if (comm->me == 0) { - printf("reading *STRENGTH_LINEAR_PLASTIC\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *STRENGTH_LINEAR_PLASTIC"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 2 + 1) { - sprintf(str, "expected 2 arguments following *STRENGTH_LINEAR_PLASTIC but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[YIELD_STRESS][itype] = force->numeric(FLERR, arg[ioffset + 1]); - Lookup[HARDENING_PARAMETER][itype] = force->numeric(FLERR, arg[ioffset + 2]); - - if (comm->me == 0) { - printf("%60s\n", "Linear elastic / perfectly plastic strength based on strain rate"); - printf("%60s : %g\n", "Young's modulus", Lookup[YOUNGS_MODULUS][itype]); - printf("%60s : %g\n", "Poisson ratio", Lookup[POISSON_RATIO][itype]); - printf("%60s : %g\n", "shear modulus", Lookup[SHEAR_MODULUS][itype]); - printf("%60s : %g\n", "constant yield stress", Lookup[YIELD_STRESS][itype]); - printf("%60s : %g\n", "constant hardening parameter", Lookup[HARDENING_PARAMETER][itype]); - } - } // end Linear Elastic / perfectly plastic strength only model based on strain rate - - else if (strcmp(arg[ioffset], "*JOHNSON_COOK") == 0) { - - /* - * JOHNSON - COOK - */ - - strengthModel[itype] = STRENGTH_JOHNSON_COOK; - if (comm->me == 0) { - printf("reading *JOHNSON_COOK\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *JOHNSON_COOK"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 8 + 1) { - sprintf(str, "expected 8 arguments following *JOHNSON_COOK but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[JC_A][itype] = force->numeric(FLERR, arg[ioffset + 1]); - Lookup[JC_B][itype] = force->numeric(FLERR, arg[ioffset + 2]); - Lookup[JC_a][itype] = force->numeric(FLERR, arg[ioffset + 3]); - Lookup[JC_C][itype] = force->numeric(FLERR, arg[ioffset + 4]); - Lookup[JC_epdot0][itype] = force->numeric(FLERR, arg[ioffset + 5]); - Lookup[JC_T0][itype] = force->numeric(FLERR, arg[ioffset + 6]); - Lookup[JC_Tmelt][itype] = force->numeric(FLERR, arg[ioffset + 7]); - Lookup[JC_M][itype] = force->numeric(FLERR, arg[ioffset + 8]); - - if (comm->me == 0) { - printf("%60s\n", "Johnson Cook material strength model"); - printf("%60s : %g\n", "A: initial yield stress", Lookup[JC_A][itype]); - printf("%60s : %g\n", "B : proportionality factor for plastic strain dependency", Lookup[JC_B][itype]); - printf("%60s : %g\n", "a : exponent for plastic strain dependency", Lookup[JC_a][itype]); - printf("%60s : %g\n", "C : proportionality factor for logarithmic plastic strain rate dependency", - Lookup[JC_C][itype]); - printf("%60s : %g\n", "epdot0 : dimensionality factor for plastic strain rate dependency", - Lookup[JC_epdot0][itype]); - printf("%60s : %g\n", "T0 : reference (room) temperature", Lookup[JC_T0][itype]); - printf("%60s : %g\n", "Tmelt : melting temperature", Lookup[JC_Tmelt][itype]); - printf("%60s : %g\n", "M : exponent for temperature dependency", Lookup[JC_M][itype]); - } - - } else if (strcmp(arg[ioffset], "*EOS_NONE") == 0) { - - /* - * no eos - */ - - eos[itype] = EOS_NONE; - if (comm->me == 0) { - printf("reading *EOS_NONE\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *EOS_NONE"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1) { - sprintf(str, "expected 0 arguments following *EOS_NONE but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - if (comm->me == 0) { - printf("\n%60s\n", "no EOS selected"); - } - - } else if (strcmp(arg[ioffset], "*EOS_LINEAR") == 0) { - - /* - * linear eos - */ - - eos[itype] = EOS_LINEAR; - if (comm->me == 0) { - printf("reading *EOS_LINEAR\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *EOS_LINEAR"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1) { - sprintf(str, "expected 0 arguments following *EOS_LINEAR but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - if (comm->me == 0) { - printf("\n%60s\n", "linear EOS based on strain rate"); - printf("%60s : %g\n", "bulk modulus", Lookup[BULK_MODULUS][itype]); - } - } // end linear eos - else if (strcmp(arg[ioffset], "*EOS_SHOCK") == 0) { - - /* - * shock eos - */ - - eos[itype] = EOS_SHOCK; - if (comm->me == 0) { - printf("reading *EOS_SHOCK\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *EOS_SHOCK"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 3 + 1) { - sprintf(str, "expected 3 arguments (c0, S, Gamma) following *EOS_SHOCK but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[EOS_SHOCK_C0][itype] = force->numeric(FLERR, arg[ioffset + 1]); - Lookup[EOS_SHOCK_S][itype] = force->numeric(FLERR, arg[ioffset + 2]); - Lookup[EOS_SHOCK_GAMMA][itype] = force->numeric(FLERR, arg[ioffset + 3]); - if (comm->me == 0) { - printf("\n%60s\n", "shock EOS based on strain rate"); - printf("%60s : %g\n", "reference speed of sound", Lookup[EOS_SHOCK_C0][itype]); - printf("%60s : %g\n", "Hugoniot parameter S", Lookup[EOS_SHOCK_S][itype]); - printf("%60s : %g\n", "Grueneisen Gamma", Lookup[EOS_SHOCK_GAMMA][itype]); - } - } // end shock eos - - else if (strcmp(arg[ioffset], "*EOS_POLYNOMIAL") == 0) { - /* - * polynomial eos - */ - - eos[itype] = EOS_POLYNOMIAL; - if (comm->me == 0) { - printf("reading *EOS_POLYNOMIAL\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *EOS_POLYNOMIAL"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 7 + 1) { - sprintf(str, "expected 7 arguments following *EOS_POLYNOMIAL but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[EOS_POLYNOMIAL_C0][itype] = force->numeric(FLERR, arg[ioffset + 1]); - Lookup[EOS_POLYNOMIAL_C1][itype] = force->numeric(FLERR, arg[ioffset + 2]); - Lookup[EOS_POLYNOMIAL_C2][itype] = force->numeric(FLERR, arg[ioffset + 3]); - Lookup[EOS_POLYNOMIAL_C3][itype] = force->numeric(FLERR, arg[ioffset + 4]); - Lookup[EOS_POLYNOMIAL_C4][itype] = force->numeric(FLERR, arg[ioffset + 5]); - Lookup[EOS_POLYNOMIAL_C5][itype] = force->numeric(FLERR, arg[ioffset + 6]); - Lookup[EOS_POLYNOMIAL_C6][itype] = force->numeric(FLERR, arg[ioffset + 7]); - if (comm->me == 0) { - printf("\n%60s\n", "polynomial EOS based on strain rate"); - printf("%60s : %g\n", "parameter c0", Lookup[EOS_POLYNOMIAL_C0][itype]); - printf("%60s : %g\n", "parameter c1", Lookup[EOS_POLYNOMIAL_C1][itype]); - printf("%60s : %g\n", "parameter c2", Lookup[EOS_POLYNOMIAL_C2][itype]); - printf("%60s : %g\n", "parameter c3", Lookup[EOS_POLYNOMIAL_C3][itype]); - printf("%60s : %g\n", "parameter c4", Lookup[EOS_POLYNOMIAL_C4][itype]); - printf("%60s : %g\n", "parameter c5", Lookup[EOS_POLYNOMIAL_C5][itype]); - printf("%60s : %g\n", "parameter c6", Lookup[EOS_POLYNOMIAL_C6][itype]); - } - } // end polynomial eos - - else if (strcmp(arg[ioffset], "*FAILURE_MAX_PLASTIC_STRAIN") == 0) { - - /* - * maximum plastic strain failure criterion - */ - - if (comm->me == 0) { - printf("reading *FAILURE_MAX_PLASTIC_SRTRAIN\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *FAILURE_MAX_PLASTIC_STRAIN"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *FAILURE_MAX_PLASTIC_STRAIN but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - failureModel[itype].failure_max_plastic_strain = true; - failureModel[itype].integration_point_wise = true; - Lookup[FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf("\n%60s\n", "maximum plastic strain failure criterion"); - printf("%60s : %g\n", "failure occurs when plastic strain reaches limit", - Lookup[FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD][itype]); - } - } // end maximum plastic strain failure criterion - else if (strcmp(arg[ioffset], "*FAILURE_MAX_PAIRWISE_STRAIN") == 0) { - - /* - * failure criterion based on maximum strain between a pair of TLSPH particles. - */ - - if (comm->me == 0) { - printf("reading *FAILURE_MAX_PAIRWISE_STRAIN\n"); - } - - if (update_method != UPDATE_NONE) { - error->all(FLERR, "cannot use *FAILURE_MAX_PAIRWISE_STRAIN with updated Total-Lagrangian formalism"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *FAILURE_MAX_PAIRWISE_STRAIN"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *FAILURE_MAX_PAIRWISE_STRAIN but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - failureModel[itype].failure_max_pairwise_strain = true; - failureModel[itype].integration_point_wise = true; - Lookup[FAILURE_MAX_PAIRWISE_STRAIN_THRESHOLD][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf("\n%60s\n", "maximum pairwise strain failure criterion"); - printf("%60s : %g\n", "failure occurs when pairwise strain reaches limit", - Lookup[FAILURE_MAX_PAIRWISE_STRAIN_THRESHOLD][itype]); - } - } // end pair based maximum strain failure criterion - else if (strcmp(arg[ioffset], "*FAILURE_MAX_PRINCIPAL_STRAIN") == 0) { - error->all(FLERR, "this failure model is currently unsupported"); - - /* - * maximum principal strain failure criterion - */ - if (comm->me == 0) { - printf("reading *FAILURE_MAX_PRINCIPAL_STRAIN\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *FAILURE_MAX_PRINCIPAL_STRAIN"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *FAILURE_MAX_PRINCIPAL_STRAIN but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - failureModel[itype].failure_max_principal_strain = true; - failureModel[itype].integration_point_wise = true; - Lookup[FAILURE_MAX_PRINCIPAL_STRAIN_THRESHOLD][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf("\n%60s\n", "maximum principal strain failure criterion"); - printf("%60s : %g\n", "failure occurs when principal strain reaches limit", - Lookup[FAILURE_MAX_PRINCIPAL_STRAIN_THRESHOLD][itype]); - } - } // end maximum principal strain failure criterion - else if (strcmp(arg[ioffset], "*FAILURE_JOHNSON_COOK") == 0) { - error->all(FLERR, "this failure model is currently unsupported"); - if (comm->me == 0) { - printf("reading *FAILURE_JOHNSON_COOK\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *FAILURE_JOHNSON_COOK"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 5 + 1) { - sprintf(str, "expected 5 arguments following *FAILURE_JOHNSON_COOK but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - failureModel[itype].failure_johnson_cook = true; - failureModel[itype].integration_point_wise = true; - - Lookup[FAILURE_JC_D1][itype] = force->numeric(FLERR, arg[ioffset + 1]); - Lookup[FAILURE_JC_D2][itype] = force->numeric(FLERR, arg[ioffset + 2]); - Lookup[FAILURE_JC_D3][itype] = force->numeric(FLERR, arg[ioffset + 3]); - Lookup[FAILURE_JC_D4][itype] = force->numeric(FLERR, arg[ioffset + 4]); - Lookup[FAILURE_JC_EPDOT0][itype] = force->numeric(FLERR, arg[ioffset + 5]); - - if (comm->me == 0) { - printf("\n%60s\n", "Johnson-Cook failure criterion"); - printf("%60s : %g\n", "parameter d1", Lookup[FAILURE_JC_D1][itype]); - printf("%60s : %g\n", "parameter d2", Lookup[FAILURE_JC_D2][itype]); - printf("%60s : %g\n", "parameter d3", Lookup[FAILURE_JC_D3][itype]); - printf("%60s : %g\n", "parameter d4", Lookup[FAILURE_JC_D4][itype]); - printf("%60s : %g\n", "reference plastic strain rate", Lookup[FAILURE_JC_EPDOT0][itype]); - } - - } else if (strcmp(arg[ioffset], "*FAILURE_MAX_PRINCIPAL_STRESS") == 0) { - error->all(FLERR, "this failure model is currently unsupported"); - - /* - * maximum principal stress failure criterion - */ - - if (comm->me == 0) { - printf("reading *FAILURE_MAX_PRINCIPAL_STRESS\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *FAILURE_MAX_PRINCIPAL_STRESS"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *FAILURE_MAX_PRINCIPAL_STRESS but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - failureModel[itype].failure_max_principal_stress = true; - failureModel[itype].integration_point_wise = true; - Lookup[FAILURE_MAX_PRINCIPAL_STRESS_THRESHOLD][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf("\n%60s\n", "maximum principal stress failure criterion"); - printf("%60s : %g\n", "failure occurs when principal stress reaches limit", - Lookup[FAILURE_MAX_PRINCIPAL_STRESS_THRESHOLD][itype]); - } - } // end maximum principal stress failure criterion - - else if (strcmp(arg[ioffset], "*FAILURE_ENERGY_RELEASE_RATE") == 0) { - if (comm->me == 0) { - printf("reading *FAILURE_ENERGY_RELEASE_RATE\n"); - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *FAILURE_ENERGY_RELEASE_RATE"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *FAILURE_ENERGY_RELEASE_RATE but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - failureModel[itype].failure_energy_release_rate = true; - Lookup[CRITICAL_ENERGY_RELEASE_RATE][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf("\n%60s\n", "critical energy release rate failure criterion"); - printf("%60s : %g\n", "failure occurs when energy release rate reaches limit", - Lookup[CRITICAL_ENERGY_RELEASE_RATE][itype]); - } - } // end energy release rate failure criterion - - else { - sprintf(str, "unknown *KEYWORD: %s", arg[ioffset]); - error->all(FLERR, str); - } - - } - - setflag[itype][itype] = 1; + eos[itype] = EOS_NONE; + strengthModel[itype] = STRENGTH_NONE; + + while (true) { + if (strcmp(arg[iNextKwd], "*END") == 0) { + if (comm->me == 0) { + printf("found *END keyword"); + printf( + "\n>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========>>========\n\n"); + } + break; + } + + /* + * Linear Elasticity model based on deformation gradient + */ + ioffset = iNextKwd; + if (strcmp(arg[ioffset], "*LINEAR_DEFGRAD") == 0) { + strengthModel[itype] = LINEAR_DEFGRAD; + + if (comm->me == 0) { + printf("reading *LINEAR_DEFGRAD\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *LINEAR_DEFGRAD"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1) { + sprintf(str, "expected 0 arguments following *LINEAR_DEFGRAD but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + if (comm->me == 0) { + printf("\n%60s\n", "Linear Elasticity model based on deformation gradient"); + } + } else if (strcmp(arg[ioffset], "*STRENGTH_LINEAR") == 0) { + + /* + * Linear Elasticity strength only model based on strain rate + */ + + strengthModel[itype] = STRENGTH_LINEAR; + if (comm->me == 0) { + printf("reading *STRENGTH_LINEAR\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *STRENGTH_LINEAR"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1) { + sprintf(str, "expected 0 arguments following *STRENGTH_LINEAR but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + if (comm->me == 0) { + printf("%60s\n", "Linear Elasticity strength based on strain rate"); + } + } // end Linear Elasticity strength only model based on strain rate + + else if (strcmp(arg[ioffset], "*STRENGTH_LINEAR_PLASTIC") == 0) { + + /* + * Linear Elastic / perfectly plastic strength only model based on strain rate + */ + + strengthModel[itype] = STRENGTH_LINEAR_PLASTIC; + if (comm->me == 0) { + printf("reading *STRENGTH_LINEAR_PLASTIC\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *STRENGTH_LINEAR_PLASTIC"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 2 + 1) { + sprintf(str, "expected 2 arguments following *STRENGTH_LINEAR_PLASTIC but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[YIELD_STRESS][itype] = force->numeric(FLERR, arg[ioffset + 1]); + Lookup[HARDENING_PARAMETER][itype] = force->numeric(FLERR, arg[ioffset + 2]); + + if (comm->me == 0) { + printf("%60s\n", "Linear elastic / perfectly plastic strength based on strain rate"); + printf("%60s : %g\n", "Young's modulus", Lookup[YOUNGS_MODULUS][itype]); + printf("%60s : %g\n", "Poisson ratio", Lookup[POISSON_RATIO][itype]); + printf("%60s : %g\n", "shear modulus", Lookup[SHEAR_MODULUS][itype]); + printf("%60s : %g\n", "constant yield stress", Lookup[YIELD_STRESS][itype]); + printf("%60s : %g\n", "constant hardening parameter", Lookup[HARDENING_PARAMETER][itype]); + } + } // end Linear Elastic / perfectly plastic strength only model based on strain rate + + else if (strcmp(arg[ioffset], "*JOHNSON_COOK") == 0) { + + /* + * JOHNSON - COOK + */ + + strengthModel[itype] = STRENGTH_JOHNSON_COOK; + if (comm->me == 0) { + printf("reading *JOHNSON_COOK\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *JOHNSON_COOK"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 8 + 1) { + sprintf(str, "expected 8 arguments following *JOHNSON_COOK but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[JC_A][itype] = force->numeric(FLERR, arg[ioffset + 1]); + Lookup[JC_B][itype] = force->numeric(FLERR, arg[ioffset + 2]); + Lookup[JC_a][itype] = force->numeric(FLERR, arg[ioffset + 3]); + Lookup[JC_C][itype] = force->numeric(FLERR, arg[ioffset + 4]); + Lookup[JC_epdot0][itype] = force->numeric(FLERR, arg[ioffset + 5]); + Lookup[JC_T0][itype] = force->numeric(FLERR, arg[ioffset + 6]); + Lookup[JC_Tmelt][itype] = force->numeric(FLERR, arg[ioffset + 7]); + Lookup[JC_M][itype] = force->numeric(FLERR, arg[ioffset + 8]); + + if (comm->me == 0) { + printf("%60s\n", "Johnson Cook material strength model"); + printf("%60s : %g\n", "A: initial yield stress", Lookup[JC_A][itype]); + printf("%60s : %g\n", "B : proportionality factor for plastic strain dependency", Lookup[JC_B][itype]); + printf("%60s : %g\n", "a : exponent for plastic strain dependency", Lookup[JC_a][itype]); + printf("%60s : %g\n", "C : proportionality factor for logarithmic plastic strain rate dependency", + Lookup[JC_C][itype]); + printf("%60s : %g\n", "epdot0 : dimensionality factor for plastic strain rate dependency", + Lookup[JC_epdot0][itype]); + printf("%60s : %g\n", "T0 : reference (room) temperature", Lookup[JC_T0][itype]); + printf("%60s : %g\n", "Tmelt : melting temperature", Lookup[JC_Tmelt][itype]); + printf("%60s : %g\n", "M : exponent for temperature dependency", Lookup[JC_M][itype]); + } + + } else if (strcmp(arg[ioffset], "*EOS_NONE") == 0) { + + /* + * no eos + */ + + eos[itype] = EOS_NONE; + if (comm->me == 0) { + printf("reading *EOS_NONE\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *EOS_NONE"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1) { + sprintf(str, "expected 0 arguments following *EOS_NONE but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + if (comm->me == 0) { + printf("\n%60s\n", "no EOS selected"); + } + + } else if (strcmp(arg[ioffset], "*EOS_LINEAR") == 0) { + + /* + * linear eos + */ + + eos[itype] = EOS_LINEAR; + if (comm->me == 0) { + printf("reading *EOS_LINEAR\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *EOS_LINEAR"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1) { + sprintf(str, "expected 0 arguments following *EOS_LINEAR but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + if (comm->me == 0) { + printf("\n%60s\n", "linear EOS based on strain rate"); + printf("%60s : %g\n", "bulk modulus", Lookup[BULK_MODULUS][itype]); + } + } // end linear eos + else if (strcmp(arg[ioffset], "*EOS_SHOCK") == 0) { + + /* + * shock eos + */ + + eos[itype] = EOS_SHOCK; + if (comm->me == 0) { + printf("reading *EOS_SHOCK\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *EOS_SHOCK"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 3 + 1) { + sprintf(str, "expected 3 arguments (c0, S, Gamma) following *EOS_SHOCK but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[EOS_SHOCK_C0][itype] = force->numeric(FLERR, arg[ioffset + 1]); + Lookup[EOS_SHOCK_S][itype] = force->numeric(FLERR, arg[ioffset + 2]); + Lookup[EOS_SHOCK_GAMMA][itype] = force->numeric(FLERR, arg[ioffset + 3]); + if (comm->me == 0) { + printf("\n%60s\n", "shock EOS based on strain rate"); + printf("%60s : %g\n", "reference speed of sound", Lookup[EOS_SHOCK_C0][itype]); + printf("%60s : %g\n", "Hugoniot parameter S", Lookup[EOS_SHOCK_S][itype]); + printf("%60s : %g\n", "Grueneisen Gamma", Lookup[EOS_SHOCK_GAMMA][itype]); + } + } // end shock eos + + else if (strcmp(arg[ioffset], "*EOS_POLYNOMIAL") == 0) { + /* + * polynomial eos + */ + + eos[itype] = EOS_POLYNOMIAL; + if (comm->me == 0) { + printf("reading *EOS_POLYNOMIAL\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *EOS_POLYNOMIAL"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 7 + 1) { + sprintf(str, "expected 7 arguments following *EOS_POLYNOMIAL but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[EOS_POLYNOMIAL_C0][itype] = force->numeric(FLERR, arg[ioffset + 1]); + Lookup[EOS_POLYNOMIAL_C1][itype] = force->numeric(FLERR, arg[ioffset + 2]); + Lookup[EOS_POLYNOMIAL_C2][itype] = force->numeric(FLERR, arg[ioffset + 3]); + Lookup[EOS_POLYNOMIAL_C3][itype] = force->numeric(FLERR, arg[ioffset + 4]); + Lookup[EOS_POLYNOMIAL_C4][itype] = force->numeric(FLERR, arg[ioffset + 5]); + Lookup[EOS_POLYNOMIAL_C5][itype] = force->numeric(FLERR, arg[ioffset + 6]); + Lookup[EOS_POLYNOMIAL_C6][itype] = force->numeric(FLERR, arg[ioffset + 7]); + if (comm->me == 0) { + printf("\n%60s\n", "polynomial EOS based on strain rate"); + printf("%60s : %g\n", "parameter c0", Lookup[EOS_POLYNOMIAL_C0][itype]); + printf("%60s : %g\n", "parameter c1", Lookup[EOS_POLYNOMIAL_C1][itype]); + printf("%60s : %g\n", "parameter c2", Lookup[EOS_POLYNOMIAL_C2][itype]); + printf("%60s : %g\n", "parameter c3", Lookup[EOS_POLYNOMIAL_C3][itype]); + printf("%60s : %g\n", "parameter c4", Lookup[EOS_POLYNOMIAL_C4][itype]); + printf("%60s : %g\n", "parameter c5", Lookup[EOS_POLYNOMIAL_C5][itype]); + printf("%60s : %g\n", "parameter c6", Lookup[EOS_POLYNOMIAL_C6][itype]); + } + } // end polynomial eos + + else if (strcmp(arg[ioffset], "*FAILURE_MAX_PLASTIC_STRAIN") == 0) { + + /* + * maximum plastic strain failure criterion + */ + + if (comm->me == 0) { + printf("reading *FAILURE_MAX_PLASTIC_SRTRAIN\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *FAILURE_MAX_PLASTIC_STRAIN"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *FAILURE_MAX_PLASTIC_STRAIN but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + failureModel[itype].failure_max_plastic_strain = true; + failureModel[itype].integration_point_wise = true; + Lookup[FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf("\n%60s\n", "maximum plastic strain failure criterion"); + printf("%60s : %g\n", "failure occurs when plastic strain reaches limit", + Lookup[FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD][itype]); + } + } // end maximum plastic strain failure criterion + else if (strcmp(arg[ioffset], "*FAILURE_MAX_PAIRWISE_STRAIN") == 0) { + + /* + * failure criterion based on maximum strain between a pair of TLSPH particles. + */ + + if (comm->me == 0) { + printf("reading *FAILURE_MAX_PAIRWISE_STRAIN\n"); + } + + if (update_method != UPDATE_NONE) { + error->all(FLERR, "cannot use *FAILURE_MAX_PAIRWISE_STRAIN with updated Total-Lagrangian formalism"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *FAILURE_MAX_PAIRWISE_STRAIN"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *FAILURE_MAX_PAIRWISE_STRAIN but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + failureModel[itype].failure_max_pairwise_strain = true; + failureModel[itype].integration_point_wise = true; + Lookup[FAILURE_MAX_PAIRWISE_STRAIN_THRESHOLD][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf("\n%60s\n", "maximum pairwise strain failure criterion"); + printf("%60s : %g\n", "failure occurs when pairwise strain reaches limit", + Lookup[FAILURE_MAX_PAIRWISE_STRAIN_THRESHOLD][itype]); + } + } // end pair based maximum strain failure criterion + else if (strcmp(arg[ioffset], "*FAILURE_MAX_PRINCIPAL_STRAIN") == 0) { + error->all(FLERR, "this failure model is currently unsupported"); + + /* + * maximum principal strain failure criterion + */ + if (comm->me == 0) { + printf("reading *FAILURE_MAX_PRINCIPAL_STRAIN\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *FAILURE_MAX_PRINCIPAL_STRAIN"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *FAILURE_MAX_PRINCIPAL_STRAIN but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + failureModel[itype].failure_max_principal_strain = true; + failureModel[itype].integration_point_wise = true; + Lookup[FAILURE_MAX_PRINCIPAL_STRAIN_THRESHOLD][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf("\n%60s\n", "maximum principal strain failure criterion"); + printf("%60s : %g\n", "failure occurs when principal strain reaches limit", + Lookup[FAILURE_MAX_PRINCIPAL_STRAIN_THRESHOLD][itype]); + } + } // end maximum principal strain failure criterion + else if (strcmp(arg[ioffset], "*FAILURE_JOHNSON_COOK") == 0) { + error->all(FLERR, "this failure model is currently unsupported"); + if (comm->me == 0) { + printf("reading *FAILURE_JOHNSON_COOK\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *FAILURE_JOHNSON_COOK"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 5 + 1) { + sprintf(str, "expected 5 arguments following *FAILURE_JOHNSON_COOK but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + failureModel[itype].failure_johnson_cook = true; + failureModel[itype].integration_point_wise = true; + + Lookup[FAILURE_JC_D1][itype] = force->numeric(FLERR, arg[ioffset + 1]); + Lookup[FAILURE_JC_D2][itype] = force->numeric(FLERR, arg[ioffset + 2]); + Lookup[FAILURE_JC_D3][itype] = force->numeric(FLERR, arg[ioffset + 3]); + Lookup[FAILURE_JC_D4][itype] = force->numeric(FLERR, arg[ioffset + 4]); + Lookup[FAILURE_JC_EPDOT0][itype] = force->numeric(FLERR, arg[ioffset + 5]); + + if (comm->me == 0) { + printf("\n%60s\n", "Johnson-Cook failure criterion"); + printf("%60s : %g\n", "parameter d1", Lookup[FAILURE_JC_D1][itype]); + printf("%60s : %g\n", "parameter d2", Lookup[FAILURE_JC_D2][itype]); + printf("%60s : %g\n", "parameter d3", Lookup[FAILURE_JC_D3][itype]); + printf("%60s : %g\n", "parameter d4", Lookup[FAILURE_JC_D4][itype]); + printf("%60s : %g\n", "reference plastic strain rate", Lookup[FAILURE_JC_EPDOT0][itype]); + } + + } else if (strcmp(arg[ioffset], "*FAILURE_MAX_PRINCIPAL_STRESS") == 0) { + error->all(FLERR, "this failure model is currently unsupported"); + + /* + * maximum principal stress failure criterion + */ + + if (comm->me == 0) { + printf("reading *FAILURE_MAX_PRINCIPAL_STRESS\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *FAILURE_MAX_PRINCIPAL_STRESS"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *FAILURE_MAX_PRINCIPAL_STRESS but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + failureModel[itype].failure_max_principal_stress = true; + failureModel[itype].integration_point_wise = true; + Lookup[FAILURE_MAX_PRINCIPAL_STRESS_THRESHOLD][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf("\n%60s\n", "maximum principal stress failure criterion"); + printf("%60s : %g\n", "failure occurs when principal stress reaches limit", + Lookup[FAILURE_MAX_PRINCIPAL_STRESS_THRESHOLD][itype]); + } + } // end maximum principal stress failure criterion + + else if (strcmp(arg[ioffset], "*FAILURE_ENERGY_RELEASE_RATE") == 0) { + if (comm->me == 0) { + printf("reading *FAILURE_ENERGY_RELEASE_RATE\n"); + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *FAILURE_ENERGY_RELEASE_RATE"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *FAILURE_ENERGY_RELEASE_RATE but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + failureModel[itype].failure_energy_release_rate = true; + Lookup[CRITICAL_ENERGY_RELEASE_RATE][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf("\n%60s\n", "critical energy release rate failure criterion"); + printf("%60s : %g\n", "failure occurs when energy release rate reaches limit", + Lookup[CRITICAL_ENERGY_RELEASE_RATE][itype]); + } + } // end energy release rate failure criterion + + else { + sprintf(str, "unknown *KEYWORD: %s", arg[ioffset]); + error->all(FLERR, str); + } + + } + + setflag[itype][itype] = 1; } @@ -1699,23 +1699,23 @@ void PairTlsph::coeff(int narg, char **arg) { double PairTlsph::init_one(int i, int j) { - if (!allocated) - allocate(); + if (!allocated) + allocate(); - if (setflag[i][j] == 0) - error->all(FLERR, "All pair coeffs are not set"); + if (setflag[i][j] == 0) + error->all(FLERR, "All pair coeffs are not set"); - if (force->newton == 1) - error->all(FLERR, "Pair style tlsph requires newton off"); + if (force->newton == 1) + error->all(FLERR, "Pair style tlsph requires newton off"); // cutoff = sum of max I,J radii for // dynamic/dynamic & dynamic/frozen interactions, but not frozen/frozen - double cutoff = maxrad_dynamic[i] + maxrad_dynamic[j]; - cutoff = MAX(cutoff, maxrad_frozen[i] + maxrad_dynamic[j]); - cutoff = MAX(cutoff, maxrad_dynamic[i] + maxrad_frozen[j]); + double cutoff = maxrad_dynamic[i] + maxrad_dynamic[j]; + cutoff = MAX(cutoff, maxrad_frozen[i] + maxrad_dynamic[j]); + cutoff = MAX(cutoff, maxrad_dynamic[i] + maxrad_frozen[j]); //printf("cutoff for pair pair tlsph = %f\n", cutoff); - return cutoff; + return cutoff; } /* ---------------------------------------------------------------------- @@ -1723,58 +1723,58 @@ double PairTlsph::init_one(int i, int j) { ------------------------------------------------------------------------- */ void PairTlsph::init_style() { - int i; + int i; - if (force->newton_pair == 1) { - error->all(FLERR, "Pair style tlsph requires newton pair off"); - } + if (force->newton_pair == 1) { + error->all(FLERR, "Pair style tlsph requires newton pair off"); + } // request a granular neighbor list - int irequest = neighbor->request(this); - neighbor->requests[irequest]->size = 1; + int irequest = neighbor->request(this); + neighbor->requests[irequest]->size = 1; // set maxrad_dynamic and maxrad_frozen for each type // include future Fix pour particles as dynamic - for (i = 1; i <= atom->ntypes; i++) - onerad_dynamic[i] = onerad_frozen[i] = 0.0; + for (i = 1; i <= atom->ntypes; i++) + onerad_dynamic[i] = onerad_frozen[i] = 0.0; - double *radius = atom->radius; - int *type = atom->type; - int nlocal = atom->nlocal; + double *radius = atom->radius; + int *type = atom->type; + int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) - onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]); + for (i = 0; i < nlocal; i++) + onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]); - MPI_Allreduce(&onerad_dynamic[1], &maxrad_dynamic[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); - MPI_Allreduce(&onerad_frozen[1], &maxrad_frozen[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); + MPI_Allreduce(&onerad_dynamic[1], &maxrad_dynamic[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); + MPI_Allreduce(&onerad_frozen[1], &maxrad_frozen[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); // if first init, create Fix needed for storing reference configuration neighbors - int igroup = group->find("tlsph"); - if (igroup == -1) - error->all(FLERR, "Pair style tlsph requires its particles to be part of a group named tlsph. This group does not exist."); - - if (fix_tlsph_reference_configuration == NULL) { - char **fixarg = new char*[3]; - fixarg[0] = (char *) "SMD_TLSPH_NEIGHBORS"; - fixarg[1] = (char *) "tlsph"; - fixarg[2] = (char *) "SMD_TLSPH_NEIGHBORS"; - modify->add_fix(3, fixarg); - delete[] fixarg; - fix_tlsph_reference_configuration = (FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[modify->nfix - 1]; - fix_tlsph_reference_configuration->pair = this; - } + int igroup = group->find("tlsph"); + if (igroup == -1) + error->all(FLERR, "Pair style tlsph requires its particles to be part of a group named tlsph. This group does not exist."); + + if (fix_tlsph_reference_configuration == NULL) { + char **fixarg = new char*[3]; + fixarg[0] = (char *) "SMD_TLSPH_NEIGHBORS"; + fixarg[1] = (char *) "tlsph"; + fixarg[2] = (char *) "SMD_TLSPH_NEIGHBORS"; + modify->add_fix(3, fixarg); + delete[] fixarg; + fix_tlsph_reference_configuration = (FixSMD_TLSPH_ReferenceConfiguration *) modify->fix[modify->nfix - 1]; + fix_tlsph_reference_configuration->pair = this; + } // find associated SMD_TLSPH_NEIGHBORS fix that must exist // could have changed locations in fix list since created - ifix_tlsph = -1; - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style, "SMD_TLSPH_NEIGHBORS") == 0) - ifix_tlsph = i; - if (ifix_tlsph == -1) - error->all(FLERR, "Fix SMD_TLSPH_NEIGHBORS does not exist"); + ifix_tlsph = -1; + for (int i = 0; i < modify->nfix; i++) + if (strcmp(modify->fix[i]->style, "SMD_TLSPH_NEIGHBORS") == 0) + ifix_tlsph = i; + if (ifix_tlsph == -1) + error->all(FLERR, "Fix SMD_TLSPH_NEIGHBORS does not exist"); } @@ -1784,8 +1784,8 @@ void PairTlsph::init_style() { ------------------------------------------------------------------------- */ void PairTlsph::init_list(int id, NeighList *ptr) { - if (id == 0) - list = ptr; + if (id == 0) + list = ptr; } /* ---------------------------------------------------------------------- @@ -1794,7 +1794,7 @@ void PairTlsph::init_list(int id, NeighList *ptr) { double PairTlsph::memory_usage() { - return 118 * nmax * sizeof(double); + return 118 * nmax * sizeof(double); } /* ---------------------------------------------------------------------- @@ -1803,122 +1803,122 @@ double PairTlsph::memory_usage() { void *PairTlsph::extract(const char *str, int &i) { //printf("in PairTlsph::extract\n"); - if (strcmp(str, "smd/tlsph/Fincr_ptr") == 0) { - return (void *) Fincr; - } else if (strcmp(str, "smd/tlsph/detF_ptr") == 0) { - return (void *) detF; - } else if (strcmp(str, "smd/tlsph/PK1_ptr") == 0) { - return (void *) PK1; - } else if (strcmp(str, "smd/tlsph/smoothVel_ptr") == 0) { - return (void *) smoothVelDifference; - } else if (strcmp(str, "smd/tlsph/numNeighsRefConfig_ptr") == 0) { - return (void *) numNeighsRefConfig; - } else if (strcmp(str, "smd/tlsph/stressTensor_ptr") == 0) { - return (void *) CauchyStress; - } else if (strcmp(str, "smd/tlsph/updateFlag_ptr") == 0) { - return (void *) &updateFlag; - } else if (strcmp(str, "smd/tlsph/strain_rate_ptr") == 0) { - return (void *) D; - } else if (strcmp(str, "smd/tlsph/hMin_ptr") == 0) { - return (void *) &hMin; - } else if (strcmp(str, "smd/tlsph/dtCFL_ptr") == 0) { - return (void *) &dtCFL; - } else if (strcmp(str, "smd/tlsph/dtRelative_ptr") == 0) { - return (void *) &dtRelative; - } else if (strcmp(str, "smd/tlsph/hourglass_error_ptr") == 0) { - return (void *) hourglass_error; - } else if (strcmp(str, "smd/tlsph/particle_dt_ptr") == 0) { - return (void *) particle_dt; - } else if (strcmp(str, "smd/tlsph/rotation_ptr") == 0) { - return (void *) R; - } - - return NULL; + if (strcmp(str, "smd/tlsph/Fincr_ptr") == 0) { + return (void *) Fincr; + } else if (strcmp(str, "smd/tlsph/detF_ptr") == 0) { + return (void *) detF; + } else if (strcmp(str, "smd/tlsph/PK1_ptr") == 0) { + return (void *) PK1; + } else if (strcmp(str, "smd/tlsph/smoothVel_ptr") == 0) { + return (void *) smoothVelDifference; + } else if (strcmp(str, "smd/tlsph/numNeighsRefConfig_ptr") == 0) { + return (void *) numNeighsRefConfig; + } else if (strcmp(str, "smd/tlsph/stressTensor_ptr") == 0) { + return (void *) CauchyStress; + } else if (strcmp(str, "smd/tlsph/updateFlag_ptr") == 0) { + return (void *) &updateFlag; + } else if (strcmp(str, "smd/tlsph/strain_rate_ptr") == 0) { + return (void *) D; + } else if (strcmp(str, "smd/tlsph/hMin_ptr") == 0) { + return (void *) &hMin; + } else if (strcmp(str, "smd/tlsph/dtCFL_ptr") == 0) { + return (void *) &dtCFL; + } else if (strcmp(str, "smd/tlsph/dtRelative_ptr") == 0) { + return (void *) &dtRelative; + } else if (strcmp(str, "smd/tlsph/hourglass_error_ptr") == 0) { + return (void *) hourglass_error; + } else if (strcmp(str, "smd/tlsph/particle_dt_ptr") == 0) { + return (void *) particle_dt; + } else if (strcmp(str, "smd/tlsph/rotation_ptr") == 0) { + return (void *) R; + } + + return NULL; } /* ---------------------------------------------------------------------- */ int PairTlsph::pack_forward_comm(int n, int *list, double *buf, int pbc_flag, int *pbc) { - int i, j, m; - tagint *mol = atom->molecule; - double *damage = atom->damage; - double *eff_plastic_strain = atom->eff_plastic_strain; - double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; + int i, j, m; + tagint *mol = atom->molecule; + double *damage = atom->damage; + double *eff_plastic_strain = atom->eff_plastic_strain; + double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; //printf("in PairTlsph::pack_forward_comm\n"); - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = PK1[j](0, 0); // PK1 is not symmetric - buf[m++] = PK1[j](0, 1); - buf[m++] = PK1[j](0, 2); - buf[m++] = PK1[j](1, 0); - buf[m++] = PK1[j](1, 1); - buf[m++] = PK1[j](1, 2); - buf[m++] = PK1[j](2, 0); - buf[m++] = PK1[j](2, 1); - buf[m++] = PK1[j](2, 2); // 9 - - buf[m++] = Fincr[j](0, 0); // Fincr is not symmetric - buf[m++] = Fincr[j](0, 1); - buf[m++] = Fincr[j](0, 2); - buf[m++] = Fincr[j](1, 0); - buf[m++] = Fincr[j](1, 1); - buf[m++] = Fincr[j](1, 2); - buf[m++] = Fincr[j](2, 0); - buf[m++] = Fincr[j](2, 1); - buf[m++] = Fincr[j](2, 2); // 9 + 9 = 18 - - buf[m++] = mol[j]; //19 - buf[m++] = damage[j]; //20 - buf[m++] = eff_plastic_strain[j]; //21 - buf[m++] = eff_plastic_strain_rate[j]; //22 - - } - return m; + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = PK1[j](0, 0); // PK1 is not symmetric + buf[m++] = PK1[j](0, 1); + buf[m++] = PK1[j](0, 2); + buf[m++] = PK1[j](1, 0); + buf[m++] = PK1[j](1, 1); + buf[m++] = PK1[j](1, 2); + buf[m++] = PK1[j](2, 0); + buf[m++] = PK1[j](2, 1); + buf[m++] = PK1[j](2, 2); // 9 + + buf[m++] = Fincr[j](0, 0); // Fincr is not symmetric + buf[m++] = Fincr[j](0, 1); + buf[m++] = Fincr[j](0, 2); + buf[m++] = Fincr[j](1, 0); + buf[m++] = Fincr[j](1, 1); + buf[m++] = Fincr[j](1, 2); + buf[m++] = Fincr[j](2, 0); + buf[m++] = Fincr[j](2, 1); + buf[m++] = Fincr[j](2, 2); // 9 + 9 = 18 + + buf[m++] = mol[j]; //19 + buf[m++] = damage[j]; //20 + buf[m++] = eff_plastic_strain[j]; //21 + buf[m++] = eff_plastic_strain_rate[j]; //22 + + } + return m; } /* ---------------------------------------------------------------------- */ void PairTlsph::unpack_forward_comm(int n, int first, double *buf) { - int i, m, last; - tagint *mol = atom->molecule; - double *damage = atom->damage; - double *eff_plastic_strain = atom->eff_plastic_strain; - double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; + int i, m, last; + tagint *mol = atom->molecule; + double *damage = atom->damage; + double *eff_plastic_strain = atom->eff_plastic_strain; + double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; //printf("in PairTlsph::unpack_forward_comm\n"); - m = 0; - last = first + n; - for (i = first; i < last; i++) { - - PK1[i](0, 0) = buf[m++]; // PK1 is not symmetric - PK1[i](0, 1) = buf[m++]; - PK1[i](0, 2) = buf[m++]; - PK1[i](1, 0) = buf[m++]; - PK1[i](1, 1) = buf[m++]; - PK1[i](1, 2) = buf[m++]; - PK1[i](2, 0) = buf[m++]; - PK1[i](2, 1) = buf[m++]; - PK1[i](2, 2) = buf[m++]; - - Fincr[i](0, 0) = buf[m++]; - Fincr[i](0, 1) = buf[m++]; - Fincr[i](0, 2) = buf[m++]; - Fincr[i](1, 0) = buf[m++]; - Fincr[i](1, 1) = buf[m++]; - Fincr[i](1, 2) = buf[m++]; - Fincr[i](2, 0) = buf[m++]; - Fincr[i](2, 1) = buf[m++]; - Fincr[i](2, 2) = buf[m++]; - - mol[i] = static_cast<int>(buf[m++]); - damage[i] = buf[m++]; - eff_plastic_strain[i] = buf[m++]; //22 - eff_plastic_strain_rate[i] = buf[m++]; //23 - } + m = 0; + last = first + n; + for (i = first; i < last; i++) { + + PK1[i](0, 0) = buf[m++]; // PK1 is not symmetric + PK1[i](0, 1) = buf[m++]; + PK1[i](0, 2) = buf[m++]; + PK1[i](1, 0) = buf[m++]; + PK1[i](1, 1) = buf[m++]; + PK1[i](1, 2) = buf[m++]; + PK1[i](2, 0) = buf[m++]; + PK1[i](2, 1) = buf[m++]; + PK1[i](2, 2) = buf[m++]; + + Fincr[i](0, 0) = buf[m++]; + Fincr[i](0, 1) = buf[m++]; + Fincr[i](0, 2) = buf[m++]; + Fincr[i](1, 0) = buf[m++]; + Fincr[i](1, 1) = buf[m++]; + Fincr[i](1, 2) = buf[m++]; + Fincr[i](2, 0) = buf[m++]; + Fincr[i](2, 1) = buf[m++]; + Fincr[i](2, 2) = buf[m++]; + + mol[i] = static_cast<int>(buf[m++]); + damage[i] = buf[m++]; + eff_plastic_strain[i] = buf[m++]; //22 + eff_plastic_strain_rate[i] = buf[m++]; //23 + } } /* ---------------------------------------------------------------------- @@ -1927,166 +1927,166 @@ void PairTlsph::unpack_forward_comm(int n, int first, double *buf) { ------------------------------------------------------------------------- */ void PairTlsph::effective_longitudinal_modulus(const int itype, const double dt, const double d_iso, const double p_rate, - const Matrix3d d_dev, const Matrix3d sigma_dev_rate, const double damage, double &K_eff, double &mu_eff, double &M_eff) { - double M0; // initial longitudinal modulus - double shear_rate_sq; - -// if (damage >= 0.5) { -// M_eff = Lookup[M_MODULUS][itype]; -// K_eff = Lookup[BULK_MODULUS][itype]; -// mu_eff = Lookup[SHEAR_MODULUS][itype]; -// return; -// } - - M0 = Lookup[M_MODULUS][itype]; - - if (dt * d_iso > 1.0e-6) { - K_eff = p_rate / d_iso; - if (K_eff < 0.0) { // it is possible for K_eff to become negative due to strain softening -// if (damage == 0.0) { -// error->one(FLERR, "computed a negative effective bulk modulus but particle is not damaged."); -// } - K_eff = Lookup[BULK_MODULUS][itype]; - } - } else { - K_eff = Lookup[BULK_MODULUS][itype]; - } - - if (domain->dimension == 3) { + const Matrix3d d_dev, const Matrix3d sigma_dev_rate, const double damage, double &K_eff, double &mu_eff, double &M_eff) { + double M0; // initial longitudinal modulus + double shear_rate_sq; + +// if (damage >= 0.5) { +// M_eff = Lookup[M_MODULUS][itype]; +// K_eff = Lookup[BULK_MODULUS][itype]; +// mu_eff = Lookup[SHEAR_MODULUS][itype]; +// return; +// } + + M0 = Lookup[M_MODULUS][itype]; + + if (dt * d_iso > 1.0e-6) { + K_eff = p_rate / d_iso; + if (K_eff < 0.0) { // it is possible for K_eff to become negative due to strain softening +// if (damage == 0.0) { +// error->one(FLERR, "computed a negative effective bulk modulus but particle is not damaged."); +// } + K_eff = Lookup[BULK_MODULUS][itype]; + } + } else { + K_eff = Lookup[BULK_MODULUS][itype]; + } + + if (domain->dimension == 3) { // Calculate 2 mu by looking at ratio shear stress / shear strain. Use numerical softening to avoid divide-by-zero. - mu_eff = 0.5 - * (sigma_dev_rate(0, 1) / (d_dev(0, 1) + 1.0e-16) + sigma_dev_rate(0, 2) / (d_dev(0, 2) + 1.0e-16) - + sigma_dev_rate(1, 2) / (d_dev(1, 2) + 1.0e-16)); + mu_eff = 0.5 + * (sigma_dev_rate(0, 1) / (d_dev(0, 1) + 1.0e-16) + sigma_dev_rate(0, 2) / (d_dev(0, 2) + 1.0e-16) + + sigma_dev_rate(1, 2) / (d_dev(1, 2) + 1.0e-16)); // Calculate magnitude of deviatoric strain rate. This is used for deciding if shear modulus should be computed from current rate or be taken as the initial value. - shear_rate_sq = d_dev(0, 1) * d_dev(0, 1) + d_dev(0, 2) * d_dev(0, 2) + d_dev(1, 2) * d_dev(1, 2); - } else { - mu_eff = 0.5 * (sigma_dev_rate(0, 1) / (d_dev(0, 1) + 1.0e-16)); - shear_rate_sq = d_dev(0, 1) * d_dev(0, 1); - } - - if (dt * dt * shear_rate_sq < 1.0e-8) { - mu_eff = Lookup[SHEAR_MODULUS][itype]; - } - - if (mu_eff < Lookup[SHEAR_MODULUS][itype]) { // it is possible for mu_eff to become negative due to strain softening -// if (damage == 0.0) { -// printf("mu_eff = %f, tau=%f, gamma=%f\n", mu_eff, sigma_dev_rate(0, 1), d_dev(0, 1)); -// error->message(FLERR, "computed a negative effective shear modulus but particle is not damaged."); -// } - mu_eff = Lookup[SHEAR_MODULUS][itype]; - } + shear_rate_sq = d_dev(0, 1) * d_dev(0, 1) + d_dev(0, 2) * d_dev(0, 2) + d_dev(1, 2) * d_dev(1, 2); + } else { + mu_eff = 0.5 * (sigma_dev_rate(0, 1) / (d_dev(0, 1) + 1.0e-16)); + shear_rate_sq = d_dev(0, 1) * d_dev(0, 1); + } + + if (dt * dt * shear_rate_sq < 1.0e-8) { + mu_eff = Lookup[SHEAR_MODULUS][itype]; + } + + if (mu_eff < Lookup[SHEAR_MODULUS][itype]) { // it is possible for mu_eff to become negative due to strain softening +// if (damage == 0.0) { +// printf("mu_eff = %f, tau=%f, gamma=%f\n", mu_eff, sigma_dev_rate(0, 1), d_dev(0, 1)); +// error->message(FLERR, "computed a negative effective shear modulus but particle is not damaged."); +// } + mu_eff = Lookup[SHEAR_MODULUS][itype]; + } //mu_eff = Lookup[SHEAR_MODULUS][itype]; - if (K_eff < 0.0) { - printf("K_eff = %f, p_rate=%f, vol_rate=%f\n", K_eff, p_rate, d_iso); - } + if (K_eff < 0.0) { + printf("K_eff = %f, p_rate=%f, vol_rate=%f\n", K_eff, p_rate, d_iso); + } - if (mu_eff < 0.0) { - printf("mu_eff = %f, tau=%f, gamma=%f\n", mu_eff, sigma_dev_rate(0, 1), d_dev(0, 1)); - error->one(FLERR, ""); - } + if (mu_eff < 0.0) { + printf("mu_eff = %f, tau=%f, gamma=%f\n", mu_eff, sigma_dev_rate(0, 1), d_dev(0, 1)); + error->one(FLERR, ""); + } - M_eff = (K_eff + 4.0 * mu_eff / 3.0); // effective dilational modulus, see Pronto 2d eqn 3.4.8 + M_eff = (K_eff + 4.0 * mu_eff / 3.0); // effective dilational modulus, see Pronto 2d eqn 3.4.8 - if (M_eff < M0) { // do not allow effective dilatational modulus to decrease beyond its initial value - M_eff = M0; - } + if (M_eff < M0) { // do not allow effective dilatational modulus to decrease beyond its initial value + M_eff = M0; + } } /* ---------------------------------------------------------------------- compute pressure. Called from AssembleStress(). ------------------------------------------------------------------------- */ void PairTlsph::ComputePressure(const int i, const double rho, const double mass_specific_energy, const double vol_specific_energy, - const double pInitial, const double d_iso, double &pFinal, double &p_rate) { - int *type = atom->type; - double dt = update->dt; - - int itype; - - itype = type[i]; - - switch (eos[itype]) { - case EOS_LINEAR: - LinearEOS(Lookup[BULK_MODULUS][itype], pInitial, d_iso, dt, pFinal, p_rate); - break; - case EOS_NONE: - pFinal = 0.0; - p_rate = 0.0; - break; - case EOS_SHOCK: + const double pInitial, const double d_iso, double &pFinal, double &p_rate) { + int *type = atom->type; + double dt = update->dt; + + int itype; + + itype = type[i]; + + switch (eos[itype]) { + case EOS_LINEAR: + LinearEOS(Lookup[BULK_MODULUS][itype], pInitial, d_iso, dt, pFinal, p_rate); + break; + case EOS_NONE: + pFinal = 0.0; + p_rate = 0.0; + break; + case EOS_SHOCK: // rho, rho0, e, e0, c0, S, Gamma, pInitial, dt, &pFinal, &p_rate); - ShockEOS(rho, Lookup[REFERENCE_DENSITY][itype], mass_specific_energy, 0.0, Lookup[EOS_SHOCK_C0][itype], - Lookup[EOS_SHOCK_S][itype], Lookup[EOS_SHOCK_GAMMA][itype], pInitial, dt, pFinal, p_rate); - break; - case EOS_POLYNOMIAL: - polynomialEOS(rho, Lookup[REFERENCE_DENSITY][itype], vol_specific_energy, Lookup[EOS_POLYNOMIAL_C0][itype], - Lookup[EOS_POLYNOMIAL_C1][itype], Lookup[EOS_POLYNOMIAL_C2][itype], Lookup[EOS_POLYNOMIAL_C3][itype], - Lookup[EOS_POLYNOMIAL_C4][itype], Lookup[EOS_POLYNOMIAL_C5][itype], Lookup[EOS_POLYNOMIAL_C6][itype], pInitial, dt, - pFinal, p_rate); - - break; - default: - error->one(FLERR, "unknown EOS."); - break; - } + ShockEOS(rho, Lookup[REFERENCE_DENSITY][itype], mass_specific_energy, 0.0, Lookup[EOS_SHOCK_C0][itype], + Lookup[EOS_SHOCK_S][itype], Lookup[EOS_SHOCK_GAMMA][itype], pInitial, dt, pFinal, p_rate); + break; + case EOS_POLYNOMIAL: + polynomialEOS(rho, Lookup[REFERENCE_DENSITY][itype], vol_specific_energy, Lookup[EOS_POLYNOMIAL_C0][itype], + Lookup[EOS_POLYNOMIAL_C1][itype], Lookup[EOS_POLYNOMIAL_C2][itype], Lookup[EOS_POLYNOMIAL_C3][itype], + Lookup[EOS_POLYNOMIAL_C4][itype], Lookup[EOS_POLYNOMIAL_C5][itype], Lookup[EOS_POLYNOMIAL_C6][itype], pInitial, dt, + pFinal, p_rate); + + break; + default: + error->one(FLERR, "unknown EOS."); + break; + } } /* ---------------------------------------------------------------------- Compute stress deviator. Called from AssembleStress(). ------------------------------------------------------------------------- */ void PairTlsph::ComputeStressDeviator(const int i, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, Matrix3d &sigmaFinal_dev, - Matrix3d &sigma_dev_rate, double &plastic_strain_increment) { - double *eff_plastic_strain = atom->eff_plastic_strain; - double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; - int *type = atom->type; - double *rmass = atom->rmass; + Matrix3d &sigma_dev_rate, double &plastic_strain_increment) { + double *eff_plastic_strain = atom->eff_plastic_strain; + double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; + int *type = atom->type; + double *rmass = atom->rmass; //double *vfrac = atom->vfrac; - double *e = atom->e; - double dt = update->dt; - double yieldStress; - int itype; + double *e = atom->e; + double dt = update->dt; + double yieldStress; + int itype; - double mass_specific_energy = e[i] / rmass[i]; // energy per unit mass - plastic_strain_increment = 0.0; - itype = type[i]; + double mass_specific_energy = e[i] / rmass[i]; // energy per unit mass + plastic_strain_increment = 0.0; + itype = type[i]; - switch (strengthModel[itype]) { - case STRENGTH_LINEAR: + switch (strengthModel[itype]) { + case STRENGTH_LINEAR: - sigma_dev_rate = 2.0 * Lookup[SHEAR_MODULUS][itype] * d_dev; - sigmaFinal_dev = sigmaInitial_dev + dt * sigma_dev_rate; + sigma_dev_rate = 2.0 * Lookup[SHEAR_MODULUS][itype] * d_dev; + sigmaFinal_dev = sigmaInitial_dev + dt * sigma_dev_rate; - break; - case LINEAR_DEFGRAD: + break; + case LINEAR_DEFGRAD: //LinearStrengthDefgrad(Lookup[LAME_LAMBDA][itype], Lookup[SHEAR_MODULUS][itype], Fincr[i], &sigmaFinal_dev); //eff_plastic_strain[i] = 0.0; //p_rate = pInitial - sigmaFinal_dev.trace() / 3.0; //sigma_dev_rate = sigmaInitial_dev - Deviator(sigmaFinal_dev); - error->one(FLERR, "LINEAR_DEFGRAD is only for debugging purposes and currently deactivated."); - R[i].setIdentity(); - break; - case STRENGTH_LINEAR_PLASTIC: - - yieldStress = Lookup[YIELD_STRESS][itype] + Lookup[HARDENING_PARAMETER][itype] * eff_plastic_strain[i]; - LinearPlasticStrength(Lookup[SHEAR_MODULUS][itype], yieldStress, sigmaInitial_dev, d_dev, dt, sigmaFinal_dev, - sigma_dev_rate, plastic_strain_increment); - break; - case STRENGTH_JOHNSON_COOK: - JohnsonCookStrength(Lookup[SHEAR_MODULUS][itype], Lookup[HEAT_CAPACITY][itype], mass_specific_energy, Lookup[JC_A][itype], - Lookup[JC_B][itype], Lookup[JC_a][itype], Lookup[JC_C][itype], Lookup[JC_epdot0][itype], Lookup[JC_T0][itype], - Lookup[JC_Tmelt][itype], Lookup[JC_M][itype], dt, eff_plastic_strain[i], eff_plastic_strain_rate[i], - sigmaInitial_dev, d_dev, sigmaFinal_dev, sigma_dev_rate, plastic_strain_increment); - break; - case STRENGTH_NONE: - sigmaFinal_dev.setZero(); - sigma_dev_rate.setZero(); - break; - default: - error->one(FLERR, "unknown strength model."); - break; - } + error->one(FLERR, "LINEAR_DEFGRAD is only for debugging purposes and currently deactivated."); + R[i].setIdentity(); + break; + case STRENGTH_LINEAR_PLASTIC: + + yieldStress = Lookup[YIELD_STRESS][itype] + Lookup[HARDENING_PARAMETER][itype] * eff_plastic_strain[i]; + LinearPlasticStrength(Lookup[SHEAR_MODULUS][itype], yieldStress, sigmaInitial_dev, d_dev, dt, sigmaFinal_dev, + sigma_dev_rate, plastic_strain_increment); + break; + case STRENGTH_JOHNSON_COOK: + JohnsonCookStrength(Lookup[SHEAR_MODULUS][itype], Lookup[HEAT_CAPACITY][itype], mass_specific_energy, Lookup[JC_A][itype], + Lookup[JC_B][itype], Lookup[JC_a][itype], Lookup[JC_C][itype], Lookup[JC_epdot0][itype], Lookup[JC_T0][itype], + Lookup[JC_Tmelt][itype], Lookup[JC_M][itype], dt, eff_plastic_strain[i], eff_plastic_strain_rate[i], + sigmaInitial_dev, d_dev, sigmaFinal_dev, sigma_dev_rate, plastic_strain_increment); + break; + case STRENGTH_NONE: + sigmaFinal_dev.setZero(); + sigma_dev_rate.setZero(); + break; + default: + error->one(FLERR, "unknown strength model."); + break; + } } @@ -2094,67 +2094,67 @@ void PairTlsph::ComputeStressDeviator(const int i, const Matrix3d sigmaInitial_d Compute damage. Called from AssembleStress(). ------------------------------------------------------------------------- */ void PairTlsph::ComputeDamage(const int i, const Matrix3d strain, const Matrix3d stress, Matrix3d &stress_damaged) { - double *eff_plastic_strain = atom->eff_plastic_strain; - double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; - double *radius = atom->radius; - double *damage = atom->damage; - int *type = atom->type; - int itype = type[i]; - double jc_failure_strain; + double *eff_plastic_strain = atom->eff_plastic_strain; + double *eff_plastic_strain_rate = atom->eff_plastic_strain_rate; + double *radius = atom->radius; + double *damage = atom->damage; + int *type = atom->type; + int itype = type[i]; + double jc_failure_strain; //double damage_gap, damage_rate; - Matrix3d eye, stress_deviator; - - eye.setIdentity(); - stress_deviator = Deviator(stress); - double pressure = -stress.trace() / 3.0; - - if (failureModel[itype].failure_max_principal_stress) { - error->one(FLERR, "not yet implemented"); - /* - * maximum stress failure criterion: - */ - IsotropicMaxStressDamage(stress, Lookup[FAILURE_MAX_PRINCIPAL_STRESS_THRESHOLD][itype]); - } else if (failureModel[itype].failure_max_principal_strain) { - error->one(FLERR, "not yet implemented"); - /* - * maximum strain failure criterion: - */ - IsotropicMaxStrainDamage(strain, Lookup[FAILURE_MAX_PRINCIPAL_STRAIN_THRESHOLD][itype]); - } else if (failureModel[itype].failure_max_plastic_strain) { - if (eff_plastic_strain[i] >= Lookup[FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD][itype]) { - damage[i] = 1.0; - //double damage_gap = 0.5 * Lookup[FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD][itype]; - //damage[i] = (eff_plastic_strain[i] - Lookup[FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD][itype]) / damage_gap; - } - } else if (failureModel[itype].failure_johnson_cook) { - - //cout << "this is stress deviator" << stress_deviator << endl; - - jc_failure_strain = JohnsonCookFailureStrain(pressure, stress_deviator, Lookup[FAILURE_JC_D1][itype], - Lookup[FAILURE_JC_D2][itype], Lookup[FAILURE_JC_D3][itype], Lookup[FAILURE_JC_D4][itype], - Lookup[FAILURE_JC_EPDOT0][itype], eff_plastic_strain_rate[i]); - - //cout << "plastic strain increment is " << plastic_strain_increment << " jc fs is " << jc_failure_strain << endl; - //printf("JC failure strain is: %f\n", jc_failure_strain); - - if (eff_plastic_strain[i] >= jc_failure_strain) { - double damage_rate = Lookup[SIGNAL_VELOCITY][itype] / (100.0 * radius[i]); - damage[i] += damage_rate * update->dt; - //damage[i] = 1.0; - } - } - - /* - * Apply damage to integration point - */ - -// damage[i] = MIN(damage[i], 0.8); + Matrix3d eye, stress_deviator; + + eye.setIdentity(); + stress_deviator = Deviator(stress); + double pressure = -stress.trace() / 3.0; + + if (failureModel[itype].failure_max_principal_stress) { + error->one(FLERR, "not yet implemented"); + /* + * maximum stress failure criterion: + */ + IsotropicMaxStressDamage(stress, Lookup[FAILURE_MAX_PRINCIPAL_STRESS_THRESHOLD][itype]); + } else if (failureModel[itype].failure_max_principal_strain) { + error->one(FLERR, "not yet implemented"); + /* + * maximum strain failure criterion: + */ + IsotropicMaxStrainDamage(strain, Lookup[FAILURE_MAX_PRINCIPAL_STRAIN_THRESHOLD][itype]); + } else if (failureModel[itype].failure_max_plastic_strain) { + if (eff_plastic_strain[i] >= Lookup[FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD][itype]) { + damage[i] = 1.0; + //double damage_gap = 0.5 * Lookup[FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD][itype]; + //damage[i] = (eff_plastic_strain[i] - Lookup[FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD][itype]) / damage_gap; + } + } else if (failureModel[itype].failure_johnson_cook) { + + //cout << "this is stress deviator" << stress_deviator << endl; + + jc_failure_strain = JohnsonCookFailureStrain(pressure, stress_deviator, Lookup[FAILURE_JC_D1][itype], + Lookup[FAILURE_JC_D2][itype], Lookup[FAILURE_JC_D3][itype], Lookup[FAILURE_JC_D4][itype], + Lookup[FAILURE_JC_EPDOT0][itype], eff_plastic_strain_rate[i]); + + //cout << "plastic strain increment is " << plastic_strain_increment << " jc fs is " << jc_failure_strain << endl; + //printf("JC failure strain is: %f\n", jc_failure_strain); + + if (eff_plastic_strain[i] >= jc_failure_strain) { + double damage_rate = Lookup[SIGNAL_VELOCITY][itype] / (100.0 * radius[i]); + damage[i] += damage_rate * update->dt; + //damage[i] = 1.0; + } + } + + /* + * Apply damage to integration point + */ + +// damage[i] = MIN(damage[i], 0.8); // -// if (pressure > 0.0) { // compression: particle can carry compressive load but reduced shear -// stress_damaged = -pressure * eye + (1.0 - damage[i]) * Deviator(stress); -// } else { // tension: particle has reduced tensile and shear load bearing capability -// stress_damaged = (1.0 - damage[i]) * (-pressure * eye + Deviator(stress)); -// } +// if (pressure > 0.0) { // compression: particle can carry compressive load but reduced shear +// stress_damaged = -pressure * eye + (1.0 - damage[i]) * Deviator(stress); +// } else { // tension: particle has reduced tensile and shear load bearing capability +// stress_damaged = (1.0 - damage[i]) * (-pressure * eye + Deviator(stress)); +// } } diff --git a/src/USER-SMD/pair_smd_tlsph.h b/src/USER-SMD/pair_smd_tlsph.h index 4c9db9209b..62e7ce2295 100644 --- a/src/USER-SMD/pair_smd_tlsph.h +++ b/src/USER-SMD/pair_smd_tlsph.h @@ -39,163 +39,163 @@ namespace LAMMPS_NS { class PairTlsph: public Pair { public: - PairTlsph(class LAMMPS *); - virtual ~PairTlsph(); - virtual void compute(int, int); - void settings(int, char **); - void coeff(int, char **); - double init_one(int, int); - void init_style(); - void init_list(int, class NeighList *); - void write_restart_settings(FILE *) { - } - void read_restart_settings(FILE *) { - } - virtual double memory_usage(); - void compute_shape_matrix(void); - void material_model(void); - void *extract(const char *, int &); - int pack_forward_comm(int, int *, double *, int, int *); - void unpack_forward_comm(int, int, double *); - void AssembleStress(); - - void PreCompute(); - void ComputeForces(int eflag, int vflag); - void effective_longitudinal_modulus(const int itype, const double dt, const double d_iso, const double p_rate, - const Eigen::Matrix3d d_dev, const Eigen::Matrix3d sigma_dev_rate, const double damage, double &K_eff, double &mu_eff, double &M_eff); - - void ComputePressure(const int i, const double rho, const double mass_specific_energy, const double vol_specific_energy, - const double pInitial, const double d_iso, double &pFinal, double &p_rate); - void ComputeStressDeviator(const int i, const Eigen::Matrix3d sigmaInitial_dev, const Eigen::Matrix3d d_dev, Eigen::Matrix3d &sigmaFinal_dev, - Eigen::Matrix3d &sigma_dev_rate, double &plastic_strain_increment); - void ComputeDamage(const int i, const Eigen::Matrix3d strain, const Eigen::Matrix3d sigmaFinal, Eigen::Matrix3d &sigma_damaged); + PairTlsph(class LAMMPS *); + virtual ~PairTlsph(); + virtual void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + double init_one(int, int); + void init_style(); + void init_list(int, class NeighList *); + void write_restart_settings(FILE *) { + } + void read_restart_settings(FILE *) { + } + virtual double memory_usage(); + void compute_shape_matrix(void); + void material_model(void); + void *extract(const char *, int &); + int pack_forward_comm(int, int *, double *, int, int *); + void unpack_forward_comm(int, int, double *); + void AssembleStress(); + + void PreCompute(); + void ComputeForces(int eflag, int vflag); + void effective_longitudinal_modulus(const int itype, const double dt, const double d_iso, const double p_rate, + const Eigen::Matrix3d d_dev, const Eigen::Matrix3d sigma_dev_rate, const double damage, double &K_eff, double &mu_eff, double &M_eff); + + void ComputePressure(const int i, const double rho, const double mass_specific_energy, const double vol_specific_energy, + const double pInitial, const double d_iso, double &pFinal, double &p_rate); + void ComputeStressDeviator(const int i, const Eigen::Matrix3d sigmaInitial_dev, const Eigen::Matrix3d d_dev, Eigen::Matrix3d &sigmaFinal_dev, + Eigen::Matrix3d &sigma_dev_rate, double &plastic_strain_increment); + void ComputeDamage(const int i, const Eigen::Matrix3d strain, const Eigen::Matrix3d sigmaFinal, Eigen::Matrix3d &sigma_damaged); protected: - void allocate(); - char *suffix; - - /* - * per-type arrays - */ - int *strengthModel, *eos; - double *onerad_dynamic, *onerad_frozen, *maxrad_dynamic, *maxrad_frozen; - - /* - * per atom arrays - */ - Eigen::Matrix3d *K, *PK1, *Fdot, *Fincr; - Eigen::Matrix3d *R; // rotation matrix - Eigen::Matrix3d *FincrInv; - Eigen::Matrix3d *D, *W; // strain rate and spin tensor - Eigen::Vector3d *smoothVelDifference; - Eigen::Matrix3d *CauchyStress; - double *detF, *particle_dt; - double *hourglass_error; - int *numNeighsRefConfig; - - int nmax; // max number of atoms on this proc - double hMin; // minimum kernel radius for two particles - double dtCFL; - double dtRelative; // relative velocity of two particles, divided by sound speed - int updateFlag; - double update_threshold; // updateFlage is set to one if the relative displacement of a pair exceeds update_threshold - double cut_comm; - - enum { - UPDATE_NONE = 5000, UPDATE_CONSTANT_THRESHOLD = 5001, UPDATE_PAIRWISE_RATIO = 5002, - }; - - enum { - LINEAR_DEFGRAD = 0, - STRENGTH_LINEAR = 1, - STRENGTH_LINEAR_PLASTIC = 2, - STRENGTH_JOHNSON_COOK = 3, - STRENGTH_NONE = 4, - EOS_LINEAR = 5, - EOS_SHOCK = 6, - EOS_POLYNOMIAL = 7, - EOS_NONE = 8, - REFERENCE_DENSITY = 9, - YOUNGS_MODULUS = 10, - POISSON_RATIO = 11, - HOURGLASS_CONTROL_AMPLITUDE = 12, - HEAT_CAPACITY = 13, - LAME_LAMBDA = 14, - SHEAR_MODULUS = 15, - M_MODULUS = 16, - SIGNAL_VELOCITY = 17, - BULK_MODULUS = 18, - VISCOSITY_Q1 = 19, - VISCOSITY_Q2 = 20, - YIELD_STRESS = 21, - FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD = 22, - JC_A = 23, - JC_B = 24, - JC_a = 25, - JC_C = 26, - JC_epdot0 = 27, - JC_T0 = 28, - JC_Tmelt = 29, - JC_M = 30, - EOS_SHOCK_C0 = 31, - EOS_SHOCK_S = 32, - EOS_SHOCK_GAMMA = 33, - HARDENING_PARAMETER = 34, - FAILURE_MAX_PRINCIPAL_STRAIN_THRESHOLD = 35, - FAILURE_MAX_PRINCIPAL_STRESS_THRESHOLD = 36, - FAILURE_MAX_PAIRWISE_STRAIN_THRESHOLD = 37, - EOS_POLYNOMIAL_C0 = 38, - EOS_POLYNOMIAL_C1 = 39, - EOS_POLYNOMIAL_C2 = 40, - EOS_POLYNOMIAL_C3 = 41, - EOS_POLYNOMIAL_C4 = 42, - EOS_POLYNOMIAL_C5 = 43, - EOS_POLYNOMIAL_C6 = 44, - - FAILURE_JC_D1 = 45, - FAILURE_JC_D2 = 46, - FAILURE_JC_D3 = 47, - FAILURE_JC_D4 = 48, - FAILURE_JC_EPDOT0 = 49, - - CRITICAL_ENERGY_RELEASE_RATE = 50, - - MAX_KEY_VALUE = 51 - }; - - struct failure_types { // this is defined per type and determines which failure/damage model is active - bool failure_none; - bool failure_max_principal_strain; - bool failure_max_principal_stress; - bool failure_max_plastic_strain; - bool failure_johnson_cook; - bool failure_max_pairwise_strain; - bool integration_point_wise; // true if failure model applies to stress/strain state of integration point - bool failure_energy_release_rate; - - failure_types() { - failure_none = true; - failure_max_principal_strain = false; - failure_max_principal_stress = false; - failure_max_plastic_strain = false; - failure_johnson_cook = false; - failure_max_pairwise_strain = false; - integration_point_wise = false; - failure_energy_release_rate = false; - //printf("constructed failure type\n"); - } - }; - failure_types *failureModel; - - int ifix_tlsph; - int update_method; - - class FixSMD_TLSPH_ReferenceConfiguration *fix_tlsph_reference_configuration; + void allocate(); + char *suffix; + + /* + * per-type arrays + */ + int *strengthModel, *eos; + double *onerad_dynamic, *onerad_frozen, *maxrad_dynamic, *maxrad_frozen; + + /* + * per atom arrays + */ + Eigen::Matrix3d *K, *PK1, *Fdot, *Fincr; + Eigen::Matrix3d *R; // rotation matrix + Eigen::Matrix3d *FincrInv; + Eigen::Matrix3d *D, *W; // strain rate and spin tensor + Eigen::Vector3d *smoothVelDifference; + Eigen::Matrix3d *CauchyStress; + double *detF, *particle_dt; + double *hourglass_error; + int *numNeighsRefConfig; + + int nmax; // max number of atoms on this proc + double hMin; // minimum kernel radius for two particles + double dtCFL; + double dtRelative; // relative velocity of two particles, divided by sound speed + int updateFlag; + double update_threshold; // updateFlage is set to one if the relative displacement of a pair exceeds update_threshold + double cut_comm; + + enum { + UPDATE_NONE = 5000, UPDATE_CONSTANT_THRESHOLD = 5001, UPDATE_PAIRWISE_RATIO = 5002, + }; + + enum { + LINEAR_DEFGRAD = 0, + STRENGTH_LINEAR = 1, + STRENGTH_LINEAR_PLASTIC = 2, + STRENGTH_JOHNSON_COOK = 3, + STRENGTH_NONE = 4, + EOS_LINEAR = 5, + EOS_SHOCK = 6, + EOS_POLYNOMIAL = 7, + EOS_NONE = 8, + REFERENCE_DENSITY = 9, + YOUNGS_MODULUS = 10, + POISSON_RATIO = 11, + HOURGLASS_CONTROL_AMPLITUDE = 12, + HEAT_CAPACITY = 13, + LAME_LAMBDA = 14, + SHEAR_MODULUS = 15, + M_MODULUS = 16, + SIGNAL_VELOCITY = 17, + BULK_MODULUS = 18, + VISCOSITY_Q1 = 19, + VISCOSITY_Q2 = 20, + YIELD_STRESS = 21, + FAILURE_MAX_PLASTIC_STRAIN_THRESHOLD = 22, + JC_A = 23, + JC_B = 24, + JC_a = 25, + JC_C = 26, + JC_epdot0 = 27, + JC_T0 = 28, + JC_Tmelt = 29, + JC_M = 30, + EOS_SHOCK_C0 = 31, + EOS_SHOCK_S = 32, + EOS_SHOCK_GAMMA = 33, + HARDENING_PARAMETER = 34, + FAILURE_MAX_PRINCIPAL_STRAIN_THRESHOLD = 35, + FAILURE_MAX_PRINCIPAL_STRESS_THRESHOLD = 36, + FAILURE_MAX_PAIRWISE_STRAIN_THRESHOLD = 37, + EOS_POLYNOMIAL_C0 = 38, + EOS_POLYNOMIAL_C1 = 39, + EOS_POLYNOMIAL_C2 = 40, + EOS_POLYNOMIAL_C3 = 41, + EOS_POLYNOMIAL_C4 = 42, + EOS_POLYNOMIAL_C5 = 43, + EOS_POLYNOMIAL_C6 = 44, + + FAILURE_JC_D1 = 45, + FAILURE_JC_D2 = 46, + FAILURE_JC_D3 = 47, + FAILURE_JC_D4 = 48, + FAILURE_JC_EPDOT0 = 49, + + CRITICAL_ENERGY_RELEASE_RATE = 50, + + MAX_KEY_VALUE = 51 + }; + + struct failure_types { // this is defined per type and determines which failure/damage model is active + bool failure_none; + bool failure_max_principal_strain; + bool failure_max_principal_stress; + bool failure_max_plastic_strain; + bool failure_johnson_cook; + bool failure_max_pairwise_strain; + bool integration_point_wise; // true if failure model applies to stress/strain state of integration point + bool failure_energy_release_rate; + + failure_types() { + failure_none = true; + failure_max_principal_strain = false; + failure_max_principal_stress = false; + failure_max_plastic_strain = false; + failure_johnson_cook = false; + failure_max_pairwise_strain = false; + integration_point_wise = false; + failure_energy_release_rate = false; + //printf("constructed failure type\n"); + } + }; + failure_types *failureModel; + + int ifix_tlsph; + int update_method; + + class FixSMD_TLSPH_ReferenceConfiguration *fix_tlsph_reference_configuration; private: - double **Lookup; // holds per-type material parameters for the quantities defined in enum statement above. - bool first; // if first is true, do not perform any computations, beacuse reference configuration is not ready yet. + double **Lookup; // holds per-type material parameters for the quantities defined in enum statement above. + bool first; // if first is true, do not perform any computations, beacuse reference configuration is not ready yet. }; } diff --git a/src/USER-SMD/pair_smd_triangulated_surface.cpp b/src/USER-SMD/pair_smd_triangulated_surface.cpp index eec9e517ea..a62e262b7a 100644 --- a/src/USER-SMD/pair_smd_triangulated_surface.cpp +++ b/src/USER-SMD/pair_smd_triangulated_surface.cpp @@ -56,245 +56,245 @@ using namespace Eigen; /* ---------------------------------------------------------------------- */ PairTriSurf::PairTriSurf(LAMMPS *lmp) : - Pair(lmp) { + Pair(lmp) { - onerad_dynamic = onerad_frozen = maxrad_dynamic = maxrad_frozen = NULL; - bulkmodulus = NULL; - kn = NULL; - scale = 1.0; + onerad_dynamic = onerad_frozen = maxrad_dynamic = maxrad_frozen = NULL; + bulkmodulus = NULL; + kn = NULL; + scale = 1.0; } /* ---------------------------------------------------------------------- */ PairTriSurf::~PairTriSurf() { - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - memory->destroy(bulkmodulus); - memory->destroy(kn); - - delete[] onerad_dynamic; - delete[] onerad_frozen; - delete[] maxrad_dynamic; - delete[] maxrad_frozen; - } + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + memory->destroy(bulkmodulus); + memory->destroy(kn); + + delete[] onerad_dynamic; + delete[] onerad_frozen; + delete[] maxrad_dynamic; + delete[] maxrad_frozen; + } } /* ---------------------------------------------------------------------- */ void PairTriSurf::compute(int eflag, int vflag) { - int i, j, ii, jj, inum, jnum, itype, jtype; - double rsq, r, evdwl, fpair; - int *ilist, *jlist, *numneigh, **firstneigh; - double rcut, r_geom, delta, r_tri, r_particle, touch_distance, dt_crit; - int tri, particle; - Vector3d normal, x1, x2, x3, x4, x13, x23, x43, w, cp, x4cp, vnew, v_old; - ; - Vector3d xi, x_center, dx; - Matrix2d C; - Vector2d w2d, rhs; - - evdwl = 0.0; - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; - - tagint *mol = atom->molecule; - double **f = atom->f; - double **smd_data_9 = atom->smd_data_9; - double **x = atom->x; - double **x0 = atom->x0; - double **v = atom->v; - double *rmass = atom->rmass; - int *type = atom->type; - int nlocal = atom->nlocal; - double *radius = atom->contact_radius; - double rcutSq; - Vector3d offset; - - int newton_pair = force->newton_pair; - int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - int max_neighs = 0; - stable_time_increment = 1.0e22; - - // loop over neighbors of my atoms using a half neighbor list - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - max_neighs = MAX(max_neighs, jnum); - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - - j &= NEIGHMASK; - - jtype = type[j]; - - /* - * decide which one of i, j is triangle and which is particle - */ - if ((mol[i] < 65535) && (mol[j] >= 65535)) { - particle = i; - tri = j; - } else if ((mol[j] < 65535) && (mol[i] >= 65535)) { - particle = j; - tri = i; - } else { - error->one(FLERR, "unknown case"); - } - - //x_center << x[tri][0], x[tri][1], x[tri][2]; // center of triangle - x_center(0) = x[tri][0]; - x_center(1) = x[tri][1]; - x_center(2) = x[tri][2]; - //x4 << x[particle][0], x[particle][1], x[particle][2]; - x4(0) = x[particle][0]; - x4(1) = x[particle][1]; - x4(2) = x[particle][2]; - dx = x_center - x4; // - if (periodic) { - domain->minimum_image(dx(0), dx(1), dx(2)); - } - rsq = dx.squaredNorm(); - - r_tri = scale * radius[tri]; - r_particle = scale * radius[particle]; - rcut = r_tri + r_particle; - rcutSq = rcut * rcut; - - //printf("type i=%d, type j=%d, r=%f, ri=%f, rj=%f\n", itype, jtype, sqrt(rsq), ri, rj); - - if (rsq < rcutSq) { - - /* - * gather triangle information - */ - normal(0) = x0[tri][0]; - normal(1) = x0[tri][1]; - normal(2) = x0[tri][2]; - - /* - * distance check: is particle closer than its radius to the triangle plane? - */ - if (fabs(dx.dot(normal)) < radius[particle]) { - /* - * get other two triangle vertices - */ - x1(0) = smd_data_9[tri][0]; - x1(1) = smd_data_9[tri][1]; - x1(2) = smd_data_9[tri][2]; - x2(0) = smd_data_9[tri][3]; - x2(1) = smd_data_9[tri][4]; - x2(2) = smd_data_9[tri][5]; - x3(0) = smd_data_9[tri][6]; - x3(1) = smd_data_9[tri][7]; - x3(2) = smd_data_9[tri][8]; - - PointTriangleDistance(x4, x1, x2, x3, cp, r); - - /* - * distance to closest point - */ - x4cp = x4 - cp; - - /* - * flip normal to point in direction of x4cp - */ - - if (x4cp.dot(normal) < 0.0) { - normal *= -1.0; - } - - /* - * penalty force pushes particle away from triangle - */ - if (r < 1.0 * radius[particle]) { - - delta = radius[particle] - r; // overlap distance - r_geom = radius[particle]; - fpair = 1.066666667e0 * bulkmodulus[itype][jtype] * delta * sqrt(delta * r_geom); - dt_crit = 3.14 * sqrt(rmass[particle] / (fpair / delta)); - stable_time_increment = MIN(stable_time_increment, dt_crit); - - evdwl = r * fpair * 0.4e0 * delta; // GCG 25 April: this expression conserves total energy - - fpair /= (r + 1.0e-2 * radius[particle]); // divide by r + softening and multiply with non-normalized distance vector - - if (particle < nlocal) { - f[particle][0] += x4cp(0) * fpair; - f[particle][1] += x4cp(1) * fpair; - f[particle][2] += x4cp(2) * fpair; - } - - if (tri < nlocal) { - f[tri][0] -= x4cp(0) * fpair; - f[tri][1] -= x4cp(1) * fpair; - f[tri][2] -= x4cp(2) * fpair; - } - - if (evflag) { - ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, x4cp(0), x4cp(1), x4cp(2)); - } - - } - - /* - * if particle comes too close to triangle, reflect its velocity and explicitly move it away - */ - - touch_distance = 1.0 * radius[particle]; - if (r < touch_distance) { - - /* - * reflect velocity if it points toward triangle - */ - - normal = x4cp / r; - - //v_old << v[particle][0], v[particle][1], v[particle][2]; - v_old(0) = v[particle][0]; - v_old(1) = v[particle][1]; - v_old(2) = v[particle][2]; - if (v_old.dot(normal) < 0.0) { - //printf("flipping velocity\n"); - vnew = 1.0 * (-2.0 * v_old.dot(normal) * normal + v_old); - v[particle][0] = vnew(0); - v[particle][1] = vnew(1); - v[particle][2] = vnew(2); - } - - //printf("moving particle on top of triangle\n"); - x[particle][0] = cp(0) + touch_distance * normal(0); - x[particle][1] = cp(1) + touch_distance * normal(1); - x[particle][2] = cp(2) + touch_distance * normal(2); - } - - } - } - } - } - -// int max_neighs_all = 0; -// MPI_Allreduce(&max_neighs, &max_neighs_all, 1, MPI_INT, MPI_MAX, world); -// if (comm->me == 0) { -// printf("max. neighs in tri pair is %d\n", max_neighs_all); -// } + int i, j, ii, jj, inum, jnum, itype, jtype; + double rsq, r, evdwl, fpair; + int *ilist, *jlist, *numneigh, **firstneigh; + double rcut, r_geom, delta, r_tri, r_particle, touch_distance, dt_crit; + int tri, particle; + Vector3d normal, x1, x2, x3, x4, x13, x23, x43, w, cp, x4cp, vnew, v_old; + ; + Vector3d xi, x_center, dx; + Matrix2d C; + Vector2d w2d, rhs; + + evdwl = 0.0; + if (eflag || vflag) + ev_setup(eflag, vflag); + else + evflag = vflag_fdotr = 0; + + tagint *mol = atom->molecule; + double **f = atom->f; + double **smd_data_9 = atom->smd_data_9; + double **x = atom->x; + double **x0 = atom->x0; + double **v = atom->v; + double *rmass = atom->rmass; + int *type = atom->type; + int nlocal = atom->nlocal; + double *radius = atom->contact_radius; + double rcutSq; + Vector3d offset; + + int newton_pair = force->newton_pair; + int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + int max_neighs = 0; + stable_time_increment = 1.0e22; + + // loop over neighbors of my atoms using a half neighbor list + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + max_neighs = MAX(max_neighs, jnum); + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + + j &= NEIGHMASK; + + jtype = type[j]; + + /* + * decide which one of i, j is triangle and which is particle + */ + if ((mol[i] < 65535) && (mol[j] >= 65535)) { + particle = i; + tri = j; + } else if ((mol[j] < 65535) && (mol[i] >= 65535)) { + particle = j; + tri = i; + } else { + error->one(FLERR, "unknown case"); + } + + //x_center << x[tri][0], x[tri][1], x[tri][2]; // center of triangle + x_center(0) = x[tri][0]; + x_center(1) = x[tri][1]; + x_center(2) = x[tri][2]; + //x4 << x[particle][0], x[particle][1], x[particle][2]; + x4(0) = x[particle][0]; + x4(1) = x[particle][1]; + x4(2) = x[particle][2]; + dx = x_center - x4; // + if (periodic) { + domain->minimum_image(dx(0), dx(1), dx(2)); + } + rsq = dx.squaredNorm(); + + r_tri = scale * radius[tri]; + r_particle = scale * radius[particle]; + rcut = r_tri + r_particle; + rcutSq = rcut * rcut; + + //printf("type i=%d, type j=%d, r=%f, ri=%f, rj=%f\n", itype, jtype, sqrt(rsq), ri, rj); + + if (rsq < rcutSq) { + + /* + * gather triangle information + */ + normal(0) = x0[tri][0]; + normal(1) = x0[tri][1]; + normal(2) = x0[tri][2]; + + /* + * distance check: is particle closer than its radius to the triangle plane? + */ + if (fabs(dx.dot(normal)) < radius[particle]) { + /* + * get other two triangle vertices + */ + x1(0) = smd_data_9[tri][0]; + x1(1) = smd_data_9[tri][1]; + x1(2) = smd_data_9[tri][2]; + x2(0) = smd_data_9[tri][3]; + x2(1) = smd_data_9[tri][4]; + x2(2) = smd_data_9[tri][5]; + x3(0) = smd_data_9[tri][6]; + x3(1) = smd_data_9[tri][7]; + x3(2) = smd_data_9[tri][8]; + + PointTriangleDistance(x4, x1, x2, x3, cp, r); + + /* + * distance to closest point + */ + x4cp = x4 - cp; + + /* + * flip normal to point in direction of x4cp + */ + + if (x4cp.dot(normal) < 0.0) { + normal *= -1.0; + } + + /* + * penalty force pushes particle away from triangle + */ + if (r < 1.0 * radius[particle]) { + + delta = radius[particle] - r; // overlap distance + r_geom = radius[particle]; + fpair = 1.066666667e0 * bulkmodulus[itype][jtype] * delta * sqrt(delta * r_geom); + dt_crit = 3.14 * sqrt(rmass[particle] / (fpair / delta)); + stable_time_increment = MIN(stable_time_increment, dt_crit); + + evdwl = r * fpair * 0.4e0 * delta; // GCG 25 April: this expression conserves total energy + + fpair /= (r + 1.0e-2 * radius[particle]); // divide by r + softening and multiply with non-normalized distance vector + + if (particle < nlocal) { + f[particle][0] += x4cp(0) * fpair; + f[particle][1] += x4cp(1) * fpair; + f[particle][2] += x4cp(2) * fpair; + } + + if (tri < nlocal) { + f[tri][0] -= x4cp(0) * fpair; + f[tri][1] -= x4cp(1) * fpair; + f[tri][2] -= x4cp(2) * fpair; + } + + if (evflag) { + ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, x4cp(0), x4cp(1), x4cp(2)); + } + + } + + /* + * if particle comes too close to triangle, reflect its velocity and explicitly move it away + */ + + touch_distance = 1.0 * radius[particle]; + if (r < touch_distance) { + + /* + * reflect velocity if it points toward triangle + */ + + normal = x4cp / r; + + //v_old << v[particle][0], v[particle][1], v[particle][2]; + v_old(0) = v[particle][0]; + v_old(1) = v[particle][1]; + v_old(2) = v[particle][2]; + if (v_old.dot(normal) < 0.0) { + //printf("flipping velocity\n"); + vnew = 1.0 * (-2.0 * v_old.dot(normal) * normal + v_old); + v[particle][0] = vnew(0); + v[particle][1] = vnew(1); + v[particle][2] = vnew(2); + } + + //printf("moving particle on top of triangle\n"); + x[particle][0] = cp(0) + touch_distance * normal(0); + x[particle][1] = cp(1) + touch_distance * normal(1); + x[particle][2] = cp(2) + touch_distance * normal(2); + } + + } + } + } + } + +// int max_neighs_all = 0; +// MPI_Allreduce(&max_neighs, &max_neighs_all, 1, MPI_INT, MPI_MAX, world); +// if (comm->me == 0) { +// printf("max. neighs in tri pair is %d\n", max_neighs_all); +// } // -// double stable_time_increment_all = 0.0; -// MPI_Allreduce(&stable_time_increment, &stable_time_increment_all, 1, MPI_DOUBLE, MPI_MIN, world); -// if (comm->me == 0) { -// printf("stable time step tri pair is %f\n", stable_time_increment_all); -// } +// double stable_time_increment_all = 0.0; +// MPI_Allreduce(&stable_time_increment, &stable_time_increment_all, 1, MPI_DOUBLE, MPI_MIN, world); +// if (comm->me == 0) { +// printf("stable time step tri pair is %f\n", stable_time_increment_all); +// } } /* ---------------------------------------------------------------------- @@ -302,23 +302,23 @@ void PairTriSurf::compute(int eflag, int vflag) { ------------------------------------------------------------------------- */ void PairTriSurf::allocate() { - allocated = 1; - int n = atom->ntypes; + allocated = 1; + int n = atom->ntypes; - memory->create(setflag, n + 1, n + 1, "pair:setflag"); - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; + memory->create(setflag, n + 1, n + 1, "pair:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; - memory->create(bulkmodulus, n + 1, n + 1, "pair:kspring"); - memory->create(kn, n + 1, n + 1, "pair:kn"); + memory->create(bulkmodulus, n + 1, n + 1, "pair:kspring"); + memory->create(kn, n + 1, n + 1, "pair:kn"); - memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); // always needs to be allocated, even with granular neighborlist + memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); // always needs to be allocated, even with granular neighborlist - onerad_dynamic = new double[n + 1]; - onerad_frozen = new double[n + 1]; - maxrad_dynamic = new double[n + 1]; - maxrad_frozen = new double[n + 1]; + onerad_dynamic = new double[n + 1]; + onerad_frozen = new double[n + 1]; + maxrad_dynamic = new double[n + 1]; + maxrad_frozen = new double[n + 1]; } /* ---------------------------------------------------------------------- @@ -326,16 +326,16 @@ void PairTriSurf::allocate() { ------------------------------------------------------------------------- */ void PairTriSurf::settings(int narg, char **arg) { - if (narg != 1) - error->all(FLERR, "Illegal number of args for pair_style smd/tri_surface"); + if (narg != 1) + error->all(FLERR, "Illegal number of args for pair_style smd/tri_surface"); - scale = force->numeric(FLERR, arg[0]); - if (comm->me == 0) { - printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); - printf("SMD/TRI_SURFACE CONTACT SETTINGS:\n"); - printf("... effective contact radius is scaled by %f\n", scale); - printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); - } + scale = force->numeric(FLERR, arg[0]); + if (comm->me == 0) { + printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); + printf("SMD/TRI_SURFACE CONTACT SETTINGS:\n"); + printf("... effective contact radius is scaled by %f\n", scale); + printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); + } } @@ -344,37 +344,37 @@ void PairTriSurf::settings(int narg, char **arg) { ------------------------------------------------------------------------- */ void PairTriSurf::coeff(int narg, char **arg) { - if (narg != 3) - error->all(FLERR, "Incorrect args for pair coefficients"); - if (!allocated) - allocate(); - - int ilo, ihi, jlo, jhi; - force->bounds(FLERR,arg[0], atom->ntypes, ilo, ihi); - force->bounds(FLERR,arg[1], atom->ntypes, jlo, jhi); - - double bulkmodulus_one = atof(arg[2]); - - // set short-range force constant - double kn_one = 0.0; - if (domain->dimension == 3) { - kn_one = (16. / 15.) * bulkmodulus_one; //assuming poisson ratio = 1/4 for 3d - } else { - kn_one = 0.251856195 * (2. / 3.) * bulkmodulus_one; //assuming poisson ratio = 1/3 for 2d - } - - int count = 0; - for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo, i); j <= jhi; j++) { - bulkmodulus[i][j] = bulkmodulus_one; - kn[i][j] = kn_one; - setflag[i][j] = 1; - count++; - } - } - - if (count == 0) - error->all(FLERR, "Incorrect args for pair coefficients"); + if (narg != 3) + error->all(FLERR, "Incorrect args for pair coefficients"); + if (!allocated) + allocate(); + + int ilo, ihi, jlo, jhi; + force->bounds(FLERR,arg[0], atom->ntypes, ilo, ihi); + force->bounds(FLERR,arg[1], atom->ntypes, jlo, jhi); + + double bulkmodulus_one = atof(arg[2]); + + // set short-range force constant + double kn_one = 0.0; + if (domain->dimension == 3) { + kn_one = (16. / 15.) * bulkmodulus_one; //assuming poisson ratio = 1/4 for 3d + } else { + kn_one = 0.251856195 * (2. / 3.) * bulkmodulus_one; //assuming poisson ratio = 1/3 for 2d + } + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo, i); j <= jhi; j++) { + bulkmodulus[i][j] = bulkmodulus_one; + kn[i][j] = kn_one; + setflag[i][j] = 1; + count++; + } + } + + if (count == 0) + error->all(FLERR, "Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -383,26 +383,26 @@ void PairTriSurf::coeff(int narg, char **arg) { double PairTriSurf::init_one(int i, int j) { - if (!allocated) - allocate(); + if (!allocated) + allocate(); - if (setflag[i][j] == 0) - error->all(FLERR, "All pair coeffs are not set"); + if (setflag[i][j] == 0) + error->all(FLERR, "All pair coeffs are not set"); - bulkmodulus[j][i] = bulkmodulus[i][j]; - kn[j][i] = kn[i][j]; + bulkmodulus[j][i] = bulkmodulus[i][j]; + kn[j][i] = kn[i][j]; - // cutoff = sum of max I,J radii for - // dynamic/dynamic & dynamic/frozen interactions, but not frozen/frozen + // cutoff = sum of max I,J radii for + // dynamic/dynamic & dynamic/frozen interactions, but not frozen/frozen - double cutoff = maxrad_dynamic[i] + maxrad_dynamic[j]; - cutoff = MAX(cutoff, maxrad_frozen[i] + maxrad_dynamic[j]); - cutoff = MAX(cutoff, maxrad_dynamic[i] + maxrad_frozen[j]); + double cutoff = maxrad_dynamic[i] + maxrad_dynamic[j]; + cutoff = MAX(cutoff, maxrad_frozen[i] + maxrad_dynamic[j]); + cutoff = MAX(cutoff, maxrad_dynamic[i] + maxrad_frozen[j]); - if (comm->me == 0) { - printf("cutoff for pair smd/smd/tri_surface = %f\n", cutoff); - } - return cutoff; + if (comm->me == 0) { + printf("cutoff for pair smd/smd/tri_surface = %f\n", cutoff); + } + return cutoff; } /* ---------------------------------------------------------------------- @@ -410,38 +410,38 @@ double PairTriSurf::init_one(int i, int j) { ------------------------------------------------------------------------- */ void PairTriSurf::init_style() { - int i; + int i; - // error checks + // error checks - if (!atom->contact_radius_flag) - error->all(FLERR, "Pair style smd/smd/tri_surface requires atom style with contact_radius"); + if (!atom->contact_radius_flag) + error->all(FLERR, "Pair style smd/smd/tri_surface requires atom style with contact_radius"); - // old: half list - int irequest = neighbor->request(this); - neighbor->requests[irequest]->size = 1; + // old: half list + int irequest = neighbor->request(this); + neighbor->requests[irequest]->size = 1; - // need a full neighbor list -// int irequest = neighbor->request(this); -// neighbor->requests[irequest]->half = 0; -// neighbor->requests[irequest]->full = 1; + // need a full neighbor list +// int irequest = neighbor->request(this); +// neighbor->requests[irequest]->half = 0; +// neighbor->requests[irequest]->full = 1; - // set maxrad_dynamic and maxrad_frozen for each type - // include future Fix pour particles as dynamic + // set maxrad_dynamic and maxrad_frozen for each type + // include future Fix pour particles as dynamic - for (i = 1; i <= atom->ntypes; i++) - onerad_dynamic[i] = onerad_frozen[i] = 0.0; + for (i = 1; i <= atom->ntypes; i++) + onerad_dynamic[i] = onerad_frozen[i] = 0.0; - double *radius = atom->radius; - int *type = atom->type; - int nlocal = atom->nlocal; + double *radius = atom->radius; + int *type = atom->type; + int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) { - onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]); - } + for (i = 0; i < nlocal; i++) { + onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]); + } - MPI_Allreduce(&onerad_dynamic[1], &maxrad_dynamic[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); - MPI_Allreduce(&onerad_frozen[1], &maxrad_frozen[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); + MPI_Allreduce(&onerad_dynamic[1], &maxrad_dynamic[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); + MPI_Allreduce(&onerad_frozen[1], &maxrad_frozen[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); } /* ---------------------------------------------------------------------- @@ -450,8 +450,8 @@ void PairTriSurf::init_style() { ------------------------------------------------------------------------- */ void PairTriSurf::init_list(int id, NeighList *ptr) { - if (id == 0) - list = ptr; + if (id == 0) + list = ptr; } /* ---------------------------------------------------------------------- @@ -460,7 +460,7 @@ void PairTriSurf::init_list(int id, NeighList *ptr) { double PairTriSurf::memory_usage() { - return 0.0; + return 0.0; } /* @@ -547,199 +547,199 @@ double PairTriSurf::memory_usage() { */ //void PairTriSurf::PointTriangleDistance(const Vector3d P, const Vector3d TRI1, const Vector3d TRI2, const Vector3d TRI3, -// Vector3d &CP, double &dist) { +// Vector3d &CP, double &dist) { // -// Vector3d B, E0, E1, D; -// double a, b, c, d, e, f; -// double det, s, t, sqrDistance, tmp0, tmp1, numer, denom, invDet; +// Vector3d B, E0, E1, D; +// double a, b, c, d, e, f; +// double det, s, t, sqrDistance, tmp0, tmp1, numer, denom, invDet; // -// // rewrite triangle in normal form -// B = TRI1; -// E0 = TRI2 - B; -// E1 = TRI3 - B; +// // rewrite triangle in normal form +// B = TRI1; +// E0 = TRI2 - B; +// E1 = TRI3 - B; // -// D = B - P; -// a = E0.dot(E0); -// b = E0.dot(E1); -// c = E1.dot(E1); -// d = E0.dot(D); -// e = E1.dot(D); -// f = D.dot(D); +// D = B - P; +// a = E0.dot(E0); +// b = E0.dot(E1); +// c = E1.dot(E1); +// d = E0.dot(D); +// e = E1.dot(D); +// f = D.dot(D); // -// det = a * c - b * b; -// //% do we have to use abs here? -// s = b * e - c * d; -// t = b * d - a * e; +// det = a * c - b * b; +// //% do we have to use abs here? +// s = b * e - c * d; +// t = b * d - a * e; // -// //% Terible tree of conditionals to determine in which region of the diagram -// //% shown above the projection of the point into the triangle-plane lies. -// if ((s + t) <= det) { -// if (s < 0) { -// if (t < 0) { -// // %region4 -// if (d < 0) { -// t = 0; -// if (-d >= a) { -// s = 1; -// sqrDistance = a + 2 * d + f; -// } else { -// s = -d / a; -// sqrDistance = d * s + f; -// } -// } else { -// s = 0; -// if (e >= 0) { -// t = 0; -// sqrDistance = f; -// } else { -// if (-e >= c) { -// t = 1; -// sqrDistance = c + 2 * e + f; -// } else { -// t = -e / c; -// sqrDistance = e * t + f; -// } -// } -// } -// // end % of region 4 -// } else { -// // % region 3 -// s = 0; -// if (e >= 0) { -// t = 0; -// sqrDistance = f; -// } else { -// if (-e >= c) { -// t = 1; -// sqrDistance = c + 2 * e + f; -// } else { -// t = -e / c; -// sqrDistance = e * t + f; -// } -// } -// } -// // end of region 3 -// } else { -// if (t < 0) { -// //% region 5 -// t = 0; -// if (d >= 0) { -// s = 0; -// sqrDistance = f; -// } else { -// if (-d >= a) { -// s = 1; -// sqrDistance = a + 2 * d + f; -// } else { -// s = -d / a; -// sqrDistance = d * s + f; -// } -// } -// } else { -// // region 0 -// invDet = 1 / det; -// s = s * invDet; -// t = t * invDet; -// sqrDistance = s * (a * s + b * t + 2 * d) + t * (b * s + c * t + 2 * e) + f; -// } -// } -// } else { -// if (s < 0) { -// // % region 2 -// tmp0 = b + d; -// tmp1 = c + e; -// if (tmp1 > tmp0) { //% minimum on edge s+t=1 -// numer = tmp1 - tmp0; -// denom = a - 2 * b + c; -// if (numer >= denom) { -// s = 1; -// t = 0; -// sqrDistance = a + 2 * d + f; -// } else { -// s = numer / denom; -// t = 1 - s; -// sqrDistance = s * (a * s + b * t + 2 * d) + t * (b * s + c * t + 2 * e) + f; -// } -// } else -// // % minimum on edge s=0 -// s = 0; -// if (tmp1 <= 0) { -// t = 1; -// sqrDistance = c + 2 * e + f; -// } else { -// if (e >= 0) { -// t = 0; -// sqrDistance = f; -// } else { -// t = -e / c; -// sqrDistance = e * t + f; -// } -// } -// } //end % of region 2 -// else { -// if (t < 0) { -// // %region6 -// tmp0 = b + e; -// tmp1 = a + d; -// if (tmp1 > tmp0) { -// numer = tmp1 - tmp0; -// denom = a - 2 * b + c; -// if (numer >= denom) { -// t = 1; -// s = 0; -// sqrDistance = c + 2 * e + f; -// } else { -// t = numer / denom; -// s = 1 - t; -// sqrDistance = s * (a * s + b * t + 2 * d) + t * (b * s + c * t + 2 * e) + f; -// } -// } else { -// t = 0; -// if (tmp1 <= 0) { -// s = 1; -// sqrDistance = a + 2 * d + f; -// } else { -// if (d >= 0) { -// s = 0; -// sqrDistance = f; -// } else { -// s = -d / a; -// sqrDistance = d * s + f; -// } -// } -// } // % end region 6 -// } else { -// //% region 1 -// numer = c + e - b - d; -// if (numer <= 0) { -// s = 0; -// t = 1; -// sqrDistance = c + 2 * e + f; -// } else { -// denom = a - 2 * b + c; -// if (numer >= denom) { -// s = 1; -// t = 0; -// sqrDistance = a + 2 * d + f; -// } else { -// s = numer / denom; -// t = 1 - s; -// sqrDistance = s * (a * s + b * t + 2 * d) + t * (b * s + c * t + 2 * e) + f; -// } -// } //% end of region 1 -// } -// } -// } +// //% Terible tree of conditionals to determine in which region of the diagram +// //% shown above the projection of the point into the triangle-plane lies. +// if ((s + t) <= det) { +// if (s < 0) { +// if (t < 0) { +// // %region4 +// if (d < 0) { +// t = 0; +// if (-d >= a) { +// s = 1; +// sqrDistance = a + 2 * d + f; +// } else { +// s = -d / a; +// sqrDistance = d * s + f; +// } +// } else { +// s = 0; +// if (e >= 0) { +// t = 0; +// sqrDistance = f; +// } else { +// if (-e >= c) { +// t = 1; +// sqrDistance = c + 2 * e + f; +// } else { +// t = -e / c; +// sqrDistance = e * t + f; +// } +// } +// } +// // end % of region 4 +// } else { +// // % region 3 +// s = 0; +// if (e >= 0) { +// t = 0; +// sqrDistance = f; +// } else { +// if (-e >= c) { +// t = 1; +// sqrDistance = c + 2 * e + f; +// } else { +// t = -e / c; +// sqrDistance = e * t + f; +// } +// } +// } +// // end of region 3 +// } else { +// if (t < 0) { +// //% region 5 +// t = 0; +// if (d >= 0) { +// s = 0; +// sqrDistance = f; +// } else { +// if (-d >= a) { +// s = 1; +// sqrDistance = a + 2 * d + f; +// } else { +// s = -d / a; +// sqrDistance = d * s + f; +// } +// } +// } else { +// // region 0 +// invDet = 1 / det; +// s = s * invDet; +// t = t * invDet; +// sqrDistance = s * (a * s + b * t + 2 * d) + t * (b * s + c * t + 2 * e) + f; +// } +// } +// } else { +// if (s < 0) { +// // % region 2 +// tmp0 = b + d; +// tmp1 = c + e; +// if (tmp1 > tmp0) { //% minimum on edge s+t=1 +// numer = tmp1 - tmp0; +// denom = a - 2 * b + c; +// if (numer >= denom) { +// s = 1; +// t = 0; +// sqrDistance = a + 2 * d + f; +// } else { +// s = numer / denom; +// t = 1 - s; +// sqrDistance = s * (a * s + b * t + 2 * d) + t * (b * s + c * t + 2 * e) + f; +// } +// } else +// // % minimum on edge s=0 +// s = 0; +// if (tmp1 <= 0) { +// t = 1; +// sqrDistance = c + 2 * e + f; +// } else { +// if (e >= 0) { +// t = 0; +// sqrDistance = f; +// } else { +// t = -e / c; +// sqrDistance = e * t + f; +// } +// } +// } //end % of region 2 +// else { +// if (t < 0) { +// // %region6 +// tmp0 = b + e; +// tmp1 = a + d; +// if (tmp1 > tmp0) { +// numer = tmp1 - tmp0; +// denom = a - 2 * b + c; +// if (numer >= denom) { +// t = 1; +// s = 0; +// sqrDistance = c + 2 * e + f; +// } else { +// t = numer / denom; +// s = 1 - t; +// sqrDistance = s * (a * s + b * t + 2 * d) + t * (b * s + c * t + 2 * e) + f; +// } +// } else { +// t = 0; +// if (tmp1 <= 0) { +// s = 1; +// sqrDistance = a + 2 * d + f; +// } else { +// if (d >= 0) { +// s = 0; +// sqrDistance = f; +// } else { +// s = -d / a; +// sqrDistance = d * s + f; +// } +// } +// } // % end region 6 +// } else { +// //% region 1 +// numer = c + e - b - d; +// if (numer <= 0) { +// s = 0; +// t = 1; +// sqrDistance = c + 2 * e + f; +// } else { +// denom = a - 2 * b + c; +// if (numer >= denom) { +// s = 1; +// t = 0; +// sqrDistance = a + 2 * d + f; +// } else { +// s = numer / denom; +// t = 1 - s; +// sqrDistance = s * (a * s + b * t + 2 * d) + t * (b * s + c * t + 2 * e) + f; +// } +// } //% end of region 1 +// } +// } +// } // -// // % account for numerical round-off error -// if (sqrDistance < 0) { -// sqrDistance = 0; -// } +// // % account for numerical round-off error +// if (sqrDistance < 0) { +// sqrDistance = 0; +// } // -// dist = sqrt(sqrDistance); +// dist = sqrt(sqrDistance); // -// // closest point -// CP = B + s * E0 + t * E1; +// // closest point +// CP = B + s * E0 + t * E1; // //} /* @@ -750,96 +750,96 @@ double PairTriSurf::memory_usage() { */ void PairTriSurf::PointTriangleDistance(const Vector3d sourcePosition, const Vector3d TRI0, const Vector3d TRI1, - const Vector3d TRI2, Vector3d &CP, double &dist) { - - Vector3d edge0 = TRI1 - TRI0; - Vector3d edge1 = TRI2 - TRI0; - Vector3d v0 = TRI0 - sourcePosition; - - double a = edge0.dot(edge0); - double b = edge0.dot(edge1); - double c = edge1.dot(edge1); - double d = edge0.dot(v0); - double e = edge1.dot(v0); - - double det = a * c - b * b; - double s = b * e - c * d; - double t = b * d - a * e; - - if (s + t < det) { - if (s < 0.f) { - if (t < 0.f) { - if (d < 0.f) { - s = clamp(-d / a, 0.f, 1.f); - t = 0.f; - } else { - s = 0.f; - t = clamp(-e / c, 0.f, 1.f); - } - } else { - s = 0.f; - t = clamp(-e / c, 0.f, 1.f); - } - } else if (t < 0.f) { - s = clamp(-d / a, 0.f, 1.f); - t = 0.f; - } else { - float invDet = 1.f / det; - s *= invDet; - t *= invDet; - } - } else { - if (s < 0.f) { - float tmp0 = b + d; - float tmp1 = c + e; - if (tmp1 > tmp0) { - float numer = tmp1 - tmp0; - float denom = a - 2 * b + c; - s = clamp(numer / denom, 0.f, 1.f); - t = 1 - s; - } else { - t = clamp(-e / c, 0.f, 1.f); - s = 0.f; - } - } else if (t < 0.f) { - if (a + d > b + e) { - float numer = c + e - b - d; - float denom = a - 2 * b + c; - s = clamp(numer / denom, 0.f, 1.f); - t = 1 - s; - } else { - s = clamp(-e / c, 0.f, 1.f); - t = 0.f; - } - } else { - float numer = c + e - b - d; - float denom = a - 2 * b + c; - s = clamp(numer / denom, 0.f, 1.f); - t = 1.f - s; - } - } - - CP = TRI0 + s * edge0 + t * edge1; - dist = (CP - sourcePosition).norm(); + const Vector3d TRI2, Vector3d &CP, double &dist) { + + Vector3d edge0 = TRI1 - TRI0; + Vector3d edge1 = TRI2 - TRI0; + Vector3d v0 = TRI0 - sourcePosition; + + double a = edge0.dot(edge0); + double b = edge0.dot(edge1); + double c = edge1.dot(edge1); + double d = edge0.dot(v0); + double e = edge1.dot(v0); + + double det = a * c - b * b; + double s = b * e - c * d; + double t = b * d - a * e; + + if (s + t < det) { + if (s < 0.f) { + if (t < 0.f) { + if (d < 0.f) { + s = clamp(-d / a, 0.f, 1.f); + t = 0.f; + } else { + s = 0.f; + t = clamp(-e / c, 0.f, 1.f); + } + } else { + s = 0.f; + t = clamp(-e / c, 0.f, 1.f); + } + } else if (t < 0.f) { + s = clamp(-d / a, 0.f, 1.f); + t = 0.f; + } else { + float invDet = 1.f / det; + s *= invDet; + t *= invDet; + } + } else { + if (s < 0.f) { + float tmp0 = b + d; + float tmp1 = c + e; + if (tmp1 > tmp0) { + float numer = tmp1 - tmp0; + float denom = a - 2 * b + c; + s = clamp(numer / denom, 0.f, 1.f); + t = 1 - s; + } else { + t = clamp(-e / c, 0.f, 1.f); + s = 0.f; + } + } else if (t < 0.f) { + if (a + d > b + e) { + float numer = c + e - b - d; + float denom = a - 2 * b + c; + s = clamp(numer / denom, 0.f, 1.f); + t = 1 - s; + } else { + s = clamp(-e / c, 0.f, 1.f); + t = 0.f; + } + } else { + float numer = c + e - b - d; + float denom = a - 2 * b + c; + s = clamp(numer / denom, 0.f, 1.f); + t = 1.f - s; + } + } + + CP = TRI0 + s * edge0 + t * edge1; + dist = (CP - sourcePosition).norm(); } double PairTriSurf::clamp(const double a, const double min, const double max) { - if (a < min) { - return min; - } else if (a > max) { - return max; - } else { - return a; - } + if (a < min) { + return min; + } else if (a > max) { + return max; + } else { + return a; + } } void *PairTriSurf::extract(const char *str, int &i) { - //printf("in PairTriSurf::extract\n"); - if (strcmp(str, "smd/tri_surface/stable_time_increment_ptr") == 0) { - return (void *) &stable_time_increment; - } + //printf("in PairTriSurf::extract\n"); + if (strcmp(str, "smd/tri_surface/stable_time_increment_ptr") == 0) { + return (void *) &stable_time_increment; + } - return NULL; + return NULL; } diff --git a/src/USER-SMD/pair_smd_ulsph.cpp b/src/USER-SMD/pair_smd_ulsph.cpp index b983620a02..fcb5e7eeb0 100644 --- a/src/USER-SMD/pair_smd_ulsph.cpp +++ b/src/USER-SMD/pair_smd_ulsph.cpp @@ -58,65 +58,65 @@ using namespace Eigen; #define FORMAT2 "\n.............................. %s \n" PairULSPH::PairULSPH(LAMMPS *lmp) : - Pair(lmp) { - - // per-type arrays - Q1 = NULL; - eos = viscosity = strength = NULL; - c0_type = NULL; - c0 = NULL; - Lookup = NULL; - artificial_stress = NULL; - artificial_pressure = NULL; - - nmax = 0; // make sure no atom on this proc such that initial memory allocation is correct - stressTensor = L = K = NULL; - shepardWeight = NULL; - smoothVel = NULL; - numNeighs = NULL; - F = NULL; - rho = NULL; - effm = NULL; - - velocity_gradient_required = false; // turn off computation of velocity gradient by default - density_summation = velocity_gradient = false; - - comm_forward = 18; // this pair style communicates 18 doubles to ghost atoms - updateFlag = 0; + Pair(lmp) { + + // per-type arrays + Q1 = NULL; + eos = viscosity = strength = NULL; + c0_type = NULL; + c0 = NULL; + Lookup = NULL; + artificial_stress = NULL; + artificial_pressure = NULL; + + nmax = 0; // make sure no atom on this proc such that initial memory allocation is correct + stressTensor = L = K = NULL; + shepardWeight = NULL; + smoothVel = NULL; + numNeighs = NULL; + F = NULL; + rho = NULL; + effm = NULL; + + velocity_gradient_required = false; // turn off computation of velocity gradient by default + density_summation = velocity_gradient = false; + + comm_forward = 18; // this pair style communicates 18 doubles to ghost atoms + updateFlag = 0; } /* ---------------------------------------------------------------------- */ PairULSPH::~PairULSPH() { - if (allocated) { - //printf("... deallocating\n"); - memory->destroy(Q1); - memory->destroy(rho0); - memory->destroy(eos); - memory->destroy(viscosity); - memory->destroy(strength); - memory->destroy(c0_type); - memory->destroy(Lookup); - memory->destroy(artificial_pressure); - memory->destroy(artificial_stress); - - delete[] onerad_dynamic; - delete[] onerad_frozen; - delete[] maxrad_dynamic; - delete[] maxrad_frozen; - - delete[] K; - delete[] shepardWeight; - delete[] c0; - delete[] smoothVel; - delete[] stressTensor; - delete[] L; - delete[] numNeighs; - delete[] F; - delete[] rho; - delete[] effm; - - } + if (allocated) { + //printf("... deallocating\n"); + memory->destroy(Q1); + memory->destroy(rho0); + memory->destroy(eos); + memory->destroy(viscosity); + memory->destroy(strength); + memory->destroy(c0_type); + memory->destroy(Lookup); + memory->destroy(artificial_pressure); + memory->destroy(artificial_stress); + + delete[] onerad_dynamic; + delete[] onerad_frozen; + delete[] maxrad_dynamic; + delete[] maxrad_frozen; + + delete[] K; + delete[] shepardWeight; + delete[] c0; + delete[] smoothVel; + delete[] stressTensor; + delete[] L; + delete[] numNeighs; + delete[] F; + delete[] rho; + delete[] effm; + + } } /* ---------------------------------------------------------------------- @@ -127,80 +127,80 @@ PairULSPH::~PairULSPH() { ---------------------------------------------------------------------- */ void PairULSPH::PreCompute_DensitySummation() { - double *radius = atom->radius; - double **x = atom->x; - double *rmass = atom->rmass; - int *type = atom->type; - int *ilist, *jlist, *numneigh; - int **firstneigh; - int nlocal = atom->nlocal; - int inum, jnum, ii, jj, i, itype, jtype, j; - double h, irad, hsq, rSq, wf; - Vector3d dx, xi, xj; - - // set up neighbor list variables - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - // zero accumulators - for (i = 0; i < nlocal; i++) { - rho[i] = 0.0; - //shepardWeight[i] = 0.0; - } - - /* - * only recompute mass density if density summation is used. - * otherwise, change in mass density is time-integrated - */ - for (i = 0; i < nlocal; i++) { - itype = type[i]; - if (setflag[itype][itype] == 1) { - // initialize particle density with self-contribution. - h = 2.0 * radius[i]; - hsq = h * h; - Poly6Kernel(hsq, h, 0.0, domain->dimension, wf); - rho[i] = wf * rmass[i]; // / shepardWeight[i]; - //printf("SIC to rho is %f\n", rho[i]); - } - } - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - irad = radius[i]; - - xi << x[i][0], x[i][1], x[i][2]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - xj << x[j][0], x[j][1], x[j][2]; - dx = xj - xi; - rSq = dx.squaredNorm(); - h = irad + radius[j]; - hsq = h * h; - if (rSq < hsq) { - - jtype = type[j]; - Poly6Kernel(hsq, h, rSq, domain->dimension, wf); - - if (setflag[itype][itype] == 1) { - rho[i] += wf * rmass[j]; // / shepardWeight[i]; - } - - if (j < nlocal) { - if (setflag[jtype][jtype] == 1) { - rho[j] += wf * rmass[i]; // / shepardWeight[j]; - } - } - } // end if check distance - } // end loop over j - } // end loop over i + double *radius = atom->radius; + double **x = atom->x; + double *rmass = atom->rmass; + int *type = atom->type; + int *ilist, *jlist, *numneigh; + int **firstneigh; + int nlocal = atom->nlocal; + int inum, jnum, ii, jj, i, itype, jtype, j; + double h, irad, hsq, rSq, wf; + Vector3d dx, xi, xj; + + // set up neighbor list variables + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // zero accumulators + for (i = 0; i < nlocal; i++) { + rho[i] = 0.0; + //shepardWeight[i] = 0.0; + } + + /* + * only recompute mass density if density summation is used. + * otherwise, change in mass density is time-integrated + */ + for (i = 0; i < nlocal; i++) { + itype = type[i]; + if (setflag[itype][itype] == 1) { + // initialize particle density with self-contribution. + h = 2.0 * radius[i]; + hsq = h * h; + Poly6Kernel(hsq, h, 0.0, domain->dimension, wf); + rho[i] = wf * rmass[i]; // / shepardWeight[i]; + //printf("SIC to rho is %f\n", rho[i]); + } + } + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + irad = radius[i]; + + xi << x[i][0], x[i][1], x[i][2]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + xj << x[j][0], x[j][1], x[j][2]; + dx = xj - xi; + rSq = dx.squaredNorm(); + h = irad + radius[j]; + hsq = h * h; + if (rSq < hsq) { + + jtype = type[j]; + Poly6Kernel(hsq, h, rSq, domain->dimension, wf); + + if (setflag[itype][itype] == 1) { + rho[i] += wf * rmass[j]; // / shepardWeight[i]; + } + + if (j < nlocal) { + if (setflag[jtype][jtype] == 1) { + rho[j] += wf * rmass[i]; // / shepardWeight[j]; + } + } + } // end if check distance + } // end loop over j + } // end loop over i } /* ---------------------------------------------------------------------- @@ -211,427 +211,427 @@ void PairULSPH::PreCompute_DensitySummation() { ---------------------------------------------------------------------- */ void PairULSPH::PreCompute() { - double **atom_data9 = atom->smd_data_9; - double *radius = atom->radius; - double **x = atom->x; - double **x0 = atom->x0; - double **v = atom->vest; - double *vfrac = atom->vfrac; - int *type = atom->type; - int *ilist, *jlist, *numneigh; - int **firstneigh; - int nlocal = atom->nlocal; - int inum, jnum, ii, jj, i, itype, j, idim; - double wfd, h, irad, r, rSq, wf, ivol, jvol; - Vector3d dx, dv, g, du; - Matrix3d Ktmp, Ltmp, Ftmp, K3di, D; - Vector3d xi, xj, vi, vj, x0i, x0j, dx0; - Matrix2d K2di, K2d; - - // zero accumulators - for (i = 0; i < nlocal; i++) { - itype = type[i]; - if (setflag[itype][itype]) { - if (gradient_correction_flag) { - K[i].setZero(); - } else { - K[i].setIdentity(); - } - L[i].setZero(); - F[i].setZero(); - } - } - - // set up neighbor list variables - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - irad = radius[i]; - ivol = vfrac[i]; - - // initialize Eigen data structures from LAMMPS data structures - for (idim = 0; idim < 3; idim++) { - x0i(idim) = x0[i][idim]; - xi(idim) = x[i][idim]; - vi(idim) = v[i][idim]; - } - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - for (idim = 0; idim < 3; idim++) { - x0j(idim) = x0[j][idim]; - xj(idim) = x[j][idim]; - vj(idim) = v[j][idim]; - } - - dx = xj - xi; - - rSq = dx.squaredNorm(); - h = irad + radius[j]; - if (rSq < h * h) { - - r = sqrt(rSq); - jvol = vfrac[j]; - - // distance vectors in current and reference configuration, velocity difference - dv = vj - vi; - dx0 = x0j - x0i; - - // kernel and derivative - spiky_kernel_and_derivative(h, r, domain->dimension, wf, wfd); - //barbara_kernel_and_derivative(h, r, domain->dimension, wf, wfd); - - // uncorrected kernel gradient - g = (wfd / r) * dx; - - /* build correction matrix for kernel derivatives */ - if (gradient_correction_flag) { - Ktmp = -g * dx.transpose(); - K[i] += jvol * Ktmp; - } - - // velocity gradient L - Ltmp = -dv * g.transpose(); - L[i] += jvol * Ltmp; - - // deformation gradient F in Eulerian frame - du = dx - dx0; - Ftmp = dv * g.transpose(); - F[i] += jvol * Ftmp; - - if (j < nlocal) { - - if (gradient_correction_flag) { - K[j] += ivol * Ktmp; - } - - L[j] += ivol * Ltmp; - F[j] += ivol * Ftmp; - } - } // end if check distance - } // end loop over j - } // end loop over i - - /* - * invert shape matrix and compute corrected quantities - */ - - for (i = 0; i < nlocal; i++) { - itype = type[i]; - if (setflag[itype][itype]) { - if (gradient_correction_flag) { - pseudo_inverse_SVD(K[i]); - K[i] = LimitEigenvalues(K[i], 2.0); - L[i] *= K[i]; - F[i] *= K[i]; - } // end if (gradient_correction[itype]) { - - /* - * accumulate strain increments - * we abuse the atom array "atom_data_9" for this purpose, which was originally designed to hold the deformation gradient. - */ - D = update->dt * 0.5 * (L[i] + L[i].transpose()); - atom_data9[i][0] += D(0, 0); // xx - atom_data9[i][1] += D(1, 1); // yy - atom_data9[i][2] += D(2, 2); // zz - atom_data9[i][3] += D(0, 1); // xy - atom_data9[i][4] += D(0, 2); // xz - atom_data9[i][5] += D(1, 2); // yz - - } // end if (setflag[itype][itype]) - } // end loop over i = 0 to nlocal + double **atom_data9 = atom->smd_data_9; + double *radius = atom->radius; + double **x = atom->x; + double **x0 = atom->x0; + double **v = atom->vest; + double *vfrac = atom->vfrac; + int *type = atom->type; + int *ilist, *jlist, *numneigh; + int **firstneigh; + int nlocal = atom->nlocal; + int inum, jnum, ii, jj, i, itype, j, idim; + double wfd, h, irad, r, rSq, wf, ivol, jvol; + Vector3d dx, dv, g, du; + Matrix3d Ktmp, Ltmp, Ftmp, K3di, D; + Vector3d xi, xj, vi, vj, x0i, x0j, dx0; + Matrix2d K2di, K2d; + + // zero accumulators + for (i = 0; i < nlocal; i++) { + itype = type[i]; + if (setflag[itype][itype]) { + if (gradient_correction_flag) { + K[i].setZero(); + } else { + K[i].setIdentity(); + } + L[i].setZero(); + F[i].setZero(); + } + } + + // set up neighbor list variables + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + irad = radius[i]; + ivol = vfrac[i]; + + // initialize Eigen data structures from LAMMPS data structures + for (idim = 0; idim < 3; idim++) { + x0i(idim) = x0[i][idim]; + xi(idim) = x[i][idim]; + vi(idim) = v[i][idim]; + } + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + for (idim = 0; idim < 3; idim++) { + x0j(idim) = x0[j][idim]; + xj(idim) = x[j][idim]; + vj(idim) = v[j][idim]; + } + + dx = xj - xi; + + rSq = dx.squaredNorm(); + h = irad + radius[j]; + if (rSq < h * h) { + + r = sqrt(rSq); + jvol = vfrac[j]; + + // distance vectors in current and reference configuration, velocity difference + dv = vj - vi; + dx0 = x0j - x0i; + + // kernel and derivative + spiky_kernel_and_derivative(h, r, domain->dimension, wf, wfd); + //barbara_kernel_and_derivative(h, r, domain->dimension, wf, wfd); + + // uncorrected kernel gradient + g = (wfd / r) * dx; + + /* build correction matrix for kernel derivatives */ + if (gradient_correction_flag) { + Ktmp = -g * dx.transpose(); + K[i] += jvol * Ktmp; + } + + // velocity gradient L + Ltmp = -dv * g.transpose(); + L[i] += jvol * Ltmp; + + // deformation gradient F in Eulerian frame + du = dx - dx0; + Ftmp = dv * g.transpose(); + F[i] += jvol * Ftmp; + + if (j < nlocal) { + + if (gradient_correction_flag) { + K[j] += ivol * Ktmp; + } + + L[j] += ivol * Ltmp; + F[j] += ivol * Ftmp; + } + } // end if check distance + } // end loop over j + } // end loop over i + + /* + * invert shape matrix and compute corrected quantities + */ + + for (i = 0; i < nlocal; i++) { + itype = type[i]; + if (setflag[itype][itype]) { + if (gradient_correction_flag) { + pseudo_inverse_SVD(K[i]); + K[i] = LimitEigenvalues(K[i], 2.0); + L[i] *= K[i]; + F[i] *= K[i]; + } // end if (gradient_correction[itype]) { + + /* + * accumulate strain increments + * we abuse the atom array "atom_data_9" for this purpose, which was originally designed to hold the deformation gradient. + */ + D = update->dt * 0.5 * (L[i] + L[i].transpose()); + atom_data9[i][0] += D(0, 0); // xx + atom_data9[i][1] += D(1, 1); // yy + atom_data9[i][2] += D(2, 2); // zz + atom_data9[i][3] += D(0, 1); // xy + atom_data9[i][4] += D(0, 2); // xz + atom_data9[i][5] += D(1, 2); // yz + + } // end if (setflag[itype][itype]) + } // end loop over i = 0 to nlocal } /* ---------------------------------------------------------------------- */ void PairULSPH::compute(int eflag, int vflag) { - double **x = atom->x; - double **v = atom->vest; - double **vint = atom->v; // Velocity-Verlet algorithm velocities - double **f = atom->f; - double *vfrac = atom->vfrac; - double *de = atom->de; - double *rmass = atom->rmass; - double *radius = atom->radius; - double *contact_radius = atom->contact_radius; - double **atom_data9 = atom->smd_data_9; - - int *type = atom->type; - int nlocal = atom->nlocal; - int i, j, ii, jj, jnum, itype, jtype, iDim, inum; - double r, wf, wfd, h, rSq, ivol, jvol; - double mu_ij, c_ij, rho_ij; - double delVdotDelR, visc_magnitude, deltaE; - int *ilist, *jlist, *numneigh; - int **firstneigh; - Vector3d fi, fj, dx, dv, f_stress, g, vinti, vintj, dvint; - Vector3d xi, xj, vi, vj, f_visc, sumForces, f_stress_new; - Vector3d gamma, f_hg, dx0, du_est, du; - double r_ref, weight, p; - //int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); - - double ini_dist; - Matrix3d S, D, V, eye; - eye.setIdentity(); - int k; - SelfAdjointEigenSolver < Matrix3d > es; - - if (eflag || vflag) - ev_setup(eflag, vflag); - else - evflag = vflag_fdotr = 0; - - if (atom->nmax > nmax) { + double **x = atom->x; + double **v = atom->vest; + double **vint = atom->v; // Velocity-Verlet algorithm velocities + double **f = atom->f; + double *vfrac = atom->vfrac; + double *de = atom->de; + double *rmass = atom->rmass; + double *radius = atom->radius; + double *contact_radius = atom->contact_radius; + double **atom_data9 = atom->smd_data_9; + + int *type = atom->type; + int nlocal = atom->nlocal; + int i, j, ii, jj, jnum, itype, jtype, iDim, inum; + double r, wf, wfd, h, rSq, ivol, jvol; + double mu_ij, c_ij, rho_ij; + double delVdotDelR, visc_magnitude, deltaE; + int *ilist, *jlist, *numneigh; + int **firstneigh; + Vector3d fi, fj, dx, dv, f_stress, g, vinti, vintj, dvint; + Vector3d xi, xj, vi, vj, f_visc, sumForces, f_stress_new; + Vector3d gamma, f_hg, dx0, du_est, du; + double r_ref, weight, p; + //int periodic = (domain->xperiodic || domain->yperiodic || domain->zperiodic); + + double ini_dist; + Matrix3d S, D, V, eye; + eye.setIdentity(); + int k; + SelfAdjointEigenSolver < Matrix3d > es; + + if (eflag || vflag) + ev_setup(eflag, vflag); + else + evflag = vflag_fdotr = 0; + + if (atom->nmax > nmax) { //printf("... allocating in compute with nmax = %d\n", atom->nmax); - nmax = atom->nmax; - delete[] K; - K = new Matrix3d[nmax]; - delete[] shepardWeight; - shepardWeight = new double[nmax]; - delete[] c0; - c0 = new double[nmax]; - delete[] smoothVel; - smoothVel = new Vector3d[nmax]; - delete[] stressTensor; - stressTensor = new Matrix3d[nmax]; - delete[] L; - L = new Matrix3d[nmax]; - delete[] numNeighs; - numNeighs = new int[nmax]; - delete[] F; - F = new Matrix3d[nmax]; - delete[] rho; - rho = new double[nmax]; - delete[] effm; - effm = new double[nmax]; - } + nmax = atom->nmax; + delete[] K; + K = new Matrix3d[nmax]; + delete[] shepardWeight; + shepardWeight = new double[nmax]; + delete[] c0; + c0 = new double[nmax]; + delete[] smoothVel; + smoothVel = new Vector3d[nmax]; + delete[] stressTensor; + stressTensor = new Matrix3d[nmax]; + delete[] L; + L = new Matrix3d[nmax]; + delete[] numNeighs; + numNeighs = new int[nmax]; + delete[] F; + F = new Matrix3d[nmax]; + delete[] rho; + rho = new double[nmax]; + delete[] effm; + effm = new double[nmax]; + } // zero accumulators - for (i = 0; i < nlocal; i++) { - shepardWeight[i] = 0.0; - smoothVel[i].setZero(); - numNeighs[i] = 0; - - h = 2.0 * radius[i]; - r = 0.0; - spiky_kernel_and_derivative(h, r, domain->dimension, wf, wfd); - } - - /* - * if this is the very first step, zero the array which holds the accumulated strain - */ - if (update->ntimestep == 0) { - for (i = 0; i < nlocal; i++) { - itype = type[i]; - if (setflag[itype][itype]) { - for (j = 0; j < 9; j++) { - atom_data9[i][j] = 0.0; - } - } - } - } - - if (density_summation) { - //printf("dens summ\n"); - PreCompute_DensitySummation(); - - for (i = 0; i < nlocal; i++) { //compute volumes from rho - itype = type[i]; - if (setflag[itype][itype]) { - vfrac[i] = rmass[i] / rho[i]; - } - } - - } - - if (velocity_gradient) { - PairULSPH::PreCompute(); // get velocity gradient and kernel gradient correction - } - - PairULSPH::AssembleStressTensor(); - - /* - * QUANTITIES ABOVE HAVE ONLY BEEN CALCULATED FOR NLOCAL PARTICLES. - * NEED TO DO A FORWARD COMMUNICATION TO GHOST ATOMS NOW - */ - comm->forward_comm_pair(this); - - updateFlag = 0; - - /* - * iterate over pairs of particles i, j and assign forces using pre-computed pressure - */ + for (i = 0; i < nlocal; i++) { + shepardWeight[i] = 0.0; + smoothVel[i].setZero(); + numNeighs[i] = 0; + + h = 2.0 * radius[i]; + r = 0.0; + spiky_kernel_and_derivative(h, r, domain->dimension, wf, wfd); + } + + /* + * if this is the very first step, zero the array which holds the accumulated strain + */ + if (update->ntimestep == 0) { + for (i = 0; i < nlocal; i++) { + itype = type[i]; + if (setflag[itype][itype]) { + for (j = 0; j < 9; j++) { + atom_data9[i][j] = 0.0; + } + } + } + } + + if (density_summation) { + //printf("dens summ\n"); + PreCompute_DensitySummation(); + + for (i = 0; i < nlocal; i++) { //compute volumes from rho + itype = type[i]; + if (setflag[itype][itype]) { + vfrac[i] = rmass[i] / rho[i]; + } + } + + } + + if (velocity_gradient) { + PairULSPH::PreCompute(); // get velocity gradient and kernel gradient correction + } + + PairULSPH::AssembleStressTensor(); + + /* + * QUANTITIES ABOVE HAVE ONLY BEEN CALCULATED FOR NLOCAL PARTICLES. + * NEED TO DO A FORWARD COMMUNICATION TO GHOST ATOMS NOW + */ + comm->forward_comm_pair(this); + + updateFlag = 0; + + /* + * iterate over pairs of particles i, j and assign forces using pre-computed pressure + */ // set up neighbor list variables - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - ivol = vfrac[i]; - - // initialize Eigen data structures from LAMMPS data structures - for (iDim = 0; iDim < 3; iDim++) { - xi(iDim) = x[i][iDim]; - vi(iDim) = v[i][iDim]; - vinti(iDim) = vint[i][iDim]; - } - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - xj(0) = x[j][0]; - xj(1) = x[j][1]; - xj(2) = x[j][2]; - - dx = xj - xi; - rSq = dx.squaredNorm(); - h = radius[i] + radius[j]; - if (rSq < h * h) { - - // initialize Eigen data structures from LAMMPS data structures - for (iDim = 0; iDim < 3; iDim++) { - vj(iDim) = v[j][iDim]; - vintj(iDim) = vint[j][iDim]; - } - - r = sqrt(rSq); - jtype = type[j]; - jvol = vfrac[j]; - - // distance vectors in current and reference configuration, velocity difference - dv = vj - vi; - dvint = vintj - vinti; - - // kernel and derivative - spiky_kernel_and_derivative(h, r, domain->dimension, wf, wfd); - //barbara_kernel_and_derivative(h, r, domain->dimension, wf, wfd); - - // uncorrected kernel gradient - g = (wfd / r) * dx; - - delVdotDelR = dx.dot(dv) / (r + 0.1 * h); // project relative velocity onto unit particle distance vector [m/s] - - S = stressTensor[i] + stressTensor[j]; - - if (artificial_pressure[itype][jtype] > 0.0) { - p = S.trace(); - if (p > 0.0) { // we are in tension - r_ref = contact_radius[i] + contact_radius[j]; - weight = Kernel_Cubic_Spline(r, h) / Kernel_Cubic_Spline(r_ref, h); - weight = pow(weight, 4.0); - S -= artificial_pressure[itype][jtype] * weight * p * eye; - } - } - - /* - * artificial stress to control tensile instability - * Only works if particles are uniformly spaced initially. - */ - if (artificial_stress[itype][jtype] > 0.0) { - ini_dist = contact_radius[i] + contact_radius[j]; - weight = Kernel_Cubic_Spline(r, h) / Kernel_Cubic_Spline(ini_dist, h); - weight = pow(weight, 4.0); - - es.compute(S); - D = es.eigenvalues().asDiagonal(); - for (k = 0; k < 3; k++) { - if (D(k, k) > 0.0) { - D(k, k) -= weight * artificial_stress[itype][jtype] * D(k, k); - } - } - V = es.eigenvectors(); - S = V * D * V.inverse(); - } - - // compute forces - f_stress = -ivol * jvol * S * g; // DO NOT TOUCH SIGN - - /* - * artificial viscosity -- alpha is dimensionless - * MonaghanBalsara form of the artificial viscosity - */ - - c_ij = 0.5 * (c0[i] + c0[j]); - LimitDoubleMagnitude(delVdotDelR, 1.1 * c_ij); - - mu_ij = h * delVdotDelR / (r + 0.1 * h); // units: [m * m/s / m = m/s] - rho_ij = 0.5 * (rmass[i] / ivol + rmass[j] / jvol); - visc_magnitude = 0.5 * (Q1[itype] + Q1[jtype]) * c_ij * mu_ij / rho_ij; - f_visc = -rmass[i] * rmass[j] * visc_magnitude * g; - - if ((Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype] > 0.0) && (Lookup[HOURGLASS_CONTROL_AMPLITUDE][jtype] > 0.0)) { - f_hg = ComputeHourglassForce(i, itype, j, jtype, dv, dx, g, c_ij, mu_ij, rho_ij); - - } else { - f_hg.setZero(); - } - - sumForces = f_stress + f_visc + f_hg; - - // energy rate -- project velocity onto force vector - deltaE = sumForces.dot(dv); - - // apply forces to pair of particles - f[i][0] += sumForces(0); - f[i][1] += sumForces(1); - f[i][2] += sumForces(2); - de[i] += deltaE; - - // accumulate smooth velocities - shepardWeight[i] += jvol * wf; - smoothVel[i] += jvol * wf * dvint; - numNeighs[i] += 1; - - if (j < nlocal) { - f[j][0] -= sumForces(0); - f[j][1] -= sumForces(1); - f[j][2] -= sumForces(2); - de[j] += deltaE; - - shepardWeight[j] += ivol * wf; - smoothVel[j] -= ivol * wf * dvint; - numNeighs[j] += 1; - } - - // tally atomistic stress tensor - if (evflag) { - ev_tally_xyz(i, j, nlocal, 0, 0.0, 0.0, sumForces(0), sumForces(1), sumForces(2), dx(0), dx(1), dx(2)); - } - } - - } - } - - for (i = 0; i < nlocal; i++) { - itype = type[i]; - if (setflag[itype][itype] == 1) { - if (shepardWeight[i] != 0.0) { - smoothVel[i] /= shepardWeight[i]; - } else { - smoothVel[i].setZero(); - } - } // end check if particle is SPH-type - } // end loop over i = 0 to nlocal - - if (vflag_fdotr) - virial_fdotr_compute(); + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + ivol = vfrac[i]; + + // initialize Eigen data structures from LAMMPS data structures + for (iDim = 0; iDim < 3; iDim++) { + xi(iDim) = x[i][iDim]; + vi(iDim) = v[i][iDim]; + vinti(iDim) = vint[i][iDim]; + } + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + xj(0) = x[j][0]; + xj(1) = x[j][1]; + xj(2) = x[j][2]; + + dx = xj - xi; + rSq = dx.squaredNorm(); + h = radius[i] + radius[j]; + if (rSq < h * h) { + + // initialize Eigen data structures from LAMMPS data structures + for (iDim = 0; iDim < 3; iDim++) { + vj(iDim) = v[j][iDim]; + vintj(iDim) = vint[j][iDim]; + } + + r = sqrt(rSq); + jtype = type[j]; + jvol = vfrac[j]; + + // distance vectors in current and reference configuration, velocity difference + dv = vj - vi; + dvint = vintj - vinti; + + // kernel and derivative + spiky_kernel_and_derivative(h, r, domain->dimension, wf, wfd); + //barbara_kernel_and_derivative(h, r, domain->dimension, wf, wfd); + + // uncorrected kernel gradient + g = (wfd / r) * dx; + + delVdotDelR = dx.dot(dv) / (r + 0.1 * h); // project relative velocity onto unit particle distance vector [m/s] + + S = stressTensor[i] + stressTensor[j]; + + if (artificial_pressure[itype][jtype] > 0.0) { + p = S.trace(); + if (p > 0.0) { // we are in tension + r_ref = contact_radius[i] + contact_radius[j]; + weight = Kernel_Cubic_Spline(r, h) / Kernel_Cubic_Spline(r_ref, h); + weight = pow(weight, 4.0); + S -= artificial_pressure[itype][jtype] * weight * p * eye; + } + } + + /* + * artificial stress to control tensile instability + * Only works if particles are uniformly spaced initially. + */ + if (artificial_stress[itype][jtype] > 0.0) { + ini_dist = contact_radius[i] + contact_radius[j]; + weight = Kernel_Cubic_Spline(r, h) / Kernel_Cubic_Spline(ini_dist, h); + weight = pow(weight, 4.0); + + es.compute(S); + D = es.eigenvalues().asDiagonal(); + for (k = 0; k < 3; k++) { + if (D(k, k) > 0.0) { + D(k, k) -= weight * artificial_stress[itype][jtype] * D(k, k); + } + } + V = es.eigenvectors(); + S = V * D * V.inverse(); + } + + // compute forces + f_stress = -ivol * jvol * S * g; // DO NOT TOUCH SIGN + + /* + * artificial viscosity -- alpha is dimensionless + * MonaghanBalsara form of the artificial viscosity + */ + + c_ij = 0.5 * (c0[i] + c0[j]); + LimitDoubleMagnitude(delVdotDelR, 1.1 * c_ij); + + mu_ij = h * delVdotDelR / (r + 0.1 * h); // units: [m * m/s / m = m/s] + rho_ij = 0.5 * (rmass[i] / ivol + rmass[j] / jvol); + visc_magnitude = 0.5 * (Q1[itype] + Q1[jtype]) * c_ij * mu_ij / rho_ij; + f_visc = -rmass[i] * rmass[j] * visc_magnitude * g; + + if ((Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype] > 0.0) && (Lookup[HOURGLASS_CONTROL_AMPLITUDE][jtype] > 0.0)) { + f_hg = ComputeHourglassForce(i, itype, j, jtype, dv, dx, g, c_ij, mu_ij, rho_ij); + + } else { + f_hg.setZero(); + } + + sumForces = f_stress + f_visc + f_hg; + + // energy rate -- project velocity onto force vector + deltaE = sumForces.dot(dv); + + // apply forces to pair of particles + f[i][0] += sumForces(0); + f[i][1] += sumForces(1); + f[i][2] += sumForces(2); + de[i] += deltaE; + + // accumulate smooth velocities + shepardWeight[i] += jvol * wf; + smoothVel[i] += jvol * wf * dvint; + numNeighs[i] += 1; + + if (j < nlocal) { + f[j][0] -= sumForces(0); + f[j][1] -= sumForces(1); + f[j][2] -= sumForces(2); + de[j] += deltaE; + + shepardWeight[j] += ivol * wf; + smoothVel[j] -= ivol * wf * dvint; + numNeighs[j] += 1; + } + + // tally atomistic stress tensor + if (evflag) { + ev_tally_xyz(i, j, nlocal, 0, 0.0, 0.0, sumForces(0), sumForces(1), sumForces(2), dx(0), dx(1), dx(2)); + } + } + + } + } + + for (i = 0; i < nlocal; i++) { + itype = type[i]; + if (setflag[itype][itype] == 1) { + if (shepardWeight[i] != 0.0) { + smoothVel[i] /= shepardWeight[i]; + } else { + smoothVel[i].setZero(); + } + } // end check if particle is SPH-type + } // end loop over i = 0 to nlocal + + if (vflag_fdotr) + virial_fdotr_compute(); } @@ -640,189 +640,189 @@ void PairULSPH::compute(int eflag, int vflag) { viscosity contributions. ------------------------------------------------------------------------- */ void PairULSPH::AssembleStressTensor() { - double *radius = atom->radius; - double *vfrac = atom->vfrac; - double *rmass = atom->rmass; - double *eff_plastic_strain = atom->eff_plastic_strain; - double **tlsph_stress = atom->smd_stress; - double *e = atom->e; - int *type = atom->type; - int i, itype; - int nlocal = atom->nlocal; - Matrix3d D, Ddev, W, V, sigma_diag; - Matrix3d eye, stressRate, StressRateDevJaumann; - Matrix3d sigmaInitial_dev, d_dev, sigmaFinal_dev, stressRateDev, oldStressDeviator, newStressDeviator; - double plastic_strain_increment, yieldStress; - double dt = update->dt; - double vol, newPressure; - double G_eff = 0.0; // effective shear modulus - double K_eff; // effective bulk modulus - double M, p_wave_speed; - double rho, effectiveViscosity; - Matrix3d deltaStressDev; - - dtCFL = 1.0e22; - eye.setIdentity(); - - for (i = 0; i < nlocal; i++) { - itype = type[i]; - if (setflag[itype][itype] == 1) { - newStressDeviator.setZero(); - newPressure = 0.0; - stressTensor[i].setZero(); - vol = vfrac[i]; - rho = rmass[i] / vfrac[i]; - effectiveViscosity = 0.0; - K_eff = 0.0; - G_eff = 0.0; - - //printf("rho = %f\n", rho); - - switch (eos[itype]) { - default: - error->one(FLERR, "unknown EOS."); - break; - case NONE: - c0[i] = 1.0; - break; - case EOS_TAIT: - TaitEOS_density(Lookup[EOS_TAIT_EXPONENT][itype], Lookup[REFERENCE_SOUNDSPEED][itype], - Lookup[REFERENCE_DENSITY][itype], rho, newPressure, c0[i]); - //printf("new pressure =%f\n", newPressure); - - break; - case EOS_PERFECT_GAS: - PerfectGasEOS(Lookup[EOS_PERFECT_GAS_GAMMA][itype], vol, rmass[i], e[i], newPressure, c0[i]); - break; - case EOS_LINEAR: - newPressure = Lookup[BULK_MODULUS][itype] * (rho / Lookup[REFERENCE_DENSITY][itype] - 1.0); - //printf("p=%f, rho0=%f, rho=%f\n", newPressure, Lookup[REFERENCE_DENSITY][itype], rho); - c0[i] = Lookup[REFERENCE_SOUNDSPEED][itype]; - break; - } - - K_eff = c0[i] * c0[i] * rho; // effective bulk modulus - - /* - * ******************************* STRENGTH MODELS ************************************************ - */ - - if (strength[itype] != NONE) { - /* - * initial stress state: given by the unrotateted Cauchy stress. - * Assemble Eigen 3d matrix from stored stress state - */ - oldStressDeviator(0, 0) = tlsph_stress[i][0]; - oldStressDeviator(0, 1) = tlsph_stress[i][1]; - oldStressDeviator(0, 2) = tlsph_stress[i][2]; - oldStressDeviator(1, 1) = tlsph_stress[i][3]; - oldStressDeviator(1, 2) = tlsph_stress[i][4]; - oldStressDeviator(2, 2) = tlsph_stress[i][5]; - oldStressDeviator(1, 0) = oldStressDeviator(0, 1); - oldStressDeviator(2, 0) = oldStressDeviator(0, 2); - oldStressDeviator(2, 1) = oldStressDeviator(1, 2); - - D = 0.5 * (L[i] + L[i].transpose()); - W = 0.5 * (L[i] - L[i].transpose()); // spin tensor:: need this for Jaumann rate - d_dev = Deviator(D); - - switch (strength[itype]) { - default: - error->one(FLERR, "unknown strength model."); - break; - case STRENGTH_LINEAR: - - // here in a version with pressure part -// stressRateDev = Lookup[BULK_MODULUS][itype] * d_iso * eye + 2.0 * Lookup[SHEAR_MODULUS][itype] * d_dev; -// c0[i] = Lookup[REFERENCE_SOUNDSPEED][itype]; -// newPressure = 0.0; - - // here only stress deviator - stressRateDev = 2.0 * Lookup[SHEAR_MODULUS][itype] * d_dev; - //cout << "stress rate deviator is " << endl << stressRateDev << endl; - break; - - case STRENGTH_LINEAR_PLASTIC: - yieldStress = Lookup[YIELD_STRENGTH][itype] + Lookup[HARDENING_PARAMETER][itype] * eff_plastic_strain[i]; - LinearPlasticStrength(Lookup[SHEAR_MODULUS][itype], yieldStress, oldStressDeviator, d_dev, dt, - newStressDeviator, stressRateDev, plastic_strain_increment); - eff_plastic_strain[i] += plastic_strain_increment; - - break; - } - - //double m = effective_longitudinal_modulus(itype, dt, d_iso, p_rate, d_dev, stressRate_dev, damage); - - StressRateDevJaumann = stressRateDev - W * oldStressDeviator + oldStressDeviator * W; - newStressDeviator = oldStressDeviator + dt * StressRateDevJaumann; - - tlsph_stress[i][0] = newStressDeviator(0, 0); - tlsph_stress[i][1] = newStressDeviator(0, 1); - tlsph_stress[i][2] = newStressDeviator(0, 2); - tlsph_stress[i][3] = newStressDeviator(1, 1); - tlsph_stress[i][4] = newStressDeviator(1, 2); - tlsph_stress[i][5] = newStressDeviator(2, 2); - - // estimate effective shear modulus for time step stability - deltaStressDev = oldStressDeviator - newStressDeviator; - G_eff = effective_shear_modulus(d_dev, deltaStressDev, dt, itype); - - } // end if (strength[itype] != NONE) - - if (viscosity[itype] != NONE) { - D = 0.5 * (L[i] + L[i].transpose()); - d_dev = Deviator(D); - - switch (viscosity[itype]) { - default: - error->one(FLERR, "unknown viscosity model."); - break; - case VISCOSITY_NEWTON: - effectiveViscosity = Lookup[VISCOSITY_MU][itype]; -// double shear_rate = 2.0 -// * sqrt(d_dev(0, 1) * d_dev(0, 1) + d_dev(0, 2) * d_dev(0, 2) + d_dev(1, 2) * d_dev(1, 2)); // 3d - //cout << "shear rate: " << shear_rate << endl; - //effectiveViscosity = PA6_270C(shear_rate); - //if (effectiveViscosity > 178.062e-6) { - // printf("effective visc is %f\n", effectiveViscosity); - //} - newStressDeviator = 2.0 * effectiveViscosity * d_dev; // newton original - //cout << "this is Ddev " << endl << d_dev << endl << endl; - break; - } - } // end if (viscosity[itype] != NONE) - - /* - * assemble stress Tensor from pressure and deviatoric parts - */ - - stressTensor[i] = -newPressure * eye + newStressDeviator; - - /* - * stable timestep based on speed-of-sound - */ - - M = K_eff + 4.0 * G_eff / 3.0; - p_wave_speed = sqrt(M / rho); - effm[i] = G_eff; - dtCFL = MIN(2 * radius[i] / p_wave_speed, dtCFL); - - /* - * stable timestep based on viscosity - */ - if (viscosity[itype] != NONE) { - dtCFL = MIN(4 * radius[i] * radius[i] * rho / effectiveViscosity, dtCFL); - } - - /* - * kernel gradient correction - */ - if (gradient_correction_flag) { - stressTensor[i] *= K[i]; - } - } - // end if (setflag[itype][itype] == 1) - } // end loop over nlocal + double *radius = atom->radius; + double *vfrac = atom->vfrac; + double *rmass = atom->rmass; + double *eff_plastic_strain = atom->eff_plastic_strain; + double **tlsph_stress = atom->smd_stress; + double *e = atom->e; + int *type = atom->type; + int i, itype; + int nlocal = atom->nlocal; + Matrix3d D, Ddev, W, V, sigma_diag; + Matrix3d eye, stressRate, StressRateDevJaumann; + Matrix3d sigmaInitial_dev, d_dev, sigmaFinal_dev, stressRateDev, oldStressDeviator, newStressDeviator; + double plastic_strain_increment, yieldStress; + double dt = update->dt; + double vol, newPressure; + double G_eff = 0.0; // effective shear modulus + double K_eff; // effective bulk modulus + double M, p_wave_speed; + double rho, effectiveViscosity; + Matrix3d deltaStressDev; + + dtCFL = 1.0e22; + eye.setIdentity(); + + for (i = 0; i < nlocal; i++) { + itype = type[i]; + if (setflag[itype][itype] == 1) { + newStressDeviator.setZero(); + newPressure = 0.0; + stressTensor[i].setZero(); + vol = vfrac[i]; + rho = rmass[i] / vfrac[i]; + effectiveViscosity = 0.0; + K_eff = 0.0; + G_eff = 0.0; + + //printf("rho = %f\n", rho); + + switch (eos[itype]) { + default: + error->one(FLERR, "unknown EOS."); + break; + case NONE: + c0[i] = 1.0; + break; + case EOS_TAIT: + TaitEOS_density(Lookup[EOS_TAIT_EXPONENT][itype], Lookup[REFERENCE_SOUNDSPEED][itype], + Lookup[REFERENCE_DENSITY][itype], rho, newPressure, c0[i]); + //printf("new pressure =%f\n", newPressure); + + break; + case EOS_PERFECT_GAS: + PerfectGasEOS(Lookup[EOS_PERFECT_GAS_GAMMA][itype], vol, rmass[i], e[i], newPressure, c0[i]); + break; + case EOS_LINEAR: + newPressure = Lookup[BULK_MODULUS][itype] * (rho / Lookup[REFERENCE_DENSITY][itype] - 1.0); + //printf("p=%f, rho0=%f, rho=%f\n", newPressure, Lookup[REFERENCE_DENSITY][itype], rho); + c0[i] = Lookup[REFERENCE_SOUNDSPEED][itype]; + break; + } + + K_eff = c0[i] * c0[i] * rho; // effective bulk modulus + + /* + * ******************************* STRENGTH MODELS ************************************************ + */ + + if (strength[itype] != NONE) { + /* + * initial stress state: given by the unrotateted Cauchy stress. + * Assemble Eigen 3d matrix from stored stress state + */ + oldStressDeviator(0, 0) = tlsph_stress[i][0]; + oldStressDeviator(0, 1) = tlsph_stress[i][1]; + oldStressDeviator(0, 2) = tlsph_stress[i][2]; + oldStressDeviator(1, 1) = tlsph_stress[i][3]; + oldStressDeviator(1, 2) = tlsph_stress[i][4]; + oldStressDeviator(2, 2) = tlsph_stress[i][5]; + oldStressDeviator(1, 0) = oldStressDeviator(0, 1); + oldStressDeviator(2, 0) = oldStressDeviator(0, 2); + oldStressDeviator(2, 1) = oldStressDeviator(1, 2); + + D = 0.5 * (L[i] + L[i].transpose()); + W = 0.5 * (L[i] - L[i].transpose()); // spin tensor:: need this for Jaumann rate + d_dev = Deviator(D); + + switch (strength[itype]) { + default: + error->one(FLERR, "unknown strength model."); + break; + case STRENGTH_LINEAR: + + // here in a version with pressure part +// stressRateDev = Lookup[BULK_MODULUS][itype] * d_iso * eye + 2.0 * Lookup[SHEAR_MODULUS][itype] * d_dev; +// c0[i] = Lookup[REFERENCE_SOUNDSPEED][itype]; +// newPressure = 0.0; + + // here only stress deviator + stressRateDev = 2.0 * Lookup[SHEAR_MODULUS][itype] * d_dev; + //cout << "stress rate deviator is " << endl << stressRateDev << endl; + break; + + case STRENGTH_LINEAR_PLASTIC: + yieldStress = Lookup[YIELD_STRENGTH][itype] + Lookup[HARDENING_PARAMETER][itype] * eff_plastic_strain[i]; + LinearPlasticStrength(Lookup[SHEAR_MODULUS][itype], yieldStress, oldStressDeviator, d_dev, dt, + newStressDeviator, stressRateDev, plastic_strain_increment); + eff_plastic_strain[i] += plastic_strain_increment; + + break; + } + + //double m = effective_longitudinal_modulus(itype, dt, d_iso, p_rate, d_dev, stressRate_dev, damage); + + StressRateDevJaumann = stressRateDev - W * oldStressDeviator + oldStressDeviator * W; + newStressDeviator = oldStressDeviator + dt * StressRateDevJaumann; + + tlsph_stress[i][0] = newStressDeviator(0, 0); + tlsph_stress[i][1] = newStressDeviator(0, 1); + tlsph_stress[i][2] = newStressDeviator(0, 2); + tlsph_stress[i][3] = newStressDeviator(1, 1); + tlsph_stress[i][4] = newStressDeviator(1, 2); + tlsph_stress[i][5] = newStressDeviator(2, 2); + + // estimate effective shear modulus for time step stability + deltaStressDev = oldStressDeviator - newStressDeviator; + G_eff = effective_shear_modulus(d_dev, deltaStressDev, dt, itype); + + } // end if (strength[itype] != NONE) + + if (viscosity[itype] != NONE) { + D = 0.5 * (L[i] + L[i].transpose()); + d_dev = Deviator(D); + + switch (viscosity[itype]) { + default: + error->one(FLERR, "unknown viscosity model."); + break; + case VISCOSITY_NEWTON: + effectiveViscosity = Lookup[VISCOSITY_MU][itype]; +// double shear_rate = 2.0 +// * sqrt(d_dev(0, 1) * d_dev(0, 1) + d_dev(0, 2) * d_dev(0, 2) + d_dev(1, 2) * d_dev(1, 2)); // 3d + //cout << "shear rate: " << shear_rate << endl; + //effectiveViscosity = PA6_270C(shear_rate); + //if (effectiveViscosity > 178.062e-6) { + // printf("effective visc is %f\n", effectiveViscosity); + //} + newStressDeviator = 2.0 * effectiveViscosity * d_dev; // newton original + //cout << "this is Ddev " << endl << d_dev << endl << endl; + break; + } + } // end if (viscosity[itype] != NONE) + + /* + * assemble stress Tensor from pressure and deviatoric parts + */ + + stressTensor[i] = -newPressure * eye + newStressDeviator; + + /* + * stable timestep based on speed-of-sound + */ + + M = K_eff + 4.0 * G_eff / 3.0; + p_wave_speed = sqrt(M / rho); + effm[i] = G_eff; + dtCFL = MIN(2 * radius[i] / p_wave_speed, dtCFL); + + /* + * stable timestep based on viscosity + */ + if (viscosity[itype] != NONE) { + dtCFL = MIN(4 * radius[i] * radius[i] * rho / effectiveViscosity, dtCFL); + } + + /* + * kernel gradient correction + */ + if (gradient_correction_flag) { + stressTensor[i] *= K[i]; + } + } + // end if (setflag[itype][itype] == 1) + } // end loop over nlocal //printf("stable timestep = %g\n", 0.1 * hMin * MaxBulkVelocity); } @@ -833,40 +833,40 @@ void PairULSPH::AssembleStressTensor() { void PairULSPH::allocate() { - allocated = 1; - int n = atom->ntypes; + allocated = 1; + int n = atom->ntypes; - memory->create(setflag, n + 1, n + 1, "pair:setflag"); + memory->create(setflag, n + 1, n + 1, "pair:setflag"); - memory->create(Q1, n + 1, "pair:Q1"); - memory->create(rho0, n + 1, "pair:Q2"); - memory->create(c0_type, n + 1, "pair:c0_type"); - memory->create(eos, n + 1, "pair:eosmodel"); - memory->create(viscosity, n + 1, "pair:viscositymodel"); - memory->create(strength, n + 1, "pair:strengthmodel"); + memory->create(Q1, n + 1, "pair:Q1"); + memory->create(rho0, n + 1, "pair:Q2"); + memory->create(c0_type, n + 1, "pair:c0_type"); + memory->create(eos, n + 1, "pair:eosmodel"); + memory->create(viscosity, n + 1, "pair:viscositymodel"); + memory->create(strength, n + 1, "pair:strengthmodel"); - memory->create(Lookup, MAX_KEY_VALUE, n + 1, "pair:LookupTable"); + memory->create(Lookup, MAX_KEY_VALUE, n + 1, "pair:LookupTable"); - memory->create(artificial_pressure, n + 1, n + 1, "pair:artificial_pressure"); - memory->create(artificial_stress, n + 1, n + 1, "pair:artificial_stress"); - memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); // always needs to be allocated, even with granular neighborlist + memory->create(artificial_pressure, n + 1, n + 1, "pair:artificial_pressure"); + memory->create(artificial_stress, n + 1, n + 1, "pair:artificial_stress"); + memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); // always needs to be allocated, even with granular neighborlist - /* - * initialize arrays to default values - */ + /* + * initialize arrays to default values + */ - for (int i = 1; i <= n; i++) { - for (int j = i; j <= n; j++) { - artificial_pressure[i][j] = 0.0; - artificial_stress[i][j] = 0.0; - setflag[i][j] = 0; - } - } + for (int i = 1; i <= n; i++) { + for (int j = i; j <= n; j++) { + artificial_pressure[i][j] = 0.0; + artificial_stress[i][j] = 0.0; + setflag[i][j] = 0; + } + } - onerad_dynamic = new double[n + 1]; - onerad_frozen = new double[n + 1]; - maxrad_dynamic = new double[n + 1]; - maxrad_frozen = new double[n + 1]; + onerad_dynamic = new double[n + 1]; + onerad_frozen = new double[n + 1]; + maxrad_dynamic = new double[n + 1]; + maxrad_frozen = new double[n + 1]; } @@ -875,63 +875,63 @@ void PairULSPH::allocate() { ------------------------------------------------------------------------- */ void PairULSPH::settings(int narg, char **arg) { - if (narg != 3) { - printf("narg = %d\n", narg); - error->all(FLERR, "Illegal number of arguments for pair_style ulsph"); - } - - if (comm->me == 0) { - printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); - printf("... SMD / ULSPH PROPERTIES\n\n"); - } - - if (strcmp(arg[0], "*DENSITY_SUMMATION") == 0) { - density_summation = true; - density_continuity = false; - if (comm->me == 0) - printf("... density summation active\n"); - } else if (strcmp(arg[0], "*DENSITY_CONTINUITY") == 0) { - density_continuity = true; - density_summation = false; - if (comm->me == 0) - printf("... density continuity active\n"); - } else { - error->all(FLERR, - "Illegal settings keyword for first keyword of pair style ulsph. Must be either *DENSITY_SUMMATION or *DENSITY_CONTINUITY"); - } - - if (strcmp(arg[1], "*VELOCITY_GRADIENT") == 0) { - velocity_gradient = true; - if (comm->me == 0) - printf("... computation of velocity gradients active\n"); - } else if (strcmp(arg[1], "*NO_VELOCITY_GRADIENT") == 0) { - velocity_gradient = false; - if (comm->me == 0) - printf("... computation of velocity gradients NOT active\n"); - } else { - error->all(FLERR, - "Illegal settings keyword for first keyword of pair style ulsph. Must be either *VELOCITY_GRADIENT or *NO_VELOCITY_GRADIENT"); - } - - if (strcmp(arg[2], "*GRADIENT_CORRECTION") == 0) { - gradient_correction_flag = true; - if (comm->me == 0) - printf("... first order correction of kernel gradients is active\n"); - } else if (strcmp(arg[2], "*NO_GRADIENT_CORRECTION") == 0) { - gradient_correction_flag = false; - if (comm->me == 0) - printf("... first order correction of kernel gradients is NOT active\n"); - } else { - error->all(FLERR, "Illegal settings keyword for pair style ulsph"); - } + if (narg != 3) { + printf("narg = %d\n", narg); + error->all(FLERR, "Illegal number of arguments for pair_style ulsph"); + } + + if (comm->me == 0) { + printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); + printf("... SMD / ULSPH PROPERTIES\n\n"); + } + + if (strcmp(arg[0], "*DENSITY_SUMMATION") == 0) { + density_summation = true; + density_continuity = false; + if (comm->me == 0) + printf("... density summation active\n"); + } else if (strcmp(arg[0], "*DENSITY_CONTINUITY") == 0) { + density_continuity = true; + density_summation = false; + if (comm->me == 0) + printf("... density continuity active\n"); + } else { + error->all(FLERR, + "Illegal settings keyword for first keyword of pair style ulsph. Must be either *DENSITY_SUMMATION or *DENSITY_CONTINUITY"); + } + + if (strcmp(arg[1], "*VELOCITY_GRADIENT") == 0) { + velocity_gradient = true; + if (comm->me == 0) + printf("... computation of velocity gradients active\n"); + } else if (strcmp(arg[1], "*NO_VELOCITY_GRADIENT") == 0) { + velocity_gradient = false; + if (comm->me == 0) + printf("... computation of velocity gradients NOT active\n"); + } else { + error->all(FLERR, + "Illegal settings keyword for first keyword of pair style ulsph. Must be either *VELOCITY_GRADIENT or *NO_VELOCITY_GRADIENT"); + } + + if (strcmp(arg[2], "*GRADIENT_CORRECTION") == 0) { + gradient_correction_flag = true; + if (comm->me == 0) + printf("... first order correction of kernel gradients is active\n"); + } else if (strcmp(arg[2], "*NO_GRADIENT_CORRECTION") == 0) { + gradient_correction_flag = false; + if (comm->me == 0) + printf("... first order correction of kernel gradients is NOT active\n"); + } else { + error->all(FLERR, "Illegal settings keyword for pair style ulsph"); + } // error check - //if ((gradient_correction_flag == true) && (density_summation)) { - // error->all(FLERR, "Cannot use *DENSITY_SUMMATION in combination with *YES_GRADIENT_CORRECTION"); - //} + //if ((gradient_correction_flag == true) && (density_summation)) { + // error->all(FLERR, "Cannot use *DENSITY_SUMMATION in combination with *YES_GRADIENT_CORRECTION"); + //} - if (comm->me == 0) - printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); + if (comm->me == 0) + printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); } @@ -940,475 +940,475 @@ void PairULSPH::settings(int narg, char **arg) { ------------------------------------------------------------------------- */ void PairULSPH::coeff(int narg, char **arg) { - int ioffset, iarg, iNextKwd, itype, jtype; - char str[128]; - std::string s, t; - - if (narg < 3) { - sprintf(str, "number of arguments for pair ulsph is too small!"); - error->all(FLERR, str); - } - if (!allocated) - allocate(); - - /* - * if parameters are give in i,i form, i.e., no a cross interaction, set material parameters - */ - - if (force->inumeric(FLERR, arg[0]) == force->inumeric(FLERR, arg[1])) { - - itype = force->inumeric(FLERR, arg[0]); - eos[itype] = viscosity[itype] = strength[itype] = NONE; - - if (comm->me == 0) { - printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); - printf("...SMD / ULSPH PROPERTIES OF PARTICLE TYPE %d\n\n", itype); - } - - /* - * read parameters which are common -- regardless of material / eos model - */ - - ioffset = 2; - if (strcmp(arg[ioffset], "*COMMON") != 0) { - sprintf(str, "common keyword missing!"); - error->all(FLERR, str); - } else { - } - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - //printf("keyword following *COMMON is %s\n", arg[iNextKwd]); - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *COMMON"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 5 + 1) { - sprintf(str, "expected 5 arguments following *COMMON but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[REFERENCE_DENSITY][itype] = force->numeric(FLERR, arg[ioffset + 1]); - Lookup[REFERENCE_SOUNDSPEED][itype] = force->numeric(FLERR, arg[ioffset + 2]); - Q1[itype] = force->numeric(FLERR, arg[ioffset + 3]); - Lookup[HEAT_CAPACITY][itype] = force->numeric(FLERR, arg[ioffset + 4]); - Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype] = force->numeric(FLERR, arg[ioffset + 5]); - - Lookup[BULK_MODULUS][itype] = Lookup[REFERENCE_SOUNDSPEED][itype] * Lookup[REFERENCE_SOUNDSPEED][itype] - * Lookup[REFERENCE_DENSITY][itype]; - - if (comm->me == 0) { - printf("material unspecific properties for SMD/ULSPH definition of particle type %d:\n", itype); - printf(FORMAT1, "reference density", Lookup[REFERENCE_DENSITY][itype]); - printf(FORMAT1, "reference speed of sound", Lookup[REFERENCE_SOUNDSPEED][itype]); - printf(FORMAT1, "linear viscosity coefficient", Q1[itype]); - printf(FORMAT1, "heat capacity [energy / (mass * temperature)]", Lookup[HEAT_CAPACITY][itype]); - printf(FORMAT1, "bulk modulus", Lookup[BULK_MODULUS][itype]); - printf(FORMAT1, "hourglass control amplitude", Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype]); - } - - /* - * read following material cards - */ - -// if (comm->me == 0) { -// printf("next kwd is %s\n", arg[iNextKwd]); -// } - while (true) { - if (strcmp(arg[iNextKwd], "*END") == 0) { -// if (comm->me == 0) { -// sprintf(str, "found *END"); -// error->message(FLERR, str); -// } - break; - } - - ioffset = iNextKwd; - if (strcmp(arg[ioffset], "*EOS_TAIT") == 0) { - - /* - * Tait EOS - */ - - eos[itype] = EOS_TAIT; - //printf("reading *EOS_TAIT\n"); - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *EOS_TAIT"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *EOS_TAIT but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[EOS_TAIT_EXPONENT][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf(FORMAT2, "Tait EOS"); - printf(FORMAT1, "Exponent", Lookup[EOS_TAIT_EXPONENT][itype]); - } - } // end Tait EOS - - else if (strcmp(arg[ioffset], "*EOS_PERFECT_GAS") == 0) { - - /* - * Perfect Gas EOS - */ - - eos[itype] = EOS_PERFECT_GAS; - //printf("reading *EOS_PERFECT_GAS\n"); - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *EOS_PERFECT_GAS"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *EOS_PERFECT_GAS but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[EOS_PERFECT_GAS_GAMMA][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf(FORMAT2, "Perfect Gas EOS"); - printf(FORMAT1, "Heat Capacity Ratio Gamma", Lookup[EOS_PERFECT_GAS_GAMMA][itype]); - } - } // end Perfect Gas EOS - else if (strcmp(arg[ioffset], "*EOS_LINEAR") == 0) { - - /* - * Linear EOS - */ - - eos[itype] = EOS_LINEAR; - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *EOS_LINEAR"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 0 + 1) { - sprintf(str, "expected 0 arguments following *EOS_LINEAR but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - if (comm->me == 0) { - printf(FORMAT2, "Linear EOS"); - printf(FORMAT1, "Bulk modulus", Lookup[BULK_MODULUS][itype]); - } - } // end Linear EOS - else if (strcmp(arg[ioffset], "*STRENGTH_LINEAR_PLASTIC") == 0) { - - if (velocity_gradient != true) { - error->all(FLERR, "A strength model was requested but *VELOCITY_GRADIENT is not set"); - } - - /* - * linear elastic / ideal plastic material model with strength - */ - - strength[itype] = STRENGTH_LINEAR_PLASTIC; - velocity_gradient_required = true; - //printf("reading *LINEAR_PLASTIC\n"); - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *STRENGTH_LINEAR_PLASTIC"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 3 + 1) { - sprintf(str, "expected 3 arguments following *STRENGTH_LINEAR_PLASTIC but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[SHEAR_MODULUS][itype] = force->numeric(FLERR, arg[ioffset + 1]); - Lookup[YIELD_STRENGTH][itype] = force->numeric(FLERR, arg[ioffset + 2]); - Lookup[HARDENING_PARAMETER][itype] = force->numeric(FLERR, arg[ioffset + 3]); - - if (comm->me == 0) { - printf(FORMAT2, "linear elastic / ideal plastic material mode"); - printf(FORMAT1, "yield_strength", Lookup[YIELD_STRENGTH][itype]); - printf(FORMAT1, "constant hardening parameter", Lookup[HARDENING_PARAMETER][itype]); - printf(FORMAT1, "shear modulus", Lookup[SHEAR_MODULUS][itype]); - } - } // end *STRENGTH_LINEAR_PLASTIC - else if (strcmp(arg[ioffset], "*STRENGTH_LINEAR") == 0) { - - if (velocity_gradient != true) { - error->all(FLERR, "A strength model was requested but *VELOCITY_GRADIENT is not set"); - } - - /* - * linear elastic / ideal plastic material model with strength - */ - - strength[itype] = STRENGTH_LINEAR; - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *STRENGTH_LINEAR"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *STRENGTH_LINEAR but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[SHEAR_MODULUS][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf(FORMAT2, "linear elastic strength model"); - printf(FORMAT1, "shear modulus", Lookup[SHEAR_MODULUS][itype]); - } - } // end *STRENGTH_LINEAR - else if (strcmp(arg[ioffset], "*VISCOSITY_NEWTON") == 0) { - - if (velocity_gradient != true) { - error->all(FLERR, "A viscosity model was requested but *VELOCITY_GRADIENT is not set"); - } - - /* - * linear elastic / ideal plastic material model with strength - */ - - viscosity[itype] = VISCOSITY_NEWTON; - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *VISCOSITY_NEWTON"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *VISCOSITY_NEWTON but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - Lookup[VISCOSITY_MU][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf(FORMAT2, "Newton viscosity model"); - printf(FORMAT1, "viscosity mu", Lookup[VISCOSITY_MU][itype]); - } - } // end *STRENGTH_VISCOSITY_NEWTON - - else if (strcmp(arg[ioffset], "*ARTIFICIAL_PRESSURE") == 0) { - - /* - * use Monaghan's artificial pressure to prevent particle clumping - */ - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *ARTIFICIAL_PRESSURE"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *ARTIFICIAL_PRESSURE but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - artificial_pressure[itype][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf(FORMAT2, "Artificial Pressure is enabled."); - printf(FORMAT1, "Artificial Pressure amplitude", artificial_pressure[itype][itype]); - } - } // end *ARTIFICIAL_PRESSURE - - else if (strcmp(arg[ioffset], "*ARTIFICIAL_STRESS") == 0) { - - /* - * use Monaghan's artificial stress to prevent particle clumping - */ - - t = string("*"); - iNextKwd = -1; - for (iarg = ioffset + 1; iarg < narg; iarg++) { - s = string(arg[iarg]); - if (s.compare(0, t.length(), t) == 0) { - iNextKwd = iarg; - break; - } - } - - if (iNextKwd < 0) { - sprintf(str, "no *KEYWORD terminates *ARTIFICIAL_STRESS"); - error->all(FLERR, str); - } - - if (iNextKwd - ioffset != 1 + 1) { - sprintf(str, "expected 1 arguments following *ARTIFICIAL_STRESS but got %d\n", iNextKwd - ioffset - 1); - error->all(FLERR, str); - } - - artificial_stress[itype][itype] = force->numeric(FLERR, arg[ioffset + 1]); - - if (comm->me == 0) { - printf(FORMAT2, "Artificial Stress is enabled."); - printf(FORMAT1, "Artificial Stress amplitude", artificial_stress[itype][itype]); - } - } // end *ARTIFICIAL_STRESS - - else { - sprintf(str, "unknown *KEYWORD: %s", arg[ioffset]); - error->all(FLERR, str); - } - - } - - /* - * copy data which is looked up in inner pairwise loops from slow maps to fast arrays - */ - - rho0[itype] = Lookup[REFERENCE_DENSITY][itype]; - c0_type[itype] = Lookup[REFERENCE_SOUNDSPEED][itype]; - setflag[itype][itype] = 1; - - /* - * error checks - */ - - if ((viscosity[itype] != NONE) && (strength[itype] != NONE)) { - sprintf(str, "cannot have both a strength and viscosity model for particle type %d", itype); - error->all(FLERR, str); - } - - if (eos[itype] == NONE) { - sprintf(str, "must specify an EOS for particle type %d", itype); - error->all(FLERR, str); - } - - } else { - /* - * we are reading a cross-interaction line for particle types i, j - */ - - itype = force->inumeric(FLERR, arg[0]); - jtype = force->inumeric(FLERR, arg[1]); - - if (strcmp(arg[2], "*CROSS") != 0) { - sprintf(str, "ulsph cross interaction between particle type %d and %d requested, however, *CROSS keyword is missing", - itype, jtype); - error->all(FLERR, str); - } - - if (setflag[itype][itype] != 1) { - sprintf(str, - "ulsph cross interaction between particle type %d and %d requested, however, properties of type %d have not yet been specified", - itype, jtype, itype); - error->all(FLERR, str); - } - - if (setflag[jtype][jtype] != 1) { - sprintf(str, - "ulsph cross interaction between particle type %d and %d requested, however, properties of type %d have not yet been specified", - itype, jtype, jtype); - error->all(FLERR, str); - } - - setflag[itype][jtype] = 1; - setflag[jtype][itype] = 1; - - if ((artificial_pressure[itype][itype] > 0.0) && (artificial_pressure[jtype][jtype] > 0.0)) { - artificial_pressure[itype][jtype] = 0.5 * (artificial_pressure[itype][itype] + artificial_pressure[jtype][jtype]); - artificial_pressure[jtype][itype] = artificial_pressure[itype][jtype]; - } else { - artificial_pressure[itype][jtype] = artificial_pressure[jtype][itype] = 0.0; - } - - if ((artificial_stress[itype][itype] > 0.0) && (artificial_stress[jtype][jtype] > 0.0)) { - artificial_stress[itype][jtype] = 0.5 * (artificial_stress[itype][itype] + artificial_stress[jtype][jtype]); - artificial_stress[jtype][itype] = artificial_stress[itype][jtype]; - } else { - artificial_stress[itype][jtype] = artificial_stress[jtype][itype] = 0.0; - } - - if (comm->me == 0) { - printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); - } - - } + int ioffset, iarg, iNextKwd, itype, jtype; + char str[128]; + std::string s, t; + + if (narg < 3) { + sprintf(str, "number of arguments for pair ulsph is too small!"); + error->all(FLERR, str); + } + if (!allocated) + allocate(); + + /* + * if parameters are give in i,i form, i.e., no a cross interaction, set material parameters + */ + + if (force->inumeric(FLERR, arg[0]) == force->inumeric(FLERR, arg[1])) { + + itype = force->inumeric(FLERR, arg[0]); + eos[itype] = viscosity[itype] = strength[itype] = NONE; + + if (comm->me == 0) { + printf("\n>>========>>========>>========>>========>>========>>========>>========>>========\n"); + printf("...SMD / ULSPH PROPERTIES OF PARTICLE TYPE %d\n\n", itype); + } + + /* + * read parameters which are common -- regardless of material / eos model + */ + + ioffset = 2; + if (strcmp(arg[ioffset], "*COMMON") != 0) { + sprintf(str, "common keyword missing!"); + error->all(FLERR, str); + } else { + } + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + //printf("keyword following *COMMON is %s\n", arg[iNextKwd]); + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *COMMON"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 5 + 1) { + sprintf(str, "expected 5 arguments following *COMMON but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[REFERENCE_DENSITY][itype] = force->numeric(FLERR, arg[ioffset + 1]); + Lookup[REFERENCE_SOUNDSPEED][itype] = force->numeric(FLERR, arg[ioffset + 2]); + Q1[itype] = force->numeric(FLERR, arg[ioffset + 3]); + Lookup[HEAT_CAPACITY][itype] = force->numeric(FLERR, arg[ioffset + 4]); + Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype] = force->numeric(FLERR, arg[ioffset + 5]); + + Lookup[BULK_MODULUS][itype] = Lookup[REFERENCE_SOUNDSPEED][itype] * Lookup[REFERENCE_SOUNDSPEED][itype] + * Lookup[REFERENCE_DENSITY][itype]; + + if (comm->me == 0) { + printf("material unspecific properties for SMD/ULSPH definition of particle type %d:\n", itype); + printf(FORMAT1, "reference density", Lookup[REFERENCE_DENSITY][itype]); + printf(FORMAT1, "reference speed of sound", Lookup[REFERENCE_SOUNDSPEED][itype]); + printf(FORMAT1, "linear viscosity coefficient", Q1[itype]); + printf(FORMAT1, "heat capacity [energy / (mass * temperature)]", Lookup[HEAT_CAPACITY][itype]); + printf(FORMAT1, "bulk modulus", Lookup[BULK_MODULUS][itype]); + printf(FORMAT1, "hourglass control amplitude", Lookup[HOURGLASS_CONTROL_AMPLITUDE][itype]); + } + + /* + * read following material cards + */ + +// if (comm->me == 0) { +// printf("next kwd is %s\n", arg[iNextKwd]); +// } + while (true) { + if (strcmp(arg[iNextKwd], "*END") == 0) { +// if (comm->me == 0) { +// sprintf(str, "found *END"); +// error->message(FLERR, str); +// } + break; + } + + ioffset = iNextKwd; + if (strcmp(arg[ioffset], "*EOS_TAIT") == 0) { + + /* + * Tait EOS + */ + + eos[itype] = EOS_TAIT; + //printf("reading *EOS_TAIT\n"); + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *EOS_TAIT"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *EOS_TAIT but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[EOS_TAIT_EXPONENT][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf(FORMAT2, "Tait EOS"); + printf(FORMAT1, "Exponent", Lookup[EOS_TAIT_EXPONENT][itype]); + } + } // end Tait EOS + + else if (strcmp(arg[ioffset], "*EOS_PERFECT_GAS") == 0) { + + /* + * Perfect Gas EOS + */ + + eos[itype] = EOS_PERFECT_GAS; + //printf("reading *EOS_PERFECT_GAS\n"); + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *EOS_PERFECT_GAS"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *EOS_PERFECT_GAS but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[EOS_PERFECT_GAS_GAMMA][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf(FORMAT2, "Perfect Gas EOS"); + printf(FORMAT1, "Heat Capacity Ratio Gamma", Lookup[EOS_PERFECT_GAS_GAMMA][itype]); + } + } // end Perfect Gas EOS + else if (strcmp(arg[ioffset], "*EOS_LINEAR") == 0) { + + /* + * Linear EOS + */ + + eos[itype] = EOS_LINEAR; + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *EOS_LINEAR"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 0 + 1) { + sprintf(str, "expected 0 arguments following *EOS_LINEAR but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + if (comm->me == 0) { + printf(FORMAT2, "Linear EOS"); + printf(FORMAT1, "Bulk modulus", Lookup[BULK_MODULUS][itype]); + } + } // end Linear EOS + else if (strcmp(arg[ioffset], "*STRENGTH_LINEAR_PLASTIC") == 0) { + + if (velocity_gradient != true) { + error->all(FLERR, "A strength model was requested but *VELOCITY_GRADIENT is not set"); + } + + /* + * linear elastic / ideal plastic material model with strength + */ + + strength[itype] = STRENGTH_LINEAR_PLASTIC; + velocity_gradient_required = true; + //printf("reading *LINEAR_PLASTIC\n"); + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *STRENGTH_LINEAR_PLASTIC"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 3 + 1) { + sprintf(str, "expected 3 arguments following *STRENGTH_LINEAR_PLASTIC but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[SHEAR_MODULUS][itype] = force->numeric(FLERR, arg[ioffset + 1]); + Lookup[YIELD_STRENGTH][itype] = force->numeric(FLERR, arg[ioffset + 2]); + Lookup[HARDENING_PARAMETER][itype] = force->numeric(FLERR, arg[ioffset + 3]); + + if (comm->me == 0) { + printf(FORMAT2, "linear elastic / ideal plastic material mode"); + printf(FORMAT1, "yield_strength", Lookup[YIELD_STRENGTH][itype]); + printf(FORMAT1, "constant hardening parameter", Lookup[HARDENING_PARAMETER][itype]); + printf(FORMAT1, "shear modulus", Lookup[SHEAR_MODULUS][itype]); + } + } // end *STRENGTH_LINEAR_PLASTIC + else if (strcmp(arg[ioffset], "*STRENGTH_LINEAR") == 0) { + + if (velocity_gradient != true) { + error->all(FLERR, "A strength model was requested but *VELOCITY_GRADIENT is not set"); + } + + /* + * linear elastic / ideal plastic material model with strength + */ + + strength[itype] = STRENGTH_LINEAR; + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *STRENGTH_LINEAR"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *STRENGTH_LINEAR but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[SHEAR_MODULUS][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf(FORMAT2, "linear elastic strength model"); + printf(FORMAT1, "shear modulus", Lookup[SHEAR_MODULUS][itype]); + } + } // end *STRENGTH_LINEAR + else if (strcmp(arg[ioffset], "*VISCOSITY_NEWTON") == 0) { + + if (velocity_gradient != true) { + error->all(FLERR, "A viscosity model was requested but *VELOCITY_GRADIENT is not set"); + } + + /* + * linear elastic / ideal plastic material model with strength + */ + + viscosity[itype] = VISCOSITY_NEWTON; + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *VISCOSITY_NEWTON"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *VISCOSITY_NEWTON but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + Lookup[VISCOSITY_MU][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf(FORMAT2, "Newton viscosity model"); + printf(FORMAT1, "viscosity mu", Lookup[VISCOSITY_MU][itype]); + } + } // end *STRENGTH_VISCOSITY_NEWTON + + else if (strcmp(arg[ioffset], "*ARTIFICIAL_PRESSURE") == 0) { + + /* + * use Monaghan's artificial pressure to prevent particle clumping + */ + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *ARTIFICIAL_PRESSURE"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *ARTIFICIAL_PRESSURE but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + artificial_pressure[itype][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf(FORMAT2, "Artificial Pressure is enabled."); + printf(FORMAT1, "Artificial Pressure amplitude", artificial_pressure[itype][itype]); + } + } // end *ARTIFICIAL_PRESSURE + + else if (strcmp(arg[ioffset], "*ARTIFICIAL_STRESS") == 0) { + + /* + * use Monaghan's artificial stress to prevent particle clumping + */ + + t = string("*"); + iNextKwd = -1; + for (iarg = ioffset + 1; iarg < narg; iarg++) { + s = string(arg[iarg]); + if (s.compare(0, t.length(), t) == 0) { + iNextKwd = iarg; + break; + } + } + + if (iNextKwd < 0) { + sprintf(str, "no *KEYWORD terminates *ARTIFICIAL_STRESS"); + error->all(FLERR, str); + } + + if (iNextKwd - ioffset != 1 + 1) { + sprintf(str, "expected 1 arguments following *ARTIFICIAL_STRESS but got %d\n", iNextKwd - ioffset - 1); + error->all(FLERR, str); + } + + artificial_stress[itype][itype] = force->numeric(FLERR, arg[ioffset + 1]); + + if (comm->me == 0) { + printf(FORMAT2, "Artificial Stress is enabled."); + printf(FORMAT1, "Artificial Stress amplitude", artificial_stress[itype][itype]); + } + } // end *ARTIFICIAL_STRESS + + else { + sprintf(str, "unknown *KEYWORD: %s", arg[ioffset]); + error->all(FLERR, str); + } + + } + + /* + * copy data which is looked up in inner pairwise loops from slow maps to fast arrays + */ + + rho0[itype] = Lookup[REFERENCE_DENSITY][itype]; + c0_type[itype] = Lookup[REFERENCE_SOUNDSPEED][itype]; + setflag[itype][itype] = 1; + + /* + * error checks + */ + + if ((viscosity[itype] != NONE) && (strength[itype] != NONE)) { + sprintf(str, "cannot have both a strength and viscosity model for particle type %d", itype); + error->all(FLERR, str); + } + + if (eos[itype] == NONE) { + sprintf(str, "must specify an EOS for particle type %d", itype); + error->all(FLERR, str); + } + + } else { + /* + * we are reading a cross-interaction line for particle types i, j + */ + + itype = force->inumeric(FLERR, arg[0]); + jtype = force->inumeric(FLERR, arg[1]); + + if (strcmp(arg[2], "*CROSS") != 0) { + sprintf(str, "ulsph cross interaction between particle type %d and %d requested, however, *CROSS keyword is missing", + itype, jtype); + error->all(FLERR, str); + } + + if (setflag[itype][itype] != 1) { + sprintf(str, + "ulsph cross interaction between particle type %d and %d requested, however, properties of type %d have not yet been specified", + itype, jtype, itype); + error->all(FLERR, str); + } + + if (setflag[jtype][jtype] != 1) { + sprintf(str, + "ulsph cross interaction between particle type %d and %d requested, however, properties of type %d have not yet been specified", + itype, jtype, jtype); + error->all(FLERR, str); + } + + setflag[itype][jtype] = 1; + setflag[jtype][itype] = 1; + + if ((artificial_pressure[itype][itype] > 0.0) && (artificial_pressure[jtype][jtype] > 0.0)) { + artificial_pressure[itype][jtype] = 0.5 * (artificial_pressure[itype][itype] + artificial_pressure[jtype][jtype]); + artificial_pressure[jtype][itype] = artificial_pressure[itype][jtype]; + } else { + artificial_pressure[itype][jtype] = artificial_pressure[jtype][itype] = 0.0; + } + + if ((artificial_stress[itype][itype] > 0.0) && (artificial_stress[jtype][jtype] > 0.0)) { + artificial_stress[itype][jtype] = 0.5 * (artificial_stress[itype][itype] + artificial_stress[jtype][jtype]); + artificial_stress[jtype][itype] = artificial_stress[itype][jtype]; + } else { + artificial_stress[itype][jtype] = artificial_stress[jtype][itype] = 0.0; + } + + if (comm->me == 0) { + printf(">>========>>========>>========>>========>>========>>========>>========>>========\n"); + } + + } } /* ---------------------------------------------------------------------- @@ -1417,20 +1417,20 @@ void PairULSPH::coeff(int narg, char **arg) { double PairULSPH::init_one(int i, int j) { - if (!allocated) - allocate(); + if (!allocated) + allocate(); - if (setflag[i][j] == 0) - error->all(FLERR, "All pair coeffs are not set"); + if (setflag[i][j] == 0) + error->all(FLERR, "All pair coeffs are not set"); // cutoff = sum of max I,J radii for // dynamic/dynamic & dynamic/frozen interactions, but not frozen/frozen - double cutoff = maxrad_dynamic[i] + maxrad_dynamic[j]; - cutoff = MAX(cutoff, maxrad_frozen[i] + maxrad_dynamic[j]); - cutoff = MAX(cutoff, maxrad_dynamic[i] + maxrad_frozen[j]); + double cutoff = maxrad_dynamic[i] + maxrad_dynamic[j]; + cutoff = MAX(cutoff, maxrad_frozen[i] + maxrad_dynamic[j]); + cutoff = MAX(cutoff, maxrad_dynamic[i] + maxrad_frozen[j]); //printf("cutoff for pair sph/fluid = %f\n", cutoff); - return cutoff; + return cutoff; } /* ---------------------------------------------------------------------- @@ -1438,28 +1438,28 @@ double PairULSPH::init_one(int i, int j) { ------------------------------------------------------------------------- */ void PairULSPH::init_style() { - int i; + int i; //printf(" in init style\n"); // request a granular neighbor list - int irequest = neighbor->request(this); - neighbor->requests[irequest]->size = 1; + int irequest = neighbor->request(this); + neighbor->requests[irequest]->size = 1; // set maxrad_dynamic and maxrad_frozen for each type // include future Fix pour particles as dynamic - for (i = 1; i <= atom->ntypes; i++) - onerad_dynamic[i] = onerad_frozen[i] = 0.0; + for (i = 1; i <= atom->ntypes; i++) + onerad_dynamic[i] = onerad_frozen[i] = 0.0; - double *radius = atom->radius; - int *type = atom->type; - int nlocal = atom->nlocal; + double *radius = atom->radius; + int *type = atom->type; + int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) - onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]); + for (i = 0; i < nlocal; i++) + onerad_dynamic[type[i]] = MAX(onerad_dynamic[type[i]], radius[i]); - MPI_Allreduce(&onerad_dynamic[1], &maxrad_dynamic[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); - MPI_Allreduce(&onerad_frozen[1], &maxrad_frozen[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); + MPI_Allreduce(&onerad_dynamic[1], &maxrad_dynamic[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); + MPI_Allreduce(&onerad_frozen[1], &maxrad_frozen[1], atom->ntypes, MPI_DOUBLE, MPI_MAX, world); } @@ -1469,8 +1469,8 @@ void PairULSPH::init_style() { ------------------------------------------------------------------------- */ void PairULSPH::init_list(int id, NeighList *ptr) { - if (id == 0) - list = ptr; + if (id == 0) + list = ptr; } /* ---------------------------------------------------------------------- @@ -1481,81 +1481,81 @@ double PairULSPH::memory_usage() { //printf("in memory usage\n"); - return 11 * nmax * sizeof(double); + return 11 * nmax * sizeof(double); } /* ---------------------------------------------------------------------- */ int PairULSPH::pack_forward_comm(int n, int *list, double *buf, int pbc_flag, int *pbc) { - double *vfrac = atom->vfrac; - double *eff_plastic_strain = atom->eff_plastic_strain; - int i, j, m; + double *vfrac = atom->vfrac; + double *eff_plastic_strain = atom->eff_plastic_strain; + int i, j, m; //printf("packing comm\n"); - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = vfrac[j]; - buf[m++] = c0[j]; //2 - - buf[m++] = stressTensor[j](0, 0); // pack symmetric stress tensor - buf[m++] = stressTensor[j](1, 1); - buf[m++] = stressTensor[j](2, 2); - buf[m++] = stressTensor[j](0, 1); - buf[m++] = stressTensor[j](0, 2); - buf[m++] = stressTensor[j](1, 2); // 2 + 6 = 8 - - buf[m++] = F[j](0, 0); // F is not symmetric - buf[m++] = F[j](0, 1); - buf[m++] = F[j](0, 2); - buf[m++] = F[j](1, 0); - buf[m++] = F[j](1, 1); - buf[m++] = F[j](1, 2); - buf[m++] = F[j](2, 0); - buf[m++] = F[j](2, 1); - buf[m++] = F[j](2, 2); // 8 + 9 = 17 - - buf[m++] = eff_plastic_strain[j]; // 18 - } - return m; + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = vfrac[j]; + buf[m++] = c0[j]; //2 + + buf[m++] = stressTensor[j](0, 0); // pack symmetric stress tensor + buf[m++] = stressTensor[j](1, 1); + buf[m++] = stressTensor[j](2, 2); + buf[m++] = stressTensor[j](0, 1); + buf[m++] = stressTensor[j](0, 2); + buf[m++] = stressTensor[j](1, 2); // 2 + 6 = 8 + + buf[m++] = F[j](0, 0); // F is not symmetric + buf[m++] = F[j](0, 1); + buf[m++] = F[j](0, 2); + buf[m++] = F[j](1, 0); + buf[m++] = F[j](1, 1); + buf[m++] = F[j](1, 2); + buf[m++] = F[j](2, 0); + buf[m++] = F[j](2, 1); + buf[m++] = F[j](2, 2); // 8 + 9 = 17 + + buf[m++] = eff_plastic_strain[j]; // 18 + } + return m; } /* ---------------------------------------------------------------------- */ void PairULSPH::unpack_forward_comm(int n, int first, double *buf) { - double *vfrac = atom->vfrac; - double *eff_plastic_strain = atom->eff_plastic_strain; - int i, m, last; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - vfrac[i] = buf[m++]; - c0[i] = buf[m++]; // 2 - - stressTensor[i](0, 0) = buf[m++]; - stressTensor[i](1, 1) = buf[m++]; - stressTensor[i](2, 2) = buf[m++]; - stressTensor[i](0, 1) = buf[m++]; - stressTensor[i](0, 2) = buf[m++]; - stressTensor[i](1, 2) = buf[m++]; // 2 + 6 = 8 - stressTensor[i](1, 0) = stressTensor[i](0, 1); - stressTensor[i](2, 0) = stressTensor[i](0, 2); - stressTensor[i](2, 1) = stressTensor[i](1, 2); - - F[i](0, 0) = buf[m++]; - F[i](0, 1) = buf[m++]; - F[i](0, 2) = buf[m++]; - F[i](1, 0) = buf[m++]; - F[i](1, 1) = buf[m++]; - F[i](1, 2) = buf[m++]; - F[i](2, 0) = buf[m++]; - F[i](2, 1) = buf[m++]; - F[i](2, 2) = buf[m++]; // 8 + 9 = 17 - - eff_plastic_strain[i] = buf[m++]; // 18 - } + double *vfrac = atom->vfrac; + double *eff_plastic_strain = atom->eff_plastic_strain; + int i, m, last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + vfrac[i] = buf[m++]; + c0[i] = buf[m++]; // 2 + + stressTensor[i](0, 0) = buf[m++]; + stressTensor[i](1, 1) = buf[m++]; + stressTensor[i](2, 2) = buf[m++]; + stressTensor[i](0, 1) = buf[m++]; + stressTensor[i](0, 2) = buf[m++]; + stressTensor[i](1, 2) = buf[m++]; // 2 + 6 = 8 + stressTensor[i](1, 0) = stressTensor[i](0, 1); + stressTensor[i](2, 0) = stressTensor[i](0, 2); + stressTensor[i](2, 1) = stressTensor[i](1, 2); + + F[i](0, 0) = buf[m++]; + F[i](0, 1) = buf[m++]; + F[i](0, 2) = buf[m++]; + F[i](1, 0) = buf[m++]; + F[i](1, 1) = buf[m++]; + F[i](1, 2) = buf[m++]; + F[i](2, 0) = buf[m++]; + F[i](2, 1) = buf[m++]; + F[i](2, 2) = buf[m++]; // 8 + 9 = 17 + + eff_plastic_strain[i] = buf[m++]; // 18 + } } /* @@ -1564,26 +1564,26 @@ void PairULSPH::unpack_forward_comm(int n, int first, double *buf) { void *PairULSPH::extract(const char *str, int &i) { //printf("in extract\n"); - if (strcmp(str, "smd/ulsph/smoothVel_ptr") == 0) { - return (void *) smoothVel; - } else if (strcmp(str, "smd/ulsph/stressTensor_ptr") == 0) { - return (void *) stressTensor; - } else if (strcmp(str, "smd/ulsph/velocityGradient_ptr") == 0) { - return (void *) L; - } else if (strcmp(str, "smd/ulsph/numNeighs_ptr") == 0) { - return (void *) numNeighs; - } else if (strcmp(str, "smd/ulsph/dtCFL_ptr") == 0) { + if (strcmp(str, "smd/ulsph/smoothVel_ptr") == 0) { + return (void *) smoothVel; + } else if (strcmp(str, "smd/ulsph/stressTensor_ptr") == 0) { + return (void *) stressTensor; + } else if (strcmp(str, "smd/ulsph/velocityGradient_ptr") == 0) { + return (void *) L; + } else if (strcmp(str, "smd/ulsph/numNeighs_ptr") == 0) { + return (void *) numNeighs; + } else if (strcmp(str, "smd/ulsph/dtCFL_ptr") == 0) { //printf("dtcfl = %f\n", dtCFL); - return (void *) &dtCFL; - } else if (strcmp(str, "smd/ulsph/updateFlag_ptr") == 0) { - return (void *) &updateFlag; - } else if (strcmp(str, "smd/ulsph/effective_modulus_ptr") == 0) { - return (void *) effm; - } else if (strcmp(str, "smd/ulsph/shape_matrix_ptr") == 0) { - return (void *) K; - } - - return NULL; + return (void *) &dtCFL; + } else if (strcmp(str, "smd/ulsph/updateFlag_ptr") == 0) { + return (void *) &updateFlag; + } else if (strcmp(str, "smd/ulsph/effective_modulus_ptr") == 0) { + return (void *) effm; + } else if (strcmp(str, "smd/ulsph/shape_matrix_ptr") == 0) { + return (void *) K; + } + + return NULL; } /* ---------------------------------------------------------------------- @@ -1591,31 +1591,31 @@ void *PairULSPH::extract(const char *str, int &i) { ------------------------------------------------------------------------- */ double PairULSPH::effective_shear_modulus(const Matrix3d d_dev, const Matrix3d deltaStressDev, const double dt, const int itype) { - double G_eff; // effective shear modulus, see Pronto 2d eq. 3.4.7 - double deltaStressDevSum, shearRateSq, strain_increment; - - if (domain->dimension == 3) { - deltaStressDevSum = deltaStressDev(0, 1) * deltaStressDev(0, 1) + deltaStressDev(0, 2) * deltaStressDev(0, 2) - + deltaStressDev(1, 2) * deltaStressDev(1, 2); - shearRateSq = d_dev(0, 1) * d_dev(0, 1) + d_dev(0, 2) * d_dev(0, 2) + d_dev(1, 2) * d_dev(1, 2); - } else { - deltaStressDevSum = deltaStressDev(0, 1) * deltaStressDev(0, 1); - shearRateSq = d_dev(0, 1) * d_dev(0, 1); - } - - strain_increment = dt * dt * shearRateSq; - - if (strain_increment > 1.0e-12) { - G_eff = 0.5 * sqrt(deltaStressDevSum / strain_increment); - } else { - if (strength[itype] != NONE) { - G_eff = Lookup[SHEAR_MODULUS][itype]; - } else { - G_eff = 0.0; - } - } - - return G_eff; + double G_eff; // effective shear modulus, see Pronto 2d eq. 3.4.7 + double deltaStressDevSum, shearRateSq, strain_increment; + + if (domain->dimension == 3) { + deltaStressDevSum = deltaStressDev(0, 1) * deltaStressDev(0, 1) + deltaStressDev(0, 2) * deltaStressDev(0, 2) + + deltaStressDev(1, 2) * deltaStressDev(1, 2); + shearRateSq = d_dev(0, 1) * d_dev(0, 1) + d_dev(0, 2) * d_dev(0, 2) + d_dev(1, 2) * d_dev(1, 2); + } else { + deltaStressDevSum = deltaStressDev(0, 1) * deltaStressDev(0, 1); + shearRateSq = d_dev(0, 1) * d_dev(0, 1); + } + + strain_increment = dt * dt * shearRateSq; + + if (strain_increment > 1.0e-12) { + G_eff = 0.5 * sqrt(deltaStressDevSum / strain_increment); + } else { + if (strength[itype] != NONE) { + G_eff = Lookup[SHEAR_MODULUS][itype]; + } else { + G_eff = 0.0; + } + } + + return G_eff; } @@ -1625,26 +1625,26 @@ double PairULSPH::effective_shear_modulus(const Matrix3d d_dev, const Matrix3d d ------------------------------------------------------------------------- */ Vector3d PairULSPH::ComputeHourglassForce(const int i, const int itype, const int j, const int jtype, const Vector3d dv, - const Vector3d xij, const Vector3d g, const double c_ij, const double mu_ij, const double rho_ij) { - - double *rmass = atom->rmass; - Vector3d dv_est, f_hg; - double visc_magnitude; - - dv_est = -0.5 * (F[i] + F[j]) * xij; - double hurz = dv_est.dot(dv) / (dv_est.norm() * dv.norm() + 1.0e-16); - if (hurz < 0.0) { - - visc_magnitude = 0.5 * (Q1[itype] + Q1[jtype]) * c_ij * mu_ij / rho_ij; - f_hg = -rmass[i] * rmass[j] * visc_magnitude * g; -// printf(" f_hg = %f %f %f\n", f_hg(0), f_hg(1), f_hg(2)); -// printf("\nnegative\n"); -// printf(" dv_est = %f %f %f\n", dv_est(0), dv_est(1), dv_est(2)); -// printf(" dv = %f %f %f\n", dv(0), dv(1), dv(2)); - } else { - f_hg.setZero(); - } - - return f_hg; + const Vector3d xij, const Vector3d g, const double c_ij, const double mu_ij, const double rho_ij) { + + double *rmass = atom->rmass; + Vector3d dv_est, f_hg; + double visc_magnitude; + + dv_est = -0.5 * (F[i] + F[j]) * xij; + double hurz = dv_est.dot(dv) / (dv_est.norm() * dv.norm() + 1.0e-16); + if (hurz < 0.0) { + + visc_magnitude = 0.5 * (Q1[itype] + Q1[jtype]) * c_ij * mu_ij / rho_ij; + f_hg = -rmass[i] * rmass[j] * visc_magnitude * g; +// printf(" f_hg = %f %f %f\n", f_hg(0), f_hg(1), f_hg(2)); +// printf("\nnegative\n"); +// printf(" dv_est = %f %f %f\n", dv_est(0), dv_est(1), dv_est(2)); +// printf(" dv = %f %f %f\n", dv(0), dv(1), dv(2)); + } else { + f_hg.setZero(); + } + + return f_hg; } diff --git a/src/USER-SMD/pair_smd_ulsph.h b/src/USER-SMD/pair_smd_ulsph.h index 032079072e..435e0cb5a2 100644 --- a/src/USER-SMD/pair_smd_ulsph.h +++ b/src/USER-SMD/pair_smd_ulsph.h @@ -38,94 +38,94 @@ namespace LAMMPS_NS { class PairULSPH: public Pair { public: - PairULSPH(class LAMMPS *); - virtual ~PairULSPH(); - virtual void compute(int, int); - void settings(int, char **); - void coeff(int, char **); - double init_one(int, int); - void init_style(); - void init_list(int, class NeighList *); - virtual double memory_usage(); - int pack_forward_comm(int, int *, double *, int, int *); - void unpack_forward_comm(int, int, double *); - void AssembleStressTensor(); - void *extract(const char *, int &); - void PreCompute(); - void PreCompute_DensitySummation(); - double effective_shear_modulus(const Eigen::Matrix3d d_dev, const Eigen::Matrix3d deltaStressDev, const double dt, const int itype); - - Eigen::Vector3d ComputeHourglassForce(const int i, const int itype, const int j, const int jtype, const Eigen::Vector3d dv, - const Eigen::Vector3d xij, const Eigen::Vector3d g, const double c_ij, const double mu_ij, const double rho_ij); + PairULSPH(class LAMMPS *); + virtual ~PairULSPH(); + virtual void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + double init_one(int, int); + void init_style(); + void init_list(int, class NeighList *); + virtual double memory_usage(); + int pack_forward_comm(int, int *, double *, int, int *); + void unpack_forward_comm(int, int, double *); + void AssembleStressTensor(); + void *extract(const char *, int &); + void PreCompute(); + void PreCompute_DensitySummation(); + double effective_shear_modulus(const Eigen::Matrix3d d_dev, const Eigen::Matrix3d deltaStressDev, const double dt, const int itype); + + Eigen::Vector3d ComputeHourglassForce(const int i, const int itype, const int j, const int jtype, const Eigen::Vector3d dv, + const Eigen::Vector3d xij, const Eigen::Vector3d g, const double c_ij, const double mu_ij, const double rho_ij); protected: - double *c0_type; // reference speed of sound defined per particle type - double *rho0; // reference mass density per type - double *Q1; // linear artificial viscosity coeff - int *eos, *viscosity, *strength; // eos and strength material models - double **artificial_pressure; // true/false: use Monaghan's artificial pressure correction? - double **artificial_stress; // artificial stress amplitude + double *c0_type; // reference speed of sound defined per particle type + double *rho0; // reference mass density per type + double *Q1; // linear artificial viscosity coeff + int *eos, *viscosity, *strength; // eos and strength material models + double **artificial_pressure; // true/false: use Monaghan's artificial pressure correction? + double **artificial_stress; // artificial stress amplitude - double *onerad_dynamic, *onerad_frozen; - double *maxrad_dynamic, *maxrad_frozen; + double *onerad_dynamic, *onerad_frozen; + double *maxrad_dynamic, *maxrad_frozen; - void allocate(); + void allocate(); - int nmax; // max number of atoms on this proc - int *numNeighs; - Eigen::Matrix3d *K; - double *shepardWeight, *c0, *rho; - Eigen::Vector3d *smoothVel; - Eigen::Matrix3d *stressTensor, *L, *F; + int nmax; // max number of atoms on this proc + int *numNeighs; + Eigen::Matrix3d *K; + double *shepardWeight, *c0, *rho; + Eigen::Vector3d *smoothVel; + Eigen::Matrix3d *stressTensor, *L, *F; - double dtCFL; + double dtCFL; private: - // enumerate EOSs. MUST BE IN THE RANGE [1000, 2000) - enum { - EOS_LINEAR = 1000, EOS_PERFECT_GAS = 1001, EOS_TAIT = 1002, - }; - - // enumerate physical viscosity models. MUST BE IN THE RANGE [2000, 3000) - enum { - VISCOSITY_NEWTON = 2000 - }; - - // enumerate strength models. MUST BE IN THE RANGE [3000, 4000) - enum { - STRENGTH_LINEAR = 3000, STRENGTH_LINEAR_PLASTIC = 3001 - }; - - // enumerate some quantitities and associate these with integer values such that they can be used for lookup in an array structure - enum { - NONE = 0, - BULK_MODULUS = 1, - HOURGLASS_CONTROL_AMPLITUDE = 2, - EOS_TAIT_EXPONENT = 3, - REFERENCE_SOUNDSPEED = 4, - REFERENCE_DENSITY = 5, - EOS_PERFECT_GAS_GAMMA = 6, - SHEAR_MODULUS = 7, - YIELD_STRENGTH = 8, - YOUNGS_MODULUS = 9, - POISSON_RATIO = 10, - LAME_LAMBDA = 11, - HEAT_CAPACITY = 12, - M_MODULUS = 13, - HARDENING_PARAMETER = 14, - VISCOSITY_MU = 15, - MAX_KEY_VALUE = 16 - }; - double **Lookup; // holds per-type material parameters for the quantities defined in enum statement above. - - bool velocity_gradient_required; - int updateFlag; // indicates if any relative particle pair movement is significant compared to smoothing length - - - bool density_summation, density_continuity, velocity_gradient, gradient_correction_flag; - double *effm; + // enumerate EOSs. MUST BE IN THE RANGE [1000, 2000) + enum { + EOS_LINEAR = 1000, EOS_PERFECT_GAS = 1001, EOS_TAIT = 1002, + }; + + // enumerate physical viscosity models. MUST BE IN THE RANGE [2000, 3000) + enum { + VISCOSITY_NEWTON = 2000 + }; + + // enumerate strength models. MUST BE IN THE RANGE [3000, 4000) + enum { + STRENGTH_LINEAR = 3000, STRENGTH_LINEAR_PLASTIC = 3001 + }; + + // enumerate some quantitities and associate these with integer values such that they can be used for lookup in an array structure + enum { + NONE = 0, + BULK_MODULUS = 1, + HOURGLASS_CONTROL_AMPLITUDE = 2, + EOS_TAIT_EXPONENT = 3, + REFERENCE_SOUNDSPEED = 4, + REFERENCE_DENSITY = 5, + EOS_PERFECT_GAS_GAMMA = 6, + SHEAR_MODULUS = 7, + YIELD_STRENGTH = 8, + YOUNGS_MODULUS = 9, + POISSON_RATIO = 10, + LAME_LAMBDA = 11, + HEAT_CAPACITY = 12, + M_MODULUS = 13, + HARDENING_PARAMETER = 14, + VISCOSITY_MU = 15, + MAX_KEY_VALUE = 16 + }; + double **Lookup; // holds per-type material parameters for the quantities defined in enum statement above. + + bool velocity_gradient_required; + int updateFlag; // indicates if any relative particle pair movement is significant compared to smoothing length + + + bool density_summation, density_continuity, velocity_gradient, gradient_correction_flag; + double *effm; }; diff --git a/src/USER-SMD/smd_kernels.h b/src/USER-SMD/smd_kernels.h index 6621881f4b..3bc89b7e64 100644 --- a/src/USER-SMD/smd_kernels.h +++ b/src/USER-SMD/smd_kernels.h @@ -14,100 +14,100 @@ namespace SMD_Kernels { static inline double Kernel_Wendland_Quintic_NotNormalized(const double r, const double h) { - if (r < h) { - double q = 2.0 * r / h; - return pow(1.0 - 0.5 * q, 4) * (2.0 * q + 1.0); - } else { - return 0.0; - } + if (r < h) { + double q = 2.0 * r / h; + return pow(1.0 - 0.5 * q, 4) * (2.0 * q + 1.0); + } else { + return 0.0; + } } static inline double Kernel_Cubic_Spline(const double r, const double h) { - double q = 2.0 * r / h; - if (q > 2.0) { - return 0.0; - } else if ((q <= 2.0) && (q > 1.0)) { - return pow(2.0 - q, 3.0) / 6.0; - } else if ((q >= 0.0) && (q <= 1.0)) { - return 2. / 3. - q * q + 0.5 * q * q * q; - } else { - return 0.0; - } + double q = 2.0 * r / h; + if (q > 2.0) { + return 0.0; + } else if ((q <= 2.0) && (q > 1.0)) { + return pow(2.0 - q, 3.0) / 6.0; + } else if ((q >= 0.0) && (q <= 1.0)) { + return 2. / 3. - q * q + 0.5 * q * q * q; + } else { + return 0.0; + } } static inline double Kernel_Barbara(const double r, const double h) { - double arg = (1.570796327 * (r + h)) / h; - double hsq = h * h; - //wf = (1.680351548 * (cos(arg) + 1.)) / hsq; - return -2.639490040 * sin(arg) / (hsq * h); + double arg = (1.570796327 * (r + h)) / h; + double hsq = h * h; + //wf = (1.680351548 * (cos(arg) + 1.)) / hsq; + return -2.639490040 * sin(arg) / (hsq * h); } static inline void spiky_kernel_and_derivative(const double h, const double r, const int dimension, double &wf, double &wfd) { - /* - * Spiky kernel - */ - - if (r > h) { - printf("r=%f > h=%f in Spiky kernel\n", r, h); - wf = wfd = 0.0; - return; - } - - double hr = h - r; // [m] - if (dimension == 2) { - double n = 0.3141592654e0 * h * h * h * h * h; // [m^5] - wfd = -3.0e0 * hr * hr / n; // [m*m/m^5] = [1/m^3] ==> correct for dW/dr in 2D - wf = -0.333333333333e0 * hr * wfd; // [m/m^3] ==> [1/m^2] correct for W in 2D - } else { - wfd = -14.0323944878e0 * hr * hr / (h * h * h * h * h * h); // [1/m^4] ==> correct for dW/dr in 3D - wf = -0.333333333333e0 * hr * wfd; // [m/m^4] ==> [1/m^3] correct for W in 3D - } - - // alternative formulation -// double hr = h - r; + /* + * Spiky kernel + */ + + if (r > h) { + printf("r=%f > h=%f in Spiky kernel\n", r, h); + wf = wfd = 0.0; + return; + } + + double hr = h - r; // [m] + if (dimension == 2) { + double n = 0.3141592654e0 * h * h * h * h * h; // [m^5] + wfd = -3.0e0 * hr * hr / n; // [m*m/m^5] = [1/m^3] ==> correct for dW/dr in 2D + wf = -0.333333333333e0 * hr * wfd; // [m/m^3] ==> [1/m^2] correct for W in 2D + } else { + wfd = -14.0323944878e0 * hr * hr / (h * h * h * h * h * h); // [1/m^4] ==> correct for dW/dr in 3D + wf = -0.333333333333e0 * hr * wfd; // [m/m^4] ==> [1/m^3] correct for W in 3D + } + + // alternative formulation +// double hr = h - r; // -// /* -// * Spiky kernel -// */ +// /* +// * Spiky kernel +// */ // -// if (domain->dimension == 2) { -// double h5 = h * h * h * h * h; -// wf = 3.183098861e0 * hr * hr * hr / h5; -// wfd = -9.549296583 * hr * hr / h5; +// if (domain->dimension == 2) { +// double h5 = h * h * h * h * h; +// wf = 3.183098861e0 * hr * hr * hr / h5; +// wfd = -9.549296583 * hr * hr / h5; // -// } else { -// double h6 = h * h * h * h * h * h; -// wf = 4.774648292 * hr * hr * hr / h6; -// wfd = -14.32394487 * hr * hr / h6; -// } -// } +// } else { +// double h6 = h * h * h * h * h * h; +// wf = 4.774648292 * hr * hr * hr / h6; +// wfd = -14.32394487 * hr * hr / h6; +// } +// } } static inline void barbara_kernel_and_derivative(const double h, const double r, const int dimension, double &wf, double &wfd) { - /* - * Barbara kernel - */ - - double arg = (1.570796327 * (r + h)) / h; - double hsq = h * h; - - if (r > h) { - printf("r = %f > h = %f in barbara kernel function\n", r, h); - exit(1); - //wf = wfd = 0.0; - //return; - } - - if (dimension == 2) { - wf = (1.680351548 * (cos(arg) + 1.)) / hsq; - wfd = -2.639490040 * sin(arg) / (hsq * h); - } else { - wf = 2.051578323 * (cos(arg) + 1.) / (hsq * h); - wfd = -3.222611694 * sin(arg) / (hsq * hsq); - } + /* + * Barbara kernel + */ + + double arg = (1.570796327 * (r + h)) / h; + double hsq = h * h; + + if (r > h) { + printf("r = %f > h = %f in barbara kernel function\n", r, h); + exit(1); + //wf = wfd = 0.0; + //return; + } + + if (dimension == 2) { + wf = (1.680351548 * (cos(arg) + 1.)) / hsq; + wfd = -2.639490040 * sin(arg) / (hsq * h); + } else { + wf = 2.051578323 * (cos(arg) + 1.) / (hsq * h); + wfd = -3.222611694 * sin(arg) / (hsq * hsq); + } } /* @@ -115,12 +115,12 @@ static inline void barbara_kernel_and_derivative(const double h, const double r, */ static inline void Poly6Kernel(const double hsq, const double h, const double rsq, const int dimension, double &wf) { - double tmp = hsq - rsq; - if (dimension == 2) { - wf = tmp * tmp * tmp / (0.7853981635e0 * hsq * hsq * hsq * hsq); - } else { - wf = tmp * tmp * tmp / (0.6382918409e0 * hsq * hsq * hsq * hsq * h); - } + double tmp = hsq - rsq; + if (dimension == 2) { + wf = tmp * tmp * tmp / (0.7853981635e0 * hsq * hsq * hsq * hsq); + } else { + wf = tmp * tmp * tmp / (0.6382918409e0 * hsq * hsq * hsq * hsq * h); + } } /* @@ -128,15 +128,15 @@ static inline void Poly6Kernel(const double hsq, const double h, const double rs */ static inline void M4PrimeKernel(const double s, double &wf) { - if (s < 1.0) { - //wf = 1.0 - 2.5 * s * s + (3./2.) * s * s * s; - wf = 1.0 - s * s *(2.5 -1.5 *s); - } else if (s < 2.0) { - //wf = 0.5 * (1.0 - s) * ((2.0 - s) * (2.0 - s)); - wf = 2.0 + (-4.0 + (2.5 - 0.5 * s)*s)*s; - } else { - wf = 0.0; - } + if (s < 1.0) { + //wf = 1.0 - 2.5 * s * s + (3./2.) * s * s * s; + wf = 1.0 - s * s *(2.5 -1.5 *s); + } else if (s < 2.0) { + //wf = 0.5 * (1.0 - s) * ((2.0 - s) * (2.0 - s)); + wf = 2.0 + (-4.0 + (2.5 - 0.5 * s)*s)*s; + } else { + wf = 0.0; + } } } diff --git a/src/USER-SMD/smd_material_models.cpp b/src/USER-SMD/smd_material_models.cpp index f1288ae5ca..93228f3724 100644 --- a/src/USER-SMD/smd_material_models.cpp +++ b/src/USER-SMD/smd_material_models.cpp @@ -41,13 +41,13 @@ using namespace Eigen; ------------------------------------------------------------------------- */ void LinearEOS(double lambda, double pInitial, double d, double dt, double &pFinal, double &p_rate) { - /* - * pressure rate - */ - p_rate = lambda * d; + /* + * pressure rate + */ + p_rate = lambda * d; - pFinal = pInitial + dt * p_rate; // increment pressure using pressure rate - //cout << "hurz" << endl; + pFinal = pInitial + dt * p_rate; // increment pressure using pressure rate + //cout << "hurz" << endl; } @@ -70,16 +70,16 @@ void LinearEOS(double lambda, double pInitial, double d, double dt, double &pFin ------------------------------------------------------------------------- */ void ShockEOS(double rho, double rho0, double e, double e0, double c0, double S, double Gamma, double pInitial, double dt, - double &pFinal, double &p_rate) { + double &pFinal, double &p_rate) { - double mu = rho / rho0 - 1.0; - double pH = rho0 * square(c0) * mu * (1.0 + mu) / square(1.0 - (S - 1.0) * mu); + double mu = rho / rho0 - 1.0; + double pH = rho0 * square(c0) * mu * (1.0 + mu) / square(1.0 - (S - 1.0) * mu); - pFinal = (-pH + rho * Gamma * (e - e0)); + pFinal = (-pH + rho * Gamma * (e - e0)); - //printf("shock EOS: rho = %g, rho0 = %g, Gamma=%f, c0=%f, S=%f, e=%f, e0=%f\n", rho, rho0, Gamma, c0, S, e, e0); - //printf("pFinal = %f\n", pFinal); - p_rate = (pFinal - pInitial) / dt; + //printf("shock EOS: rho = %g, rho0 = %g, Gamma=%f, c0=%f, S=%f, e=%f, e0=%f\n", rho, rho0, Gamma, c0, S, e, e0); + //printf("pFinal = %f\n", pFinal); + p_rate = (pFinal - pInitial) / dt; } @@ -98,20 +98,20 @@ void ShockEOS(double rho, double rho0, double e, double e0, double c0, double S, ------------------------------------------------------------------------- */ void polynomialEOS(double rho, double rho0, double e, double C0, double C1, double C2, double C3, double C4, double C5, double C6, - double pInitial, double dt, double &pFinal, double &p_rate) { + double pInitial, double dt, double &pFinal, double &p_rate) { - double mu = rho / rho0 - 1.0; + double mu = rho / rho0 - 1.0; - if (mu > 0.0) { - pFinal = C0 + C1 * mu + C2 * mu * mu + C3 * mu * mu * mu; // + (C4 + C5 * mu + C6 * mu * mu) * e; - } else { - pFinal = C0 + C1 * mu + C3 * mu * mu * mu; // + (C4 + C5 * mu) * e; - } - pFinal = -pFinal; // we want the mean stress, not the pressure. + if (mu > 0.0) { + pFinal = C0 + C1 * mu + C2 * mu * mu + C3 * mu * mu * mu; // + (C4 + C5 * mu + C6 * mu * mu) * e; + } else { + pFinal = C0 + C1 * mu + C3 * mu * mu * mu; // + (C4 + C5 * mu) * e; + } + pFinal = -pFinal; // we want the mean stress, not the pressure. - //printf("pFinal = %f\n", pFinal); - p_rate = (pFinal - pInitial) / dt; + //printf("pFinal = %f\n", pFinal); + p_rate = (pFinal - pInitial) / dt; } @@ -126,17 +126,17 @@ void polynomialEOS(double rho, double rho0, double e, double C0, double C1, doub (2) current speed of sound ------------------------------------------------------------------------- */ void TaitEOS_density(const double exponent, const double c0_reference, const double rho_reference, const double rho_current, - double &pressure, double &sound_speed) { + double &pressure, double &sound_speed) { - double B = rho_reference * c0_reference * c0_reference / exponent; - double tmp = pow(rho_current / rho_reference, exponent); - pressure = B * (tmp - 1.0); - double bulk_modulus = B * tmp * exponent; // computed as rho * d(pressure)/d(rho) - sound_speed = sqrt(bulk_modulus / rho_current); + double B = rho_reference * c0_reference * c0_reference / exponent; + double tmp = pow(rho_current / rho_reference, exponent); + pressure = B * (tmp - 1.0); + double bulk_modulus = B * tmp * exponent; // computed as rho * d(pressure)/d(rho) + sound_speed = sqrt(bulk_modulus / rho_current); -// if (fabs(pressure) > 0.01) { -// printf("tmp = %f, press=%f, K=%f\n", tmp, pressure, bulk_modulus); -// } +// if (fabs(pressure) > 0.01) { +// printf("tmp = %f, press=%f, K=%f\n", tmp, pressure, bulk_modulus); +// } } @@ -154,20 +154,20 @@ void TaitEOS_density(const double exponent, const double c0_reference, const dou ------------------------------------------------------------------------- */ void PerfectGasEOS(const double gamma, const double vol, const double mass, const double energy, double &pFinal, double &c0) { - /* - * perfect gas EOS is p = (gamma - 1) rho e - */ + /* + * perfect gas EOS is p = (gamma - 1) rho e + */ - if (energy > 0.0) { + if (energy > 0.0) { - pFinal = (1.0 - gamma) * energy / vol; + pFinal = (1.0 - gamma) * energy / vol; //printf("gamma = %f, vol%f, e=%g ==> p=%g\n", gamma, vol, energy, *pFinal__/1.0e-9); - c0 = sqrt((gamma - 1.0) * energy / mass); + c0 = sqrt((gamma - 1.0) * energy / mass); - } else { - pFinal = c0 = 0.0; - } + } else { + pFinal = c0 = 0.0; + } } @@ -179,17 +179,17 @@ void PerfectGasEOS(const double gamma, const double vol, const double mass, cons output: sigmaFinal_dev, sigmaFinal_dev_rate__: final stress deviator and its rate. ------------------------------------------------------------------------- */ void LinearStrength(const double mu, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, const double dt, - Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__) { + Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__) { - /* - * deviatoric rate of unrotated stress - */ - sigma_dev_rate__ = 2.0 * mu * d_dev; + /* + * deviatoric rate of unrotated stress + */ + sigma_dev_rate__ = 2.0 * mu * d_dev; - /* - * elastic update to the deviatoric stress - */ - sigmaFinal_dev__ = sigmaInitial_dev + dt * sigma_dev_rate__; + /* + * elastic update to the deviatoric stress + */ + sigmaFinal_dev__ = sigmaInitial_dev + dt * sigma_dev_rate__; } /* ---------------------------------------------------------------------- @@ -199,13 +199,13 @@ void LinearStrength(const double mu, const Matrix3d sigmaInitial_dev, const Matr output: total stress tensor, deviator + pressure ------------------------------------------------------------------------- */ //void PairTlsph::LinearStrengthDefgrad(double lambda, double mu, Matrix3d F, Matrix3d *T) { -// Matrix3d E, PK2, eye, sigma, S, tau; +// Matrix3d E, PK2, eye, sigma, S, tau; // -// eye.setIdentity(); +// eye.setIdentity(); // -// E = 0.5 * (F * F.transpose() - eye); // strain measure E = 0.5 * (B - I) = 0.5 * (F * F^T - I) -// tau = lambda * E.trace() * eye + 2.0 * mu * E; // Kirchhoff stress, work conjugate to above strain -// sigma = tau / F.determinant(); // convert Kirchhoff stress to Cauchy stress +// E = 0.5 * (F * F.transpose() - eye); // strain measure E = 0.5 * (B - I) = 0.5 * (F * F^T - I) +// tau = lambda * E.trace() * eye + 2.0 * mu * E; // Kirchhoff stress, work conjugate to above strain +// sigma = tau / F.determinant(); // convert Kirchhoff stress to Cauchy stress // ////printf("l=%f, mu=%f, sigma xy = %f\n", lambda, mu, sigma(0,1)); // @@ -214,20 +214,20 @@ void LinearStrength(const double mu, const Matrix3d sigmaInitial_dev, const Matr //// tau = F * S * F.transpose(); // convert PK2 to Kirchhoff stress //// sigma = tau / F.determinant(); // -// //*T = sigma; +// //*T = sigma; // -// /* -// * neo-hookean model due to Bonet -// */ +// /* +// * neo-hookean model due to Bonet +// */ //// lambda = mu = 100.0; //// // left Cauchy-Green Tensor, b = F.F^T -// double J = F.determinant(); -// double logJ = log(J); -// Matrix3d b; -// b = F * F.transpose(); +// double J = F.determinant(); +// double logJ = log(J); +// Matrix3d b; +// b = F * F.transpose(); // -// sigma = (mu / J) * (b - eye) + (lambda / J) * logJ * eye; -// *T = sigma; +// sigma = (mu / J) * (b - eye) + (lambda / J) * logJ * eye; +// *T = sigma; //} /* ---------------------------------------------------------------------- linear strength model for use with linear elasticity @@ -237,55 +237,55 @@ void LinearStrength(const double mu, const Matrix3d sigmaInitial_dev, const Matr output: sigmaFinal_dev, sigmaFinal_dev_rate__: final stress deviator and its rate. ------------------------------------------------------------------------- */ void LinearPlasticStrength(const double G, const double yieldStress, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, - const double dt, Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__, double &plastic_strain_increment) { - - Matrix3d sigmaTrial_dev, dev_rate; - double J2; - - /* - * deviatoric rate of unrotated stress - */ - dev_rate = 2.0 * G * d_dev; - - /* - * perform a trial elastic update to the deviatoric stress - */ - sigmaTrial_dev = sigmaInitial_dev + dt * dev_rate; // increment stress deviator using deviatoric rate - - /* - * check yield condition - */ - J2 = sqrt(3. / 2.) * sigmaTrial_dev.norm(); - - if (J2 < yieldStress) { - /* - * no yielding has occured. - * final deviatoric stress is trial deviatoric stress - */ - sigma_dev_rate__ = dev_rate; - sigmaFinal_dev__ = sigmaTrial_dev; - plastic_strain_increment = 0.0; - //printf("no yield\n"); - - } else { - //printf("yiedl\n"); - /* - * yielding has occured - */ - plastic_strain_increment = (J2 - yieldStress) / (3.0 * G); - - /* - * new deviatoric stress: - * obtain by scaling the trial stress deviator - */ - sigmaFinal_dev__ = (yieldStress / J2) * sigmaTrial_dev; - - /* - * new deviatoric stress rate - */ - sigma_dev_rate__ = sigmaFinal_dev__ - sigmaInitial_dev; - //printf("yielding has occured.\n"); - } + const double dt, Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__, double &plastic_strain_increment) { + + Matrix3d sigmaTrial_dev, dev_rate; + double J2; + + /* + * deviatoric rate of unrotated stress + */ + dev_rate = 2.0 * G * d_dev; + + /* + * perform a trial elastic update to the deviatoric stress + */ + sigmaTrial_dev = sigmaInitial_dev + dt * dev_rate; // increment stress deviator using deviatoric rate + + /* + * check yield condition + */ + J2 = sqrt(3. / 2.) * sigmaTrial_dev.norm(); + + if (J2 < yieldStress) { + /* + * no yielding has occured. + * final deviatoric stress is trial deviatoric stress + */ + sigma_dev_rate__ = dev_rate; + sigmaFinal_dev__ = sigmaTrial_dev; + plastic_strain_increment = 0.0; + //printf("no yield\n"); + + } else { + //printf("yiedl\n"); + /* + * yielding has occured + */ + plastic_strain_increment = (J2 - yieldStress) / (3.0 * G); + + /* + * new deviatoric stress: + * obtain by scaling the trial stress deviator + */ + sigmaFinal_dev__ = (yieldStress / J2) * sigmaTrial_dev; + + /* + * new deviatoric stress rate + */ + sigma_dev_rate__ = sigmaFinal_dev__ - sigmaInitial_dev; + //printf("yielding has occured.\n"); + } } /* ---------------------------------------------------------------------- @@ -307,66 +307,66 @@ void LinearPlasticStrength(const double G, const double yieldStress, const Matri output: sigmaFinal_dev, sigmaFinal_dev_rate__: final stress deviator and its rate. ------------------------------------------------------------------------- */ void JohnsonCookStrength(const double G, const double cp, const double espec, const double A, const double B, const double a, - const double C, const double epdot0, const double T0, const double Tmelt, const double M, const double dt, const double ep, - const double epdot, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, Matrix3d &sigmaFinal_dev__, - Matrix3d &sigma_dev_rate__, double &plastic_strain_increment) { - - Matrix3d sigmaTrial_dev, dev_rate; - double J2, yieldStress; - - double deltaT = espec / cp; - double TH = deltaT / (Tmelt - T0); - TH = MAX(TH, 0.0); - double epdot_ratio = epdot / epdot0; - epdot_ratio = MAX(epdot_ratio, 1.0); - //printf("current temperature delta is %f, TH=%f\n", deltaT, TH); - - yieldStress = (A + B * pow(ep, a)) * (1.0 + C * log(epdot_ratio)); // * (1.0 - pow(TH, M)); - - /* - * deviatoric rate of unrotated stress - */ - dev_rate = 2.0 * G * d_dev; - - /* - * perform a trial elastic update to the deviatoric stress - */ - sigmaTrial_dev = sigmaInitial_dev + dt * dev_rate; // increment stress deviator using deviatoric rate - - /* - * check yield condition - */ - J2 = sqrt(3. / 2.) * sigmaTrial_dev.norm(); - - if (J2 < yieldStress) { - /* - * no yielding has occured. - * final deviatoric stress is trial deviatoric stress - */ - sigma_dev_rate__ = dev_rate; - sigmaFinal_dev__ = sigmaTrial_dev; - plastic_strain_increment = 0.0; - //printf("no yield\n"); - - } else { - //printf("yiedl\n"); - /* - * yielding has occured - */ - plastic_strain_increment = (J2 - yieldStress) / (3.0 * G); - - /* - * new deviatoric stress: - * obtain by scaling the trial stress deviator - */ - sigmaFinal_dev__ = (yieldStress / J2) * sigmaTrial_dev; - - /* - * new deviatoric stress rate - */ - sigma_dev_rate__ = sigmaFinal_dev__ - sigmaInitial_dev; - //printf("yielding has occured.\n"); - } + const double C, const double epdot0, const double T0, const double Tmelt, const double M, const double dt, const double ep, + const double epdot, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, Matrix3d &sigmaFinal_dev__, + Matrix3d &sigma_dev_rate__, double &plastic_strain_increment) { + + Matrix3d sigmaTrial_dev, dev_rate; + double J2, yieldStress; + + double deltaT = espec / cp; + double TH = deltaT / (Tmelt - T0); + TH = MAX(TH, 0.0); + double epdot_ratio = epdot / epdot0; + epdot_ratio = MAX(epdot_ratio, 1.0); + //printf("current temperature delta is %f, TH=%f\n", deltaT, TH); + + yieldStress = (A + B * pow(ep, a)) * (1.0 + C * log(epdot_ratio)); // * (1.0 - pow(TH, M)); + + /* + * deviatoric rate of unrotated stress + */ + dev_rate = 2.0 * G * d_dev; + + /* + * perform a trial elastic update to the deviatoric stress + */ + sigmaTrial_dev = sigmaInitial_dev + dt * dev_rate; // increment stress deviator using deviatoric rate + + /* + * check yield condition + */ + J2 = sqrt(3. / 2.) * sigmaTrial_dev.norm(); + + if (J2 < yieldStress) { + /* + * no yielding has occured. + * final deviatoric stress is trial deviatoric stress + */ + sigma_dev_rate__ = dev_rate; + sigmaFinal_dev__ = sigmaTrial_dev; + plastic_strain_increment = 0.0; + //printf("no yield\n"); + + } else { + //printf("yiedl\n"); + /* + * yielding has occured + */ + plastic_strain_increment = (J2 - yieldStress) / (3.0 * G); + + /* + * new deviatoric stress: + * obtain by scaling the trial stress deviator + */ + sigmaFinal_dev__ = (yieldStress / J2) * sigmaTrial_dev; + + /* + * new deviatoric stress rate + */ + sigma_dev_rate__ = sigmaFinal_dev__ - sigmaInitial_dev; + //printf("yielding has occured.\n"); + } } /* ---------------------------------------------------------------------- @@ -382,19 +382,19 @@ void JohnsonCookStrength(const double G, const double cp, const double espec, co bool IsotropicMaxStrainDamage(const Matrix3d E, const double maxStrain) { - /* - * compute Eigenvalues of strain matrix - */ - SelfAdjointEigenSolver < Matrix3d > es; - es.compute(E); // compute eigenvalue and eigenvectors of strain + /* + * compute Eigenvalues of strain matrix + */ + SelfAdjointEigenSolver < Matrix3d > es; + es.compute(E); // compute eigenvalue and eigenvectors of strain - double max_eigenvalue = es.eigenvalues().maxCoeff(); + double max_eigenvalue = es.eigenvalues().maxCoeff(); - if (max_eigenvalue > maxStrain) { - return true; - } else { - return false; - } + if (max_eigenvalue > maxStrain) { + return true; + } else { + return false; + } } /* ---------------------------------------------------------------------- @@ -410,19 +410,19 @@ bool IsotropicMaxStrainDamage(const Matrix3d E, const double maxStrain) { bool IsotropicMaxStressDamage(const Matrix3d S, const double maxStress) { - /* - * compute Eigenvalues of strain matrix - */ - SelfAdjointEigenSolver < Matrix3d > es; - es.compute(S); // compute eigenvalue and eigenvectors of strain + /* + * compute Eigenvalues of strain matrix + */ + SelfAdjointEigenSolver < Matrix3d > es; + es.compute(S); // compute eigenvalue and eigenvectors of strain - double max_eigenvalue = es.eigenvalues().maxCoeff(); + double max_eigenvalue = es.eigenvalues().maxCoeff(); - if (max_eigenvalue > maxStress) { - return true; - } else { - return false; - } + if (max_eigenvalue > maxStress) { + return true; + } else { + return false; + } } /* ---------------------------------------------------------------------- @@ -436,39 +436,39 @@ bool IsotropicMaxStressDamage(const Matrix3d S, const double maxStress) { ------------------------------------------------------------------------- */ double JohnsonCookFailureStrain(const double p, const Matrix3d Sdev, const double d1, const double d2, const double d3, - const double d4, const double epdot0, const double epdot) { + const double d4, const double epdot0, const double epdot) { - double vm = sqrt(3. / 2.) * Sdev.norm(); // von-Mises equivalent stress - if (vm < 0.0) { - cout << "this is sdev " << endl << Sdev << endl; - printf("vm=%f < 0.0, surely must be an error\n", vm); - exit(1); - } + double vm = sqrt(3. / 2.) * Sdev.norm(); // von-Mises equivalent stress + if (vm < 0.0) { + cout << "this is sdev " << endl << Sdev << endl; + printf("vm=%f < 0.0, surely must be an error\n", vm); + exit(1); + } - // determine stress triaxiality - double triax = p / (vm + 0.01 * fabs(p)); // have softening in denominator to avoid divison by zero - if (triax < 0.0) { - triax = 0.0; - } else if (triax > 3.0) { - triax = 3.0; - } + // determine stress triaxiality + double triax = p / (vm + 0.01 * fabs(p)); // have softening in denominator to avoid divison by zero + if (triax < 0.0) { + triax = 0.0; + } else if (triax > 3.0) { + triax = 3.0; + } - // Johnson-Cook failure strain, dependence on stress triaxiality - double jc_failure_strain = d1 + d2 * exp(d3 * triax); + // Johnson-Cook failure strain, dependence on stress triaxiality + double jc_failure_strain = d1 + d2 * exp(d3 * triax); - // include strain rate dependency if parameter d4 is defined and current plastic strain rate exceeds reference strain rate - if (d4 > 0.0) { // - if (epdot > epdot0) { - double epdot_ratio = epdot / epdot0; - jc_failure_strain *= (1.0 + d4 * log(epdot_ratio)); - //printf("epsdot=%f, epsdot0=%f, factor = %f\n", epdot, epdot0, (1.0 + d4 * log(epdot_ratio))); - //exit(1); + // include strain rate dependency if parameter d4 is defined and current plastic strain rate exceeds reference strain rate + if (d4 > 0.0) { // + if (epdot > epdot0) { + double epdot_ratio = epdot / epdot0; + jc_failure_strain *= (1.0 + d4 * log(epdot_ratio)); + //printf("epsdot=%f, epsdot0=%f, factor = %f\n", epdot, epdot0, (1.0 + d4 * log(epdot_ratio))); + //exit(1); - } - } + } + } - return jc_failure_strain; + return jc_failure_strain; } diff --git a/src/USER-SMD/smd_material_models.h b/src/USER-SMD/smd_material_models.h index c6b6f8d94c..acb498c04d 100644 --- a/src/USER-SMD/smd_material_models.h +++ b/src/USER-SMD/smd_material_models.h @@ -32,24 +32,24 @@ using namespace Eigen; */ void LinearEOS(double lambda, double pInitial, double d, double dt, double &pFinal, double &p_rate); void ShockEOS(double rho, double rho0, double e, double e0, double c0, double S, double Gamma, double pInitial, double dt, - double &pFinal, double &p_rate); + double &pFinal, double &p_rate); void polynomialEOS(double rho, double rho0, double e, double C0, double C1, double C2, double C3, double C4, double C5, double C6, - double pInitial, double dt, double &pFinal, double &p_rate); + double pInitial, double dt, double &pFinal, double &p_rate); void TaitEOS_density(const double exponent, const double c0_reference, const double rho_reference, const double rho_current, - double &pressure, double &sound_speed); + double &pressure, double &sound_speed); void PerfectGasEOS(const double gamma, const double vol, const double mass, const double energy, double &pFinal__, double &c0); /* * Material strength models */ void LinearStrength(const double mu, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, const double dt, - Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__); + Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__); void LinearPlasticStrength(const double G, const double yieldStress, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, - const double dt, Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__, double &plastic_strain_increment); + const double dt, Matrix3d &sigmaFinal_dev__, Matrix3d &sigma_dev_rate__, double &plastic_strain_increment); void JohnsonCookStrength(const double G, const double cp, const double espec, const double A, const double B, const double a, - const double C, const double epdot0, const double T0, const double Tmelt, const double M, const double dt, const double ep, - const double epdot, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, Matrix3d &sigmaFinal_dev__, - Matrix3d &sigma_dev_rate__, double &plastic_strain_increment); + const double C, const double epdot0, const double T0, const double Tmelt, const double M, const double dt, const double ep, + const double epdot, const Matrix3d sigmaInitial_dev, const Matrix3d d_dev, Matrix3d &sigmaFinal_dev__, + Matrix3d &sigma_dev_rate__, double &plastic_strain_increment); /* * Damage models @@ -58,7 +58,7 @@ void JohnsonCookStrength(const double G, const double cp, const double espec, co bool IsotropicMaxStrainDamage(const Matrix3d E, const double maxStrain); bool IsotropicMaxStressDamage(const Matrix3d E, const double maxStrain); double JohnsonCookFailureStrain(const double p, const Matrix3d Sdev, const double d1, const double d2, const double d3, - const double d4, const double epdot0, const double epdot); + const double d4, const double epdot0, const double epdot); diff --git a/src/USER-SMD/smd_math.h b/src/USER-SMD/smd_math.h index b7bf9c112d..23d76f0fdb 100644 --- a/src/USER-SMD/smd_math.h +++ b/src/USER-SMD/smd_math.h @@ -20,22 +20,22 @@ using namespace std; namespace SMD_Math { static inline void LimitDoubleMagnitude(double &x, const double limit) { - /* - * if |x| exceeds limit, set x to limit with the sign of x - */ - if (fabs(x) > limit) { // limit delVdotDelR to a fraction of speed of sound - x = limit * copysign(1, x); - } + /* + * if |x| exceeds limit, set x to limit with the sign of x + */ + if (fabs(x) > limit) { // limit delVdotDelR to a fraction of speed of sound + x = limit * copysign(1, x); + } } /* * deviator of a tensor */ static inline Matrix3d Deviator(const Matrix3d M) { - Matrix3d eye; - eye.setIdentity(); - eye *= M.trace() / 3.0; - return M - eye; + Matrix3d eye; + eye.setIdentity(); + eye *= M.trace() / 3.0; + return M - eye; } /* @@ -55,50 +55,50 @@ static inline Matrix3d Deviator(const Matrix3d M) { static inline bool PolDec(Matrix3d M, Matrix3d &R, Matrix3d &T, bool scaleF) { - JacobiSVD<Matrix3d> svd(M, ComputeFullU | ComputeFullV); // SVD(A) = U S V* - Vector3d S_eigenvalues = svd.singularValues(); - Matrix3d S = svd.singularValues().asDiagonal(); - Matrix3d U = svd.matrixU(); - Matrix3d V = svd.matrixV(); - Matrix3d eye; - eye.setIdentity(); - - // now do polar decomposition into M = R * T, where R is rotation - // and T is translation matrix - R = U * V.transpose(); - T = V * S * V.transpose(); - - if (R.determinant() < 0.0) { // this is an improper rotation - // identify the smallest entry in S and flip its sign - int imin; - S_eigenvalues.minCoeff(&imin); - S(imin, imin) *= -1.0; - - R = M * V * S.inverse() * V.transpose(); // recompute R using flipped stretch eigenvalues - } - - /* - * scale S to avoid small principal strains - */ - - if (scaleF) { - double min = 0.3; // 0.3^2 = 0.09, should suffice for most problems - double max = 2.0; - for (int i = 0; i < 3; i++) { - if (S(i, i) < min) { - S(i, i) = min; - } else if (S(i, i) > max) { - S(i, i) = max; - } - } - T = V * S * V.transpose(); - } - - if (R.determinant() > 0.0) { - return true; - } else { - return false; - } + JacobiSVD<Matrix3d> svd(M, ComputeFullU | ComputeFullV); // SVD(A) = U S V* + Vector3d S_eigenvalues = svd.singularValues(); + Matrix3d S = svd.singularValues().asDiagonal(); + Matrix3d U = svd.matrixU(); + Matrix3d V = svd.matrixV(); + Matrix3d eye; + eye.setIdentity(); + + // now do polar decomposition into M = R * T, where R is rotation + // and T is translation matrix + R = U * V.transpose(); + T = V * S * V.transpose(); + + if (R.determinant() < 0.0) { // this is an improper rotation + // identify the smallest entry in S and flip its sign + int imin; + S_eigenvalues.minCoeff(&imin); + S(imin, imin) *= -1.0; + + R = M * V * S.inverse() * V.transpose(); // recompute R using flipped stretch eigenvalues + } + + /* + * scale S to avoid small principal strains + */ + + if (scaleF) { + double min = 0.3; // 0.3^2 = 0.09, should suffice for most problems + double max = 2.0; + for (int i = 0; i < 3; i++) { + if (S(i, i) < min) { + S(i, i) = min; + } else if (S(i, i) > max) { + S(i, i) = max; + } + } + T = V * S * V.transpose(); + } + + if (R.determinant() > 0.0) { + return true; + } else { + return false; + } } /* @@ -107,44 +107,44 @@ static inline bool PolDec(Matrix3d M, Matrix3d &R, Matrix3d &T, bool scaleF) { static inline void pseudo_inverse_SVD(Matrix3d &M) { - //JacobiSVD < Matrix3d > svd(M, ComputeFullU | ComputeFullV); - JacobiSVD<Matrix3d> svd(M, ComputeFullU); // one Eigevector base is sufficient because matrix is square and symmetric + //JacobiSVD < Matrix3d > svd(M, ComputeFullU | ComputeFullV); + JacobiSVD<Matrix3d> svd(M, ComputeFullU); // one Eigevector base is sufficient because matrix is square and symmetric - Vector3d singularValuesInv; - Vector3d singularValues = svd.singularValues(); + Vector3d singularValuesInv; + Vector3d singularValues = svd.singularValues(); //cout << "Here is the matrix V:" << endl << V * singularValues.asDiagonal() * U << endl; //cout << "Its singular values are:" << endl << singularValues << endl; - double pinvtoler = 1.0e-16; // 2d machining example goes unstable if this value is increased (1.0e-16). - for (int row = 0; row < 3; row++) { - if (singularValues(row) > pinvtoler) { - singularValuesInv(row) = 1.0 / singularValues(row); - } else { - singularValuesInv(row) = 0.0; - } - } + double pinvtoler = 1.0e-16; // 2d machining example goes unstable if this value is increased (1.0e-16). + for (int row = 0; row < 3; row++) { + if (singularValues(row) > pinvtoler) { + singularValuesInv(row) = 1.0 / singularValues(row); + } else { + singularValuesInv(row) = 0.0; + } + } - M = svd.matrixU() * singularValuesInv.asDiagonal() * svd.matrixU().transpose(); + M = svd.matrixU() * singularValuesInv.asDiagonal() * svd.matrixU().transpose(); -// JacobiSVD < Matrix3d > svd(M, ComputeFullU | ComputeFullV); +// JacobiSVD < Matrix3d > svd(M, ComputeFullU | ComputeFullV); // -// Vector3d singularValuesInv; -// Vector3d singularValues = svd.singularValues(); +// Vector3d singularValuesInv; +// Vector3d singularValues = svd.singularValues(); // -// //cout << "Here is the matrix V:" << endl << V * singularValues.asDiagonal() * U << endl; -// //cout << "Its singular values are:" << endl << singularValues << endl; +// //cout << "Here is the matrix V:" << endl << V * singularValues.asDiagonal() * U << endl; +// //cout << "Its singular values are:" << endl << singularValues << endl; // -// double pinvtoler = 1.0e-16; // 2d machining example goes unstable if this value is increased (1.0e-16). -// for (int row = 0; row < 3; row++) { -// if (singularValues(row) > pinvtoler) { -// singularValuesInv(row) = 1.0 / singularValues(row); -// } else { -// singularValuesInv(row) = 0.0; -// } -// } +// double pinvtoler = 1.0e-16; // 2d machining example goes unstable if this value is increased (1.0e-16). +// for (int row = 0; row < 3; row++) { +// if (singularValues(row) > pinvtoler) { +// singularValuesInv(row) = 1.0 / singularValues(row); +// } else { +// singularValuesInv(row) = 0.0; +// } +// } // -// M = svd.matrixU() * singularValuesInv.asDiagonal() * svd.matrixV().transpose(); +// M = svd.matrixU() * singularValuesInv.asDiagonal() * svd.matrixV().transpose(); } @@ -152,15 +152,15 @@ static inline void pseudo_inverse_SVD(Matrix3d &M) { * test if two matrices are equal */ static inline double TestMatricesEqual(Matrix3d A, Matrix3d B, double eps) { - Matrix3d diff; - diff = A - B; - double norm = diff.norm(); - if (norm > eps) { - printf("Matrices A and B are not equal! The L2-norm difference is: %g\n", norm); - cout << "Here is matrix A:" << endl << A << endl; - cout << "Here is matrix B:" << endl << B << endl; - } - return norm; + Matrix3d diff; + diff = A - B; + double norm = diff.norm(); + if (norm > eps) { + printf("Matrices A and B are not equal! The L2-norm difference is: %g\n", norm); + cout << "Here is matrix A:" << endl << A << endl; + cout << "Here is matrix B:" << endl << B << endl; + } + return norm; } /* ---------------------------------------------------------------------- @@ -169,116 +169,116 @@ static inline double TestMatricesEqual(Matrix3d A, Matrix3d B, double eps) { static inline Matrix3d LimitEigenvalues(Matrix3d S, double limitEigenvalue) { - /* - * compute Eigenvalues of matrix S - */ - SelfAdjointEigenSolver < Matrix3d > es; - es.compute(S); - - double max_eigenvalue = es.eigenvalues().maxCoeff(); - double min_eigenvalue = es.eigenvalues().minCoeff(); - double amax_eigenvalue = fabs(max_eigenvalue); - double amin_eigenvalue = fabs(min_eigenvalue); - - if ((amax_eigenvalue > limitEigenvalue) || (amin_eigenvalue > limitEigenvalue)) { - if (amax_eigenvalue > amin_eigenvalue) { // need to scale with max_eigenvalue - double scale = amax_eigenvalue / limitEigenvalue; - Matrix3d V = es.eigenvectors(); - Matrix3d S_diag = V.inverse() * S * V; // diagonalized input matrix - S_diag /= scale; - Matrix3d S_scaled = V * S_diag * V.inverse(); // undiagonalize matrix - return S_scaled; - } else { // need to scale using min_eigenvalue - double scale = amin_eigenvalue / limitEigenvalue; - Matrix3d V = es.eigenvectors(); - Matrix3d S_diag = V.inverse() * S * V; // diagonalized input matrix - S_diag /= scale; - Matrix3d S_scaled = V * S_diag * V.inverse(); // undiagonalize matrix - return S_scaled; - } - } else { // limiting does not apply - return S; - } + /* + * compute Eigenvalues of matrix S + */ + SelfAdjointEigenSolver < Matrix3d > es; + es.compute(S); + + double max_eigenvalue = es.eigenvalues().maxCoeff(); + double min_eigenvalue = es.eigenvalues().minCoeff(); + double amax_eigenvalue = fabs(max_eigenvalue); + double amin_eigenvalue = fabs(min_eigenvalue); + + if ((amax_eigenvalue > limitEigenvalue) || (amin_eigenvalue > limitEigenvalue)) { + if (amax_eigenvalue > amin_eigenvalue) { // need to scale with max_eigenvalue + double scale = amax_eigenvalue / limitEigenvalue; + Matrix3d V = es.eigenvectors(); + Matrix3d S_diag = V.inverse() * S * V; // diagonalized input matrix + S_diag /= scale; + Matrix3d S_scaled = V * S_diag * V.inverse(); // undiagonalize matrix + return S_scaled; + } else { // need to scale using min_eigenvalue + double scale = amin_eigenvalue / limitEigenvalue; + Matrix3d V = es.eigenvectors(); + Matrix3d S_diag = V.inverse() * S * V; // diagonalized input matrix + S_diag /= scale; + Matrix3d S_scaled = V * S_diag * V.inverse(); // undiagonalize matrix + return S_scaled; + } + } else { // limiting does not apply + return S; + } } static inline bool LimitMinMaxEigenvalues(Matrix3d &S, double min, double max) { - /* - * compute Eigenvalues of matrix S - */ - SelfAdjointEigenSolver < Matrix3d > es; - es.compute(S); - - if ((es.eigenvalues().maxCoeff() > max) || (es.eigenvalues().minCoeff() < min)) { - Matrix3d S_diag = es.eigenvalues().asDiagonal(); - Matrix3d V = es.eigenvectors(); - for (int i = 0; i < 3; i++) { - if (S_diag(i, i) < min) { - //printf("limiting eigenvalue %f --> %f\n", S_diag(i, i), min); - //printf("these are the eigenvalues of U: %f %f %f\n", es.eigenvalues()(0), es.eigenvalues()(1), es.eigenvalues()(2)); - S_diag(i, i) = min; - } else if (S_diag(i, i) > max) { - //printf("limiting eigenvalue %f --> %f\n", S_diag(i, i), max); - S_diag(i, i) = max; - } - } - S = V * S_diag * V.inverse(); // undiagonalize matrix - return true; - } else { - return false; - } + /* + * compute Eigenvalues of matrix S + */ + SelfAdjointEigenSolver < Matrix3d > es; + es.compute(S); + + if ((es.eigenvalues().maxCoeff() > max) || (es.eigenvalues().minCoeff() < min)) { + Matrix3d S_diag = es.eigenvalues().asDiagonal(); + Matrix3d V = es.eigenvectors(); + for (int i = 0; i < 3; i++) { + if (S_diag(i, i) < min) { + //printf("limiting eigenvalue %f --> %f\n", S_diag(i, i), min); + //printf("these are the eigenvalues of U: %f %f %f\n", es.eigenvalues()(0), es.eigenvalues()(1), es.eigenvalues()(2)); + S_diag(i, i) = min; + } else if (S_diag(i, i) > max) { + //printf("limiting eigenvalue %f --> %f\n", S_diag(i, i), max); + S_diag(i, i) = max; + } + } + S = V * S_diag * V.inverse(); // undiagonalize matrix + return true; + } else { + return false; + } } static inline void reconstruct_rank_deficient_shape_matrix(Matrix3d &K) { - JacobiSVD<Matrix3d> svd(K, ComputeFullU | ComputeFullV); - Vector3d singularValues = svd.singularValues(); + JacobiSVD<Matrix3d> svd(K, ComputeFullU | ComputeFullV); + Vector3d singularValues = svd.singularValues(); - for (int i = 0; i < 3; i++) { - if (singularValues(i) < 1.0e-8) { - singularValues(i) = 1.0; - } - } + for (int i = 0; i < 3; i++) { + if (singularValues(i) < 1.0e-8) { + singularValues(i) = 1.0; + } + } -// int imin; -// double minev = singularValues.minCoeff(&imin); +// int imin; +// double minev = singularValues.minCoeff(&imin); // -// printf("min eigenvalue=%f has index %d\n", minev, imin); -// Vector3d singularVec = U.col(0).cross(U.col(1)); -// cout << "the eigenvalues are " << endl << singularValues << endl; -// cout << "the singular vector is " << endl << singularVec << endl; +// printf("min eigenvalue=%f has index %d\n", minev, imin); +// Vector3d singularVec = U.col(0).cross(U.col(1)); +// cout << "the eigenvalues are " << endl << singularValues << endl; +// cout << "the singular vector is " << endl << singularVec << endl; // -// // reconstruct original K +// // reconstruct original K // -// singularValues(2) = 1.0; +// singularValues(2) = 1.0; - K = svd.matrixU() * singularValues.asDiagonal() * svd.matrixV().transpose(); - //cout << "the reconstructed K is " << endl << K << endl; - //exit(1); + K = svd.matrixU() * singularValues.asDiagonal() * svd.matrixV().transpose(); + //cout << "the reconstructed K is " << endl << K << endl; + //exit(1); } /* ---------------------------------------------------------------------- helper functions for crack_exclude ------------------------------------------------------------------------- */ static inline bool IsOnSegment(double xi, double yi, double xj, double yj, double xk, double yk) { - return (xi <= xk || xj <= xk) && (xk <= xi || xk <= xj) && (yi <= yk || yj <= yk) && (yk <= yi || yk <= yj); + return (xi <= xk || xj <= xk) && (xk <= xi || xk <= xj) && (yi <= yk || yj <= yk) && (yk <= yi || yk <= yj); } static inline char ComputeDirection(double xi, double yi, double xj, double yj, double xk, double yk) { - double a = (xk - xi) * (yj - yi); - double b = (xj - xi) * (yk - yi); - return a < b ? -1.0 : a > b ? 1.0 : 0; + double a = (xk - xi) * (yj - yi); + double b = (xj - xi) * (yk - yi); + return a < b ? -1.0 : a > b ? 1.0 : 0; } /** Do line segments (x1, y1)--(x2, y2) and (x3, y3)--(x4, y4) intersect? */ static inline bool DoLineSegmentsIntersect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { - char d1 = ComputeDirection(x3, y3, x4, y4, x1, y1); - char d2 = ComputeDirection(x3, y3, x4, y4, x2, y2); - char d3 = ComputeDirection(x1, y1, x2, y2, x3, y3); - char d4 = ComputeDirection(x1, y1, x2, y2, x4, y4); - return (((d1 > 0 && d2 < 0) || (d1 < 0 && d2 > 0)) && ((d3 > 0 && d4 < 0) || (d3 < 0 && d4 > 0))) - || (d1 == 0 && IsOnSegment(x3, y3, x4, y4, x1, y1)) || (d2 == 0 && IsOnSegment(x3, y3, x4, y4, x2, y2)) - || (d3 == 0 && IsOnSegment(x1, y1, x2, y2, x3, y3)) || (d4 == 0 && IsOnSegment(x1, y1, x2, y2, x4, y4)); + char d1 = ComputeDirection(x3, y3, x4, y4, x1, y1); + char d2 = ComputeDirection(x3, y3, x4, y4, x2, y2); + char d3 = ComputeDirection(x1, y1, x2, y2, x3, y3); + char d4 = ComputeDirection(x1, y1, x2, y2, x4, y4); + return (((d1 > 0 && d2 < 0) || (d1 < 0 && d2 > 0)) && ((d3 > 0 && d4 < 0) || (d3 < 0 && d4 > 0))) + || (d1 == 0 && IsOnSegment(x3, y3, x4, y4, x1, y1)) || (d2 == 0 && IsOnSegment(x3, y3, x4, y4, x2, y2)) + || (d3 == 0 && IsOnSegment(x1, y1, x2, y2, x3, y3)) || (d4 == 0 && IsOnSegment(x1, y1, x2, y2, x4, y4)); } } diff --git a/src/VORONOI/compute_voronoi_atom.cpp b/src/VORONOI/compute_voronoi_atom.cpp index 5e49b72c66..cd7d73392d 100644 --- a/src/VORONOI/compute_voronoi_atom.cpp +++ b/src/VORONOI/compute_voronoi_atom.cpp @@ -80,7 +80,7 @@ ComputeVoronoi::ComputeVoronoi(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg], "radius") == 0) { if (iarg + 2 > narg || strstr(arg[iarg+1],"v_") != arg[iarg+1] ) - error->all(FLERR,"Illegal compute voronoi/atom command"); + error->all(FLERR,"Illegal compute voronoi/atom command"); int n = strlen(&arg[iarg+1][2]) + 1; radstr = new char[n]; strcpy(radstr,&arg[iarg+1][2]); @@ -274,8 +274,8 @@ void ComputeVoronoi::buildCells() sublo_bound[i] = sublo_lamda[i]-cut[i]-e; subhi_bound[i] = subhi_lamda[i]+cut[i]+e; if (domain->periodicity[i]==0) { - sublo_bound[i] = MAX(sublo_bound[i],0.0); - subhi_bound[i] = MIN(subhi_bound[i],1.0); + sublo_bound[i] = MAX(sublo_bound[i],0.0); + subhi_bound[i] = MIN(subhi_bound[i],1.0); } } if (dim == 2) { @@ -295,8 +295,8 @@ void ComputeVoronoi::buildCells() sublo_bound[i] = sublo[i]-cut[i]-e; subhi_bound[i] = subhi[i]+cut[i]+e; if (domain->periodicity[i]==0) { - sublo_bound[i] = MAX(sublo_bound[i],domain->boxlo[i]); - subhi_bound[i] = MIN(subhi_bound[i],domain->boxhi[i]); + sublo_bound[i] = MAX(sublo_bound[i],domain->boxlo[i]); + subhi_bound[i] = MIN(subhi_bound[i],domain->boxhi[i]); } } if (dim == 2) { @@ -345,13 +345,13 @@ void ComputeVoronoi::buildCells() // polydisperse voro++ container delete con_poly; con_poly = new container_poly(sublo_bound[0], - subhi_bound[0], - sublo_bound[1], - subhi_bound[1], - sublo_bound[2], - subhi_bound[2], - int(n[0]),int(n[1]),int(n[2]), - false,false,false,8); + subhi_bound[0], + sublo_bound[1], + subhi_bound[1], + sublo_bound[2], + subhi_bound[2], + int(n[0]),int(n[1]),int(n[2]), + false,false,false,8); // pass coordinates for local and ghost atoms to voro++ for (i = 0; i < nall; i++) { @@ -363,13 +363,13 @@ void ComputeVoronoi::buildCells() delete con_mono; con_mono = new container(sublo_bound[0], - subhi_bound[0], - sublo_bound[1], - subhi_bound[1], - sublo_bound[2], - subhi_bound[2], - int(n[0]),int(n[1]),int(n[2]), - false,false,false,8); + subhi_bound[0], + sublo_bound[1], + subhi_bound[1], + sublo_bound[2], + subhi_bound[2], + int(n[0]),int(n[1]),int(n[2]), + false,false,false,8); // pass coordinates for local and ghost atoms to voro++ for (i = 0; i < nall; i++) @@ -581,9 +581,9 @@ void ComputeVoronoi::processCell(voronoicell_neighbor &c, int i) if (faces_flag) { if (nfaces+voro[i][1] > nfacesmax) { - while (nfacesmax < nfaces+voro[i][1]) nfacesmax += FACESDELTA; - memory->grow(faces,nfacesmax,size_local_cols,"compute/voronoi/atom:faces"); - array_local = faces; + while (nfacesmax < nfaces+voro[i][1]) nfacesmax += FACESDELTA; + memory->grow(faces,nfacesmax,size_local_cols,"compute/voronoi/atom:faces"); + array_local = faces; } if (!have_narea) c.face_areas(narea); @@ -594,19 +594,19 @@ void ComputeVoronoi::processCell(voronoicell_neighbor &c, int i) tagint *tag = atom->tag; itag = tag[i]; for (j=0; j<neighs; ++j) - if (narea[j] > fthresh) { + if (narea[j] > fthresh) { - // external faces assigned the tag 0 + // external faces assigned the tag 0 - int jj = neigh[j]; - if (jj >= 0) jtag = tag[jj]; - else jtag = 0; + int jj = neigh[j]; + if (jj >= 0) jtag = tag[jj]; + else jtag = 0; - faces[nfaces][0] = itag; - faces[nfaces][1] = jtag; - faces[nfaces][2] = narea[j]; - nfaces++; - } + faces[nfaces][0] = itag; + faces[nfaces][1] = jtag; + faces[nfaces][2] = narea[j]; + nfaces++; + } } diff --git a/src/atom.cpp b/src/atom.cpp index fa86046d23..aeb3c1303e 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1387,27 +1387,27 @@ void Atom::data_bodies(int n, char *buf, AtomVecBody *avec_body, if ((m = map(tagdata)) >= 0) { if (ninteger > maxint) { - delete [] ivalues; - maxint = ninteger; - ivalues = new int[maxint]; + delete [] ivalues; + maxint = ninteger; + ivalues = new int[maxint]; } if (ndouble > maxdouble) { - delete [] dvalues; - maxdouble = ndouble; - dvalues = new double[maxdouble]; + delete [] dvalues; + maxdouble = ndouble; + dvalues = new double[maxdouble]; } for (j = 0; j < ninteger; j++) - ivalues[j] = force->inumeric(FLERR,strtok(NULL," \t\n\r\f")); + ivalues[j] = force->inumeric(FLERR,strtok(NULL," \t\n\r\f")); for (j = 0; j < ndouble; j++) - dvalues[j] = force->numeric(FLERR,strtok(NULL," \t\n\r\f")); + dvalues[j] = force->numeric(FLERR,strtok(NULL," \t\n\r\f")); avec_body->data_body(m,ninteger,ndouble,ivalues,dvalues); } else { nvalues = ninteger + ndouble; // number of values to skip for (j = 0; j < nvalues; j++) - strtok(NULL," \t\n\r\f"); + strtok(NULL," \t\n\r\f"); } } @@ -1673,7 +1673,7 @@ void Atom::add_molecule_atom(Molecule *onemol, int iatom, if (onemol->bodyflag) { body[ilocal] = 0; // as if a body read from data file onemol->avec_body->data_body(ilocal,onemol->nibody,onemol->ndbody, - onemol->ibodyparams,onemol->dbodyparams); + onemol->ibodyparams,onemol->dbodyparams); onemol->avec_body->set_quat(ilocal,onemol->quat_external); } diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index ca080ff0b6..b7422cf229 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -1055,9 +1055,9 @@ int AtomVecBody::unpack_exchange(double *buf) bonus[nlocal_bonus].ndouble = (int) ubuf(buf[m++]).i; // corresponding put() calls are in copy() bonus[nlocal_bonus].ivalue = icp->get(bonus[nlocal_bonus].ninteger, - bonus[nlocal_bonus].iindex); + bonus[nlocal_bonus].iindex); bonus[nlocal_bonus].dvalue = dcp->get(bonus[nlocal_bonus].ndouble, - bonus[nlocal_bonus].dindex); + bonus[nlocal_bonus].dindex); memcpy(bonus[nlocal_bonus].ivalue,&buf[m], bonus[nlocal_bonus].ninteger*sizeof(int)); if (intdoubleratio == 1) m += bonus[nlocal_bonus].ninteger; @@ -1209,9 +1209,9 @@ int AtomVecBody::unpack_restart(double *buf) bonus[nlocal_bonus].ninteger = (int) ubuf(buf[m++]).i; bonus[nlocal_bonus].ndouble = (int) ubuf(buf[m++]).i; bonus[nlocal_bonus].ivalue = icp->get(bonus[nlocal_bonus].ninteger, - bonus[nlocal_bonus].iindex); + bonus[nlocal_bonus].iindex); bonus[nlocal_bonus].dvalue = dcp->get(bonus[nlocal_bonus].ndouble, - bonus[nlocal_bonus].dindex); + bonus[nlocal_bonus].dindex); memcpy(bonus[nlocal_bonus].ivalue,&buf[m], bonus[nlocal_bonus].ninteger*sizeof(int)); if (intdoubleratio == 1) m += bonus[nlocal_bonus].ninteger; @@ -1331,7 +1331,7 @@ int AtomVecBody::data_atom_hybrid(int nlocal, char **values) ------------------------------------------------------------------------- */ void AtomVecBody::data_body(int m, int ninteger, int ndouble, - int *ivalues, double *dvalues) + int *ivalues, double *dvalues) { if (body[m]) error->one(FLERR,"Assigning body parameters to non-body atom"); if (nlocal_bonus == nmax_bonus) grow_bonus(); @@ -1482,7 +1482,7 @@ int AtomVecBody::write_vel_hybrid(FILE *fp, double *buf) ------------------------------------------------------------------------- */ double AtomVecBody::radius_body(int ninteger, int ndouble, - int *ivalues, double *dvalues) + int *ivalues, double *dvalues) { return bptr->radius_body(ninteger,ndouble,ivalues,dvalues); } diff --git a/src/comm.cpp b/src/comm.cpp index d997c2914f..14d2d70c5a 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -743,8 +743,8 @@ int Comm::read_lines_from_file(FILE *fp, int nlines, int maxline, char *buf) m = 0; for (int i = 0; i < nlines; i++) { if (!fgets(&buf[m],maxline,fp)) { - m = 0; - break; + m = 0; + break; } m += strlen(&buf[m]); } @@ -779,8 +779,8 @@ int Comm::read_lines_from_file_universe(FILE *fp, int nlines, int maxline, m = 0; for (int i = 0; i < nlines; i++) { if (!fgets(&buf[m],maxline,fp)) { - m = 0; - break; + m = 0; + break; } m += strlen(&buf[m]); } diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index d08f462907..4463e48fa8 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -407,14 +407,14 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : if (which == BIN2D) ndim = 2; if (which == BIN3D) ndim = 3; for (int idim = 0; idim < ndim; idim++) { - if (dim[idim] == 0) scale = xscale; - else if (dim[idim] == 1) scale = yscale; - else if (dim[idim] == 2) scale = zscale; - delta[idim] *= scale; - invdelta[idim] = 1.0/delta[idim]; - if (originflag[idim] == COORD) origin[idim] *= scale; - if (minflag[idim] == COORD) minvalue[idim] *= scale; - if (maxflag[idim] == COORD) maxvalue[idim] *= scale; + if (dim[idim] == 0) scale = xscale; + else if (dim[idim] == 1) scale = yscale; + else if (dim[idim] == 2) scale = zscale; + delta[idim] *= scale; + invdelta[idim] = 1.0/delta[idim]; + if (originflag[idim] == COORD) origin[idim] *= scale; + if (minflag[idim] == COORD) minvalue[idim] *= scale; + if (maxflag[idim] == COORD) maxvalue[idim] *= scale; } } else if (which == BINSPHERE) { sorigin_user[0] *= xscale; diff --git a/src/compute_hexorder_atom.cpp b/src/compute_hexorder_atom.cpp index 85324651c1..04421dca3e 100644 --- a/src/compute_hexorder_atom.cpp +++ b/src/compute_hexorder_atom.cpp @@ -66,11 +66,11 @@ ComputeHexOrderAtom::ComputeHexOrderAtom(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"nnn") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute hexorder/atom command"); if (strcmp(arg[iarg+1],"NULL") == 0) - nnn = 0; + nnn = 0; else { - nnn = force->numeric(FLERR,arg[iarg+1]); - if (nnn < 0) - error->all(FLERR,"Illegal compute hexorder/atom command"); + nnn = force->numeric(FLERR,arg[iarg+1]); + if (nnn < 0) + error->all(FLERR,"Illegal compute hexorder/atom command"); } iarg += 2; } else if (strcmp(arg[iarg],"cutoff") == 0) { @@ -212,30 +212,30 @@ void ComputeHexOrderAtom::compute_peratom() // if not nnn neighbors, order parameter = 0; if (ncount < nnn) { - qn[0] = qn[1] = 0.0; + qn[0] = qn[1] = 0.0; continue; } // if nnn > 0, use only nearest nnn neighbors if (nnn > 0) { - select2(nnn,ncount,distsq,nearest); - ncount = nnn; + select2(nnn,ncount,distsq,nearest); + ncount = nnn; } double usum = 0.0; double vsum = 0.0; for (jj = 0; jj < ncount; jj++) { - j = nearest[jj]; - j &= NEIGHMASK; - - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - double u, v; - calc_qn_complex(delx, dely, u, v); - usum += u; - vsum += v; + j = nearest[jj]; + j &= NEIGHMASK; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + double u, v; + calc_qn_complex(delx, dely, u, v); + usum += u; + vsum += v; } qn[0] = usum/nnn; qn[1] = vsum/nnn; diff --git a/src/compute_msd.cpp b/src/compute_msd.cpp index f2e82fe239..ac510bca8e 100644 --- a/src/compute_msd.cpp +++ b/src/compute_msd.cpp @@ -198,17 +198,17 @@ void ComputeMSD::compute_vector() xbox = (image[i] & IMGMASK) - IMGMAX; ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX; zbox = (image[i] >> IMG2BITS) - IMGMAX; - xtmp = x[i][0] + xbox*xprd - cm[0]; - ytmp = x[i][1] + ybox*yprd - cm[1]; - ztmp = x[i][2] + zbox*zprd - cm[2]; + xtmp = x[i][0] + xbox*xprd - cm[0]; + ytmp = x[i][1] + ybox*yprd - cm[1]; + ztmp = x[i][2] + zbox*zprd - cm[2]; - // use running average position for reference if requested + // use running average position for reference if requested - if (avflag) { - xoriginal[i][0] = (xoriginal[i][0]*naverage + xtmp)*navfac; - xoriginal[i][1] = (xoriginal[i][1]*naverage + ytmp)*navfac; - xoriginal[i][2] = (xoriginal[i][2]*naverage + ztmp)*navfac; - } + if (avflag) { + xoriginal[i][0] = (xoriginal[i][0]*naverage + xtmp)*navfac; + xoriginal[i][1] = (xoriginal[i][1]*naverage + ytmp)*navfac; + xoriginal[i][2] = (xoriginal[i][2]*naverage + ztmp)*navfac; + } dx = xtmp - xoriginal[i][0]; dy = ytmp - xoriginal[i][1]; @@ -229,13 +229,13 @@ void ComputeMSD::compute_vector() ytmp = x[i][1] + h[1]*ybox + h[3]*zbox - cm[1]; ztmp = x[i][2] + h[2]*zbox - cm[2]; - // use running average position for reference if requested + // use running average position for reference if requested - if (avflag) { - xoriginal[i][0] = (xoriginal[i][0]*naverage + xtmp)*navfac; - xoriginal[i][1] = (xoriginal[i][0]*naverage + xtmp)*navfac; - xoriginal[i][2] = (xoriginal[i][0]*naverage + xtmp)*navfac; - } + if (avflag) { + xoriginal[i][0] = (xoriginal[i][0]*naverage + xtmp)*navfac; + xoriginal[i][1] = (xoriginal[i][0]*naverage + xtmp)*navfac; + xoriginal[i][2] = (xoriginal[i][0]*naverage + xtmp)*navfac; + } dx = xtmp - xoriginal[i][0]; dy = ytmp - xoriginal[i][1]; diff --git a/src/compute_orientorder_atom.h b/src/compute_orientorder_atom.h index eb814e9c1c..d5905df63b 100644 --- a/src/compute_orientorder_atom.h +++ b/src/compute_orientorder_atom.h @@ -50,7 +50,7 @@ class ComputeOrientOrderAtom : public Compute { void select3(int, int, double *, int *, double **); void calc_boop(double **rlist, int numNeighbors, - double qn[], int nlist[], int nnlist); + double qn[], int nlist[], int nnlist); double dist(const double r[]); double polar_prefactor(int, int, double); diff --git a/src/compute_pressure.cpp b/src/compute_pressure.cpp index 80289c59b3..99046e864c 100644 --- a/src/compute_pressure.cpp +++ b/src/compute_pressure.cpp @@ -99,7 +99,7 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) : if (keflag && id_temp == NULL) error->all(FLERR,"Compute pressure requires temperature ID " - "to include kinetic energy"); + "to include kinetic energy"); vector = new double[6]; nvirial = 0; @@ -224,7 +224,7 @@ void ComputePressure::compute_vector() if (force->kspace && kspace_virial && force->kspace->scalar_pressure_flag) error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' for " - "tensor components with kspace_style msm"); + "tensor components with kspace_style msm"); // invoke temperature if it hasn't been already diff --git a/src/compute_property_chunk.cpp b/src/compute_property_chunk.cpp index 1461a83ad2..c169e20d73 100644 --- a/src/compute_property_chunk.cpp +++ b/src/compute_property_chunk.cpp @@ -53,22 +53,22 @@ ComputePropertyChunk::ComputePropertyChunk(LAMMPS *lmp, int narg, char **arg) : countflag = 1; } else if (strcmp(arg[iarg],"id") == 0) { if (!cchunk->compress) - error->all(FLERR,"Compute chunk/atom stores no IDs for " + error->all(FLERR,"Compute chunk/atom stores no IDs for " "compute property/chunk"); pack_choice[i] = &ComputePropertyChunk::pack_id; } else if (strcmp(arg[iarg],"coord1") == 0) { if (cchunk->ncoord < 1) - error->all(FLERR,"Compute chunk/atom stores no coord1 for " + error->all(FLERR,"Compute chunk/atom stores no coord1 for " "compute property/chunk"); pack_choice[i] = &ComputePropertyChunk::pack_coord1; } else if (strcmp(arg[iarg],"coord2") == 0) { if (cchunk->ncoord < 2) - error->all(FLERR,"Compute chunk/atom stores no coord2 for " + error->all(FLERR,"Compute chunk/atom stores no coord2 for " "compute property/chunk"); pack_choice[i] = &ComputePropertyChunk::pack_coord2; } else if (strcmp(arg[iarg],"coord3") == 0) { if (cchunk->ncoord < 3) - error->all(FLERR,"Compute chunk/atom stores no coord3 for " + error->all(FLERR,"Compute chunk/atom stores no coord3 for " "compute property/chunk"); pack_choice[i] = &ComputePropertyChunk::pack_coord3; } else error->all(FLERR, diff --git a/src/compute_stress_atom.cpp b/src/compute_stress_atom.cpp index 46ee2ec3c5..fd38f13dba 100644 --- a/src/compute_stress_atom.cpp +++ b/src/compute_stress_atom.cpp @@ -61,7 +61,7 @@ ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Could not find compute stress/atom temperature ID"); if (modify->compute[icompute]->tempflag == 0) error->all(FLERR, - "Compute stress/atom temperature ID does not " + "Compute stress/atom temperature ID does not " "compute temperature"); } @@ -263,28 +263,28 @@ void ComputeStressAtom::compute_peratom() if (biasflag == NOBIAS) { if (rmass) { - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) { - onemass = mvv2e * rmass[i]; - stress[i][0] += onemass*v[i][0]*v[i][0]; - stress[i][1] += onemass*v[i][1]*v[i][1]; - stress[i][2] += onemass*v[i][2]*v[i][2]; - stress[i][3] += onemass*v[i][0]*v[i][1]; - stress[i][4] += onemass*v[i][0]*v[i][2]; - stress[i][5] += onemass*v[i][1]*v[i][2]; - } + for (i = 0; i < nlocal; i++) + if (mask[i] & groupbit) { + onemass = mvv2e * rmass[i]; + stress[i][0] += onemass*v[i][0]*v[i][0]; + stress[i][1] += onemass*v[i][1]*v[i][1]; + stress[i][2] += onemass*v[i][2]*v[i][2]; + stress[i][3] += onemass*v[i][0]*v[i][1]; + stress[i][4] += onemass*v[i][0]*v[i][2]; + stress[i][5] += onemass*v[i][1]*v[i][2]; + } } else { - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) { - onemass = mvv2e * mass[type[i]]; - stress[i][0] += onemass*v[i][0]*v[i][0]; - stress[i][1] += onemass*v[i][1]*v[i][1]; - stress[i][2] += onemass*v[i][2]*v[i][2]; - stress[i][3] += onemass*v[i][0]*v[i][1]; - stress[i][4] += onemass*v[i][0]*v[i][2]; - stress[i][5] += onemass*v[i][1]*v[i][2]; - } + for (i = 0; i < nlocal; i++) + if (mask[i] & groupbit) { + onemass = mvv2e * mass[type[i]]; + stress[i][0] += onemass*v[i][0]*v[i][0]; + stress[i][1] += onemass*v[i][1]*v[i][1]; + stress[i][2] += onemass*v[i][2]*v[i][2]; + stress[i][3] += onemass*v[i][0]*v[i][1]; + stress[i][4] += onemass*v[i][0]*v[i][2]; + stress[i][5] += onemass*v[i][1]*v[i][2]; + } } } else { @@ -293,35 +293,35 @@ void ComputeStressAtom::compute_peratom() // this insures bias factor is pre-computed if (keflag && temperature->invoked_scalar != update->ntimestep) - temperature->compute_scalar(); + temperature->compute_scalar(); if (rmass) { - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) { - temperature->remove_bias(i,v[i]); - onemass = mvv2e * rmass[i]; - stress[i][0] += onemass*v[i][0]*v[i][0]; - stress[i][1] += onemass*v[i][1]*v[i][1]; - stress[i][2] += onemass*v[i][2]*v[i][2]; - stress[i][3] += onemass*v[i][0]*v[i][1]; - stress[i][4] += onemass*v[i][0]*v[i][2]; - stress[i][5] += onemass*v[i][1]*v[i][2]; - temperature->restore_bias(i,v[i]); - } + for (i = 0; i < nlocal; i++) + if (mask[i] & groupbit) { + temperature->remove_bias(i,v[i]); + onemass = mvv2e * rmass[i]; + stress[i][0] += onemass*v[i][0]*v[i][0]; + stress[i][1] += onemass*v[i][1]*v[i][1]; + stress[i][2] += onemass*v[i][2]*v[i][2]; + stress[i][3] += onemass*v[i][0]*v[i][1]; + stress[i][4] += onemass*v[i][0]*v[i][2]; + stress[i][5] += onemass*v[i][1]*v[i][2]; + temperature->restore_bias(i,v[i]); + } } else { - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) { - temperature->remove_bias(i,v[i]); - onemass = mvv2e * mass[type[i]]; - stress[i][0] += onemass*v[i][0]*v[i][0]; - stress[i][1] += onemass*v[i][1]*v[i][1]; - stress[i][2] += onemass*v[i][2]*v[i][2]; - stress[i][3] += onemass*v[i][0]*v[i][1]; - stress[i][4] += onemass*v[i][0]*v[i][2]; - stress[i][5] += onemass*v[i][1]*v[i][2]; - temperature->restore_bias(i,v[i]); - } + for (i = 0; i < nlocal; i++) + if (mask[i] & groupbit) { + temperature->remove_bias(i,v[i]); + onemass = mvv2e * mass[type[i]]; + stress[i][0] += onemass*v[i][0]*v[i][0]; + stress[i][1] += onemass*v[i][1]*v[i][1]; + stress[i][2] += onemass*v[i][2]*v[i][2]; + stress[i][3] += onemass*v[i][0]*v[i][1]; + stress[i][4] += onemass*v[i][0]*v[i][2]; + stress[i][5] += onemass*v[i][1]*v[i][2]; + temperature->restore_bias(i,v[i]); + } } } } diff --git a/src/compute_temp_chunk.cpp b/src/compute_temp_chunk.cpp index 8daaeb0621..7de894d367 100644 --- a/src/compute_temp_chunk.cpp +++ b/src/compute_temp_chunk.cpp @@ -342,34 +342,34 @@ void ComputeTempChunk::compute_vector() if (!comflag) { for (i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - index = ichunk[i]-1; - if (index < 0) continue; - if (rmass) massone = rmass[i]; - else massone = mass[type[i]]; - t[0] += massone * v[i][0]*v[i][0]; - t[1] += massone * v[i][1]*v[i][1]; - t[2] += massone * v[i][2]*v[i][2]; - t[3] += massone * v[i][0]*v[i][1]; - t[4] += massone * v[i][0]*v[i][2]; - t[5] += massone * v[i][1]*v[i][2]; + index = ichunk[i]-1; + if (index < 0) continue; + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + t[0] += massone * v[i][0]*v[i][0]; + t[1] += massone * v[i][1]*v[i][1]; + t[2] += massone * v[i][2]*v[i][2]; + t[3] += massone * v[i][0]*v[i][1]; + t[4] += massone * v[i][0]*v[i][2]; + t[5] += massone * v[i][1]*v[i][2]; } } else { double vx,vy,vz; for (i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - index = ichunk[i]-1; - if (index < 0) continue; - if (rmass) massone = rmass[i]; - else massone = mass[type[i]]; - vx = v[i][0] - vcmall[index][0]; - vy = v[i][1] - vcmall[index][1]; - vz = v[i][2] - vcmall[index][2]; - t[0] += massone * vx*vx; - t[1] += massone * vy*vy; - t[2] += massone * vz*vz; - t[3] += massone * vx*vy; - t[4] += massone * vx*vz; - t[5] += massone * vy*vz; + index = ichunk[i]-1; + if (index < 0) continue; + if (rmass) massone = rmass[i]; + else massone = mass[type[i]]; + vx = v[i][0] - vcmall[index][0]; + vy = v[i][1] - vcmall[index][1]; + vz = v[i][2] - vcmall[index][2]; + t[0] += massone * vx*vx; + t[1] += massone * vy*vy; + t[2] += massone * vz*vz; + t[3] += massone * vx*vy; + t[4] += massone * vx*vz; + t[5] += massone * vy*vz; } } diff --git a/src/compute_vacf.cpp b/src/compute_vacf.cpp index 6ba272e579..b3f487a4d7 100644 --- a/src/compute_vacf.cpp +++ b/src/compute_vacf.cpp @@ -67,9 +67,9 @@ ComputeVACF::ComputeVACF(LAMMPS *lmp, int narg, char **arg) : for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - voriginal[i][0] = v[i][0]; - voriginal[i][1] = v[i][1]; - voriginal[i][2] = v[i][2]; + voriginal[i][0] = v[i][0]; + voriginal[i][1] = v[i][1]; + voriginal[i][2] = v[i][2]; } else voriginal[i][0] = voriginal[i][1] = voriginal[i][2] = 0.0; } diff --git a/src/domain.cpp b/src/domain.cpp index bad5030373..8522046434 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -633,8 +633,8 @@ int Domain::inside(double* x) hi = boxhi; if (x[0] < lo[0] || x[0] >= hi[0] || - x[1] < lo[1] || x[1] >= hi[1] || - x[2] < lo[2] || x[2] >= hi[2]) return 0; + x[1] < lo[1] || x[1] >= hi[1] || + x[2] < lo[2] || x[2] >= hi[2]) return 0; else return 1; } else { @@ -644,8 +644,8 @@ int Domain::inside(double* x) x2lamda(x,lamda); if (lamda[0] < lo[0] || lamda[0] >= hi[0] || - lamda[1] < lo[1] || lamda[1] >= hi[1] || - lamda[2] < lo[2] || lamda[2] >= hi[2]) return 0; + lamda[1] < lo[1] || lamda[1] >= hi[1] || + lamda[2] < lo[2] || lamda[2] >= hi[2]) return 0; else return 1; } diff --git a/src/dump_cfg.cpp b/src/dump_cfg.cpp index 8c08bb9edb..6ebdd0f99a 100644 --- a/src/dump_cfg.cpp +++ b/src/dump_cfg.cpp @@ -13,7 +13,7 @@ /* ---------------------------------------------------------------------- Contributing author: Liang Wan (Chinese Academy of Sciences) - Memory efficiency improved by Ray Shan (Sandia) + Memory efficiency improved by Ray Shan (Sandia) ------------------------------------------------------------------------- */ #include <math.h> @@ -177,9 +177,9 @@ int DumpCFG::convert_string(int n, double *mybuf) for (j = 0; j < size_one; j++) { if (j == 0) { - offset += sprintf(&sbuf[offset],"%f \n",mybuf[m]); + offset += sprintf(&sbuf[offset],"%f \n",mybuf[m]); } else if (j == 1) { - offset += sprintf(&sbuf[offset],"%s \n",typenames[(int) mybuf[m]]); + offset += sprintf(&sbuf[offset],"%s \n",typenames[(int) mybuf[m]]); } else if (j >= 2) { if (vtype[j] == INT) offset += @@ -209,9 +209,9 @@ int DumpCFG::convert_string(int n, double *mybuf) for (j = 0; j < size_one; j++) { if (j == 0) { - offset += sprintf(&sbuf[offset],"%f \n",mybuf[m]); + offset += sprintf(&sbuf[offset],"%f \n",mybuf[m]); } else if (j == 1) { - offset += sprintf(&sbuf[offset],"%s \n",typenames[(int) mybuf[m]]); + offset += sprintf(&sbuf[offset],"%s \n",typenames[(int) mybuf[m]]); } else if (j >= 2 && j <= 4) { unwrap_coord = (mybuf[m] - 0.5)/UNWRAPEXPAND + 0.5; offset += sprintf(&sbuf[offset],vformat[j],unwrap_coord); diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 4821171cc9..84ada95975 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -937,16 +937,16 @@ int DumpCustom::count() nstride = 1; } else if (thresh_array[ithresh] == DNAME) { - int iwhich,tmp; + int iwhich,tmp; i = nfield + ithresh; - iwhich = atom->find_custom(id_custom[field2index[i]],tmp); + iwhich = atom->find_custom(id_custom[field2index[i]],tmp); ptr = atom->dvector[iwhich]; nstride = 1; } else if (thresh_array[ithresh] == INAME) { - int iwhich,tmp; + int iwhich,tmp; i = nfield + ithresh; - iwhich = atom->find_custom(id_custom[field2index[i]],tmp); + iwhich = atom->find_custom(id_custom[field2index[i]],tmp); int *ivector = atom->ivector[iwhich]; for (i = 0; i < nlocal; i++) @@ -960,87 +960,87 @@ int DumpCustom::count() // copy ptr attribute into thresh_fix if this is first comparison if (thresh_last[ithresh] < 0) { - lastflag = 0; - value = thresh_value[ithresh]; + lastflag = 0; + value = thresh_value[ithresh]; } else { - lastflag = 1; - int ilast = thresh_last[ithresh]; - values = thresh_fix[ilast]->vstore; - ptrhold = ptr; - if (thresh_first[ilast]) { - thresh_first[ilast] = 0; - for (i = 0; i < nlocal; i++, ptr += nstride) values[i] = *ptr; - ptr = ptrhold; - } + lastflag = 1; + int ilast = thresh_last[ithresh]; + values = thresh_fix[ilast]->vstore; + ptrhold = ptr; + if (thresh_first[ilast]) { + thresh_first[ilast] = 0; + for (i = 0; i < nlocal; i++, ptr += nstride) values[i] = *ptr; + ptr = ptrhold; + } } if (thresh_op[ithresh] == LT) { - if (lastflag) { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr >= values[i]) choose[i] = 0; - } else { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr >= value) choose[i] = 0; - } + if (lastflag) { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr >= values[i]) choose[i] = 0; + } else { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr >= value) choose[i] = 0; + } } else if (thresh_op[ithresh] == LE) { - if (lastflag) { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr > values[i]) choose[i] = 0; - } else { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr > value) choose[i] = 0; - } + if (lastflag) { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr > values[i]) choose[i] = 0; + } else { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr > value) choose[i] = 0; + } } else if (thresh_op[ithresh] == GT) { - if (lastflag) { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr <= values[i]) choose[i] = 0; - } else { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr <= value) choose[i] = 0; - } + if (lastflag) { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr <= values[i]) choose[i] = 0; + } else { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr <= value) choose[i] = 0; + } } else if (thresh_op[ithresh] == GE) { - if (lastflag) { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr < values[i]) choose[i] = 0; - } else { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr < value) choose[i] = 0; - } + if (lastflag) { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr < values[i]) choose[i] = 0; + } else { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr < value) choose[i] = 0; + } } else if (thresh_op[ithresh] == EQ) { - if (lastflag) { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr != values[i]) choose[i] = 0; - } else { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr != value) choose[i] = 0; - } + if (lastflag) { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr != values[i]) choose[i] = 0; + } else { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr != value) choose[i] = 0; + } } else if (thresh_op[ithresh] == NEQ) { - if (lastflag) { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr == values[i]) choose[i] = 0; - } else { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && *ptr == value) choose[i] = 0; - } + if (lastflag) { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr == values[i]) choose[i] = 0; + } else { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && *ptr == value) choose[i] = 0; + } } else if (thresh_op[ithresh] == XOR) { - if (lastflag) { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && (*ptr == 0.0 && values[i] == 0.0) || - (*ptr != 0.0 && values[i] != 0.0)) - choose[i] = 0; - } else { - for (i = 0; i < nlocal; i++, ptr += nstride) - if (choose[i] && (*ptr == 0.0 && value == 0.0) || - (*ptr != 0.0 && value != 0.0)) - choose[i] = 0; - } + if (lastflag) { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && (*ptr == 0.0 && values[i] == 0.0) || + (*ptr != 0.0 && values[i] != 0.0)) + choose[i] = 0; + } else { + for (i = 0; i < nlocal; i++, ptr += nstride) + if (choose[i] && (*ptr == 0.0 && value == 0.0) || + (*ptr != 0.0 && value != 0.0)) + choose[i] = 0; + } } // update values stored in threshfix if (lastflag) { - ptr = ptrhold; - for (i = 0; i < nlocal; i++, ptr += nstride) values[i] = *ptr; + ptr = ptrhold; + for (i = 0; i < nlocal; i++, ptr += nstride) values[i] = *ptr; } } } @@ -1684,12 +1684,12 @@ int DumpCustom::modify_param(int narg, char **arg) thresh_op = NULL; thresh_value = NULL; thresh_last = NULL; - for (int i = 0; i < nthreshlast; i++) { - modify->delete_fix(thresh_fixID[i]); - delete [] thresh_fixID[i]; - } - thresh_fix = NULL; - thresh_fixID = NULL; + for (int i = 0; i < nthreshlast; i++) { + modify->delete_fix(thresh_fixID[i]); + delete [] thresh_fixID[i]; + } + thresh_fix = NULL; + thresh_fixID = NULL; thresh_first = NULL; } nthresh = nthreshlast = 0; @@ -1950,11 +1950,11 @@ int DumpCustom::modify_param(int narg, char **arg) thresh_last[nthresh] = -1; } else { thresh_fix = (FixStore **) - memory->srealloc(thresh_fix,(nthreshlast+1)*sizeof(FixStore *), - "dump:thresh_fix"); + memory->srealloc(thresh_fix,(nthreshlast+1)*sizeof(FixStore *), + "dump:thresh_fix"); thresh_fixID = (char **) - memory->srealloc(thresh_fixID,(nthreshlast+1)*sizeof(char *), - "dump:thresh_fixID"); + memory->srealloc(thresh_fixID,(nthreshlast+1)*sizeof(char *), + "dump:thresh_fixID"); memory->grow(thresh_first,(nthreshlast+1),"dump:thresh_first"); int n = strlen(id) + strlen("_DUMP_STORE") + 8; diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index bc7aa843ef..e34f2dcf55 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -433,8 +433,8 @@ void FixAdapt::init() error->all(FLERR,"Fix adapt requires atom attribute diameter"); } if (ad->aparam == CHARGE) { - if (!atom->q_flag) - error->all(FLERR,"Fix adapt requires atom attribute charge"); + if (!atom->q_flag) + error->all(FLERR,"Fix adapt requires atom attribute charge"); } } } @@ -597,12 +597,12 @@ void FixAdapt::change_settings() } } else if (ad->aparam == CHARGE) { double *q = atom->q; - int *mask = atom->mask; - int nlocal = atom->nlocal; + int *mask = atom->mask; + int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - for (i = 0; i < nall; i++) - if (mask[i] & groupbit) q[i] = value; + for (i = 0; i < nall; i++) + if (mask[i] & groupbit) q[i] = value; } } } diff --git a/src/fix_ave_chunk.cpp b/src/fix_ave_chunk.cpp index 73df50c66c..5b57c7a1f8 100644 --- a/src/fix_ave_chunk.cpp +++ b/src/fix_ave_chunk.cpp @@ -176,14 +176,14 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg],"norm") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command"); if (strcmp(arg[iarg+1],"all") == 0) { - normflag = ALL; - scaleflag = ATOM; + normflag = ALL; + scaleflag = ATOM; } else if (strcmp(arg[iarg+1],"sample") == 0) { - normflag = SAMPLE; - scaleflag = ATOM; + normflag = SAMPLE; + scaleflag = ATOM; } else if (strcmp(arg[iarg+1],"none") == 0) { - normflag = SAMPLE; - scaleflag = NOSCALE; + normflag = SAMPLE; + scaleflag = NOSCALE; } else error->all(FLERR,"Illegal fix ave/chunk command"); iarg += 2; } else if (strcmp(arg[iarg],"ave") == 0) { @@ -686,16 +686,16 @@ void FixAveChunk::end_of_step() double *rmass = atom->rmass; if (rmass) { - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit && ichunk[i] > 0) { - index = ichunk[i]-1; - values_one[index][m] += rmass[i]; + for (i = 0; i < nlocal; i++) + if (mask[i] & groupbit && ichunk[i] > 0) { + index = ichunk[i]-1; + values_one[index][m] += rmass[i]; } } else { for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit && ichunk[i] > 0) { - index = ichunk[i]-1; - values_one[index][m] += mass[type[i]]; + if (mask[i] & groupbit && ichunk[i] > 0) { + index = ichunk[i]-1; + values_one[index][m] += mass[type[i]]; } } diff --git a/src/fix_group.cpp b/src/fix_group.cpp index 51abebdf29..8479565891 100644 --- a/src/fix_group.cpp +++ b/src/fix_group.cpp @@ -75,8 +75,8 @@ idregion(NULL), idvar(NULL), idprop(NULL) strcpy(idvar,arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"property") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal group command"); - if (atom->find_custom(arg[iarg+1],typeflag) < 0) + if (iarg+2 > narg) error->all(FLERR,"Illegal group command"); + if (atom->find_custom(arg[iarg+1],typeflag) < 0) error->all(FLERR,"Per atom property for group dynamic does not exist"); propflag = 1; delete [] idprop; @@ -84,7 +84,7 @@ idregion(NULL), idvar(NULL), idprop(NULL) idprop = new char[n]; strcpy(idprop,arg[iarg+1]); iarg += 2; - } else if (strcmp(arg[iarg],"every") == 0) { + } else if (strcmp(arg[iarg],"every") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal group command"); nevery = force->inumeric(FLERR,arg[iarg+1]); if (nevery <= 0) error->all(FLERR,"Illegal group command"); diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp index 542d2d6d6f..7afc18b33c 100644 --- a/src/fix_langevin.cpp +++ b/src/fix_langevin.cpp @@ -310,132 +310,132 @@ void FixLangevin::post_force(int vflag) if (tstyle == ATOM) if (gjfflag) if (tallyflag) - if (tbiasflag == BIAS) - if (rmass) - if (zeroflag) post_force_templated<1,1,1,1,1,1>(); + if (tbiasflag == BIAS) + if (rmass) + if (zeroflag) post_force_templated<1,1,1,1,1,1>(); else post_force_templated<1,1,1,1,1,0>(); - else - if (zeroflag) post_force_templated<1,1,1,1,0,1>(); + else + if (zeroflag) post_force_templated<1,1,1,1,0,1>(); else post_force_templated<1,1,1,1,0,0>(); - else - if (rmass) - if (zeroflag) post_force_templated<1,1,1,0,1,1>(); - else post_force_templated<1,1,1,0,1,0>(); - else - if (zeroflag) post_force_templated<1,1,1,0,0,1>(); - else post_force_templated<1,1,1,0,0,0>(); + else + if (rmass) + if (zeroflag) post_force_templated<1,1,1,0,1,1>(); + else post_force_templated<1,1,1,0,1,0>(); + else + if (zeroflag) post_force_templated<1,1,1,0,0,1>(); + else post_force_templated<1,1,1,0,0,0>(); else - if (tbiasflag == BIAS) - if (rmass) - if (zeroflag) post_force_templated<1,1,0,1,1,1>(); - else post_force_templated<1,1,0,1,1,0>(); - else - if (zeroflag) post_force_templated<1,1,0,1,0,1>(); - else post_force_templated<1,1,0,1,0,0>(); - else - if (rmass) - if (zeroflag) post_force_templated<1,1,0,0,1,1>(); - else post_force_templated<1,1,0,0,1,0>(); - else - if (zeroflag) post_force_templated<1,1,0,0,0,1>(); - else post_force_templated<1,1,0,0,0,0>(); + if (tbiasflag == BIAS) + if (rmass) + if (zeroflag) post_force_templated<1,1,0,1,1,1>(); + else post_force_templated<1,1,0,1,1,0>(); + else + if (zeroflag) post_force_templated<1,1,0,1,0,1>(); + else post_force_templated<1,1,0,1,0,0>(); + else + if (rmass) + if (zeroflag) post_force_templated<1,1,0,0,1,1>(); + else post_force_templated<1,1,0,0,1,0>(); + else + if (zeroflag) post_force_templated<1,1,0,0,0,1>(); + else post_force_templated<1,1,0,0,0,0>(); else if (tallyflag) - if (tbiasflag == BIAS) - if (rmass) - if (zeroflag) post_force_templated<1,0,1,1,1,1>(); - else post_force_templated<1,0,1,1,1,0>(); - else - if (zeroflag) post_force_templated<1,0,1,1,0,1>(); - else post_force_templated<1,0,1,1,0,0>(); - else - if (rmass) - if (zeroflag) post_force_templated<1,0,1,0,1,1>(); - else post_force_templated<1,0,1,0,1,0>(); - else - if (zeroflag) post_force_templated<1,0,1,0,0,1>(); - else post_force_templated<1,0,1,0,0,0>(); + if (tbiasflag == BIAS) + if (rmass) + if (zeroflag) post_force_templated<1,0,1,1,1,1>(); + else post_force_templated<1,0,1,1,1,0>(); + else + if (zeroflag) post_force_templated<1,0,1,1,0,1>(); + else post_force_templated<1,0,1,1,0,0>(); + else + if (rmass) + if (zeroflag) post_force_templated<1,0,1,0,1,1>(); + else post_force_templated<1,0,1,0,1,0>(); + else + if (zeroflag) post_force_templated<1,0,1,0,0,1>(); + else post_force_templated<1,0,1,0,0,0>(); else - if (tbiasflag == BIAS) - if (rmass) - if (zeroflag) post_force_templated<1,0,0,1,1,1>(); - else post_force_templated<1,0,0,1,1,0>(); - else - if (zeroflag) post_force_templated<1,0,0,1,0,1>(); - else post_force_templated<1,0,0,1,0,0>(); - else - if (rmass) - if (zeroflag) post_force_templated<1,0,0,0,1,1>(); - else post_force_templated<1,0,0,0,1,0>(); - else - if (zeroflag) post_force_templated<1,0,0,0,0,1>(); - else post_force_templated<1,0,0,0,0,0>(); + if (tbiasflag == BIAS) + if (rmass) + if (zeroflag) post_force_templated<1,0,0,1,1,1>(); + else post_force_templated<1,0,0,1,1,0>(); + else + if (zeroflag) post_force_templated<1,0,0,1,0,1>(); + else post_force_templated<1,0,0,1,0,0>(); + else + if (rmass) + if (zeroflag) post_force_templated<1,0,0,0,1,1>(); + else post_force_templated<1,0,0,0,1,0>(); + else + if (zeroflag) post_force_templated<1,0,0,0,0,1>(); + else post_force_templated<1,0,0,0,0,0>(); else if (gjfflag) if (tallyflag) - if (tbiasflag == BIAS) - if (rmass) - if (zeroflag) post_force_templated<0,1,1,1,1,1>(); - else post_force_templated<0,1,1,1,1,0>(); - else - if (zeroflag) post_force_templated<0,1,1,1,0,1>(); - else post_force_templated<0,1,1,1,0,0>(); - else - if (rmass) - if (zeroflag) post_force_templated<0,1,1,0,1,1>(); - else post_force_templated<0,1,1,0,1,0>(); - else - if (zeroflag) post_force_templated<0,1,1,0,0,1>(); - else post_force_templated<0,1,1,0,0,0>(); + if (tbiasflag == BIAS) + if (rmass) + if (zeroflag) post_force_templated<0,1,1,1,1,1>(); + else post_force_templated<0,1,1,1,1,0>(); + else + if (zeroflag) post_force_templated<0,1,1,1,0,1>(); + else post_force_templated<0,1,1,1,0,0>(); + else + if (rmass) + if (zeroflag) post_force_templated<0,1,1,0,1,1>(); + else post_force_templated<0,1,1,0,1,0>(); + else + if (zeroflag) post_force_templated<0,1,1,0,0,1>(); + else post_force_templated<0,1,1,0,0,0>(); else - if (tbiasflag == BIAS) - if (rmass) - if (zeroflag) post_force_templated<0,1,0,1,1,1>(); - else post_force_templated<0,1,0,1,1,0>(); - else - if (zeroflag) post_force_templated<0,1,0,1,0,1>(); - else post_force_templated<0,1,0,1,0,0>(); - else - if (rmass) - if (zeroflag) post_force_templated<0,1,0,0,1,1>(); - else post_force_templated<0,1,0,0,1,0>(); - else - if (zeroflag) post_force_templated<0,1,0,0,0,1>(); - else post_force_templated<0,1,0,0,0,0>(); + if (tbiasflag == BIAS) + if (rmass) + if (zeroflag) post_force_templated<0,1,0,1,1,1>(); + else post_force_templated<0,1,0,1,1,0>(); + else + if (zeroflag) post_force_templated<0,1,0,1,0,1>(); + else post_force_templated<0,1,0,1,0,0>(); + else + if (rmass) + if (zeroflag) post_force_templated<0,1,0,0,1,1>(); + else post_force_templated<0,1,0,0,1,0>(); + else + if (zeroflag) post_force_templated<0,1,0,0,0,1>(); + else post_force_templated<0,1,0,0,0,0>(); else if (tallyflag) - if (tbiasflag == BIAS) - if (rmass) - if (zeroflag) post_force_templated<0,0,1,1,1,1>(); - else post_force_templated<0,0,1,1,1,0>(); - else - if (zeroflag) post_force_templated<0,0,1,1,0,1>(); - else post_force_templated<0,0,1,1,0,0>(); - else - if (rmass) - if (zeroflag) post_force_templated<0,0,1,0,1,1>(); - else post_force_templated<0,0,1,0,1,0>(); - else - if (zeroflag) post_force_templated<0,0,1,0,0,1>(); - else post_force_templated<0,0,1,0,0,0>(); + if (tbiasflag == BIAS) + if (rmass) + if (zeroflag) post_force_templated<0,0,1,1,1,1>(); + else post_force_templated<0,0,1,1,1,0>(); + else + if (zeroflag) post_force_templated<0,0,1,1,0,1>(); + else post_force_templated<0,0,1,1,0,0>(); + else + if (rmass) + if (zeroflag) post_force_templated<0,0,1,0,1,1>(); + else post_force_templated<0,0,1,0,1,0>(); + else + if (zeroflag) post_force_templated<0,0,1,0,0,1>(); + else post_force_templated<0,0,1,0,0,0>(); else - if (tbiasflag == BIAS) - if (rmass) - if (zeroflag) post_force_templated<0,0,0,1,1,1>(); - else post_force_templated<0,0,0,1,1,0>(); - else - if (zeroflag) post_force_templated<0,0,0,1,0,1>(); - else post_force_templated<0,0,0,1,0,0>(); - else - if (rmass) - if (zeroflag) post_force_templated<0,0,0,0,1,1>(); - else post_force_templated<0,0,0,0,1,0>(); - else - if (zeroflag) post_force_templated<0,0,0,0,0,1>(); - else post_force_templated<0,0,0,0,0,0>(); + if (tbiasflag == BIAS) + if (rmass) + if (zeroflag) post_force_templated<0,0,0,1,1,1>(); + else post_force_templated<0,0,0,1,1,0>(); + else + if (zeroflag) post_force_templated<0,0,0,1,0,1>(); + else post_force_templated<0,0,0,1,0,0>(); + else + if (rmass) + if (zeroflag) post_force_templated<0,0,0,0,1,1>(); + else post_force_templated<0,0,0,0,1,0>(); + else + if (zeroflag) post_force_templated<0,0,0,0,0,1>(); + else post_force_templated<0,0,0,0,0,0>(); #else post_force_untemplated(int(tstyle==ATOM), gjfflag, tallyflag, - int(tbiasflag==BIAS), int(rmass!=NULL), zeroflag); + int(tbiasflag==BIAS), int(rmass!=NULL), zeroflag); #endif } @@ -452,7 +452,7 @@ void FixLangevin::post_force_respa(int vflag, int ilevel, int iloop) #ifdef TEMPLATED_FIX_LANGEVIN template < int Tp_TSTYLEATOM, int Tp_GJF, int Tp_TALLY, - int Tp_BIAS, int Tp_RMASS, int Tp_ZERO > + int Tp_BIAS, int Tp_RMASS, int Tp_ZERO > void FixLangevin::post_force_templated() #else void FixLangevin::post_force_untemplated @@ -525,13 +525,13 @@ void FixLangevin::post_force_untemplated if (mask[i] & groupbit) { if (Tp_TSTYLEATOM) tsqrt = sqrt(tforce[i]); if (Tp_RMASS) { - gamma1 = -rmass[i] / t_period / ftm2v; - gamma2 = sqrt(rmass[i]) * sqrt(24.0*boltz/t_period/dt/mvv2e) / ftm2v; - gamma1 *= 1.0/ratio[type[i]]; - gamma2 *= 1.0/sqrt(ratio[type[i]]) * tsqrt; + gamma1 = -rmass[i] / t_period / ftm2v; + gamma2 = sqrt(rmass[i]) * sqrt(24.0*boltz/t_period/dt/mvv2e) / ftm2v; + gamma1 *= 1.0/ratio[type[i]]; + gamma2 *= 1.0/sqrt(ratio[type[i]]) * tsqrt; } else { - gamma1 = gfactor1[type[i]]; - gamma2 = gfactor2[type[i]] * tsqrt; + gamma1 = gfactor1[type[i]]; + gamma2 = gfactor2[type[i]] * tsqrt; } fran[0] = gamma2*(random->uniform()-0.5); @@ -539,40 +539,40 @@ void FixLangevin::post_force_untemplated fran[2] = gamma2*(random->uniform()-0.5); if (Tp_BIAS) { - temperature->remove_bias(i,v[i]); - fdrag[0] = gamma1*v[i][0]; - fdrag[1] = gamma1*v[i][1]; - fdrag[2] = gamma1*v[i][2]; - if (v[i][0] == 0.0) fran[0] = 0.0; - if (v[i][1] == 0.0) fran[1] = 0.0; - if (v[i][2] == 0.0) fran[2] = 0.0; - temperature->restore_bias(i,v[i]); + temperature->remove_bias(i,v[i]); + fdrag[0] = gamma1*v[i][0]; + fdrag[1] = gamma1*v[i][1]; + fdrag[2] = gamma1*v[i][2]; + if (v[i][0] == 0.0) fran[0] = 0.0; + if (v[i][1] == 0.0) fran[1] = 0.0; + if (v[i][2] == 0.0) fran[2] = 0.0; + temperature->restore_bias(i,v[i]); } else { - fdrag[0] = gamma1*v[i][0]; - fdrag[1] = gamma1*v[i][1]; - fdrag[2] = gamma1*v[i][2]; + fdrag[0] = gamma1*v[i][0]; + fdrag[1] = gamma1*v[i][1]; + fdrag[2] = gamma1*v[i][2]; } if (Tp_GJF) { - fswap = 0.5*(fran[0]+franprev[i][0]); - franprev[i][0] = fran[0]; - fran[0] = fswap; - fswap = 0.5*(fran[1]+franprev[i][1]); - franprev[i][1] = fran[1]; - fran[1] = fswap; - fswap = 0.5*(fran[2]+franprev[i][2]); - franprev[i][2] = fran[2]; - fran[2] = fswap; - - fdrag[0] *= gjffac; - fdrag[1] *= gjffac; - fdrag[2] *= gjffac; - fran[0] *= gjffac; - fran[1] *= gjffac; - fran[2] *= gjffac; - f[i][0] *= gjffac; - f[i][1] *= gjffac; - f[i][2] *= gjffac; + fswap = 0.5*(fran[0]+franprev[i][0]); + franprev[i][0] = fran[0]; + fran[0] = fswap; + fswap = 0.5*(fran[1]+franprev[i][1]); + franprev[i][1] = fran[1]; + fran[1] = fswap; + fswap = 0.5*(fran[2]+franprev[i][2]); + franprev[i][2] = fran[2]; + fran[2] = fswap; + + fdrag[0] *= gjffac; + fdrag[1] *= gjffac; + fdrag[2] *= gjffac; + fran[0] *= gjffac; + fran[1] *= gjffac; + fran[2] *= gjffac; + f[i][0] *= gjffac; + f[i][1] *= gjffac; + f[i][2] *= gjffac; } f[i][0] += fdrag[0] + fran[0]; @@ -580,15 +580,15 @@ void FixLangevin::post_force_untemplated f[i][2] += fdrag[2] + fran[2]; if (Tp_TALLY) { - flangevin[i][0] = fdrag[0] + fran[0]; - flangevin[i][1] = fdrag[1] + fran[1]; - flangevin[i][2] = fdrag[2] + fran[2]; + flangevin[i][0] = fdrag[0] + fran[0]; + flangevin[i][1] = fdrag[1] + fran[1]; + flangevin[i][2] = fdrag[2] + fran[2]; } if (Tp_ZERO) { - fsum[0] += fran[0]; - fsum[1] += fran[1]; - fsum[2] += fran[2]; + fsum[0] += fran[0]; + fsum[1] += fran[1]; + fsum[2] += fran[2]; } } } diff --git a/src/fix_langevin.h b/src/fix_langevin.h index 34eec63987..2883ac9ea2 100644 --- a/src/fix_langevin.h +++ b/src/fix_langevin.h @@ -76,11 +76,11 @@ class FixLangevin : public Fix { #define TEMPLATED_FIX_LANGEVIN #ifdef TEMPLATED_FIX_LANGEVIN template < int Tp_TSTYLEATOM, int Tp_GJF, int Tp_TALLY, - int Tp_BIAS, int Tp_RMASS, int Tp_ZERO > + int Tp_BIAS, int Tp_RMASS, int Tp_ZERO > void post_force_templated(); #else void post_force_untemplated(int, int, int, - int, int, int); + int, int, int); #endif void omega_thermostat(); void angmom_thermostat(); diff --git a/src/fix_nh_sphere.cpp b/src/fix_nh_sphere.cpp index 5307889f5e..28de5490d4 100644 --- a/src/fix_nh_sphere.cpp +++ b/src/fix_nh_sphere.cpp @@ -47,7 +47,7 @@ FixNHSphere::FixNHSphere(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg],"disc") == 0){ inertia = 0.5; if (domain->dimension != 2) - error->all(FLERR, + error->all(FLERR, "Fix nvt/nph/npt sphere disc option requires 2d simulation"); } iarg++; diff --git a/src/fix_nve_sphere.cpp b/src/fix_nve_sphere.cpp index 8c43800939..7ffd92e232 100644 --- a/src/fix_nve_sphere.cpp +++ b/src/fix_nve_sphere.cpp @@ -62,7 +62,7 @@ FixNVESphere::FixNVESphere(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[iarg],"disc")==0) { inertia = 0.5; if (domain->dimension != 2) - error->all(FLERR,"Fix nve/sphere disc requires 2d simulation"); + error->all(FLERR,"Fix nve/sphere disc requires 2d simulation"); iarg++; } else error->all(FLERR,"Illegal fix nve/sphere command"); diff --git a/src/fix_store_state.cpp b/src/fix_store_state.cpp index 8b742d5ad4..36f5c6a92e 100644 --- a/src/fix_store_state.cpp +++ b/src/fix_store_state.cpp @@ -418,7 +418,7 @@ void FixStoreState::init() icustom = atom->find_custom(ids[m],iflag); if ((icustom < 0) || (iflag != 0)) error->all(FLERR, - "Custom integer vector for fix store/state does not exist"); + "Custom integer vector for fix store/state does not exist"); value2index[m] = icustom; } else if (which[m] == DNAME) { @@ -426,7 +426,7 @@ void FixStoreState::init() icustom = atom->find_custom(ids[m],iflag); if ((icustom < 0) || (iflag != 1)) error->all(FLERR, - "Custom floating point vector for fix store/state does not exist"); + "Custom floating point vector for fix store/state does not exist"); value2index[m] = icustom; } else if (which[m] == FIX) { @@ -1089,7 +1089,7 @@ void FixStoreState::pack_xsu_triclinic(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = h_inv[0]*(x[i][0]-boxlo[0]) + h_inv[5]*(x[i][1]-boxlo[1]) + - h_inv[4]*(x[i][2]-boxlo[2]) + (image[i] & IMGMASK) - IMGMAX; + h_inv[4]*(x[i][2]-boxlo[2]) + (image[i] & IMGMASK) - IMGMAX; else vbuf[n] = 0.0; n += nvalues; } @@ -1110,7 +1110,7 @@ void FixStoreState::pack_ysu_triclinic(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = h_inv[1]*(x[i][1]-boxlo[1]) + h_inv[3]*(x[i][2]-boxlo[2]) + - (image[i] >> IMGBITS & IMGMASK) - IMGMAX; + (image[i] >> IMGBITS & IMGMASK) - IMGMAX; else vbuf[n] = 0.0; n += nvalues; } diff --git a/src/fix_wall_lj1043.cpp b/src/fix_wall_lj1043.cpp index 064a5a8d60..35bfff1749 100644 --- a/src/fix_wall_lj1043.cpp +++ b/src/fix_wall_lj1043.cpp @@ -47,7 +47,7 @@ void FixWallLJ1043::precompute(int m) double r2inv = rinv*rinv; double r4inv = r2inv*r2inv; offset[m] = coeff1[m]*r4inv*r4inv*r2inv - coeff2[m]*r4inv - - coeff3[m]*pow(cutoff[m]+coeff4[m],-3.0); + coeff3[m]*pow(cutoff[m]+coeff4[m],-3.0); } /* ---------------------------------------------------------------------- */ @@ -78,10 +78,10 @@ void FixWallLJ1043::wall_particle(int m, int which, double coord) r10inv = r4inv*r4inv*r2inv; fwall = side * (coeff5[m]*r10inv*rinv - coeff6[m]*r4inv*rinv - - coeff7[m]*pow(delta+coeff4[m],-4.0)); + coeff7[m]*pow(delta+coeff4[m],-4.0)); f[i][dim] -= fwall; ewall[0] += coeff1[m]*r10inv - coeff2[m]*r4inv - - coeff3[m]*pow(delta+coeff4[m],-3.0) - offset[m]; + coeff3[m]*pow(delta+coeff4[m],-3.0) - offset[m]; ewall[m+1] += fwall; if (evflag) { diff --git a/src/input.cpp b/src/input.cpp index 0640327682..3d458c1ea4 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -163,8 +163,8 @@ void Input::file() while (1) { if (maxline-m < 2) reallocate(line,maxline,0); - // end of file reached, so break - // n == 0 if nothing read, else n = line with str terminator + // end of file reached, so break + // n == 0 if nothing read, else n = line with str terminator if (fgets(&line[m],maxline-m,infile) == NULL) { if (m) n = strlen(line) + 1; @@ -172,23 +172,23 @@ void Input::file() break; } - // continue if last char read was not a newline - // could happen if line is very long + // continue if last char read was not a newline + // could happen if line is very long m = strlen(line); if (line[m-1] != '\n') continue; - // continue reading if final printable char is & char - // or if odd number of triple quotes - // else break with n = line with str terminator + // continue reading if final printable char is & char + // or if odd number of triple quotes + // else break with n = line with str terminator m--; while (m >= 0 && isspace(line[m])) m--; if (m < 0 || line[m] != '&') { - if (numtriple(line) % 2) { - m += 2; - continue; - } + if (numtriple(line) % 2) { + m += 2; + continue; + } line[m+1] = '\0'; n = m+2; break; @@ -559,17 +559,17 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag) if (quoteflag == 0) { if (strstr(ptr,"\"\"\"") == ptr) { - quoteflag = 3; - *ptr2++ = *ptr++; - *ptr2++ = *ptr++; + quoteflag = 3; + *ptr2++ = *ptr++; + *ptr2++ = *ptr++; } else if (*ptr == '"') quoteflag = 2; else if (*ptr == '\'') quoteflag = 1; } else { if (quoteflag == 3 && strstr(ptr,"\"\"\"") == ptr) { - quoteflag = 0; - *ptr2++ = *ptr++; - *ptr2++ = *ptr++; + quoteflag = 0; + *ptr2++ = *ptr++; + *ptr2++ = *ptr++; } else if (quoteflag == 2 && *ptr == '"') quoteflag = 0; else if (quoteflag == 1 && *ptr == '\'') quoteflag = 0; @@ -626,62 +626,62 @@ int Input::expand_args(int narg, char **arg, int mode, char **&earg) ptr1 = strchr(&arg[iarg][2],'['); if (ptr1) { - ptr2 = strchr(ptr1,']'); - if (ptr2) { - *ptr2 = '\0'; - if (strchr(ptr1,'*')) { - if (arg[iarg][0] == 'c') { - *ptr1 = '\0'; - icompute = modify->find_compute(&arg[iarg][2]); - *ptr1 = '['; + ptr2 = strchr(ptr1,']'); + if (ptr2) { + *ptr2 = '\0'; + if (strchr(ptr1,'*')) { + if (arg[iarg][0] == 'c') { + *ptr1 = '\0'; + icompute = modify->find_compute(&arg[iarg][2]); + *ptr1 = '['; // check for global vector/array, peratom array, local array - if (icompute >= 0) { - if (mode == 0 && modify->compute[icompute]->vector_flag) { - nmax = modify->compute[icompute]->size_vector; - expandflag = 1; - } else if (mode == 1 && modify->compute[icompute]->array_flag) { - nmax = modify->compute[icompute]->size_array_cols; - expandflag = 1; + if (icompute >= 0) { + if (mode == 0 && modify->compute[icompute]->vector_flag) { + nmax = modify->compute[icompute]->size_vector; + expandflag = 1; + } else if (mode == 1 && modify->compute[icompute]->array_flag) { + nmax = modify->compute[icompute]->size_array_cols; + expandflag = 1; } else if (modify->compute[icompute]->peratom_flag && modify->compute[icompute]->size_peratom_cols) { - nmax = modify->compute[icompute]->size_peratom_cols; - expandflag = 1; + nmax = modify->compute[icompute]->size_peratom_cols; + expandflag = 1; } else if (modify->compute[icompute]->local_flag && modify->compute[icompute]->size_local_cols) { - nmax = modify->compute[icompute]->size_local_cols; - expandflag = 1; - } - } - } else if (arg[iarg][0] == 'f') { - *ptr1 = '\0'; - ifix = modify->find_fix(&arg[iarg][2]); - *ptr1 = '['; + nmax = modify->compute[icompute]->size_local_cols; + expandflag = 1; + } + } + } else if (arg[iarg][0] == 'f') { + *ptr1 = '\0'; + ifix = modify->find_fix(&arg[iarg][2]); + *ptr1 = '['; // check for global vector/array, peratom array, local array - if (ifix >= 0) { - if (mode == 0 && modify->fix[ifix]->vector_flag) { - nmax = modify->fix[ifix]->size_vector; - expandflag = 1; - } else if (mode == 1 && modify->fix[ifix]->array_flag) { - nmax = modify->fix[ifix]->size_array_cols; - expandflag = 1; + if (ifix >= 0) { + if (mode == 0 && modify->fix[ifix]->vector_flag) { + nmax = modify->fix[ifix]->size_vector; + expandflag = 1; + } else if (mode == 1 && modify->fix[ifix]->array_flag) { + nmax = modify->fix[ifix]->size_array_cols; + expandflag = 1; } else if (modify->fix[ifix]->peratom_flag && modify->fix[ifix]->size_peratom_cols) { - nmax = modify->fix[ifix]->size_peratom_cols; - expandflag = 1; + nmax = modify->fix[ifix]->size_peratom_cols; + expandflag = 1; } else if (modify->fix[ifix]->local_flag && modify->fix[ifix]->size_local_cols) { - nmax = modify->fix[ifix]->size_local_cols; - expandflag = 1; - } - } - } - } - *ptr2 = ']'; - } + nmax = modify->fix[ifix]->size_local_cols; + expandflag = 1; + } + } + } + } + *ptr2 = ']'; + } } } @@ -690,23 +690,23 @@ int Input::expand_args(int narg, char **arg, int mode, char **&earg) force->bounds(FLERR,ptr1+1,nmax,nlo,nhi); *ptr2 = ']'; if (newarg+nhi-nlo+1 > maxarg) { - maxarg += nhi-nlo+1; - earg = (char **) + maxarg += nhi-nlo+1; + earg = (char **) memory->srealloc(earg,maxarg*sizeof(char *),"input:earg"); } for (index = nlo; index <= nhi; index++) { - n = strlen(arg[iarg]) + 16; // 16 = space for large inserted integer - str = earg[newarg] = new char[n]; - strncpy(str,arg[iarg],ptr1+1-arg[iarg]); - sprintf(&str[ptr1+1-arg[iarg]],"%d",index); - strcat(str,ptr2); + n = strlen(arg[iarg]) + 16; // 16 = space for large inserted integer + str = earg[newarg] = new char[n]; + strncpy(str,arg[iarg],ptr1+1-arg[iarg]); + sprintf(&str[ptr1+1-arg[iarg]],"%d",index); + strcat(str,ptr2); newarg++; } } else { if (newarg == maxarg) { - maxarg++; - earg = (char **) + maxarg++; + earg = (char **) memory->srealloc(earg,maxarg*sizeof(char *),"input:earg"); } n = strlen(arg[iarg]) + 1; diff --git a/src/kspace.cpp b/src/kspace.cpp index 07e117e162..b2db585f12 100644 --- a/src/kspace.cpp +++ b/src/kspace.cpp @@ -541,11 +541,11 @@ void KSpace::modify_params(int narg, char **arg) ky_ewald = atoi(arg[iarg+2]); kz_ewald = atoi(arg[iarg+3]); if (kx_ewald < 0 || ky_ewald < 0 || kz_ewald < 0) - error->all(FLERR,"Bad kspace_modify kmax/ewald parameter"); + error->all(FLERR,"Bad kspace_modify kmax/ewald parameter"); if (kx_ewald > 0 && ky_ewald > 0 && kz_ewald > 0) - kewaldflag = 1; + kewaldflag = 1; else - kewaldflag = 0; + kewaldflag = 0; iarg += 4; } else if (strcmp(arg[iarg],"mix/disp") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); diff --git a/src/lammps.cpp b/src/lammps.cpp index bde7ca035d..dd91ea7c19 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -197,18 +197,18 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) if (strcmp(arg[iarg+1],"hybrid") == 0) { if (iarg+4 > narg) error->universe_all(FLERR,"Invalid command-line argument"); - int n = strlen(arg[iarg+2]) + 1; - suffix = new char[n]; - strcpy(suffix,arg[iarg+2]); - n = strlen(arg[iarg+3]) + 1; - suffix2 = new char[n]; - strcpy(suffix2,arg[iarg+3]); - iarg += 4; + int n = strlen(arg[iarg+2]) + 1; + suffix = new char[n]; + strcpy(suffix,arg[iarg+2]); + n = strlen(arg[iarg+3]) + 1; + suffix2 = new char[n]; + strcpy(suffix2,arg[iarg+3]); + iarg += 4; } else { - int n = strlen(arg[iarg+1]) + 1; - suffix = new char[n]; - strcpy(suffix,arg[iarg+1]); - iarg += 2; + int n = strlen(arg[iarg+1]) + 1; + suffix = new char[n]; + strcpy(suffix,arg[iarg+1]); + iarg += 2; } } else if (strcmp(arg[iarg],"-reorder") == 0 || strcmp(arg[iarg],"-ro") == 0) { diff --git a/src/library.cpp b/src/library.cpp index 233bb3122c..b30c6e9595 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -1002,7 +1002,7 @@ void lammps_scatter_atoms(void *ptr, char *name, ------------------------------------------------------------------------- */ void lammps_create_atoms(void *ptr, int n, tagint *id, int *type, - double *x, double *v, imageint *image, + double *x, double *v, imageint *image, int shrinkexceed) { LAMMPS *lmp = (LAMMPS *) ptr; @@ -1044,9 +1044,9 @@ void lammps_create_atoms(void *ptr, int n, tagint *id, int *type, if (id) atom->tag[nlocal] = id[i]; else atom->tag[nlocal] = i+1; if (v) { - atom->v[nlocal][0] = v[3*i]; - atom->v[nlocal][1] = v[3*i+1]; - atom->v[nlocal][2] = v[3*i+2]; + atom->v[nlocal][0] = v[3*i]; + atom->v[nlocal][1] = v[3*i+1]; + atom->v[nlocal][2] = v[3*i+2]; } if (image) atom->image[nlocal] = image[i]; nlocal++; diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 686552656a..82017c8525 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -1455,7 +1455,7 @@ void Neighbor::print_pairwise_info() nlist,nperpetual,noccasional,nextra); for (i = 0; i < nlist; i++) { - rq = requests[i]; + rq = requests[i]; if (rq->pair) { char *pname = force->pair_match_ptr((Pair *) rq->requestor); sprintf(str," (%d) pair %s",i+1,pname); @@ -1491,12 +1491,12 @@ void Neighbor::print_pairwise_info() if (rq->half) fprintf(out,"half"); else if (rq->full) fprintf(out,"full"); - if (rq->newton == 0) { - if (force->newton_pair) fprintf(out,", newton on"); - else fprintf(out,", newton off"); - } else if (rq->newton == 1) fprintf(out,", newton on"); - else if (rq->newton == 2) fprintf(out,", newton off"); - + if (rq->newton == 0) { + if (force->newton_pair) fprintf(out,", newton on"); + else fprintf(out,", newton off"); + } else if (rq->newton == 1) fprintf(out,", newton on"); + else if (rq->newton == 2) fprintf(out,", newton off"); + if (rq->ghost) fprintf(out,", ghost"); if (rq->size) fprintf(out,", size"); if (rq->history) fprintf(out,", history"); @@ -2303,7 +2303,7 @@ void Neighbor::modify_params(int narg, char **arg) iarg += 4; } else if (strcmp(arg[iarg+1],"molecule/inter") == 0 || - strcmp(arg[iarg+1],"molecule/intra") == 0) { + strcmp(arg[iarg+1],"molecule/intra") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal neigh_modify command"); if (atom->molecule_flag == 0) error->all(FLERR,"Neigh_modify exclude molecule " @@ -2319,13 +2319,13 @@ void Neighbor::modify_params(int narg, char **arg) ex_mol_group[nex_mol] = group->find(arg[iarg+2]); if (ex_mol_group[nex_mol] == -1) error->all(FLERR,"Invalid group ID in neigh_modify command"); - if (strcmp(arg[iarg+1],"molecule/intra") == 0) - ex_mol_intra[nex_mol] = 1; - else - ex_mol_intra[nex_mol] = 0; + if (strcmp(arg[iarg+1],"molecule/intra") == 0) + ex_mol_intra[nex_mol] = 1; + else + ex_mol_intra[nex_mol] = 0; nex_mol++; iarg += 3; - + } else if (strcmp(arg[iarg+1],"none") == 0) { nex_type = nex_group = nex_mol = 0; iarg += 2; diff --git a/src/pair.h b/src/pair.h index cfb6576653..94de38ab57 100644 --- a/src/pair.h +++ b/src/pair.h @@ -138,7 +138,7 @@ class Pair : protected Pointers { virtual double single(int, int, int, int, double, double, double, - double& fforce) { + double& fforce) { fforce = 0.0; return 0.0; } diff --git a/src/pair_born_coul_dsf.cpp b/src/pair_born_coul_dsf.cpp index d53e9cf00e..3700aa46d7 100644 --- a/src/pair_born_coul_dsf.cpp +++ b/src/pair_born_coul_dsf.cpp @@ -132,7 +132,7 @@ void PairBornCoulDSF::compute(int eflag, int vflag) if (rsq < cut_coulsq) { r = sqrt(rsq); prefactor = qqrd2e*qtmp*q[j]/r; - arg = alpha * r ; + arg = alpha * r ; erfcd = MathSpecial::expmsq(arg); erfcc = MathSpecial::my_erfcx(arg) * erfcd; forcecoul = prefactor * (erfcc/r + 2.0*alpha/MY_PIS * erfcd + diff --git a/src/pair_coul_streitz.cpp b/src/pair_coul_streitz.cpp index 6b9ba9df9c..82ecd1d810 100644 --- a/src/pair_coul_streitz.cpp +++ b/src/pair_coul_streitz.cpp @@ -189,7 +189,7 @@ void PairCoulStreitz::coeff(int narg, char **arg) for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) if (map[i] >= 0 && map[j] >= 0) { - scale[i][j] = 1.0; + scale[i][j] = 1.0; setflag[i][j] = 1; count++; } @@ -488,7 +488,7 @@ void PairCoulStreitz::compute(int eflag, int vflag) } if (evflag) ev_tally(i,j,nlocal,newton_pair, - 0.0,ecoul,fpair,delr[0],delr[1],delr[2]); + 0.0,ecoul,fpair,delr[0],delr[1],delr[2]); } } @@ -544,7 +544,7 @@ void PairCoulStreitz::compute(int eflag, int vflag) // Ewald: real-space ewald_sum(qi, qj, zj, r, ci_jfi, dci_jfi, ci_fifj, dci_fifj, - ecoul, forcecoul, factor_coul); + ecoul, forcecoul, factor_coul); // Forces @@ -560,7 +560,7 @@ void PairCoulStreitz::compute(int eflag, int vflag) } if (evflag) ev_tally(i,j,nlocal,newton_pair, - 0.0,ecoul,fpair,delr[0],delr[1],delr[2]); + 0.0,ecoul,fpair,delr[0],delr[1],delr[2]); } } } @@ -585,8 +585,8 @@ double PairCoulStreitz::self(Param *param, double qi) /* ---------------------------------------------------------------------- */ void PairCoulStreitz::coulomb_integral_wolf(double zei, double zej, double r, - double &ci_jfi, double &dci_jfi, double &ci_fifj, - double &dci_fifj) + double &ci_jfi, double &dci_jfi, double &ci_fifj, + double &dci_fifj) { double rinv = 1.0/r; double rinv2 = rinv*rinv; @@ -625,12 +625,12 @@ void PairCoulStreitz::coulomb_integral_wolf(double zei, double zej, double r, eshift = -exp2zirsh*(rcinv + zei*(sm1 + sm2*zei*rc + sm3*zei2*rc*rc)); fshift = exp2zirsh*(rcinv2 + 2.0*zei*rcinv + zei2* - (2.0 + 7.0/6.0*zei*rc + 1.0/3.0*zei2*rc*rc)); + (2.0 + 7.0/6.0*zei*rc + 1.0/3.0*zei2*rc*rc)); ci_fifj = -exp2zir*(rinv + zei*(sm1 + sm2*zei*r + sm3*zei2*r*r)) - - eshift - (r-rc)*fshift; + - eshift - (r-rc)*fshift; dci_fifj = exp2zir*(rinv2 + 2.0*zei*rinv + zei2* - (2.0 + 7.0/6.0*zei*r + 1.0/3.0*zei2*r*r)) - fshift; + (2.0 + 7.0/6.0*zei*r + 1.0/3.0*zei2*r*r)) - fshift; } else { @@ -646,7 +646,7 @@ void PairCoulStreitz::coulomb_integral_wolf(double zei, double zej, double r, + exp2zjrsh*(2.0*zej*(e2+e4/rc) + e4*rcinv2)); ci_fifj = -exp2zir*(e1+e3/r) - exp2zjr*(e2+e4/r) - - eshift - (r-rc)*fshift; + - eshift - (r-rc)*fshift; dci_fifj = (exp2zir*(2.0*zei*(e1+e3/r) + e3*rinv2) + exp2zjr*(2.0*zej*(e2+e4/r) + e4*rinv2)) - fshift; } @@ -655,8 +655,8 @@ void PairCoulStreitz::coulomb_integral_wolf(double zei, double zej, double r, /* ---------------------------------------------------------------------- */ void PairCoulStreitz::wolf_sum(double qi, double qj, double zj, double r, - double ci_jfi, double dci_jfi, double ci_fifj, - double dci_fifj, double &etmp, double &ftmp) + double ci_jfi, double dci_jfi, double ci_fifj, + double dci_fifj, double &etmp, double &ftmp) { double a = g_wolf; double rc = cut_coul; @@ -688,8 +688,8 @@ void PairCoulStreitz::wolf_sum(double qi, double qj, double zj, double r, /* ---------------------------------------------------------------------- */ void PairCoulStreitz::coulomb_integral_ewald(double zei, double zej, double r, - double &ci_jfi, double &dci_jfi, double &ci_fifj, - double &dci_fifj) + double &ci_jfi, double &dci_jfi, double &ci_fifj, + double &dci_fifj) { double rinv = 1.0/r; double rinv2 = rinv*rinv; @@ -718,7 +718,7 @@ void PairCoulStreitz::coulomb_integral_ewald(double zei, double zej, double r, ci_fifj = -exp2zir*(rinv + zei*(sm1 + sm2*zei*r + sm3*zei2*r*r)); dci_fifj = exp2zir*(rinv2 + 2.0*zei*rinv + - zei2*(2.0 + 7.0/6.0*zei*r + 1.0/3.0*zei2*r*r)); + zei2*(2.0 + 7.0/6.0*zei*r + 1.0/3.0*zei2*r*r)); } else { @@ -739,8 +739,8 @@ void PairCoulStreitz::coulomb_integral_ewald(double zei, double zej, double r, /* ---------------------------------------------------------------------- */ void PairCoulStreitz::ewald_sum(double qi, double qj, double zj, double r, - double ci_jfi, double dci_jfi, double ci_fifj, - double dci_fifj, double &etmp, double &ftmp, double fac) + double ci_jfi, double dci_jfi, double ci_fifj, + double dci_fifj, double &etmp, double &ftmp, double fac) { double etmp1, etmp2, etmp3, etmp4; double ftmp1, ftmp2, ftmp3, ftmp4; diff --git a/src/pair_coul_streitz.h b/src/pair_coul_streitz.h index 8e713997f5..c304365270 100644 --- a/src/pair_coul_streitz.h +++ b/src/pair_coul_streitz.h @@ -74,11 +74,11 @@ class PairCoulStreitz : public Pair { void coulomb_integral_wolf(double, double, double, double &, double &, double &, double &); void wolf_sum(double, double, double, double, double, double, double, - double, double &, double &); + double, double &, double &); void coulomb_integral_ewald(double, double, double, double &, double &, double &, double &); void ewald_sum(double, double, double, double, double, double, double, - double, double &, double &, double); + double, double &, double &, double); }; diff --git a/src/pair_lj_cut_coul_dsf.cpp b/src/pair_lj_cut_coul_dsf.cpp index 5d95d06ed7..4290586501 100644 --- a/src/pair_lj_cut_coul_dsf.cpp +++ b/src/pair_lj_cut_coul_dsf.cpp @@ -360,7 +360,7 @@ void PairLJCutCoulDSF::write_restart(FILE *fp) fwrite(&epsilon[i][j],sizeof(double),1,fp); fwrite(&sigma[i][j],sizeof(double),1,fp); fwrite(&cut_lj[i][j],sizeof(double),1,fp); - } + } } } diff --git a/src/pair_lj_expand.cpp b/src/pair_lj_expand.cpp index 785733dccc..f2f49c872d 100644 --- a/src/pair_lj_expand.cpp +++ b/src/pair_lj_expand.cpp @@ -282,9 +282,9 @@ double PairLJExpand::init_one(int i, int j) (1.0/3.0 + 2.0*shift1/(4.0*rc1) + shift2/(5.0*rc2))/rc3); ptail_ij = 16.0*MY_PI*all[0]*all[1]*epsilon[i][j] * sig6 * ((1.0/9.0 + 3.0*shift1/(10.0*rc1) + - 3.0*shift2/(11.0*rc2) + shift3/(12.0*rc3))*2.0*sig6/rc9 - + 3.0*shift2/(11.0*rc2) + shift3/(12.0*rc3))*2.0*sig6/rc9 - (1.0/3.0 + 3.0*shift1/(4.0*rc1) + - 3.0*shift2/(5.0*rc2) + shift3/(6.0*rc3))/rc3); + 3.0*shift2/(5.0*rc2) + shift3/(6.0*rc3))/rc3); } return cut[i][j] + shift[i][j]; diff --git a/src/pair_morse.h b/src/pair_morse.h index d1282f8bf1..e7fb9a8cd5 100644 --- a/src/pair_morse.h +++ b/src/pair_morse.h @@ -29,7 +29,7 @@ class PairMorse : public Pair { PairMorse(class LAMMPS *); virtual ~PairMorse(); virtual void compute(int, int); - + void settings(int, char **); void coeff(int, char **); double init_one(int, int); diff --git a/src/pair_zbl.cpp b/src/pair_zbl.cpp index ce6c581ced..d2dbaeae70 100644 --- a/src/pair_zbl.cpp +++ b/src/pair_zbl.cpp @@ -114,15 +114,15 @@ void PairZBL::compute(int eflag, int vflag) jtype = type[j]; if (rsq < cut_globalsq) { - r = sqrt(rsq); + r = sqrt(rsq); fpair = dzbldr(r, itype, jtype); - if (rsq > cut_innersq) { - t = r - cut_inner; - fswitch = t*t * - (sw1[itype][jtype] + sw2[itype][jtype]*t); - fpair += fswitch; - } + if (rsq > cut_innersq) { + t = r - cut_inner; + fswitch = t*t * + (sw1[itype][jtype] + sw2[itype][jtype]*t); + fpair += fswitch; + } fpair *= -1.0/r; f[i][0] += delx*fpair; @@ -136,12 +136,12 @@ void PairZBL::compute(int eflag, int vflag) if (eflag) { evdwl = e_zbl(r, itype, jtype); - evdwl += sw5[itype][jtype]; - if (rsq > cut_innersq) { - eswitch = t*t*t * - (sw3[itype][jtype] + sw4[itype][jtype]*t); - evdwl += eswitch; - } + evdwl += sw5[itype][jtype]; + if (rsq > cut_innersq) { + eswitch = t*t*t * + (sw3[itype][jtype] + sw4[itype][jtype]*t); + evdwl += eswitch; + } } if (evflag) ev_tally(i,j,nlocal,newton_pair, @@ -228,9 +228,9 @@ void PairZBL::coeff(int narg, char **arg) for (int i = ilo; i <= ihi; i++) { for (int j = MAX(jlo,i); j <= jhi; j++) { if (i == j) { - if (z_one != z_two) - error->all(FLERR,"Incorrect args for pair coefficients"); - z[i] = z_one; + if (z_one != z_two) + error->all(FLERR,"Incorrect args for pair coefficients"); + z[i] = z_one; } setflag[i][j] = 1; set_coeff(i, j, z_one, z_two); @@ -385,7 +385,7 @@ double PairZBL::d2zbldr2(double r, int i, int j) { sum_pp += c4*e4*d4aij*d4aij; double result = zzeij*(sum_pp + 2.0*sum_p*rinv + - 2.0*sum*rinv*rinv)*rinv; + 2.0*sum*rinv*rinv)*rinv; return result; } diff --git a/src/rcb.cpp b/src/rcb.cpp index 7ad1e84d4c..2ef3e0c136 100644 --- a/src/rcb.cpp +++ b/src/rcb.cpp @@ -500,8 +500,8 @@ void RCB::compute(int dimension, int n, double **x, double *wt, if (readnumber) { MPI_Recv(&incoming,1,MPI_INT,procpartner,0,world,MPI_STATUS_IGNORE); if (readnumber == 2) { - MPI_Recv(&incoming2,1,MPI_INT,procpartner2,0,world,MPI_STATUS_IGNORE); - incoming += incoming2; + MPI_Recv(&incoming2,1,MPI_INT,procpartner2,0,world,MPI_STATUS_IGNORE); + incoming += incoming2; } } @@ -533,9 +533,9 @@ void RCB::compute(int dimension, int n, double **x, double *wt, keep = outgoing = 0; for (i = 0; i < ndot; i++) { if (dotmark[i] == markactive) - memcpy(&buf[outgoing++],&dots[i],sizeof(Dot)); + memcpy(&buf[outgoing++],&dots[i],sizeof(Dot)); else - memcpy(&dots[keep++],&dots[i],sizeof(Dot)); + memcpy(&dots[keep++],&dots[i],sizeof(Dot)); } // post receives for dots @@ -544,8 +544,8 @@ void RCB::compute(int dimension, int n, double **x, double *wt, MPI_Irecv(&dots[keep],incoming*sizeof(Dot),MPI_CHAR, procpartner,1,world,&request); if (readnumber == 2) { - keep += incoming - incoming2; - MPI_Irecv(&dots[keep],incoming2*sizeof(Dot),MPI_CHAR, + keep += incoming - incoming2; + MPI_Irecv(&dots[keep],incoming2*sizeof(Dot),MPI_CHAR, procpartner2,1,world,&request2); } } @@ -801,15 +801,15 @@ void RCB::compute_old(int dimension, int n, double **x, double *wt, // with "1.0-factor" to force overshoot if (first_iteration && reuse && dim == tree[procmid].dim) { - counters[5]++; - valuehalf = tree[procmid].cut; - if (valuehalf < valuemin || valuehalf > valuemax) - valuehalf = 0.5 * (valuemin + valuemax); + counters[5]++; + valuehalf = tree[procmid].cut; + if (valuehalf < valuemin || valuehalf > valuemax) + valuehalf = 0.5 * (valuemin + valuemax); } else if (wt) - valuehalf = valuemin + (targetlo - wtlo) / - (wttot - wtlo - wthi) * (valuemax - valuemin); + valuehalf = valuemin + (targetlo - wtlo) / + (wttot - wtlo - wthi) * (valuemax - valuemin); else - valuehalf = 0.5 * (valuemin + valuemax); + valuehalf = 0.5 * (valuemin + valuemax); first_iteration = 0; @@ -827,33 +827,33 @@ void RCB::compute_old(int dimension, int n, double **x, double *wt, // save indices of closest dots on either side for (j = 0; j < nlist; j++) { - i = dotlist[j]; - if (dots[i].x[dim] <= valuehalf) { // in lower part - medme.totallo += dots[i].wt; - dotmark[i] = 0; - if (dots[i].x[dim] > medme.valuelo) { // my closest dot - medme.valuelo = dots[i].x[dim]; - medme.wtlo = dots[i].wt; - medme.countlo = 1; - indexlo = i; - } else if (dots[i].x[dim] == medme.valuelo) { // tied for closest - medme.wtlo += dots[i].wt; - medme.countlo++; - } - } - else { // in upper part - medme.totalhi += dots[i].wt; - dotmark[i] = 1; - if (dots[i].x[dim] < medme.valuehi) { // my closest dot - medme.valuehi = dots[i].x[dim]; - medme.wthi = dots[i].wt; - medme.counthi = 1; - indexhi = i; - } else if (dots[i].x[dim] == medme.valuehi) { // tied for closest - medme.wthi += dots[i].wt; - medme.counthi++; - } - } + i = dotlist[j]; + if (dots[i].x[dim] <= valuehalf) { // in lower part + medme.totallo += dots[i].wt; + dotmark[i] = 0; + if (dots[i].x[dim] > medme.valuelo) { // my closest dot + medme.valuelo = dots[i].x[dim]; + medme.wtlo = dots[i].wt; + medme.countlo = 1; + indexlo = i; + } else if (dots[i].x[dim] == medme.valuelo) { // tied for closest + medme.wtlo += dots[i].wt; + medme.countlo++; + } + } + else { // in upper part + medme.totalhi += dots[i].wt; + dotmark[i] = 1; + if (dots[i].x[dim] < medme.valuehi) { // my closest dot + medme.valuehi = dots[i].x[dim]; + medme.wthi = dots[i].wt; + medme.counthi = 1; + indexhi = i; + } else if (dots[i].x[dim] == medme.valuehi) { // tied for closest + medme.wthi += dots[i].wt; + medme.counthi++; + } + } } // combine median data struct across current subset of procs @@ -866,99 +866,99 @@ void RCB::compute_old(int dimension, int n, double **x, double *wt, if (wtlo + med.totallo < targetlo) { // lower half TOO SMALL - wtlo += med.totallo; - valuehalf = med.valuehi; - - if (med.counthi == 1) { // only one dot to move - if (wtlo + med.wthi < targetlo) { // move it, keep iterating - if (me == med.prochi) dotmark[indexhi] = 0; - } - else { // only move if beneficial - if (wtlo + med.wthi - targetlo < targetlo - wtlo) - if (me == med.prochi) dotmark[indexhi] = 0; - break; // all done - } - } - else { // multiple dots to move - breakflag = 0; - wtok = 0.0; - if (medme.valuehi == med.valuehi) wtok = medme.wthi; - if (wtlo + med.wthi >= targetlo) { // all done - MPI_Scan(&wtok,&wtupto,1,MPI_DOUBLE,MPI_SUM,comm); - wtmax = targetlo - wtlo; - if (wtupto > wtmax) wtok = wtok - (wtupto - wtmax); - breakflag = 1; - } // wtok = most I can move - for (j = 0, wtsum = 0.0; j < nlist && wtsum < wtok; j++) { - i = dotlist[j]; - if (dots[i].x[dim] == med.valuehi) { // only move if better - if (wtsum + dots[i].wt - wtok < wtok - wtsum) - dotmark[i] = 0; - wtsum += dots[i].wt; - } - } - if (breakflag) break; // done if moved enough - } - - wtlo += med.wthi; - if (targetlo-wtlo <= tolerance) break; // close enough - - valuemin = med.valuehi; // iterate again - markactive = 1; + wtlo += med.totallo; + valuehalf = med.valuehi; + + if (med.counthi == 1) { // only one dot to move + if (wtlo + med.wthi < targetlo) { // move it, keep iterating + if (me == med.prochi) dotmark[indexhi] = 0; + } + else { // only move if beneficial + if (wtlo + med.wthi - targetlo < targetlo - wtlo) + if (me == med.prochi) dotmark[indexhi] = 0; + break; // all done + } + } + else { // multiple dots to move + breakflag = 0; + wtok = 0.0; + if (medme.valuehi == med.valuehi) wtok = medme.wthi; + if (wtlo + med.wthi >= targetlo) { // all done + MPI_Scan(&wtok,&wtupto,1,MPI_DOUBLE,MPI_SUM,comm); + wtmax = targetlo - wtlo; + if (wtupto > wtmax) wtok = wtok - (wtupto - wtmax); + breakflag = 1; + } // wtok = most I can move + for (j = 0, wtsum = 0.0; j < nlist && wtsum < wtok; j++) { + i = dotlist[j]; + if (dots[i].x[dim] == med.valuehi) { // only move if better + if (wtsum + dots[i].wt - wtok < wtok - wtsum) + dotmark[i] = 0; + wtsum += dots[i].wt; + } + } + if (breakflag) break; // done if moved enough + } + + wtlo += med.wthi; + if (targetlo-wtlo <= tolerance) break; // close enough + + valuemin = med.valuehi; // iterate again + markactive = 1; } else if (wthi + med.totalhi < targethi) { // upper half TOO SMALL - wthi += med.totalhi; - valuehalf = med.valuelo; - - if (med.countlo == 1) { // only one dot to move - if (wthi + med.wtlo < targethi) { // move it, keep iterating - if (me == med.proclo) dotmark[indexlo] = 1; - } - else { // only move if beneficial - if (wthi + med.wtlo - targethi < targethi - wthi) - if (me == med.proclo) dotmark[indexlo] = 1; - break; // all done - } - } - else { // multiple dots to move - breakflag = 0; - wtok = 0.0; - if (medme.valuelo == med.valuelo) wtok = medme.wtlo; - if (wthi + med.wtlo >= targethi) { // all done - MPI_Scan(&wtok,&wtupto,1,MPI_DOUBLE,MPI_SUM,comm); - wtmax = targethi - wthi; - if (wtupto > wtmax) wtok = wtok - (wtupto - wtmax); - breakflag = 1; - } // wtok = most I can move - for (j = 0, wtsum = 0.0; j < nlist && wtsum < wtok; j++) { - i = dotlist[j]; - if (dots[i].x[dim] == med.valuelo) { // only move if better - if (wtsum + dots[i].wt - wtok < wtok - wtsum) - dotmark[i] = 1; - wtsum += dots[i].wt; - } - } - if (breakflag) break; // done if moved enough - } - - wthi += med.wtlo; - if (targethi-wthi <= tolerance) break; // close enough - - valuemax = med.valuelo; // iterate again - markactive = 0; + wthi += med.totalhi; + valuehalf = med.valuelo; + + if (med.countlo == 1) { // only one dot to move + if (wthi + med.wtlo < targethi) { // move it, keep iterating + if (me == med.proclo) dotmark[indexlo] = 1; + } + else { // only move if beneficial + if (wthi + med.wtlo - targethi < targethi - wthi) + if (me == med.proclo) dotmark[indexlo] = 1; + break; // all done + } + } + else { // multiple dots to move + breakflag = 0; + wtok = 0.0; + if (medme.valuelo == med.valuelo) wtok = medme.wtlo; + if (wthi + med.wtlo >= targethi) { // all done + MPI_Scan(&wtok,&wtupto,1,MPI_DOUBLE,MPI_SUM,comm); + wtmax = targethi - wthi; + if (wtupto > wtmax) wtok = wtok - (wtupto - wtmax); + breakflag = 1; + } // wtok = most I can move + for (j = 0, wtsum = 0.0; j < nlist && wtsum < wtok; j++) { + i = dotlist[j]; + if (dots[i].x[dim] == med.valuelo) { // only move if better + if (wtsum + dots[i].wt - wtok < wtok - wtsum) + dotmark[i] = 1; + wtsum += dots[i].wt; + } + } + if (breakflag) break; // done if moved enough + } + + wthi += med.wtlo; + if (targethi-wthi <= tolerance) break; // close enough + + valuemax = med.valuelo; // iterate again + markactive = 0; } else // Goldilocks result: both partitions just right - break; + break; // shrink the active list k = 0; for (j = 0; j < nlist; j++) { - i = dotlist[j]; - if (dotmark[i] == markactive) dotlist[k++] = i; + i = dotlist[j]; + if (dotmark[i] == markactive) dotlist[k++] = i; } nlist = k; } @@ -992,8 +992,8 @@ void RCB::compute_old(int dimension, int n, double **x, double *wt, if (readnumber) { MPI_Recv(&incoming,1,MPI_INT,procpartner,0,world,MPI_STATUS_IGNORE); if (readnumber == 2) { - MPI_Recv(&incoming2,1,MPI_INT,procpartner2,0,world,MPI_STATUS_IGNORE); - incoming += incoming2; + MPI_Recv(&incoming2,1,MPI_INT,procpartner2,0,world,MPI_STATUS_IGNORE); + incoming += incoming2; } } @@ -1025,9 +1025,9 @@ void RCB::compute_old(int dimension, int n, double **x, double *wt, keep = outgoing = 0; for (i = 0; i < ndot; i++) { if (dotmark[i] == markactive) - memcpy(&buf[outgoing++],&dots[i],sizeof(Dot)); + memcpy(&buf[outgoing++],&dots[i],sizeof(Dot)); else - memcpy(&dots[keep++],&dots[i],sizeof(Dot)); + memcpy(&dots[keep++],&dots[i],sizeof(Dot)); } // post receives for dots @@ -1036,8 +1036,8 @@ void RCB::compute_old(int dimension, int n, double **x, double *wt, MPI_Irecv(&dots[keep],incoming*sizeof(Dot),MPI_CHAR, procpartner,1,world,&request); if (readnumber == 2) { - keep += incoming - incoming2; - MPI_Irecv(&dots[keep],incoming2*sizeof(Dot),MPI_CHAR, + keep += incoming - incoming2; + MPI_Irecv(&dots[keep],incoming2*sizeof(Dot),MPI_CHAR, procpartner2,1,world,&request2); } } @@ -1133,7 +1133,7 @@ void box_merge(void *in, void *inout, int *len, MPI_Datatype *dptr) wtlo, wthi = total wt of dot(s) at that position countlo, counthi = total # of dot(s) nearest to cut proclo, prochi = one unique proc who owns a nearest dot - all procs must get same proclo,prochi + all procs must get same proclo,prochi ------------------------------------------------------------------------- */ void median_merge(void *in, void *inout, int *len, MPI_Datatype *dptr) @@ -1266,7 +1266,7 @@ void RCB::check() if (total1 != total2) { if (me == 0) printf("ERROR: Points before RCB = %d, Points after RCB = %d\n", - total1,total2); + total1,total2); } // check that result is load-balanced within log2(P)*max-wt @@ -1302,8 +1302,8 @@ void RCB::check() iflag = 0; for (i = 0; i < ndot; i++) { if (dots[i].x[0] < lo[0] || dots[i].x[0] > hi[0] || - dots[i].x[1] < lo[1] || dots[i].x[1] > hi[1] || - dots[i].x[2] < lo[2] || dots[i].x[2] > hi[2]) + dots[i].x[1] < lo[1] || dots[i].x[1] > hi[1] || + dots[i].x[2] < lo[2] || dots[i].x[2] > hi[2]) iflag++; } if (iflag > 0) @@ -1330,7 +1330,7 @@ void RCB::stats(int flag) if (me == 0) { printf(" Total weight of dots = %g\n",wttot); printf(" Weight on each proc: ave = %g, max = %g, min = %g\n", - wttot/nprocs,wtmax,wtmin); + wttot/nprocs,wtmax,wtmin); } if (flag) { MPI_Barrier(world); diff --git a/src/read_data.cpp b/src/read_data.cpp index 3b93098a6e..bc588051af 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -1644,9 +1644,9 @@ void ReadData::bodies(int firstpass) eof = fgets(&buffer[m],MAXLINE,fp); if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); ncount = atom->count_words(&buffer[m],copy); - if (ncount == 0) - error->one(FLERR,"Too few values in body lines in data file"); - nword += ncount; + if (ncount == 0) + error->one(FLERR,"Too few values in body lines in data file"); + nword += ncount; m += strlen(&buffer[m]); onebody++; } @@ -1658,9 +1658,9 @@ void ReadData::bodies(int firstpass) eof = fgets(&buffer[m],MAXLINE,fp); if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); ncount = atom->count_words(&buffer[m],copy); - if (ncount == 0) - error->one(FLERR,"Too few values in body lines in data file"); - nword += ncount; + if (ncount == 0) + error->one(FLERR,"Too few values in body lines in data file"); + nword += ncount; m += strlen(&buffer[m]); onebody++; } diff --git a/src/region_cylinder.cpp b/src/region_cylinder.cpp index 3f2715ea3e..959992f77b 100644 --- a/src/region_cylinder.cpp +++ b/src/region_cylinder.cpp @@ -399,13 +399,13 @@ int RegCylinder::surface_exterior(double *x, double cutoff) yp = c1 + del1*radius/r; zp = c2 + del2*radius/r; crad = 2.0*radius; - varflag = 1; + varflag = 1; } else { yp = x[1]; zp = x[2]; } if (x[0] < lo) xp = lo; - else if (x[0] > hi) xp = hi; + else if (x[0] > hi) xp = hi; else xp = x[0]; } @@ -493,7 +493,7 @@ int RegCylinder::surface_exterior(double *x, double cutoff) xp = c1 + del1*radius/r; zp = c2 + del2*radius/r; crad = 2.0*radius; - varflag = 1; + varflag = 1; } else { xp = x[0]; zp = x[2]; @@ -587,7 +587,7 @@ int RegCylinder::surface_exterior(double *x, double cutoff) xp = c1 + del1*radius/r; yp = c2 + del2*radius/r; crad = 2.0*radius; - varflag = 1; + varflag = 1; } else { xp = x[0]; yp = x[1]; diff --git a/src/region_union.cpp b/src/region_union.cpp index b78ee5580a..abb6f854e3 100644 --- a/src/region_union.cpp +++ b/src/region_union.cpp @@ -183,7 +183,7 @@ int RegUnion::surface_interior(double *x, double cutoff) contact[n].dely = regions[iregion]->contact[m].dely; contact[n].delz = regions[iregion]->contact[m].delz; contact[n].iwall = regions[iregion]->contact[m].iwall + walloffset; - contact[n].varflag = regions[iregion]->contact[m].varflag; + contact[n].varflag = regions[iregion]->contact[m].varflag; n++; } } diff --git a/src/set.cpp b/src/set.cpp index 11b91df4c4..0565dafb7d 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -780,9 +780,9 @@ void Set::set(int keyword) else if (keyword == DENSITY) { if (dvalue <= 0.0) error->one(FLERR,"Invalid density in set command"); if (atom->radius_flag && atom->radius[i] > 0.0) - if (discflag) + if (discflag) atom->rmass[i] = MY_PI*atom->radius[i]*atom->radius[i] * dvalue; - else + else atom->rmass[i] = 4.0*MY_PI/3.0 * atom->radius[i]*atom->radius[i]*atom->radius[i] * dvalue; else if (atom->ellipsoid_flag && atom->ellipsoid[i] >= 0) { @@ -791,7 +791,7 @@ void Set::set(int keyword) // options (fix nve/asphere, fix nh/asphere) are also implemented // if (discflag) // atom->rmass[i] = MY_PI*shape[0]*shape[1] * dvalue; - // else + // else atom->rmass[i] = 4.0*MY_PI/3.0 * shape[0]*shape[1]*shape[2] * dvalue; } else if (atom->line_flag && atom->line[i] >= 0) { double length = avec_line->bonus[atom->line[i]].length; @@ -837,7 +837,7 @@ void Set::set(int keyword) if (domain->dimension == 2 && (xvalue != 0.0 || yvalue != 0.0)) error->one(FLERR,"Cannot set quaternion with xy components " "for 2d system"); - + double theta2 = MY_PI2 * wvalue/180.0; double sintheta2 = sin(theta2); quat[0] = cos(theta2); @@ -995,8 +995,8 @@ void Set::setrandom(int keyword) quat = avec_ellipsoid->bonus[atom->ellipsoid[i]].quat; else if (avec_tri && atom->tri[i] >= 0) quat = avec_tri->bonus[atom->tri[i]].quat; - else if (avec_body && atom->body[i] >= 0) - quat = avec_body->bonus[atom->body[i]].quat; + else if (avec_body && atom->body[i] >= 0) + quat = avec_body->bonus[atom->body[i]].quat; else error->one(FLERR,"Cannot set quaternion for atom that has none"); @@ -1019,8 +1019,8 @@ void Set::setrandom(int keyword) if (select[i]) { if (avec_ellipsoid && atom->ellipsoid[i] >= 0) quat = avec_ellipsoid->bonus[atom->ellipsoid[i]].quat; - else if (avec_body && atom->body[i] >= 0) - quat = avec_body->bonus[atom->body[i]].quat; + else if (avec_body && atom->body[i] >= 0) + quat = avec_body->bonus[atom->body[i]].quat; else error->one(FLERR,"Cannot set quaternion for atom that has none"); @@ -1040,11 +1040,11 @@ void Set::setrandom(int keyword) int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { if (select[i]) { - if (atom->line[i] < 0) - error->one(FLERR,"Cannot set theta for atom that is not a line"); - random->reset(seed,x[i]); - avec_line->bonus[atom->line[i]].theta = MY_2PI*random->uniform(); - count++; + if (atom->line[i] < 0) + error->one(FLERR,"Cannot set theta for atom that is not a line"); + random->reset(seed,x[i]); + avec_line->bonus[atom->line[i]].theta = MY_2PI*random->uniform(); + count++; } } } diff --git a/src/variable.cpp b/src/variable.cpp index 399fddeee1..744762dcd4 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -889,7 +889,7 @@ char *Variable::retrieve(char *name) sprintf(data[ivar][0],"%.15g",dvalue[ivar]); str = data[ivar][0]; } else if (style[ivar] == ATOM || style[ivar] == ATOMFILE || - style[ivar] == VECTOR) return NULL; + style[ivar] == VECTOR) return NULL; eval_in_progress[ivar] = 0; @@ -1279,11 +1279,11 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) print_var_error(FLERR,"Variable evaluation before " "simulation box is defined",ivar); - // uppercase used to force access of - // global vector vs global scalar, and global array vs global vector + // uppercase used to force access of + // global vector vs global scalar, and global array vs global vector - int lowercase = 1; - if (word[0] == 'C') lowercase = 0; + int lowercase = 1; + if (word[0] == 'C') lowercase = 0; int icompute = modify->find_compute(word+2); if (icompute < 0) @@ -1396,7 +1396,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) } else argstack[nargstack++] = value1; // c_ID = vector from global vector, lowercase or uppercase - + } else if (nbracket == 0 && compute->vector_flag) { if (tree == NULL) @@ -1428,7 +1428,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) treestack[ntreestack++] = newtree; // c_ID[i] = vector from global array, lowercase or uppercase - + } else if (nbracket == 1 && compute->array_flag) { if (tree == NULL) @@ -1576,11 +1576,11 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (domain->box_exist == 0) print_var_error(FLERR,"Variable evaluation before simulation box is defined",ivar); - // uppercase used to force access of - // global vector vs global scalar, and global array vs global vector + // uppercase used to force access of + // global vector vs global scalar, and global array vs global vector - int lowercase = 1; - if (word[0] == 'F') lowercase = 0; + int lowercase = 1; + if (word[0] == 'F') lowercase = 0; int ifix = modify->find_fix(word+2); if (ifix < 0) { @@ -1686,11 +1686,11 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (fix->size_vector == 0) print_var_error(FLERR,"Variable formula fix vector is zero length",ivar); - int nvec = fix->size_vector; - double *vec; - memory->create(vec,nvec,"variable:values"); - for (int m = 0; m < nvec; m++) - vec[m] = fix->compute_vector(m); + int nvec = fix->size_vector; + double *vec; + memory->create(vec,nvec,"variable:values"); + for (int m = 0; m < nvec; m++) + vec[m] = fix->compute_vector(m); Tree *newtree = new Tree(); newtree->type = VECTORARRAY; @@ -1917,7 +1917,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) // v_name = vector from vector-style variable // evaluate the vector-style variable, put result in newtree - } else if (nbracket == 0 && style[ivar] == VECTOR) { + } else if (nbracket == 0 && style[ivar] == VECTOR) { if (tree == NULL) print_var_error(FLERR,"Vector-style variable in " @@ -1926,18 +1926,18 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) print_var_error(FLERR,"Vector-style variable in " "atom-style variable formula",ivar); - double *vec; - int nvec = compute_vector(ivar,&vec); + double *vec; + int nvec = compute_vector(ivar,&vec); - Tree *newtree = new Tree(); - newtree->type = VECTORARRAY; - newtree->array = vec; - newtree->nvector = nvec; - newtree->nstride = 1; - newtree->selfalloc = 0; - newtree->first = newtree->second = NULL; - newtree->nextra = 0; - treestack[ntreestack++] = newtree; + Tree *newtree = new Tree(); + newtree->type = VECTORARRAY; + newtree->array = vec; + newtree->nvector = nvec; + newtree->nstride = 1; + newtree->selfalloc = 0; + newtree->first = newtree->second = NULL; + newtree->nextra = 0; + treestack[ntreestack++] = newtree; // v_name[N] = scalar from atom-style variable // compute the per-atom variable in result @@ -1964,11 +1964,11 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) } else if (nbracket && style[ivar] == VECTOR) { - double *vec; - int nvec = compute_vector(ivar,&vec); - if (index <= 0 || index > nvec) - print_var_error(FLERR,"Invalid index into vector-style variable",ivar); - int m = index; // convert from tagint to int + double *vec; + int nvec = compute_vector(ivar,&vec); + if (index <= 0 || index > nvec) + print_var_error(FLERR,"Invalid index into vector-style variable",ivar); + int m = index; // convert from tagint to int if (tree) { Tree *newtree = new Tree(); @@ -2661,9 +2661,9 @@ double Variable::collapse_tree(Tree *tree) double delta = ivalue1*(ivalue3-1.0)/ivalue2; int count = 0; while (update->ntimestep >= tree->value) { - tree->value += delta; - count++; - if (count % ivalue2 == 0) delta *= ivalue3; + tree->value += delta; + count++; + if (count % ivalue2 == 0) delta *= ivalue3; } } tree->value = ceil(tree->value); @@ -2697,7 +2697,7 @@ double Variable::collapse_tree(Tree *tree) int ivalue6 = static_cast<int> (collapse_tree(tree->extra[3])); if (tree->first->type != VALUE || tree->second->type != VALUE || tree->extra[0]->type != VALUE || tree->extra[1]->type != VALUE || - tree->extra[2]->type != VALUE || tree->extra[3]->type != VALUE) + tree->extra[2]->type != VALUE || tree->extra[3]->type != VALUE) return 0.0; tree->type = VALUE; if (ivalue1 < 0 || ivalue2 < 0 || ivalue3 <= 0 || ivalue1 > ivalue2) @@ -2998,9 +2998,9 @@ double Variable::eval_tree(Tree *tree, int i) double delta = ivalue1*(ivalue3-1.0)/ivalue2; int count = 0; while (update->ntimestep >= arg) { - arg += delta; - count++; - if (count % ivalue2 == 0) delta *= ivalue3; + arg += delta; + count++; + if (count % ivalue2 == 0) delta *= ivalue3; } } arg = ceil(arg); @@ -3534,13 +3534,13 @@ int Variable::math_function(char *word, char *contents, Tree **tree, if (update->ntimestep < ivalue1) value = ivalue1; else { value = ivalue1; - double delta = ivalue1*(ivalue3-1.0)/ivalue2; - int count = 0; + double delta = ivalue1*(ivalue3-1.0)/ivalue2; + int count = 0; while (update->ntimestep >= value) { - value += delta; - count++; - if (count % ivalue2 == 0) delta *= ivalue3; - } + value += delta; + count++; + if (count % ivalue2 == 0) delta *= ivalue3; + } } argstack[nargstack++] = ceil(value); } @@ -3581,7 +3581,7 @@ int Variable::math_function(char *word, char *contents, Tree **tree, if (ivalue4 < 0 || ivalue5 < 0 || ivalue6 <= 0 || ivalue4 > ivalue5) error->one(FLERR,"Invalid math function in variable formula"); if (ivalue4 < ivalue1 || ivalue5 > ivalue2) - error->one(FLERR,"Invalid math function in variable formula"); + error->one(FLERR,"Invalid math function in variable formula"); bigint istep; if (update->ntimestep < ivalue1) istep = ivalue1; else if (update->ntimestep < ivalue2) { @@ -4117,7 +4117,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree, double one; double *vec = vecs[ivar].values; for (int i = 0; i < nvec; i++) { - one = vec[i]; + one = vec[i]; if (method == SUM) value += one; else if (method == XMIN) value = MIN(value,one); else if (method == XMAX) value = MAX(value,one); -- GitLab