Merge branch 'develop' into compute_temp_profile_dof

This commit is contained in:
Axel Kohlmeyer
2022-04-22 22:16:06 -04:00
9013 changed files with 726380 additions and 704622 deletions

32
src/.clang-format Normal file
View File

@ -0,0 +1,32 @@
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -1
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: None
AllowShortLoopsOnASingleLine: true
BraceWrapping:
AfterFunction: true
BreakBeforeBraces: Custom
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
ColumnLimit: 100
IndentCaseLabels: true
IndentWidth: 2
NamespaceIndentation: Inner
ObjCBlockIndentWidth: 2
PenaltyBreakAssignment: 4
ReflowComments: false
SpaceAfterCStyleCast: true
SpacesBeforeTrailingComments: 4
SpacesInContainerLiterals: false
Standard: Cpp11
TabWidth: 2
UseTab: Never
...

295
src/.gitignore vendored
View File

@ -1,6 +1,7 @@
/Makefile.package
/Makefile.package.settings
/MAKE/MINE
/ADIOS/Makefile.lammps
/Make.py.last
/lmp_*
@ -27,11 +28,36 @@
/*_ssa.h
/*_ssa.cpp
!accelerator_kokkos.h
!accelerator_omp.h
/fix_mdi_engine.cpp
/fix_mdi_engine.h
/library_mdi.cpp
/library_mdi.h
/mdi_engine.cpp
/mdi_engine.h
/fix_brownian*.cpp
/fix_brownian*.h
/fix_propel_self.cpp
/fix_propel_self.h
/kim_*.cpp
/kim_*.h
/pair_kim.cpp
/pair_kim.h
/pair_pace.cpp
/pair_pace.h
/fix_polarize*.cpp
/fix_polarize*.h
/*_dielectric.cpp
/*_dielectric.h
/compute_efield_atom.cpp
/compute_efield_atom.h
/superpose3d.h
/kokkos.cpp
@ -48,13 +74,14 @@
/meam*.h
/meam*.cpp
/pair_meamc.cpp
/pair_meamc.h
/pair_meam.cpp
/pair_meam.h
/compute_mliap.cpp
/compute_mliap.h
/mliap_*.cpp
/mliap_*.h
/mliap_model_python_couple.pyx
/pair_mliap.cpp
/pair_mliap.h
@ -72,6 +99,11 @@
/fix_pafi*.cpp
/fix_pafi*.h
/pair_rann.cpp
/pair_rann.h
/rann_*.cpp
/rann_*.h
/compute_test_nbl.cpp
/compute_test_nbl.h
/pair_multi_lucy.cpp
@ -172,6 +204,9 @@
/pair_lj_charmmfsw_coul_long.cpp
/pair_lj_charmmfsw_coul_long.h
/plugin.cpp
/plugin.h
/atom_vec_spin.cpp
/atom_vec_spin.h
/compute_spin.cpp
@ -219,6 +254,83 @@
/pair_mesont_tpm.cpp
/pair_mesont_tpm.h
/atom_vec_bpm_sphere.cpp
/atom_vec_bpm_sphere.h
/bond_bpm.cpp
/bond_bpm.h
/bond_bpm_rotational.cpp
/bond_bpm_rotational.h
/bond_bpm_spring.cpp
/bond_bpm_spring.h
/compute_nbond_atom.cpp
/compute_nbond_atom.h
/fix_nve_bpm_sphere.cpp
/fix_nve_bpm_sphere.h
/pair_bpm_spring.cpp
/pair_bpm_spring.h
/compute_adf.cpp
/compute_adf.h
/compute_contact_atom.cpp
/compute_contact_atom.h
/compute_hexorder_atom.cpp
/compute_hexorder_atom.h
/dump_dcd.cpp
/dump_dcd.h
/fix_controller.cpp
/fix_controller.h
/fix_drag.cpp
/fix_drag.h
/fix_numdiff.cpp
/fix_numdiff.h
/fix_numdiff_virial.cpp
/fix_numdiff_virial.h
/fix_spring_rg.cpp
/fix_spring_rg.h
/fix_temp_csld.cpp
/fix_temp_csld.h
/fix_temp_csvr.cpp
/fix_temp_csvr.h
/fix_tmd.cpp
/fix_tmd.h
/pair_beck.cpp
/pair_beck.h
/pair_born_coul_dsf.cpp
/pair_born_coul_dsf.h
/pair_born_coul_wolf.cpp
/pair_born_coul_wolf.h
/pair_coul_cut_global.cpp
/pair_coul_cut_global.h
/pair_coul_streitz.cpp
/pair_coul_streitz.h
/pair_gauss.cpp
/pair_gauss.h
/pair_lj96_cut.cpp
/pair_lj96_cut.h
/pair_lj_cubic.cpp
/pair_lj_cubic.h
/pair_lj_cubic_const.h
/pair_lj_cut_coul_debye.cpp
/pair_lj_cut_coul_debye.h
/pair_lj_cut_coul_dsf.cpp
/pair_lj_cut_coul_dsf.h
/pair_lj_cut_coul_wolf.cpp
/pair_lj_cut_coul_wolf.h
/pair_lj_gromacs.cpp
/pair_lj_gromacs.h
/pair_lj_gromacs_coul_gromacs.cpp
/pair_lj_gromacs_coul_gromacs.h
/pair_lj_relres.cpp
/pair_lj_relres.h
/pair_lj_smooth.cpp
/pair_lj_smooth.h
/pair_lj_smooth_linear.cpp
/pair_lj_smooth_linear.h
/pair_mie_cut.cpp
/pair_mie_cut.h
/pair_ufm.cpp
/pair_ufm.h
/angle_cg_cmm.cpp
/angle_cg_cmm.h
/angle_charmm.cpp
@ -273,8 +385,6 @@
/atom_vec_dpd.h
/atom_vec_electron.cpp
/atom_vec_electron.h
/atom_vec_ellipsoid.cpp
/atom_vec_ellipsoid.h
/atom_vec_full.cpp
/atom_vec_full.h
/atom_vec_full_hars.cpp
@ -283,6 +393,8 @@
/atom_vec_granular.h
/atom_vec_molecular.cpp
/atom_vec_molecular.h
/atom_vec_oxdna.cpp
/atom_vec_oxdna.h
/atom_vec_peri.cpp
/atom_vec_peri.h
/atom_vec_template.cpp
@ -299,6 +411,8 @@
/bond_fene.h
/bond_fene_expand.cpp
/bond_fene_expand.h
/bond_fene_nm.cpp
/bond_fene_nm.h
/bond_gaussian.cpp
/bond_gaussian.h
/bond_gromos.cpp
@ -333,6 +447,8 @@
/commgrid.h
/compute_ackland_atom.cpp
/compute_ackland_atom.h
/compute_ave_sphere_atom.cpp
/compute_ave_sphere_atom.h
/compute_basal_atom.cpp
/compute_basal_atom.h
/compute_body_local.cpp
@ -355,8 +471,12 @@
/compute_erotate_rigid.h
/compute_event_displace.cpp
/compute_event_displace.h
/compute_fabric.cpp
/compute_fabric.h
/compute_fep.cpp
/compute_fep.h
/compute_fep_ta.cpp
/compute_fep_ta.h
/compute_force_tally.cpp
/compute_force_tally.h
/compute_gyration_shape.cpp
@ -389,8 +509,6 @@
/compute_plasticity_atom.h
/compute_pressure_bocs.cpp
/compute_pressure_bocs.h
/compute_pressure_cylinder.cpp
/compute_pressure_cylinder.h
/compute_pressure_grem.cpp
/compute_pressure_grem.h
/compute_ptm_atom.cpp
@ -401,10 +519,16 @@
/compute_smd_triangle_vertices.h
/compute_spec_atom.cpp
/compute_spec_atom.h
/compute_stress_cartesian.cpp
/compute_stress_cartesian.h
/compute_stress_cylinder.cpp
/compute_stress_cylinder.h
/compute_stress_mop.cpp
/compute_stress_mop.h
/compute_stress_mop_profile.cpp
/compute_stress_mop_profile.h
/compute_stress_spherical.cpp
/compute_stress_spherical.h
/compute_stress_tally.cpp
/compute_stress_tally.h
/compute_temp_asphere.cpp
@ -437,8 +561,6 @@
/dihedral_harmonic.h
/dihedral_helix.cpp
/dihedral_helix.h
/dihedral_hybrid.cpp
/dihedral_hybrid.h
/dihedral_multi_harmonic.cpp
/dihedral_multi_harmonic.h
/dihedral_nharmonic.cpp
@ -495,6 +617,8 @@
/dump_xyz_mpiio.h
/dump_xyz_zstd.cpp
/dump_xyz_zstd.h
/dump_yaml.cpp
/dump_yaml.h
/dynamical_matrix.cpp
/dynamical_matrix.h
/ewald.cpp
@ -515,6 +639,8 @@
/fft3d_wrap.h
/fix_accelerate_cos.cpp
/fix_accelerate_cos.h
/fix_acks2_reaxff.cpp
/fix_acks2_reaxff.h
/fix_adapt_fep.cpp
/fix_adapt_fep.h
/fix_addtorque.cpp
@ -537,16 +663,14 @@
/fix_bond_react.h
/fix_bond_swap.cpp
/fix_bond_swap.h
/fix_charge_regulation.cpp
/fix_charge_regulation.h
/fix_client_md.cpp
/fix_client_md.h
/fix_cmap.cpp
/fix_cmap.h
/fix_deposit.cpp
/fix_deposit.h
/fix_dpd_energy.cpp
/fix_dpd_energy.h
/fix_efield.cpp
/fix_efield.h
/fix_electron_stopping.cpp
/fix_electron_stopping.h
/fix_electron_stopping_fit.cpp
@ -555,8 +679,6 @@
/fix_eos_cv.h
/fix_eos_table.cpp
/fix_eos_table.h
/fix_evaporate.cpp
/fix_evaporate.h
/fix_ffl.cpp
/fix_ffl.h
/fix_filter_corotate.cpp
@ -693,22 +815,20 @@
/fix_poems.h
/fix_pour.cpp
/fix_pour.h
/fix_propel_self.cpp
/fix_propel_self.h
/fix_qeq_comb.cpp
/fix_qeq_comb.h
/fix_qeq_reax.cpp
/fix_qeq_fire.cpp
/fix_qeq_fire.h
/fix_qeq_reax.h
/fix_qeq_reaxff.cpp
/fix_qeq_reaxff.h
/fix_qmmm.cpp
/fix_qmmm.h
/fix_reaxc.cpp
/fix_reaxc.h
/fix_reaxc_bonds.cpp
/fix_reaxc_bonds.h
/fix_reaxc_species.cpp
/fix_reaxc_species.h
/fix_reaxff.cpp
/fix_reaxff.h
/fix_reaxff_bonds.cpp
/fix_reaxff_bonds.h
/fix_reaxff_species.cpp
/fix_reaxff_species.h
/fix_rhok.cpp
/fix_rhok.h
/fix_rigid.cpp
@ -760,14 +880,10 @@
/fix_tgnpt_drude.h
/fix_tgnvt_drude.cpp
/fix_tgnvt_drude.h
/fix_thermal_conductivity.cpp
/fix_thermal_conductivity.h
/fix_ti_rs.cpp
/fix_ti_rs.h
/fix_ti_spring.cpp
/fix_ti_spring.h
/fix_ttm.cpp
/fix_ttm.h
/fix_tune_kspace.cpp
/fix_tune_kspace.h
/fix_wall_body_polygon.cpp
@ -793,10 +909,10 @@
/fix_widom.cpp
/fix_widom.h
/gpu_extra.h
/gridcomm.cpp
/gridcomm.h
/group_ndx.cpp
/group_ndx.h
/gz_file_writer.cpp
/gz_file_writer.h
/ndx_group.cpp
/ndx_group.h
/hyper.cpp
@ -817,14 +933,13 @@
/improper_fourier.h
/improper_harmonic.cpp
/improper_harmonic.h
/improper_hybrid.cpp
/improper_hybrid.h
/improper_inversion_harmonic.cpp
/improper_inversion_harmonic.h
/improper_ring.cpp
/improper_ring.h
/improper_umbrella.cpp
/improper_umbrella.h
/interlayer_taper.h
/kissfft.h
/lj_sdk_common.h
/math_complex.h
@ -839,7 +954,8 @@
/msm_cg.h
/neb.cpp
/neb.h
/netcdf_units.cpp
/netcdf_units.h
/pair_adp.cpp
/pair_adp.h
/pair_agni.cpp
@ -900,6 +1016,8 @@
/pair_cosine_squared.h
/pair_coul_diel.cpp
/pair_coul_diel.h
/pair_coul_exclude.cpp
/pair_coul_exclude.h
/pair_coul_long.cpp
/pair_coul_long.h
/pair_coul_msm.cpp
@ -916,8 +1034,6 @@
/pair_dipole_cut.h
/pair_dipole_sf.cpp
/pair_dipole_sf.h
/pair_dpd_mt.cpp
/pair_dpd_mt.h
/pair_dsmc.cpp
/pair_dsmc.h
/pair_e3b.cpp
@ -971,8 +1087,12 @@
/pair_hbond_dreiding_lj.h
/pair_hbond_dreiding_morse.cpp
/pair_hbond_dreiding_morse.h
/pair_hdnnp.cpp
/pair_hdnnp.h
/pair_ilp_graphene_hbn.cpp
/pair_ilp_graphene_hbn.h
/pair_ilp_tmd.cpp
/pair_ilp_tmd.h
/pair_kolmogorov_crespi_full.cpp
/pair_kolmogorov_crespi_full.h
/pair_kolmogorov_crespi_z.cpp
@ -1079,6 +1199,8 @@
/pair_nm_cut_coul_cut.h
/pair_nm_cut_coul_long.cpp
/pair_nm_cut_coul_long.h
/pair_nm_cut_split.cpp
/pair_nm_cut_split.h
/pair_oxdna_*.cpp
/pair_oxdna_*.h
/pair_oxdna2_*.cpp
@ -1086,6 +1208,8 @@
/pair_oxrna2_*.cpp
/pair_oxrna2_*.h
/mf_oxdna.h
/pair_peri.cpp
/pair_peri.h
/pair_peri_eps.cpp
/pair_peri_eps.h
/pair_peri_lps.cpp
@ -1096,12 +1220,14 @@
/pair_peri_ves.h
/pair_quip.cpp
/pair_quip.h
/pair_reaxc.cpp
/pair_reaxc.h
/pair_reaxff.cpp
/pair_reaxff.h
/pair_rebo.cpp
/pair_rebo.h
/pair_resquared.cpp
/pair_resquared.h
/pair_saip_metal.cpp
/pair_saip_metal.h
/pair_sdpd_taitwater_isothermal.cpp
/pair_sdpd_taitwater_isothermal.h
/pair_sph_heatconduction.cpp
@ -1118,6 +1244,8 @@
/pair_sph_taitwater_morris.h
/pair_sw.cpp
/pair_sw.h
/pair_sw_mod.cpp
/pair_sw_mod.h
/pair_tersoff.cpp
/pair_tersoff.h
/pair_tersoff_mod.cpp
@ -1134,6 +1262,8 @@
/pair_tip4p_long.h
/pair_tip4p_long_soft.cpp
/pair_tip4p_long_soft.h
/pair_tracker.h
/pair_tracker.cpp
/pair_tri_lj.cpp
/pair_tri_lj.h
/pair_yukawa_colloid.cpp
@ -1171,6 +1301,7 @@
/python_impl.cpp
/python_impl.h
/python_compat.h
/python_utils.h
/fix_python_move.cpp
/fix_python_move.h
/fix_python_invoke.cpp
@ -1181,50 +1312,27 @@
/reader_adios.h
/reader_molfile.cpp
/reader_molfile.h
/reaxc_allocate.cpp
/reaxc_allocate.h
/reaxc_basic_comm.cpp
/reaxc_basic_comm.h
/reaxc_bond_orders.cpp
/reaxc_bond_orders.h
/reaxc_bonds.cpp
/reaxc_bonds.h
/reaxc_control.cpp
/reaxc_control.h
/reaxc_defs.h
/reaxc_ffield.cpp
/reaxc_ffield.h
/reaxc_forces.cpp
/reaxc_forces.h
/reaxc_hydrogen_bonds.cpp
/reaxc_hydrogen_bonds.h
/reaxc_init_md.cpp
/reaxc_init_md.h
/reaxc_io_tools.cpp
/reaxc_io_tools.h
/reaxc_list.cpp
/reaxc_list.h
/reaxc_lookup.cpp
/reaxc_lookup.h
/reaxc_multi_body.cpp
/reaxc_multi_body.h
/reaxc_nonbonded.cpp
/reaxc_nonbonded.h
/reaxc_reset_tools.cpp
/reaxc_reset_tools.h
/reaxc_system_props.cpp
/reaxc_system_props.h
/reaxc_tool_box.cpp
/reaxc_tool_box.h
/reaxc_torsion_angles.cpp
/reaxc_torsion_angles.h
/reaxc_traj.cpp
/reaxc_traj.h
/reaxc_types.h
/reaxc_valence_angles.cpp
/reaxc_valence_angles.h
/reaxc_vector.cpp
/reaxc_vector.h
/reaxff_allocate.cpp
/reaxff_bond_orders.cpp
/reaxff_bonds.cpp
/reaxff_control.cpp
/reaxff_ffield.cpp
/reaxff_forces.cpp
/reaxff_hydrogen_bonds.cpp
/reaxff_init_md.cpp
/reaxff_list.cpp
/reaxff_lookup.cpp
/reaxff_multi_body.cpp
/reaxff_nonbonded.cpp
/reaxff_reset_tools.cpp
/reaxff_tool_box.cpp
/reaxff_torsion_angles.cpp
/reaxff_valence_angles.cpp
/reaxff_api.h
/reaxff_defs.h
/reaxff_inline.h
/reaxff_omp.h
/reaxff_types.h
/remap.cpp
/remap.h
/remap_wrap.cpp
@ -1258,10 +1366,10 @@
/thr_data.h
/verlet_split.cpp
/verlet_split.h
/write_dump.cpp
/write_dump.h
/xdr_compat.cpp
/xdr_compat.h
/zstd_file_writer.cpp
/zstd_file_writer.h
/atom_vec_smd.cpp
/atom_vec_smd.h
@ -1327,6 +1435,8 @@
/fix_drude_transform.h
/fix_langevin_drude.cpp
/fix_langevin_drude.h
/fix_mol_swap.cpp
/fix_mol_swap.h
/fix_pimd.cpp
/fix_pimd.h
/fix_qbmsst.cpp
@ -1355,6 +1465,10 @@
/fix_srp.h
/fix_tfmc.cpp
/fix_tfmc.h
/fix_ttm.cpp
/fix_ttm.h
/fix_ttm_grid.cpp
/fix_ttm_grid.h
/fix_ttm_mod.cpp
/fix_ttm_mod.h
/pair_born_coul_long_cs.cpp
@ -1393,12 +1507,20 @@
/pair_thole.h
/pair_buck_mdf.cpp
/pair_buck_mdf.h
/pair_dpd_conservative.cpp
/pair_dpd_conservative.h
/pair_dpd.cpp
/pair_dpd.h
/pair_dpd_tstat.cpp
/pair_dpd_tstat.h
/pair_dpd_ext.cpp
/pair_dpd_ext.h
/pair_dpd_ext_tstat.cpp
/pair_dpd_ext_tstat.h
/pair_dpd_fdt.cpp
/pair_dpd_fdt.h
/pair_dpd_fdt_energy.cpp
/pair_dpd_fdt_energy.h
/pair_harmonic_cut.cpp
/pair_harmonic_cut.h
/pair_lennard_mdf.cpp
/pair_lennard_mdf.h
/pair_lj_cut_coul_long_cs.cpp
@ -1415,5 +1537,4 @@
/pair_smtbq.h
/pair_vashishta*.cpp
/pair_vashishta*.h
/zstd_file_writer.cpp
/zstd_file_writer.h

View File

@ -72,7 +72,7 @@ adios_SYSLIB=${ADIOS2_LIB}
sed -i -e '/^include.*ADIOS.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs
sed -i -e '4 i \
include ../USER-ADIOS/Makefile.lammps
include ../ADIOS/Makefile.lammps
' ../Makefile.package.settings
fi
fi

View File

@ -8,7 +8,7 @@ Configure LAMMPS with CMake
ADIOS2_DIR
to the ADIOS 2.x installation path
b. use the cmake option
-D PKG_USER-ADIOS=yes
-D PKG_ADIOS=yes
The person who created this package is Norbert Podhorszki (Oak Ridge National Laboratory);
If you need help, please submit a ticket at the OLCF ticket user support mentioning his name in the ticket.

39
src/ADIOS/adios_common.h Normal file
View File

@ -0,0 +1,39 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
Contributed by Norbert Podhorszki (Oak Ridge National Laboratory)
------------------------------------------------------------------------- */
#ifndef LMP_ADIOS_COMMON_H
#define LMP_ADIOS_COMMON_H
// common definitions for all ADIOS package classes
static const char default_config[] = "<?xml version=\"1.0\"?>\n"
"<adios-config>\n"
" <io name=\"atom\">\n"
" <engine type=\"BP4\">\n"
" <parameter key=\"substreams\" value=\"1\"/>\n"
" </engine>\n"
" </io>\n"
" <io name=\"custom\">\n"
" <engine type=\"BP4\">\n"
" <parameter key=\"substreams\" value=\"1\"/>\n"
" </engine>\n"
" </io>\n"
" <io name=\"read_dump\">\n"
" <engine type=\"BP4\">\n"
" </engine>\n"
" </io>\n"
"</adios-config>\n";
#endif

View File

@ -0,0 +1,316 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Norbert Podhorszki (ORNL)
------------------------------------------------------------------------- */
#include "dump_atom_adios.h"
#include "atom.h"
#include "domain.h"
#include "error.h"
#include "group.h"
#include "memory.h"
#include "universe.h"
#include "update.h"
#include <cstring>
#include "adios2.h"
#include "adios_common.h"
using namespace LAMMPS_NS;
namespace LAMMPS_NS {
class DumpAtomADIOSInternal {
public:
DumpAtomADIOSInternal(){};
~DumpAtomADIOSInternal() = default;
// name of adios group, referrable in adios2_config.xml
const std::string ioName = "atom";
adios2::ADIOS *ad = nullptr; // adios object
adios2::IO io; // adios group of variables and attributes in this dump
adios2::Engine fh; // adios file/stream handle object
// one ADIOS output variable we need to change every step
adios2::Variable<double> varAtoms;
};
} // namespace LAMMPS_NS
/* ---------------------------------------------------------------------- */
DumpAtomADIOS::DumpAtomADIOS(LAMMPS *lmp, int narg, char **arg) : DumpAtom(lmp, narg, arg)
{
// create a default adios2_config.xml if it doesn't exist yet.
FILE *cfgfp = fopen("adios2_config.xml", "r");
if (!cfgfp) {
cfgfp = fopen("adios2_config.xml", "w");
if (cfgfp) fputs(default_config, cfgfp);
}
if (cfgfp) fclose(cfgfp);
internal = new DumpAtomADIOSInternal();
try {
internal->ad = new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
} catch (std::ios_base::failure &e) {
error->all(FLERR, "ADIOS initialization failed with error: {}", e.what());
}
}
/* ---------------------------------------------------------------------- */
DumpAtomADIOS::~DumpAtomADIOS()
{
if (internal->fh) internal->fh.Close();
delete internal->ad;
delete internal;
}
/* ---------------------------------------------------------------------- */
void DumpAtomADIOS::openfile()
{
if (multifile) {
// if one file per timestep, replace '*' with current timestep
auto filecurrent = utils::star_subst(filename, update->ntimestep, padflag);
internal->fh = internal->io.Open(filecurrent, adios2::Mode::Write, world);
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filecurrent);
} else {
if (!singlefile_opened) {
internal->fh = internal->io.Open(filename, adios2::Mode::Write, world);
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filename);
singlefile_opened = 1;
}
}
}
/* ---------------------------------------------------------------------- */
void DumpAtomADIOS::write()
{
if (domain->triclinic == 0) {
boxxlo = domain->boxlo[0];
boxxhi = domain->boxhi[0];
boxylo = domain->boxlo[1];
boxyhi = domain->boxhi[1];
boxzlo = domain->boxlo[2];
boxzhi = domain->boxhi[2];
} else {
boxxlo = domain->boxlo_bound[0];
boxxhi = domain->boxhi_bound[0];
boxylo = domain->boxlo_bound[1];
boxyhi = domain->boxhi_bound[1];
boxzlo = domain->boxlo_bound[2];
boxzhi = domain->boxhi_bound[2];
boxxy = domain->xy;
boxxz = domain->xz;
boxyz = domain->yz;
}
// nme = # of dump lines this proc contributes to dump
nme = count();
// ntotal = total # of atoms in snapshot
// atomOffset = sum of # of atoms up to this proc (exclusive prefix sum)
bigint bnme = nme;
MPI_Allreduce(&bnme, &ntotal, 1, MPI_LMP_BIGINT, MPI_SUM, world);
bigint atomOffset; // sum of all atoms on processes 0..me-1
MPI_Scan(&bnme, &atomOffset, 1, MPI_LMP_BIGINT, MPI_SUM, world);
atomOffset -= nme; // exclusive prefix sum needed
// Now we know the global size and the local subset size and offset
// of the atoms table
auto nAtomsGlobal = static_cast<size_t>(ntotal);
auto startRow = static_cast<size_t>(atomOffset);
auto nAtomsLocal = static_cast<size_t>(nme);
auto nColumns = static_cast<size_t>(size_one);
internal->varAtoms.SetShape({nAtomsGlobal, nColumns});
internal->varAtoms.SetSelection({{startRow, 0}, {nAtomsLocal, nColumns}});
// insure buf is sized for packing
// adios does not limit per-process data size so nme*size_one is not
// constrained to int
// if sorting on IDs also request ID list from pack()
// sort buf as needed
if (nme > maxbuf) {
maxbuf = nme;
memory->destroy(buf);
memory->create(buf, (maxbuf * size_one), "dump:buf");
}
if (sort_flag && sortcol == 0 && nme > maxids) {
maxids = nme;
memory->destroy(ids);
memory->create(ids, maxids, "dump:ids");
}
if (sort_flag && sortcol == 0)
pack(ids);
else
pack(nullptr);
if (sort_flag) sort();
openfile();
internal->fh.BeginStep();
// write info on data as scalars (by me==0)
if (me == 0) {
internal->fh.Put<uint64_t>("ntimestep", update->ntimestep);
internal->fh.Put<int>("nprocs", nprocs);
internal->fh.Put<double>("boxxlo", boxxlo);
internal->fh.Put<double>("boxxhi", boxxhi);
internal->fh.Put<double>("boxylo", boxylo);
internal->fh.Put<double>("boxyhi", boxyhi);
internal->fh.Put<double>("boxzlo", boxzlo);
internal->fh.Put<double>("boxzhi", boxzhi);
if (domain->triclinic) {
internal->fh.Put<double>("boxxy", boxxy);
internal->fh.Put<double>("boxxz", boxxz);
internal->fh.Put<double>("boxyz", boxyz);
}
}
// Everyone needs to write scalar variables that are used as dimensions and
// offsets of arrays
internal->fh.Put<uint64_t>("natoms", ntotal);
internal->fh.Put<int>("ncolumns", size_one);
internal->fh.Put<uint64_t>("nme", bnme);
internal->fh.Put<uint64_t>("offset", atomOffset);
// now write the atoms
internal->fh.Put<double>(internal->varAtoms, buf);
internal->fh.EndStep(); // I/O will happen now...
if (multifile) internal->fh.Close();
}
/* ---------------------------------------------------------------------- */
void DumpAtomADIOS::init_style()
{
if (image_flag == 0)
size_one = 5;
else
size_one = 8;
// setup boundary string
domain->boundary_string(boundstr);
// remove % from filename since ADIOS always writes a global file with
// data/metadata.
char *ptr = strchr(filename, '%');
if (ptr) {
while (*ptr) {
ptr[0] = ptr[1];
++ptr;
}
}
// setup column string
std::vector<std::string> columnNames;
if (scale_flag == 0 && image_flag == 0) {
columns = (char *) "id type x y z";
columnNames = {"id", "type", "x", "y", "z"};
} else if (scale_flag == 0 && image_flag == 1) {
columns = (char *) "id type x y z ix iy iz";
columnNames = {"id", "type", "x", "y", "z", "ix", "iy", "iz"};
} else if (scale_flag == 1 && image_flag == 0) {
columns = (char *) "id type xs ys zs";
columnNames = {"id", "type", "xs", "ys", "zs"};
} else if (scale_flag == 1 && image_flag == 1) {
columns = (char *) "id type xs ys zs ix iy iz";
columnNames = {"id", "type", "xs", "ys", "zs", "ix", "iy", "iz"};
}
for (int icol = 0; icol < (int)columnNames.size(); ++icol)
if (keyword_user[icol].size()) columnNames[icol] = keyword_user[icol];
// setup function ptrs
if (scale_flag == 1 && image_flag == 0 && domain->triclinic == 0)
pack_choice = &DumpAtomADIOS::pack_scale_noimage;
else if (scale_flag == 1 && image_flag == 1 && domain->triclinic == 0)
pack_choice = &DumpAtomADIOS::pack_scale_image;
else if (scale_flag == 1 && image_flag == 0 && domain->triclinic == 1)
pack_choice = &DumpAtomADIOS::pack_scale_noimage_triclinic;
else if (scale_flag == 1 && image_flag == 1 && domain->triclinic == 1)
pack_choice = &DumpAtomADIOS::pack_scale_image_triclinic;
else if (scale_flag == 0 && image_flag == 0)
pack_choice = &DumpAtomADIOS::pack_noscale_noimage;
else if (scale_flag == 0 && image_flag == 1)
pack_choice = &DumpAtomADIOS::pack_noscale_image;
/* Define the group of variables for the atom style here since it's a fixed
* set */
internal->io = internal->ad->DeclareIO(internal->ioName);
if (!internal->io.InConfigFile()) {
// if not defined by user, we can change the default settings
// BPFile is the default writer
internal->io.SetEngine("BPFile");
int num_aggregators = multiproc;
if (num_aggregators == 0) num_aggregators = 1;
auto nstreams = std::to_string(num_aggregators);
internal->io.SetParameters({{"substreams", nstreams}});
if (me == 0)
utils::logmesg(lmp, "ADIOS method for {} is n-to-m (aggregation with {} writers)\n", filename,
nstreams);
}
internal->io.DefineVariable<uint64_t>("ntimestep");
internal->io.DefineVariable<uint64_t>("natoms");
internal->io.DefineVariable<int>("nprocs");
internal->io.DefineVariable<int>("ncolumns");
internal->io.DefineVariable<double>("boxxlo");
internal->io.DefineVariable<double>("boxxhi");
internal->io.DefineVariable<double>("boxylo");
internal->io.DefineVariable<double>("boxyhi");
internal->io.DefineVariable<double>("boxzlo");
internal->io.DefineVariable<double>("boxzhi");
internal->io.DefineVariable<double>("boxxy");
internal->io.DefineVariable<double>("boxxz");
internal->io.DefineVariable<double>("boxyz");
internal->io.DefineAttribute<int>("triclinic", domain->triclinic);
internal->io.DefineAttribute<int>("scaled", scale_flag);
internal->io.DefineAttribute<int>("image", image_flag);
int *boundaryptr = reinterpret_cast<int *>(domain->boundary);
internal->io.DefineAttribute<int>("boundary", boundaryptr, 6);
auto nColumns = static_cast<size_t>(size_one);
internal->io.DefineAttribute<std::string>("columns", columnNames.data(), nColumns);
internal->io.DefineAttribute<std::string>("columnstr", columns);
internal->io.DefineAttribute<std::string>("boundarystr", boundstr);
internal->io.DefineAttribute<std::string>("LAMMPS/dump_style", "atom");
internal->io.DefineAttribute<std::string>("LAMMPS/version", lmp->version);
internal->io.DefineAttribute<std::string>("LAMMPS/num_ver", std::to_string(lmp->num_ver));
// local dimension variables
internal->io.DefineVariable<uint64_t>("nme", {adios2::LocalValueDim});
internal->io.DefineVariable<uint64_t>("offset", {adios2::LocalValueDim});
// atom table size is not known at the moment
// it will be correctly defined at the moment of write
size_t UnknownSizeYet = 1;
internal->varAtoms = internal->io.DefineVariable<double>(
"atoms", {UnknownSizeYet, nColumns}, {UnknownSizeYet, 0}, {UnknownSizeYet, nColumns});
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -13,7 +13,7 @@
#ifdef DUMP_CLASS
// clang-format off
DumpStyle(atom/adios, DumpAtomADIOS)
DumpStyle(atom/adios, DumpAtomADIOS);
// clang-format on
#else
@ -22,32 +22,30 @@ DumpStyle(atom/adios, DumpAtomADIOS)
#include "dump_atom.h"
namespace LAMMPS_NS
{
namespace LAMMPS_NS {
class DumpAtomADIOSInternal;
class DumpAtomADIOS : public DumpAtom
{
class DumpAtomADIOS : public DumpAtom {
public:
DumpAtomADIOS(class LAMMPS *, int, char **);
virtual ~DumpAtomADIOS();
public:
DumpAtomADIOS(class LAMMPS *, int, char **);
~DumpAtomADIOS() override;
protected:
virtual void openfile();
virtual void write();
virtual void init_style();
protected:
void openfile() override;
void write() override;
void init_style() override;
private:
DumpAtomADIOSInternal *internal;
private:
DumpAtomADIOSInternal *internal;
};
}
} // namespace LAMMPS_NS
#endif
#endif
/* ERROR/WARNING messages:
/* ERROR/WARNING messages:
E: Cannot open dump file %s

View File

@ -0,0 +1,337 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Norbert Podhorszki (ORNL)
------------------------------------------------------------------------- */
#include "dump_custom_adios.h"
#include "atom.h"
#include "compute.h"
#include "domain.h"
#include "error.h"
#include "fix.h"
#include "input.h"
#include "memory.h"
#include "modify.h"
#include "update.h"
#include "variable.h"
#include <cmath>
#include <cstring>
#include "adios2.h"
#include "adios_common.h"
using namespace LAMMPS_NS;
namespace LAMMPS_NS {
class DumpCustomADIOSInternal {
public:
DumpCustomADIOSInternal(){};
~DumpCustomADIOSInternal() = default;
// name of adios group, referrable in adios2_config.xml
const std::string ioName = "custom";
adios2::ADIOS *ad = nullptr; // adios object
adios2::IO io; // adios group of variables and attributes in this dump
adios2::Engine fh; // adios file/stream handle object
// one ADIOS output variable we need to change every step
adios2::Variable<double> varAtoms;
// list of column names for the atom table
// (individual list of 'columns' string)
std::vector<std::string> columnNames;
};
} // namespace LAMMPS_NS
/* ---------------------------------------------------------------------- */
DumpCustomADIOS::DumpCustomADIOS(LAMMPS *lmp, int narg, char **arg) : DumpCustom(lmp, narg, arg)
{
// create a default adios2_config.xml if it doesn't exist yet.
FILE *cfgfp = fopen("adios2_config.xml", "r");
if (!cfgfp) {
cfgfp = fopen("adios2_config.xml", "w");
if (cfgfp) fputs(default_config, cfgfp);
}
if (cfgfp) fclose(cfgfp);
internal = new DumpCustomADIOSInternal();
try {
internal->ad = new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
} catch (std::ios_base::failure &e) {
error->all(FLERR, "ADIOS initialization failed with error: {}", e.what());
}
internal->columnNames.reserve(nfield);
for (int i = 0; i < nfield; ++i) { internal->columnNames.push_back(earg[i]); }
}
/* ---------------------------------------------------------------------- */
DumpCustomADIOS::~DumpCustomADIOS()
{
internal->columnNames.clear();
if (internal->fh) { internal->fh.Close(); }
delete internal->ad;
delete internal;
}
/* ---------------------------------------------------------------------- */
void DumpCustomADIOS::openfile()
{
if (multifile) {
// if one file per timestep, replace '*' with current timestep
auto filecurrent = utils::star_subst(filename, update->ntimestep, padflag);
internal->fh = internal->io.Open(filecurrent, adios2::Mode::Write, world);
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filecurrent);
} else {
if (!singlefile_opened) {
internal->fh = internal->io.Open(filename, adios2::Mode::Write, world);
if (!internal->fh) error->one(FLERR, "Cannot open dump file {}", filename);
singlefile_opened = 1;
}
}
}
/* ---------------------------------------------------------------------- */
void DumpCustomADIOS::write()
{
if (domain->triclinic == 0) {
boxxlo = domain->boxlo[0];
boxxhi = domain->boxhi[0];
boxylo = domain->boxlo[1];
boxyhi = domain->boxhi[1];
boxzlo = domain->boxlo[2];
boxzhi = domain->boxhi[2];
} else {
boxxlo = domain->boxlo_bound[0];
boxxhi = domain->boxhi_bound[0];
boxylo = domain->boxlo_bound[1];
boxyhi = domain->boxhi_bound[1];
boxzlo = domain->boxlo_bound[2];
boxzhi = domain->boxhi_bound[2];
boxxy = domain->xy;
boxxz = domain->xz;
boxyz = domain->yz;
}
// nme = # of dump lines this proc contributes to dump
nme = count();
// ntotal = total # of atoms in snapshot
// atomOffset = sum of # of atoms up to this proc (exclusive prefix sum)
bigint bnme = nme;
MPI_Allreduce(&bnme, &ntotal, 1, MPI_LMP_BIGINT, MPI_SUM, world);
bigint atomOffset; // sum of all atoms on processes 0..me-1
MPI_Scan(&bnme, &atomOffset, 1, MPI_LMP_BIGINT, MPI_SUM, world);
atomOffset -= nme; // exclusive prefix sum needed
// Now we know the global size and the local subset size and offset
// of the atoms table
auto nAtomsGlobal = static_cast<size_t>(ntotal);
auto startRow = static_cast<size_t>(atomOffset);
auto nAtomsLocal = static_cast<size_t>(nme);
auto nColumns = static_cast<size_t>(size_one);
internal->varAtoms.SetShape({nAtomsGlobal, nColumns});
internal->varAtoms.SetSelection({{startRow, 0}, {nAtomsLocal, nColumns}});
// insure filewriter proc can receive everyone's info
// limit nmax*size_one to int since used as arg in MPI_Rsend() below
// pack my data into buf
// if sorting on IDs also request ID list from pack()
// sort buf as needed
if (nme > maxbuf) {
if ((bigint) nme * size_one > MAXSMALLINT) error->all(FLERR, "Too much per-proc info for dump");
maxbuf = nme;
memory->destroy(buf);
memory->create(buf, (maxbuf * size_one), "dump:buf");
}
if (sort_flag && sortcol == 0 && nme > maxids) {
maxids = nme;
memory->destroy(ids);
memory->create(ids, maxids, "dump:ids");
}
if (sort_flag && sortcol == 0)
pack(ids);
else
pack(nullptr);
if (sort_flag) sort();
openfile();
internal->fh.BeginStep();
// write info on data as scalars (by me==0)
if (me == 0) {
internal->fh.Put<uint64_t>("ntimestep", update->ntimestep);
internal->fh.Put<int>("nprocs", nprocs);
internal->fh.Put<double>("boxxlo", boxxlo);
internal->fh.Put<double>("boxxhi", boxxhi);
internal->fh.Put<double>("boxylo", boxylo);
internal->fh.Put<double>("boxyhi", boxyhi);
internal->fh.Put<double>("boxzlo", boxzlo);
internal->fh.Put<double>("boxzhi", boxzhi);
if (domain->triclinic) {
internal->fh.Put<double>("boxxy", boxxy);
internal->fh.Put<double>("boxxz", boxxz);
internal->fh.Put<double>("boxyz", boxyz);
}
}
// Everyone needs to write scalar variables that are used as dimensions and
// offsets of arrays
internal->fh.Put<uint64_t>("natoms", ntotal);
internal->fh.Put<int>("ncolumns", size_one);
internal->fh.Put<uint64_t>("nme", bnme);
internal->fh.Put<uint64_t>("offset", atomOffset);
// now write the atoms
internal->fh.Put<double>("atoms", buf);
internal->fh.EndStep(); // I/O will happen now...
if (multifile) { internal->fh.Close(); }
}
/* ---------------------------------------------------------------------- */
void DumpCustomADIOS::init_style()
{
// assemble column string from defaults and user values
delete[] columns;
std::string combined;
int icol = 0;
for (auto item : utils::split_words(columns_default)) {
if (combined.size()) combined += " ";
if (keyword_user[icol].size()) combined += keyword_user[icol];
else combined += item;
++icol;
}
columns = utils::strdup(combined);
// setup boundary string
domain->boundary_string(boundstr);
// remove % from filename since ADIOS always writes a global file with
// data/metadata
char *ptr = strchr(filename, '%');
if (ptr) {
while (*ptr) {
ptr[0] = ptr[1];
++ptr;
}
}
/* The next four loops are copied from dump_custom_mpiio, but nothing is
* done with them.
* It is unclear why we need them here.
* For metadata, variable[] will be written out as an ADIOS attribute if
* nvariable>0
*/
// find current ptr for each compute,fix,variable
// check that fix frequency is acceptable
int icompute;
for (int i = 0; i < ncompute; i++) {
icompute = modify->find_compute(id_compute[i]);
if (icompute < 0) error->all(FLERR, "Could not find dump custom compute ID");
compute[i] = modify->compute[icompute];
}
int ifix;
for (int i = 0; i < nfix; i++) {
ifix = modify->find_fix(id_fix[i]);
if (ifix < 0) error->all(FLERR, "Could not find dump custom fix ID");
fix[i] = modify->fix[ifix];
if (nevery % modify->fix[ifix]->peratom_freq)
error->all(FLERR, "Dump custom and fix not computed at compatible times");
}
int ivariable;
for (int i = 0; i < nvariable; i++) {
ivariable = input->variable->find(id_variable[i]);
if (ivariable < 0) error->all(FLERR, "Could not find dump custom variable name");
variable[i] = ivariable;
}
// set index and check validity of region
if (iregion >= 0) {
iregion = domain->find_region(idregion);
if (iregion == -1) error->all(FLERR, "Region ID for dump custom does not exist");
}
/* Define the group of variables for the atom style here since it's a fixed
* set */
internal->io = internal->ad->DeclareIO(internal->ioName);
if (!internal->io.InConfigFile()) {
// if not defined by user, we can change the default settings
// BPFile is the default writer
internal->io.SetEngine("BPFile");
int num_aggregators = multiproc;
if (num_aggregators == 0) num_aggregators = 1;
auto nstreams = std::to_string(num_aggregators);
internal->io.SetParameters({{"substreams", nstreams}});
if (me == 0)
utils::logmesg(lmp, "ADIOS method for {} is n-to-m (aggregation with {} writers)\n", filename,
nstreams);
}
internal->io.DefineVariable<uint64_t>("ntimestep");
internal->io.DefineVariable<uint64_t>("natoms");
internal->io.DefineVariable<int>("nprocs");
internal->io.DefineVariable<int>("ncolumns");
internal->io.DefineVariable<double>("boxxlo");
internal->io.DefineVariable<double>("boxxhi");
internal->io.DefineVariable<double>("boxylo");
internal->io.DefineVariable<double>("boxyhi");
internal->io.DefineVariable<double>("boxzlo");
internal->io.DefineVariable<double>("boxzhi");
internal->io.DefineVariable<double>("boxxy");
internal->io.DefineVariable<double>("boxxz");
internal->io.DefineVariable<double>("boxyz");
internal->io.DefineAttribute<int>("triclinic", domain->triclinic);
int *boundaryptr = reinterpret_cast<int *>(domain->boundary);
internal->io.DefineAttribute<int>("boundary", boundaryptr, 6);
auto nColumns = static_cast<size_t>(size_one);
internal->io.DefineAttribute<std::string>("columns", internal->columnNames.data(), nColumns);
internal->io.DefineAttribute<std::string>("columnstr", columns);
internal->io.DefineAttribute<std::string>("boundarystr", boundstr);
internal->io.DefineAttribute<std::string>("LAMMPS/dump_style", "custom");
internal->io.DefineAttribute<std::string>("LAMMPS/version", lmp->version);
internal->io.DefineAttribute<std::string>("LAMMPS/num_ver", std::to_string(lmp->num_ver));
internal->io.DefineVariable<uint64_t>("nme",
{adios2::LocalValueDim}); // local dimension variable
internal->io.DefineVariable<uint64_t>("offset",
{adios2::LocalValueDim}); // local dimension variable
// atom table size is not known at the moment
// it will be correctly defined at the moment of write
size_t UnknownSizeYet = 1;
internal->varAtoms = internal->io.DefineVariable<double>(
"atoms", {UnknownSizeYet, nColumns}, {UnknownSizeYet, 0}, {UnknownSizeYet, nColumns});
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -13,7 +13,7 @@
#ifdef DUMP_CLASS
// clang-format off
DumpStyle(custom/adios, DumpCustomADIOS)
DumpStyle(custom/adios, DumpCustomADIOS);
// clang-format on
#else
@ -22,31 +22,29 @@ DumpStyle(custom/adios, DumpCustomADIOS)
#include "dump_custom.h"
namespace LAMMPS_NS
{
namespace LAMMPS_NS {
class DumpCustomADIOSInternal;
class DumpCustomADIOS : public DumpCustom
{
public:
DumpCustomADIOS(class LAMMPS *, int, char **);
virtual ~DumpCustomADIOS();
class DumpCustomADIOS : public DumpCustom {
public:
DumpCustomADIOS(class LAMMPS *, int, char **);
~DumpCustomADIOS() override;
protected:
virtual void openfile();
virtual void write();
virtual void init_style();
protected:
void openfile() override;
void write() override;
void init_style() override;
private:
DumpCustomADIOSInternal *internal;
private:
DumpCustomADIOSInternal *internal;
};
}
} // namespace LAMMPS_NS
#endif
#endif
/* ERROR/WARNING messages:
/* ERROR/WARNING messages:
E: Cannot open dump file %s

456
src/ADIOS/reader_adios.cpp Normal file
View File

@ -0,0 +1,456 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Norbert Podhorszki (Oak Ridge National Laboratory)
------------------------------------------------------------------------- */
#include "reader_adios.h"
#include "comm.h"
#include "error.h"
#include "memory.h"
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "adios2.h"
#include "adios_common.h"
using namespace LAMMPS_NS;
// also in read_dump.cpp
enum { ID, TYPE, X, Y, Z, VX, VY, VZ, Q, IX, IY, IZ, FX, FY, FZ };
enum { UNSET, NOSCALE_NOWRAP, NOSCALE_WRAP, SCALE_NOWRAP, SCALE_WRAP };
#define SMALL 1.0e-6
namespace LAMMPS_NS {
class ReadADIOSInternal {
public:
ReadADIOSInternal(){};
~ReadADIOSInternal() = default;
// name of adios group, referrable in adios2_config.xml
const std::string ioName = "read_dump";
adios2::ADIOS *ad = nullptr; // adios object
adios2::IO io; // adios group of variables and attributes in this dump
adios2::Engine fh; // adios file/stream handle object
// ADIOS input variables we need to change every step
adios2::Variable<uint64_t> varNtimestep;
adios2::Variable<uint64_t> varNatoms;
adios2::Variable<double> varAtoms;
// list of column names for the atom table
// (individual list of 'columns' string)
std::vector<std::string> columnNames;
float timeout = 0.0;
};
} // namespace LAMMPS_NS
/* ---------------------------------------------------------------------- */
ReaderADIOS::ReaderADIOS(LAMMPS *lmp) : Reader(lmp)
{
fieldindex = nullptr;
nAtoms = 0;
nAtomsTotal = 0;
atomOffset = 0;
nstep = 0;
nid = 0;
me = comm->me;
// create a default adios2_config.xml if it doesn't exist yet.
FILE *cfgfp = fopen("adios2_config.xml", "r");
if (!cfgfp) {
cfgfp = fopen("adios2_config.xml", "w");
if (cfgfp) fputs(default_config, cfgfp);
}
if (cfgfp) fclose(cfgfp);
internal = new ReadADIOSInternal();
try {
internal->ad = new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
} catch (std::ios_base::failure &e) {
error->one(FLERR, "ADIOS initialization failed with error: {}", e.what());
}
/* Define the group holding all variables and attributes */
internal->io = internal->ad->DeclareIO(internal->ioName);
}
/* ---------------------------------------------------------------------- */
ReaderADIOS::~ReaderADIOS()
{
if (me == 0) memory->destroy(fieldindex);
internal->columnNames.clear();
if (internal->fh) internal->fh.Close();
delete internal->ad;
delete internal;
}
/* ----------------------------------------------------------------------
pass on settings to find and load the proper plugin
Called by all processors.
------------------------------------------------------------------------- */
void ReaderADIOS::settings(int narg, char **arg)
{
int idx = 0;
while (idx < narg) {
if (!strcmp(arg[idx], "timeout")) {
if (idx + 1 < narg) {
internal->timeout = std::stof(arg[idx + 1]);
internal->io.SetParameter("OpenTimeoutSecs", arg[idx + 1]);
++idx;
} else {
error->one(FLERR, "Missing value for 'timeout' option for ADIOS read_dump command");
}
}
++idx;
}
}
/* ----------------------------------------------------------------------
try to open given file
Every process must call this Collective operation
------------------------------------------------------------------------- */
void ReaderADIOS::open_file(const std::string &file)
{
// close open file, if needed.
if (internal->fh) internal->fh.Close();
try {
internal->fh = internal->io.Open(file, adios2::Mode::Read, world);
} catch (std::ios_base::failure &e) {
error->one(FLERR, "Error opening file {}: {}", file, e.what());
}
if (!internal->fh) error->one(FLERR, "Cannot open file {} using ADIOS", file);
}
/* ----------------------------------------------------------------------
close current file
Every process must call this Collective operation
------------------------------------------------------------------------- */
void ReaderADIOS::close_file()
{
// close open file, if needed.
if (internal->fh) { internal->fh.Close(); }
}
/* ----------------------------------------------------------------------
read and return time stamp from dump file
if first read reaches end-of-file, return 1 so caller can open next file
Called by all processors.
------------------------------------------------------------------------- */
int ReaderADIOS::read_time(bigint &ntimestep)
{
adios2::StepStatus status = internal->fh.BeginStep(adios2::StepMode::Read, internal->timeout);
switch (status) {
case adios2::StepStatus::EndOfStream:
case adios2::StepStatus::NotReady:
case adios2::StepStatus::OtherError:
return 1;
default:
break;
}
internal->varNtimestep = internal->io.InquireVariable<uint64_t>("ntimestep");
if (!internal->varNtimestep)
error->one(FLERR, "Did not find 'ntimestep' variable in ADIOS file {}", internal->fh.Name());
ntimestep = static_cast<bigint>(internal->varNtimestep.Max());
return 0;
}
/* ----------------------------------------------------------------------
skip snapshot for given timestamp
Called by all processors.
------------------------------------------------------------------------- */
void ReaderADIOS::skip()
{
internal->fh.EndStep();
}
/* ----------------------------------------------------------------------
read remaining header info:
return natoms
box bounds, triclinic (inferred), fieldflag (1 if any fields not found),
xyz flags = from input scaleflag & wrapflag
if fieldflag set:
match Nfield fields to per-atom column labels
allocate and set fieldindex = which column each field maps to
fieldtype = X,VX,IZ etc
fieldlabel = user-specified label or nullptr if use fieldtype default
xyz flag = scaledflag if has fieldlabel name, else set by x,xs,xu,xsu
only called by proc 0
------------------------------------------------------------------------- */
bigint ReaderADIOS::read_header(double box[3][3], int &boxinfo, int &triclinic, int fieldinfo,
int nfield, int *fieldtype, char **fieldlabel, int scaleflag,
int wrapflag, int &fieldflag, int &xflag, int &yflag, int &zflag)
{
nid = 0;
// signal that we have no box info at all so far.
internal->varNatoms = internal->io.InquireVariable<uint64_t>("natoms");
if (!internal->varNatoms)
error->one(FLERR, "Did not find 'natoms' variable in ADIOS file {}", internal->fh.Name());
/* nAtoms */
nAtomsTotal = internal->varNatoms.Max();
uint64_t rem = nAtomsTotal % comm->nprocs;
nAtoms = nAtomsTotal / comm->nprocs;
atomOffset = comm->me * nAtoms;
if (comm->me < (int)rem) {
++nAtoms;
atomOffset += comm->me;
} else {
atomOffset += rem;
}
/* triclinic */
adios2::Attribute<int32_t> attTriclinic = internal->io.InquireAttribute<int32_t>("triclinic");
if (!attTriclinic)
error->one(FLERR, "Did not find 'triclinic' attribute in ADIOS file {}", internal->fh.Name());
triclinic = attTriclinic.Data()[0];
/* read Box */
adios2::Variable<double> varBoxxlo = internal->io.InquireVariable<double>("boxxlo");
adios2::Variable<double> varBoxxhi = internal->io.InquireVariable<double>("boxxhi");
adios2::Variable<double> varBoxylo = internal->io.InquireVariable<double>("boxylo");
adios2::Variable<double> varBoxyhi = internal->io.InquireVariable<double>("boxyhi");
adios2::Variable<double> varBoxzlo = internal->io.InquireVariable<double>("boxzlo");
adios2::Variable<double> varBoxzhi = internal->io.InquireVariable<double>("boxzhi");
box[0][0] = varBoxxlo.Max();
box[0][1] = varBoxxhi.Max();
box[0][2] = 0.0;
box[1][0] = varBoxylo.Max();
box[1][1] = varBoxyhi.Max();
box[1][2] = 0.0;
box[2][0] = varBoxzlo.Max();
box[2][1] = varBoxzhi.Max();
box[2][2] = 0.0;
if (triclinic) {
adios2::Variable<double> varBoxxy = internal->io.InquireVariable<double>("boxxy");
adios2::Variable<double> varBoxxz = internal->io.InquireVariable<double>("boxxz");
adios2::Variable<double> varBoxyz = internal->io.InquireVariable<double>("boxyz");
box[0][2] = varBoxxy.Max();
box[1][2] = varBoxxz.Max();
box[2][2] = varBoxyz.Max();
}
boxinfo = 1;
// if no field info requested, just return
if (!fieldinfo) return nAtoms;
memory->create(fieldindex, nfield, "read_dump:fieldindex");
/* Columns */
adios2::Attribute<std::string> attColumns = internal->io.InquireAttribute<std::string>("columns");
std::vector<std::string> labelVector = attColumns.Data();
int nwords = labelVector.size();
std::map<std::string, int> labels;
for (int i = 0; i < nwords; ++i) { labels.emplace(labelVector[i], i); }
int s_index, u_index, su_index;
xflag = UNSET;
yflag = UNSET;
zflag = UNSET;
// copy fieldtype list for supported fields
for (int i = 0; i < nfield; i++) {
if (fieldlabel[i]) {
fieldindex[i] = find_label(fieldlabel[i], labels);
if (fieldtype[i] == X)
xflag = 2 * scaleflag + wrapflag + 1;
else if (fieldtype[i] == Y)
yflag = 2 * scaleflag + wrapflag + 1;
else if (fieldtype[i] == Z)
zflag = 2 * scaleflag + wrapflag + 1;
}
else if (fieldtype[i] == ID)
fieldindex[i] = find_label("id", labels);
else if (fieldtype[i] == TYPE)
fieldindex[i] = find_label("type", labels);
else if (fieldtype[i] == X) {
fieldindex[i] = find_label("x", labels);
xflag = NOSCALE_WRAP;
if (fieldindex[i] < 0) {
fieldindex[i] = nwords;
s_index = find_label("xs", labels);
u_index = find_label("xu", labels);
su_index = find_label("xsu", labels);
if (s_index >= 0 && s_index < fieldindex[i]) {
fieldindex[i] = s_index;
xflag = SCALE_WRAP;
}
if (u_index >= 0 && u_index < fieldindex[i]) {
fieldindex[i] = u_index;
xflag = NOSCALE_NOWRAP;
}
if (su_index >= 0 && su_index < fieldindex[i]) {
fieldindex[i] = su_index;
xflag = SCALE_NOWRAP;
}
}
if (fieldindex[i] == nwords) fieldindex[i] = -1;
} else if (fieldtype[i] == Y) {
fieldindex[i] = find_label("y", labels);
yflag = NOSCALE_WRAP;
if (fieldindex[i] < 0) {
fieldindex[i] = nwords;
s_index = find_label("ys", labels);
u_index = find_label("yu", labels);
su_index = find_label("ysu", labels);
if (s_index >= 0 && s_index < fieldindex[i]) {
fieldindex[i] = s_index;
yflag = SCALE_WRAP;
}
if (u_index >= 0 && u_index < fieldindex[i]) {
fieldindex[i] = u_index;
yflag = NOSCALE_NOWRAP;
}
if (su_index >= 0 && su_index < fieldindex[i]) {
fieldindex[i] = su_index;
yflag = SCALE_NOWRAP;
}
}
if (fieldindex[i] == nwords) fieldindex[i] = -1;
} else if (fieldtype[i] == Z) {
fieldindex[i] = find_label("z", labels);
zflag = NOSCALE_WRAP;
if (fieldindex[i] < 0) {
fieldindex[i] = nwords;
s_index = find_label("zs", labels);
u_index = find_label("zu", labels);
su_index = find_label("zsu", labels);
if (s_index >= 0 && s_index < fieldindex[i]) {
fieldindex[i] = s_index;
zflag = SCALE_WRAP;
}
if (u_index >= 0 && u_index < fieldindex[i]) {
fieldindex[i] = u_index;
zflag = NOSCALE_NOWRAP;
}
if (su_index >= 0 && su_index < fieldindex[i]) {
fieldindex[i] = su_index;
zflag = SCALE_NOWRAP;
}
}
if (fieldindex[i] == nwords) fieldindex[i] = -1;
} else if (fieldtype[i] == VX)
fieldindex[i] = find_label("vx", labels);
else if (fieldtype[i] == VY)
fieldindex[i] = find_label("vy", labels);
else if (fieldtype[i] == VZ)
fieldindex[i] = find_label("vz", labels);
else if (fieldtype[i] == FX)
fieldindex[i] = find_label("fx", labels);
else if (fieldtype[i] == FY)
fieldindex[i] = find_label("fy", labels);
else if (fieldtype[i] == FZ)
fieldindex[i] = find_label("fz", labels);
else if (fieldtype[i] == Q)
fieldindex[i] = find_label("q", labels);
else if (fieldtype[i] == IX)
fieldindex[i] = find_label("ix", labels);
else if (fieldtype[i] == IY)
fieldindex[i] = find_label("iy", labels);
else if (fieldtype[i] == IZ)
fieldindex[i] = find_label("iz", labels);
}
// set fieldflag = -1 if any unfound fields
fieldflag = 0;
for (int i = 0; i < nfield; i++)
if (fieldindex[i] < 0) fieldflag = -1;
return nAtoms;
}
/* ----------------------------------------------------------------------
read N atom lines from dump file
stores appropriate values in fields array
return 0 if success, 1 if error
only called by proc 0
------------------------------------------------------------------------- */
void ReaderADIOS::read_atoms(int n, int nfield, double **fields)
{
/* Read Atoms */
/* This is the firsts (and last) read of array data, so we
* call EndStep() here instead of PerformGets()
*/
adios2::Variable<double> varAtoms = internal->io.InquireVariable<double>("atoms");
if ((uint64_t)n != nAtoms)
error->one(FLERR,
"ReaderADIOS::read_atoms() expects 'n={}' equal to the number of "
"atoms (={}) for process {} in ADIOS file {}.",
n, nAtoms, comm->me, internal->fh.Name());
size_t ncols = varAtoms.Count()[1];
varAtoms.SetSelection({{atomOffset, 0}, {nAtoms, ncols}});
std::vector<double> table;
internal->fh.Get<double>(varAtoms, table);
// EndStep or PerformGets required to make the read happen
internal->fh.EndStep();
size_t idx;
for (uint64_t i = 0; i < nAtoms; i++) {
idx = i * ncols;
for (int m = 0; m < nfield; m++) { fields[i][m] = table[idx + fieldindex[m]]; }
}
}
/* ----------------------------------------------------------------------
match label to any of N labels
return index of match or -1 if no match
------------------------------------------------------------------------- */
int ReaderADIOS::find_label(const std::string &label, const std::map<std::string, int> &labels)
{
auto it = labels.find(label);
if (it != labels.end()) { return it->second; }
return -1;
}

69
src/ADIOS/reader_adios.h Normal file
View File

@ -0,0 +1,69 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
Contributed by Norbert Podhorszki (Oak Ridge National Laboratory)
------------------------------------------------------------------------- */
#ifdef READER_CLASS
// clang-format off
ReaderStyle(adios, ReaderADIOS);
// clang-format on
#else
#ifndef LMP_READER_ADIOS_H
#define LMP_READER_ADIOS_H
#include "reader.h"
#include <map>
#include <string>
#include <vector>
namespace LAMMPS_NS {
class ReadADIOSInternal;
class ReaderADIOS : public Reader {
public:
ReaderADIOS(class LAMMPS *);
~ReaderADIOS() override;
void settings(int, char **) override;
int read_time(bigint &) override;
void skip() override;
bigint read_header(double[3][3], int &, int &, int, int, int *, char **, int, int, int &,
int &, int &, int &) override;
void read_atoms(int, int, double **) override;
void open_file(const std::string &) override;
void close_file() override;
private:
int *fieldindex; // mapping of input fields to dump
uint64_t nAtomsTotal; // current number of atoms in entire dump step
uint64_t nAtoms; // current number of atoms for this process
// (Sum(nAtoms)=nAtomsTotal)
uint64_t atomOffset; // starting atom position for this process to read
bigint nstep; // current (time) step number
bigint nid; // current atom id.
int me;
ReadADIOSInternal *internal;
int find_label(const std::string &label, const std::map<std::string, int> &labels);
};
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -42,9 +43,9 @@ void ComputeERotateAsphere::init()
{
// error check
avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
avec_line = (AtomVecLine *) atom->style_match("line");
avec_tri = (AtomVecTri *) atom->style_match("tri");
avec_ellipsoid = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
avec_line = dynamic_cast<AtomVecLine *>( atom->style_match("line"));
avec_tri = dynamic_cast<AtomVecTri *>( atom->style_match("tri"));
if (!avec_ellipsoid && !avec_line && !avec_tri)
error->all(FLERR,"Compute erotate/asphere requires "
"atom style ellipsoid or line or tri");

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef COMPUTE_CLASS
ComputeStyle(erotate/asphere,ComputeERotateAsphere)
// clang-format off
ComputeStyle(erotate/asphere,ComputeERotateAsphere);
// clang-format on
#else
#ifndef LMP_COMPUTE_EROTATE_ASPHERE_H
@ -27,8 +27,8 @@ namespace LAMMPS_NS {
class ComputeERotateAsphere : public Compute {
public:
ComputeERotateAsphere(class LAMMPS *, int, char **);
void init();
double compute_scalar();
void init() override;
double compute_scalar() override;
private:
double pfactor;
@ -37,7 +37,7 @@ class ComputeERotateAsphere : public Compute {
class AtomVecTri *avec_tri;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -58,9 +59,7 @@ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) :
if (iarg+2 > narg)
error->all(FLERR,"Illegal compute temp/asphere command");
tempbias = 1;
int n = strlen(arg[iarg+1]) + 1;
id_bias = new char[n];
strcpy(id_bias,arg[iarg+1]);
id_bias = utils::strdup(arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"dof") == 0) {
if (iarg+2 > narg)
@ -95,7 +94,7 @@ void ComputeTempAsphere::init()
{
// error check
avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
if (!avec)
error->all(FLERR,"Compute temp/asphere requires atom style ellipsoid");

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef COMPUTE_CLASS
ComputeStyle(temp/asphere,ComputeTempAsphere)
// clang-format off
ComputeStyle(temp/asphere,ComputeTempAsphere);
// clang-format on
#else
#ifndef LMP_COMPUTE_TEMP_ASPHERE_H
@ -27,28 +27,28 @@ namespace LAMMPS_NS {
class ComputeTempAsphere : public Compute {
public:
ComputeTempAsphere(class LAMMPS *, int, char **);
~ComputeTempAsphere();
void init();
void setup();
double compute_scalar();
void compute_vector();
~ComputeTempAsphere() override;
void init() override;
void setup() override;
double compute_scalar() override;
void compute_vector() override;
void remove_bias(int, double *);
void restore_bias(int, double *);
void remove_bias_thr(int, double *, double *);
void restore_bias_thr(int, double *, double *);
void remove_bias(int, double *) override;
void restore_bias(int, double *) override;
void remove_bias_thr(int, double *, double *) override;
void restore_bias_thr(int, double *, double *) override;
private:
int mode;
double tfactor;
char *id_bias;
class Compute *tbias; // ptr to additional bias compute
class Compute *tbias; // ptr to additional bias compute
class AtomVecEllipsoid *avec;
void dof_compute();
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -35,7 +36,7 @@ FixNHAsphere::FixNHAsphere(LAMMPS *lmp, int narg, char **arg) :
void FixNHAsphere::init()
{
avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
if (!avec)
error->all(FLERR,
"Compute nvt/nph/npt asphere requires atom style ellipsoid");

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -21,19 +21,18 @@ namespace LAMMPS_NS {
class FixNHAsphere : public FixNH {
public:
FixNHAsphere(class LAMMPS *, int, char **);
virtual ~FixNHAsphere() {}
void init();
void init() override;
protected:
double dtq;
class AtomVecEllipsoid *avec;
void nve_v();
void nve_x();
void nh_v_temp();
void nve_v() override;
void nve_x() override;
void nh_v_temp() override;
};
}
} // namespace LAMMPS_NS
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,10 +13,9 @@
------------------------------------------------------------------------- */
#include "fix_nph_asphere.h"
#include <cstring>
#include "modify.h"
#include "error.h"
#include "modify.h"
using namespace LAMMPS_NS;
using namespace FixConst;
@ -36,21 +36,15 @@ FixNPHAsphere::FixNPHAsphere(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp");
id_temp = new char[tcmd.size()+1];
strcpy(id_temp,tcmd.c_str());
modify->add_compute(tcmd + " all temp/asphere");
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} all temp/asphere",id_temp));
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press");
id_press = new char[pcmd.size()+1];
strcpy(id_press,pcmd.c_str());
modify->add_compute(pcmd + " all pressure " + std::string(id_temp));
id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
pcomputeflag = 1;
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nph/asphere,FixNPHAsphere)
// clang-format off
FixStyle(nph/asphere,FixNPHAsphere);
// clang-format on
#else
#ifndef LMP_FIX_NPH_ASPHERE_H
@ -27,10 +27,9 @@ namespace LAMMPS_NS {
class FixNPHAsphere : public FixNHAsphere {
public:
FixNPHAsphere(class LAMMPS *, int, char **);
~FixNPHAsphere() {}
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,10 +13,9 @@
------------------------------------------------------------------------- */
#include "fix_npt_asphere.h"
#include <cstring>
#include "modify.h"
#include "error.h"
#include "modify.h"
using namespace LAMMPS_NS;
using namespace FixConst;
@ -35,21 +35,15 @@ FixNPTAsphere::FixNPTAsphere(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp");
id_temp = new char[tcmd.size()+1];
strcpy(id_temp,tcmd.c_str());
modify->add_compute(tcmd + " all temp/asphere");
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} all temp/asphere",id_temp));
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press");
id_press = new char[pcmd.size()+1];
strcpy(id_press,pcmd.c_str());
modify->add_compute(pcmd + " all pressure " + std::string(id_temp));
id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
pcomputeflag = 1;
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(npt/asphere,FixNPTAsphere)
// clang-format off
FixStyle(npt/asphere,FixNPTAsphere);
// clang-format on
#else
#ifndef LMP_FIX_NPT_ASPHERE_H
@ -27,10 +27,9 @@ namespace LAMMPS_NS {
class FixNPTAsphere : public FixNHAsphere {
public:
FixNPTAsphere(class LAMMPS *, int, char **);
~FixNPTAsphere() {}
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -16,10 +17,11 @@
------------------------------------------------------------------------- */
#include "fix_nve_asphere.h"
#include "math_extra.h"
#include "atom.h"
#include "atom_vec_ellipsoid.h"
#include "error.h"
#include "math_extra.h"
using namespace LAMMPS_NS;
using namespace FixConst;
@ -35,7 +37,7 @@ FixNVEAsphere::FixNVEAsphere(LAMMPS *lmp, int narg, char **arg) :
void FixNVEAsphere::init()
{
avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
if (!avec)
error->all(FLERR,"Compute nve/asphere requires atom style ellipsoid");

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nve/asphere,FixNVEAsphere)
// clang-format off
FixStyle(nve/asphere,FixNVEAsphere);
// clang-format on
#else
#ifndef LMP_FIX_NVE_ASPHERE_H
@ -27,16 +27,16 @@ namespace LAMMPS_NS {
class FixNVEAsphere : public FixNVE {
public:
FixNVEAsphere(class LAMMPS *, int, char **);
void init();
void initial_integrate(int);
void final_integrate();
void init() override;
void initial_integrate(int) override;
void final_integrate() override;
private:
double dtq;
class AtomVecEllipsoid *avec;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -36,7 +37,7 @@ void FixNVEAsphereNoforce::init()
{
// error check
avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
if (!atom->ellipsoid_flag)
error->all(FLERR,"Fix nve/asphere/noforce requires atom style ellipsoid");

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nve/asphere/noforce,FixNVEAsphereNoforce)
// clang-format off
FixStyle(nve/asphere/noforce,FixNVEAsphereNoforce);
// clang-format on
#else
#ifndef LMP_FIX_NVE_ASPHERE_NOFORCE_H
@ -27,15 +27,15 @@ namespace LAMMPS_NS {
class FixNVEAsphereNoforce : public FixNVENoforce {
public:
FixNVEAsphereNoforce(class LAMMPS *, int, char **);
void initial_integrate(int);
void init();
void initial_integrate(int) override;
void init() override;
private:
double dtq;
class AtomVecEllipsoid *avec;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -55,7 +56,7 @@ void FixNVELine::init()
{
// error checks
avec = (AtomVecLine *) atom->style_match("line");
avec = dynamic_cast<AtomVecLine *>( atom->style_match("line"));
if (!avec) error->all(FLERR,"Fix nve/line requires atom style line");
if (domain->dimension != 2)

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nve/line,FixNVELine)
// clang-format off
FixStyle(nve/line,FixNVELine);
// clang-format on
#else
#ifndef LMP_FIX_NVE_LINE_H
@ -27,18 +27,17 @@ namespace LAMMPS_NS {
class FixNVELine : public FixNVE {
public:
FixNVELine(class LAMMPS *, int, char **);
~FixNVELine() {}
int setmask();
void init();
void initial_integrate(int);
void final_integrate();
int setmask() override;
void init() override;
void initial_integrate(int) override;
void final_integrate() override;
private:
double MINUSPI,TWOPI;
double MINUSPI, TWOPI;
class AtomVecLine *avec;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -49,7 +50,7 @@ void FixNVETri::init()
{
// error checks
avec = (AtomVecTri *) atom->style_match("tri");
avec = dynamic_cast<AtomVecTri *>( atom->style_match("tri"));
if (!avec) error->all(FLERR,"Fix nve/tri requires atom style tri");
if (domain->dimension != 3)

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nve/tri,FixNVETri)
// clang-format off
FixStyle(nve/tri,FixNVETri);
// clang-format on
#else
#ifndef LMP_FIX_NVE_TRI_H
@ -27,18 +27,17 @@ namespace LAMMPS_NS {
class FixNVETri : public FixNVE {
public:
FixNVETri(class LAMMPS *, int, char **);
~FixNVETri() {}
int setmask();
void init();
void initial_integrate(int);
void final_integrate();
int setmask() override;
void init() override;
void initial_integrate(int) override;
void final_integrate() override;
private:
double dtq;
class AtomVecTri *avec;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,12 +13,10 @@
------------------------------------------------------------------------- */
#include "fix_nvt_asphere.h"
#include <cstring>
#include "error.h"
#include "group.h"
#include "modify.h"
#include "error.h"
using namespace LAMMPS_NS;
using namespace FixConst;
@ -35,11 +34,8 @@ FixNVTAsphere::FixNVTAsphere(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style
// id = fix-ID + temp
std::string cmd = id + std::string("_temp");
id_temp = new char[cmd.size()+1];
strcpy(id_temp,cmd.c_str());
cmd += fmt::format(" {} temp/asphere",group->names[igroup]);
modify->add_compute(cmd);
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} {} temp/asphere",
id_temp,group->names[igroup]));
tcomputeflag = 1;
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nvt/asphere,FixNVTAsphere)
// clang-format off
FixStyle(nvt/asphere,FixNVTAsphere);
// clang-format on
#else
#ifndef LMP_FIX_NVT_ASPHERE_H
@ -27,10 +27,9 @@ namespace LAMMPS_NS {
class FixNVTAsphere : public FixNHAsphere {
public:
FixNVTAsphere(class LAMMPS *, int, char **);
~FixNVTAsphere() {}
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -17,18 +18,18 @@
#include "pair_gayberne.h"
#include <cmath>
#include "math_extra.h"
#include "atom.h"
#include "atom_vec_ellipsoid.h"
#include "comm.h"
#include "force.h"
#include "neighbor.h"
#include "neigh_list.h"
#include "citeme.h"
#include "memory.h"
#include "comm.h"
#include "error.h"
#include "force.h"
#include "math_extra.h"
#include "memory.h"
#include "neigh_list.h"
#include "neighbor.h"
#include <cmath>
using namespace LAMMPS_NS;
@ -344,10 +345,10 @@ void PairGayBerne::coeff(int narg, char **arg)
void PairGayBerne::init_style()
{
avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
avec = dynamic_cast<AtomVecEllipsoid *>( atom->style_match("ellipsoid"));
if (!avec) error->all(FLERR,"Pair gayberne requires atom style ellipsoid");
neighbor->request(this,instance_me);
neighbor->add_request(this,NeighConst::REQ_DEFAULT);
// per-type shape precalculations
// require that atom shapes are identical within each type

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(gayberne,PairGayBerne)
// clang-format off
PairStyle(gayberne,PairGayBerne);
// clang-format on
#else
#ifndef LMP_PAIR_GAYBERNE_H
@ -27,52 +27,49 @@ namespace LAMMPS_NS {
class PairGayBerne : public Pair {
public:
PairGayBerne(LAMMPS *lmp);
virtual ~PairGayBerne();
virtual void compute(int, int);
virtual void settings(int, char **);
void coeff(int, char **);
virtual void init_style();
double init_one(int, int);
void write_restart(FILE *);
void read_restart(FILE *);
void write_restart_settings(FILE *);
void read_restart_settings(FILE *);
void write_data(FILE *);
void write_data_all(FILE *);
~PairGayBerne() override;
void compute(int, int) override;
void settings(int, char **) override;
void coeff(int, char **) override;
void init_style() override;
double init_one(int, int) override;
void write_restart(FILE *) override;
void read_restart(FILE *) override;
void write_restart_settings(FILE *) override;
void read_restart_settings(FILE *) override;
void write_data(FILE *) override;
void write_data_all(FILE *) override;
protected:
enum{SPHERE_SPHERE,SPHERE_ELLIPSE,ELLIPSE_SPHERE,ELLIPSE_ELLIPSE};
enum { SPHERE_SPHERE, SPHERE_ELLIPSE, ELLIPSE_SPHERE, ELLIPSE_ELLIPSE };
double cut_global;
double **cut;
double gamma,upsilon,mu; // Gay-Berne parameters
double **shape1; // per-type radii in x, y and z
double **shape2; // per-type radii in x, y and z SQUARED
double *lshape; // precalculation based on the shape
double **well; // well depth scaling along each axis ^ -1.0/mu
double **epsilon,**sigma; // epsilon and sigma values for atom-type pairs
double gamma, upsilon, mu; // Gay-Berne parameters
double **shape1; // per-type radii in x, y and z
double **shape2; // per-type radii in x, y and z SQUARED
double *lshape; // precalculation based on the shape
double **well; // well depth scaling along each axis ^ -1.0/mu
double **epsilon, **sigma; // epsilon and sigma values for atom-type pairs
int **form;
double **lj1,**lj2,**lj3,**lj4;
double **lj1, **lj2, **lj3, **lj4;
double **offset;
int *setwell;
class AtomVecEllipsoid *avec;
void allocate();
double gayberne_analytic(const int i, const int j, double a1[3][3],
double a2[3][3], double b1[3][3], double b2[3][3],
double g1[3][3], double g2[3][3], double *r12,
const double rsq, double *fforce, double *ttor,
double gayberne_analytic(const int i, const int j, double a1[3][3], double a2[3][3],
double b1[3][3], double b2[3][3], double g1[3][3], double g2[3][3],
double *r12, const double rsq, double *fforce, double *ttor,
double *rtor);
double gayberne_lj(const int i, const int j, double a1[3][3],
double b1[3][3],double g1[3][3],double *r12,
const double rsq, double *fforce, double *ttor);
void compute_eta_torque(double m[3][3], double m2[3][3],
double *s, double ans[3][3]);
double gayberne_lj(const int i, const int j, double a1[3][3], double b1[3][3], double g1[3][3],
double *r12, const double rsq, double *fforce, double *ttor);
void compute_eta_torque(double m[3][3], double m2[3][3], double *s, double ans[3][3]);
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -300,8 +301,7 @@ void PairLineLJ::compute(int eflag, int vflag)
}
}
if (evflag) ev_tally(i,j,nlocal,newton_pair,
evdwl,0.0,fpair,delx,dely,delz);
if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
}
}
@ -402,10 +402,10 @@ void PairLineLJ::coeff(int narg, char **arg)
void PairLineLJ::init_style()
{
avec = (AtomVecLine *) atom->style_match("line");
avec = dynamic_cast<AtomVecLine *>( atom->style_match("line"));
if (!avec) error->all(FLERR,"Pair line/lj requires atom style line");
neighbor->request(this,instance_me);
neighbor->add_request(this,NeighConst::REQ_DEFAULT);
}
/* ----------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(line/lj,PairLineLJ)
// clang-format off
PairStyle(line/lj,PairLineLJ);
// clang-format on
#else
#ifndef LMP_PAIR_LINE_LJ_H
@ -27,38 +27,38 @@ namespace LAMMPS_NS {
class PairLineLJ : public Pair {
public:
PairLineLJ(class LAMMPS *);
virtual ~PairLineLJ();
virtual void compute(int, int);
void settings(int, char **);
void coeff(int, char **);
virtual void init_style();
double init_one(int, int);
~PairLineLJ() override;
void compute(int, int) override;
void settings(int, char **) override;
void coeff(int, char **) override;
void init_style() override;
double init_one(int, int) override;
protected:
double cut_global;
double *subsize;
double **epsilon,**sigma,**cutsub,**cutsubsq;
double **epsilon, **sigma, **cutsub, **cutsubsq;
double **cut;
double **lj1,**lj2,**lj3,**lj4; // for sphere/sphere interactions
double **lj1, **lj2, **lj3, **lj4; // for sphere/sphere interactions
class AtomVecLine *avec;
double *size; // per-type size of sub-particles to tile line segment
double *size; // per-type size of sub-particles to tile line segment
struct Discrete {
double dx,dy;
double dx, dy;
};
Discrete *discrete; // list of all discretes for all lines
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
Discrete *discrete; // list of all discretes for all lines
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
void allocate();
void discretize(int, double);
};
}
} // namespace LAMMPS_NS
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(resquared,PairRESquared)
// clang-format off
PairStyle(resquared,PairRESquared);
// clang-format on
#else
#ifndef LMP_PAIR_RESQUARED_H
@ -27,31 +27,31 @@ namespace LAMMPS_NS {
class PairRESquared : public Pair {
public:
PairRESquared(LAMMPS *lmp);
virtual ~PairRESquared();
virtual void compute(int, int);
void settings(int, char **);
void coeff(int, char **);
virtual void init_style();
double init_one(int, int);
void write_restart(FILE *);
void read_restart(FILE *);
void write_restart_settings(FILE *);
void read_restart_settings(FILE *);
~PairRESquared() override;
void compute(int, int) override;
void settings(int, char **) override;
void coeff(int, char **) override;
void init_style() override;
double init_one(int, int) override;
void write_restart(FILE *) override;
void read_restart(FILE *) override;
void write_restart_settings(FILE *) override;
void read_restart_settings(FILE *) override;
protected:
enum{SPHERE_SPHERE,SPHERE_ELLIPSE,ELLIPSE_SPHERE,ELLIPSE_ELLIPSE};
enum { SPHERE_SPHERE, SPHERE_ELLIPSE, ELLIPSE_SPHERE, ELLIPSE_ELLIPSE };
double cut_global;
double **cut;
double **shape1; // per-type radii in x, y and z
double **shape2; // per-type radii in x, y and z SQUARED
double *lshape; // product of the radii
double **well; // well depth scaling along each axis
double **epsilon,**sigma; // epsilon and sigma values for atom-type pairs
double **shape1; // per-type radii in x, y and z
double **shape2; // per-type radii in x, y and z SQUARED
double *lshape; // product of the radii
double **well; // well depth scaling along each axis
double **epsilon, **sigma; // epsilon and sigma values for atom-type pairs
int **form;
double **lj1,**lj2,**lj3,**lj4;
double **lj1, **lj2, **lj3, **lj4;
double **offset;
int *setwell;
class AtomVecEllipsoid *avec;
@ -61,38 +61,35 @@ class PairRESquared : public Pair {
struct RE2Vars {
// per particle precomputations for energy, force, torque
double A[3][3]; // Rotation matrix (lab->body)
double aTe[3][3]; // A'*E
double gamma[3][3]; // A'*S^2*A
double A[3][3]; // Rotation matrix (lab->body)
double aTe[3][3]; // A'*E
double gamma[3][3]; // A'*S^2*A
// per particle precomputations for torque
double sa[3][3]; // S^2*A;
double lA[3][3][3]; // -A*rotation generator (x,y, or z)
double lAtwo[3][3][3]; // A'*S^2*lA
double lAsa[3][3][3]; // lAtwo+lA'*sa
double sa[3][3]; // S^2*A;
double lA[3][3][3]; // -A*rotation generator (x,y, or z)
double lAtwo[3][3][3]; // A'*S^2*lA
double lAsa[3][3][3]; // lAtwo+lA'*sa
};
void allocate();
void precompute_i(const int i,RE2Vars &ws);
void precompute_i(const int i, RE2Vars &ws);
double det_prime(const double m[3][3], const double m2[3][3]);
double resquared_analytic(const int i, const int j,
const RE2Vars &wi, const RE2Vars &wj,
const double *r, const double rsq,
double *fforce, double *ttor,
double resquared_analytic(const int i, const int j, const RE2Vars &wi, const RE2Vars &wj,
const double *r, const double rsq, double *fforce, double *ttor,
double *rtor);
double resquared_lj(const int i, const int j, const RE2Vars &wi,
const double *r, const double rsq, double *fforce,
double *ttor, bool calc_torque);
double resquared_lj(const int i, const int j, const RE2Vars &wi, const double *r,
const double rsq, double *fforce, double *ttor, bool calc_torque);
double cr60; // 60^1/3
double b_alpha; // 45/56
double solv_f_a; // 3.0/(4.0*PI*-36)
double solv_f_r; // 3.0/(4.0*PI*2025)
double cr60; // 60^1/3
double b_alpha; // 45/56
double solv_f_a; // 3.0/(4.0*PI*-36)
double solv_f_r; // 3.0/(4.0*PI*2025)
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -374,8 +375,7 @@ void PairTriLJ::compute(int eflag, int vflag)
}
}
if (evflag) ev_tally(i,j,nlocal,newton_pair,
evdwl,0.0,fpair,delx,dely,delz);
if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
}
}
@ -467,10 +467,10 @@ void PairTriLJ::coeff(int narg, char **arg)
void PairTriLJ::init_style()
{
avec = (AtomVecTri *) atom->style_match("tri");
avec = dynamic_cast<AtomVecTri *>( atom->style_match("tri"));
if (!avec) error->all(FLERR,"Pair tri/lj requires atom style tri");
neighbor->request(this,instance_me);
neighbor->add_request(this,NeighConst::REQ_DEFAULT);
}
/* ----------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(tri/lj,PairTriLJ)
// clang-format off
PairStyle(tri/lj,PairTriLJ);
// clang-format on
#else
#ifndef LMP_PAIR_TRI_LJ_H
@ -27,36 +27,36 @@ namespace LAMMPS_NS {
class PairTriLJ : public Pair {
public:
PairTriLJ(class LAMMPS *);
virtual ~PairTriLJ();
virtual void compute(int, int);
void settings(int, char **);
void coeff(int, char **);
virtual void init_style();
double init_one(int, int);
~PairTriLJ() override;
void compute(int, int) override;
void settings(int, char **) override;
void coeff(int, char **) override;
void init_style() override;
double init_one(int, int) override;
protected:
double cut_global;
double **cut;
double **epsilon,**sigma;
double **lj1,**lj2,**lj3,**lj4;
double **epsilon, **sigma;
double **lj1, **lj2, **lj3, **lj4;
class AtomVecTri *avec;
struct Discrete {
double dx,dy,dz;
double dx, dy, dz;
double sigma;
};
Discrete *discrete; // list of all discretes for all lines
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
Discrete *discrete; // list of all discretes for all lines
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
void allocate();
void discretize(int, double, double *, double *, double *);
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -31,7 +31,7 @@ action () {
if (test $1 = 1) then
if (test ! -e ../pair_eam.cpp) then
echo "Must install MANYBODY package with USER-ATC"
echo "Must install MANYBODY package with ATC"
exit 1
fi
fi
@ -54,9 +54,9 @@ if (test $1 = 1) then
# sed -i -e 's|^PKG_INC =[ \t]*|&-I../../lib/atc |' ../Makefile.package
# sed -i -e 's|^PKG_PATH =[ \t]*|&-L../../lib/atc$(LIBSOBJDIR) |' ../Makefile.package
sed -i -e 's|^PKG_LIB =[ \t]*|&-latc |' ../Makefile.package
sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(user-atc_SYSINC) |' ../Makefile.package
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(user-atc_SYSLIB) |' ../Makefile.package
sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(user-atc_SYSPATH) |' ../Makefile.package
sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(atc_SYSINC) |' ../Makefile.package
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(atc_SYSLIB) |' ../Makefile.package
sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(atc_SYSPATH) |' ../Makefile.package
fi
if (test -e ../Makefile.package.settings) then

View File

@ -7,7 +7,7 @@ See the doc page for the fix atc command to get started. At the
bottom of the doc page are many links to additional documentation
contained in the doc/USER/atc directory.
There are example scripts for using this package in examples/USER/atc.
There are example scripts for using this package in examples/PACKAGES/atc.
This package uses an external library in lib/atc which must be
compiled before making LAMMPS. See the lib/atc/README file and the

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/
https://www.lammps.org/
Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -17,7 +18,6 @@
#include "comm.h"
#include "error.h"
#include "group.h"
#include "neigh_request.h"
#include "neighbor.h"
#include "ATC_Method.h"
@ -36,7 +36,7 @@ using namespace FixConst;
using std::string;
#ifdef LAMMPS_BIGBIG
#error "The USER-ATC package is not compatible with -DLAMMPS_BIGBIG"
#error "The ATC package is not compatible with -DLAMMPS_BIGBIG"
#endif
// main page of doxygen documentation
@ -557,11 +557,7 @@ int FixATC::modify_param(int narg, char** arg)
void FixATC::init()
{
// Guarantee construction of full neighborlist
int irequest = neighbor->request(this,instance_me);
neighbor->requests[irequest]->pair = 0;
neighbor->requests[irequest]->fix = 1;
neighbor->requests[irequest]->half = 0;
neighbor->requests[irequest]->full = 1;
neighbor->add_request(this, NeighConst::REQ_FULL);
// create computes, if necessary
atc_->init_computes();
@ -574,7 +570,7 @@ void FixATC::min_setup(int vflag)
void FixATC::setup(int /* vflag */)
{
comm->forward_comm_fix(this);
comm->forward_comm(this);
try {
atc_->initialize();
@ -699,20 +695,17 @@ int FixATC::size_restart(int /* nlocal */) {
void FixATC::write_restart(FILE * /* fp */) {
char ** args = new char*[2];
args[0] = new char[50];
args[1] = new char[50];
sprintf(args[0],"write_restart");
sprintf(args[1],"ATC.restart");
char *args[2];
args[0] = utils::strdup("write_restart");
args[1] = utils::strdup("ATC.restart");
// Then call all objects I own to write their data
if (comm->me == 0) {
atc_->modify(2,args);
}
delete [] args[0];
delete [] args[1];
delete [] args;
delete[] args[0];
delete[] args[1];
}
/* ----------------------------------------------------------------------
@ -721,20 +714,17 @@ void FixATC::write_restart(FILE * /* fp */) {
void FixATC::restart(char * /* buf */) {
char ** args = new char*[2];
args[0] = new char[50];
args[1] = new char[50];
sprintf(args[0],"read_restart");
sprintf(args[1],"ATC.restart");
char *args[2];
args[0] = utils::strdup("read_restart");
args[1] = utils::strdup("ATC.restart");
// Then call all objects I own to write their data
if (comm->me == 0) {
atc_->modify(2,args);
}
delete [] args[0];
delete [] args[1];
delete [] args;
delete[] args[0];
delete[] args[1];
}
/* ----------------------------------------------------------------------
@ -819,7 +809,7 @@ void FixATC::pre_neighbor()
{
try {
atc_->pre_neighbor();
comm->forward_comm_fix(this);
comm->forward_comm(this);
}
catch (ATC::ATC_Error& atcError) {
ATC::LammpsInterface::instance()->print_msg(atcError.error_description());

142
src/ATC/fix_atc.h Normal file
View File

@ -0,0 +1,142 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
// clang-format off
FixStyle(atc,FixATC);
// clang-format on
#else
#ifndef FIX_ATC_H
#define FIX_ATC_H
#include "fix.h"
namespace ATC {
class ATC_Method;
}
namespace LAMMPS_NS {
class NeighList;
/**
* @class FixATC
* @brief Class for an atom-to-continuum (ATC) LAMMPS fix.
*/
class FixATC : public Fix {
public:
/** constructor & destructor */
FixATC(class LAMMPS *, int, char **);
~FixATC() override;
/** initialization functions */
void init() override;
void init_list(int id, NeighList *ptr) override;
void setup(int vflag) override;
void min_setup(int vflag) override;
/** setmask: tell LAMMPS which fix methods to call */
int setmask() override;
/** initial_integrate */
void initial_integrate(int vflag) override;
/** after first integrate phase */
void post_integrate() override;
/** final_integrate */
void final_integrate() override;
/** end of step for run or minimize */
void end_of_step() override;
/** pre_exchange is used to modify fix-specific data
and is called before domain->pbc() and comm->exchange(). */
void setup_pre_exchange() override;
void pre_exchange() override;
void min_pre_exchange() override;
double memory_usage() override;
void grow_arrays(int) override;
void copy_arrays(int, int, int) override;
/** pack_exchange called from atom_vec->pack_exchange()
and packs fix-specific data for a given real (local)
atom being sent to another processor. */
int pack_exchange(int, double *) override;
/** unpack_exchange called from atom_vec->unpack_exchange()
and unpacks fix-specific data for a given real (local)
atom received from another processor. */
int unpack_exchange(int, double *) override;
/** pack_comm called from comm->forward_comm and
packs fix-specific data for a given ghost atom
from exchange with another proc */
int pack_forward_comm(int, int *, double *, int, int *) override;
/** unpack_comm called from comm->forward_comm and
unpacks fix-specific data for a given ghost atom
from exchange with another proc */
void unpack_forward_comm(int, int, double *) override;
/** pre_neighbor is used to modify fix-specific data
and is called before neighbor list is built in
neighbor->build(). */
void pre_neighbor() override;
void setup_pre_neighbor() override;
/** pre/post_force is used to modify fix-specific data
and is before/after the various force computations. */
void pre_force(int vflag) override;
void post_force(int vflag) override;
/** post_run is called after a run completes */
void post_run() override;
/** min_pre_force is called before forces are calculated in minimize */
void min_pre_force(int vflag) override;
/** min_post_force is called after forces are calculated in minimize */
void min_post_force(int vflag) override;
/** modify atc parameters (parser) */
int modify_param(int narg, char **arg) override;
/** calls ATC_Method to handle restarting/checkpointing */
/** these four methods are for writing per-atom quantities */
int pack_restart(int, double *) override;
void unpack_restart(int, int) override;
int size_restart(int) override;
int maxsize_restart() override;
/** these two methods are for writing all other quantities */
void write_restart(FILE *) override;
void restart(char *) override;
/** accessor function for ATC_Method class pointer */
const ATC::ATC_Method *atc() { return atc_; }
protected:
LAMMPS *lammps_;
/** functions for "thermo" output */
double compute_scalar() override;
double compute_vector(int n) override;
double compute_array(int irow, int icol) override;
double dtv, dtf;
ATC::ATC_Method *atc_;
};
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -41,8 +41,8 @@ if (test $1 = 1) then
sed -i -e 's|^PKG_INC =[ \t]*|&-I../../lib/awpmd/ivutils/include -I../../lib/awpmd/systems/interact |' ../Makefile.package
sed -i -e 's|^PKG_PATH =[ \t]*|&-L../../lib/awpmd |' ../Makefile.package
sed -i -e 's|^PKG_LIB =[ \t]*|&-lawpmd |' ../Makefile.package
sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(user-awpmd_SYSPATH) |' ../Makefile.package
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(user-awpmd_SYSLIB) |' ../Makefile.package
sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(awpmd_SYSPATH) |' ../Makefile.package
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(awpmd_SYSLIB) |' ../Makefile.package
fi
if (test -e ../Makefile.package.settings) then

View File

@ -4,7 +4,7 @@ Wave Packet Molecular Dynamics (AWPMD) method.
See the doc page for the pair_style awpmd/cut command to get started.
There are example scripts for using this package in
examples/USER/awpmd.
examples/PACKAGES/awpmd.
This package uses an external library in lib/awpmd which must be
compiled before making LAMMPS. See the lib/awpmd/README file and the

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -19,8 +19,6 @@
#include "atom.h"
#include <cstring>
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
@ -31,33 +29,29 @@ AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp)
molecular = Atom::ATOMIC;
forceclearflag = 1;
atom->wavepacket_flag = 1;
atom->electron_flag = 1; // compatible with eff
atom->q_flag = atom->spin_flag = atom->eradius_flag =
atom->ervel_flag = atom->erforce_flag = 1;
atom->cs_flag = atom->csforce_flag =
atom->vforce_flag = atom->ervelforce_flag = atom->etag_flag = 1;
atom->wavepacket_flag = atom->q_flag = atom->spin_flag = atom->eradius_flag = 1;
atom->ervel_flag = atom->erforce_flag = atom->cs_flag = atom->csforce_flag = 1;
atom->vforce_flag = atom->ervelforce_flag = atom->etag_flag = 1;
// strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings
// order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file
fields_grow = (char *)
"q spin eradius ervel erforce cs csforce "
"vforce ervelforce etag";
fields_copy = (char *) "q spin eradius ervel cs etag";
fields_comm = (char *) "eradius";
fields_comm_vel = (char *) "eradius ervel cs";
fields_reverse = (char *) "erforce ervelforce vforce csforce";
fields_border = (char *) "q spin eradius etag";
fields_border_vel = (char *) "q spin eradius etag ervel cs";
fields_exchange = (char *) "q spin eradius ervel etag cs";
fields_restart = (char *) "q spin eradius ervel etag cs";
fields_create = (char *) "q spin eradius ervel etag cs";
fields_data_atom = (char *) "id type q spin eradius etag cs x";
fields_data_vel = (char *) "id v ervel";
fields_grow = {"q", "spin", "eradius", "ervel", "erforce",
"cs", "csforce", "vforce", "ervelforce", "etag"};
fields_copy = {"q", "spin", "eradius", "ervel", "cs", "etag"};
fields_comm = {"eradius"};
fields_comm_vel = {"eradius", "ervel", "cs"};
fields_reverse = {"erforce", "ervelforce", "vforce", "csforce"};
fields_border = {"q", "spin", "eradius", "etag"};
fields_border_vel = {"q", "spin", "eradius", "etag", "ervel", "cs"};
fields_exchange = {"q", "spin", "eradius", "ervel", "etag", "cs"};
fields_restart = {"q", "spin", "eradius", "ervel", "etag", "cs"};
fields_create = {"q", "spin", "eradius", "ervel", "etag", "cs"};
fields_data_atom = {"id", "type", "q", "spin", "eradius", "etag", "cs", "x"};
fields_data_vel = {"id", "v", "ervel"};
setup_fields();
}
@ -83,7 +77,7 @@ void AtomVecWavepacket::grow_pointers()
void AtomVecWavepacket::force_clear(int n, size_t nbytes)
{
memset(&erforce[n],0,nbytes);
memset(&erforce[n], 0, nbytes);
}
/* ----------------------------------------------------------------------
@ -111,12 +105,12 @@ void AtomVecWavepacket::data_atom_post(int ilocal)
return -1 if name is unknown to this atom style
------------------------------------------------------------------------- */
int AtomVecWavepacket::property_atom(char *name)
int AtomVecWavepacket::property_atom(const std::string &name)
{
if (strcmp(name,"spin") == 0) return 0;
if (strcmp(name,"eradius") == 0) return 1;
if (strcmp(name,"ervel") == 0) return 2;
if (strcmp(name,"erforce") == 0) return 3;
if (name == "spin") return 0;
if (name == "eradius") return 1;
if (name == "ervel") return 2;
if (name == "erforce") return 3;
return -1;
}
@ -125,34 +119,41 @@ int AtomVecWavepacket::property_atom(char *name)
index maps to data specific to this atom style
------------------------------------------------------------------------- */
void AtomVecWavepacket::pack_property_atom(int index, double *buf,
int nvalues, int groupbit)
void AtomVecWavepacket::pack_property_atom(int index, double *buf, int nvalues, int groupbit)
{
int nlocal = atom->nlocal;
int n = 0;
if (index == 0) {
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = spin[i];
else buf[n] = 0.0;
if (mask[i] & groupbit)
buf[n] = spin[i];
else
buf[n] = 0.0;
n += nvalues;
}
} else if (index == 1) {
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = eradius[i];
else buf[n] = 0.0;
if (mask[i] & groupbit)
buf[n] = eradius[i];
else
buf[n] = 0.0;
n += nvalues;
}
} else if (index == 2) {
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = ervel[i];
else buf[n] = 0.0;
if (mask[i] & groupbit)
buf[n] = ervel[i];
else
buf[n] = 0.0;
n += nvalues;
}
} else if (index == 3) {
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = erforce[i];
else buf[n] = 0.0;
if (mask[i] & groupbit)
buf[n] = erforce[i];
else
buf[n] = 0.0;
n += nvalues;
}
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef ATOM_CLASS
AtomStyle(wavepacket,AtomVecWavepacket)
// clang-format off
AtomStyle(wavepacket,AtomVecWavepacket);
// clang-format on
#else
#ifndef LMP_ATOM_VEC_WAVEPACKET_H
@ -25,22 +25,22 @@ AtomStyle(wavepacket,AtomVecWavepacket)
namespace LAMMPS_NS {
class AtomVecWavepacket : public AtomVec {
public:
public:
AtomVecWavepacket(class LAMMPS *);
void grow_pointers();
void force_clear(int, size_t);
void create_atom_post(int);
void data_atom_post(int);
int property_atom(char *);
void pack_property_atom(int, double *, int, int);
void grow_pointers() override;
void force_clear(int, size_t) override;
void create_atom_post(int) override;
void data_atom_post(int) override;
int property_atom(const std::string &) override;
void pack_property_atom(int, double *, int, int) override;
private:
int *spin;
double *q,*eradius,*ervel,*erforce;
double *q, *eradius, *ervel, *erforce;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -60,9 +61,9 @@ void FixNVEAwpmd::init()
dtf = 0.5 * update->dt * force->ftm2v;
if (utils::strmatch(update->integrate_style,"^respa"))
step_respa = ((Respa *) update->integrate)->step;
step_respa = (dynamic_cast<Respa *>( update->integrate))->step;
awpmd_pair=(PairAWPMDCut *)force->pair;
awpmd_pair=dynamic_cast<PairAWPMDCut *>(force->pair);
awpmd_pair->wpmd->norm_needed=1;
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -16,9 +16,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nve/awpmd,FixNVEAwpmd)
// clang-format off
FixStyle(nve/awpmd,FixNVEAwpmd);
// clang-format on
#else
#ifndef LMP_FIX_NVE_awpmd_H
@ -31,23 +31,23 @@ namespace LAMMPS_NS {
class FixNVEAwpmd : public Fix {
public:
FixNVEAwpmd(class LAMMPS *, int, char **);
int setmask();
virtual void init();
virtual void initial_integrate(int);
virtual void final_integrate();
void initial_integrate_respa(int, int, int);
void final_integrate_respa(int, int);
void reset_dt();
int setmask() override;
void init() override;
void initial_integrate(int) override;
void final_integrate() override;
void initial_integrate_respa(int, int, int) override;
void final_integrate_respa(int, int) override;
void reset_dt() override;
protected:
double dtv,dtf;
double dtv, dtf;
double *step_respa;
int mass_require;
class PairAWPMDCut *awpmd_pair;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -25,7 +26,6 @@
#include "memory.h"
#include "min.h"
#include "neigh_list.h"
#include "neigh_request.h"
#include "neighbor.h"
#include "update.h"
@ -38,7 +38,6 @@
#include <cstring>
#include <map>
#include <utility>
#include <vector>
using namespace LAMMPS_NS;
@ -96,10 +95,7 @@ struct cmp_x{
else if (d>tol)
return false;
d=xx[left.second][2]-xx[right.second][2];
if (d<-tol)
return true;
else
return false;
return d < -tol;
}
else
return left.first<right.first;
@ -150,7 +146,7 @@ void PairAWPMDCut::compute(int eflag, int vflag)
# if 1
// mapping of the LAMMPS numbers to the AWPMC numbers
vector<int> gmap(ntot,-1);
std::vector<int> gmap(ntot,-1);
for (int ii = 0; ii < inum; ii++) {
int i = ilist[ii];
@ -226,7 +222,7 @@ void PairAWPMDCut::compute(int eflag, int vflag)
// prepare the solver object
wpmd->reset();
map<int,vector<int> > etmap;
std::map<int,std::vector<int> > etmap;
// add particles to the AWPMD solver object
for (int i = 0; i < ntot; i++) {
//int i = ilist[ii];
@ -246,8 +242,8 @@ void PairAWPMDCut::compute(int eflag, int vflag)
fi= new Vector_3[wpmd->ni];
// adding electrons
for (map<int,vector<int> >::iterator it=etmap.begin(); it!= etmap.end(); ++it) {
vector<int> &el=it->second;
for (auto & it : etmap) {
std::vector<int> &el=it.second;
if (!el.size()) // should not happen
continue;
int s=spin[el[0]] >0 ? 0 : 1;
@ -513,45 +509,18 @@ void PairAWPMDCut::init_style()
if (!atom->q_flag || !atom->spin_flag ||
!atom->eradius_flag || !atom->erforce_flag ) // TO DO: adjust this to match approximation used
error->all(FLERR,"Pair awpmd/cut requires atom attributes "
"q, spin, eradius, erforce");
/*
if (vflag_atom) { // can't compute virial per atom
//warning->
error->all(FLERR,"Pair style awpmd can't compute per atom virials");
}*/
error->all(FLERR,"Pair awpmd/cut requires atom attributes q, spin, eradius, erforce");
// add hook to minimizer for eradius and erforce
if (update->whichflag == 2)
int ignore = update->minimize->request(this,1,0.01);
// make sure to use the appropriate timestep when using real units
/*if (update->whichflag == 1) {
if (force->qqr2e == 332.06371 && update->dt == 1.0)
error->all(FLERR,"You must lower the default real units timestep for pEFF ");
}*/
// need a half neigh list and optionally a granular history neigh list
//int irequest = neighbor->request(this,instance_me);
//if (atom->tag_enable == 0)
// error->all(FLERR,"Pair style reax requires atom IDs");
//if (force->newton_pair == 0)
//error->all(FLERR,"Pair style awpmd requires newton pair on");
//if (strcmp(update->unit_style,"real") != 0 && comm->me == 0)
//error->warning(FLERR,"Not using real units with pair reax");
int irequest = neighbor->request(this,instance_me);
neighbor->requests[irequest]->newton = 2;
neighbor->add_request(this, NeighConst::REQ_NEWTON_OFF);
if (force->e_mass==0. || force->hhmrr2e==0. || force->mvh2r==0.)
error->all(FLERR,"Pair style awpmd requires e_mass and conversions hhmrr2e, mvh2r to be properly set for unit system");
error->all(FLERR,"Pair style awpmd requires e_mass and conversions "
"hhmrr2e, mvh2r to be properly set for unit system");
wpmd->me=force->e_mass;
wpmd->h2_me=force->hhmrr2e/force->e_mass;

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -14,11 +14,10 @@
Contributing author: Ilya Valuev (JIHT RAS)
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(awpmd/cut,PairAWPMDCut)
// clang-format off
PairStyle(awpmd/cut,PairAWPMDCut);
// clang-format on
#else
#ifndef LMP_PAIR_AWPMD_CUT_H
@ -26,56 +25,51 @@ PairStyle(awpmd/cut,PairAWPMDCut)
#include "pair.h"
class AWPMD_split;
namespace LAMMPS_NS {
class PairAWPMDCut : public Pair {
friend class FixNVEAwpmd;
public:
PairAWPMDCut(class LAMMPS *);
virtual ~PairAWPMDCut();
virtual void compute(int, int);
virtual void settings(int, char **);
void coeff(int, char **);
void init_style();
~PairAWPMDCut() override;
void compute(int, int) override;
void settings(int, char **) override;
void coeff(int, char **) override;
void init_style() override;
void min_pointers(double **, double **);
double init_one(int, int);
void write_restart(FILE *);
void read_restart(FILE *);
virtual void write_restart_settings(FILE *);
virtual void read_restart_settings(FILE *);
double init_one(int, int) override;
void write_restart(FILE *) override;
void read_restart(FILE *) override;
void write_restart_settings(FILE *) override;
void read_restart_settings(FILE *) override;
void min_xf_pointers(int, double **, double **);
void min_xf_get(int);
void min_x_set(int);
double memory_usage();
void min_xf_pointers(int, double **, double **) override;
void min_xf_get(int) override;
void min_x_set(int) override;
double memory_usage() override;
private:
int flexible_pressure_flag;
double cut_global;
double **cut;
int nmax; // number of additional variables for minimizer
double *min_var,*min_varforce; // additional variables for minimizer
int nmax; // number of additional variables for minimizer
double *min_var, *min_varforce; // additional variables for minimizer
void allocate();
void virial_eradius_compute();
AWPMD_split *wpmd; // solver object
double ermscale; // scale of width mass for motion
double width_pbc; // setting for width pbc
double half_box_length; // calculated by coeff function
AWPMD_split *wpmd; // solver object
double ermscale; // scale of width mass for motion
double width_pbc; // setting for width pbc
double half_box_length; // calculated by coeff function
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -7,7 +7,7 @@ molecular liquids," J. Chem. Phys. 143, 243148 (2015).
doi: 10.1063/1.4937383
The USER-BOCS user package for LAMMPS is part of the BOCS software package:
The BOCS user package for LAMMPS is part of the BOCS software package:
https://github.com/noid-group/BOCS
See the following reference for information about the entire package:
@ -16,4 +16,4 @@ Dunn, NJH; Lebold, KM; DeLyser, MR; Rudzinski, JF; Noid, WG.
"BOCS: Bottom-Up Open-Source Coarse-Graining Software."
J. Phys. Chem. B. 122, 13, 3363-3377 (2018).
Example inputs are in the examples/USER/bocs folder.
Example inputs are in the examples/PACKAGES/bocs folder.

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -10,7 +11,7 @@
See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------
USER-BOCS written by: Nicholas J. H. Dunn and Michael R. DeLyser
BOCS written by: Nicholas J. H. Dunn and Michael R. DeLyser
from The Pennsylvania State University
------------------------------------------------------------------------- */
@ -59,9 +60,7 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
if (strcmp(arg[3],"NULL") == 0) id_temp = nullptr;
else {
int n = strlen(arg[3]) + 1;
id_temp = new char[n];
strcpy(id_temp,arg[3]);
id_temp = utils::strdup(arg[3]);
int icompute = modify->find_compute(id_temp);
if (icompute < 0)
@ -217,7 +216,7 @@ double ComputePressureBocs::find_index(double * grid, double value)
if (value >= grid[i] && value <= (grid[i] + spacing)) { return i; }
error->all(FLERR, fmt::format("find_index could not find value in grid for value: {}", value));
error->all(FLERR,"find_index could not find value in grid for value: {}", value);
for (int i = 0; i < gridsize; ++i)
{
fprintf(stderr, "grid %d: %f\n",i,grid[i]);
@ -234,23 +233,14 @@ double ComputePressureBocs::get_cg_p_corr(double ** grid, int basis_type,
double vCG)
{
int i = find_index(grid[0],vCG);
double correction, deltax = vCG - grid[0][i];
double deltax = vCG - grid[0][i];
if (basis_type == BASIS_LINEAR_SPLINE)
{
correction = grid[1][i] + (deltax) *
( grid[1][i+1] - grid[1][i] ) / ( grid[0][i+1] - grid[0][i] );
}
return grid[1][i] + (deltax) * ( grid[1][i+1] - grid[1][i] ) / ( grid[0][i+1] - grid[0][i] );
else if (basis_type == BASIS_CUBIC_SPLINE)
{
correction = grid[1][i] + (grid[2][i] * deltax) +
(grid[3][i] * pow(deltax,2)) + (grid[4][i] * pow(deltax,3));
}
else
{
error->all(FLERR,"bad spline type passed to get_cg_p_corr()\n");
}
return correction;
return grid[1][i] + (grid[2][i] * deltax) + (grid[3][i] * pow(deltax,2)) + (grid[4][i] * pow(deltax,3));
else error->all(FLERR,"bad spline type passed to get_cg_p_corr()\n");
return 0.0;
}
/* ----------------------------------------------------------------------
@ -262,11 +252,8 @@ void ComputePressureBocs::send_cg_info(int basis_type, int sent_N_basis,
double *sent_phi_coeff, int sent_N_mol,
double sent_vavg)
{
if (basis_type == BASIS_ANALYTIC) { p_basis_type = BASIS_ANALYTIC; }
else
{
error->all(FLERR,"Incorrect basis type passed to ComputePressureBocs\n");
}
if (basis_type == BASIS_ANALYTIC) p_basis_type = BASIS_ANALYTIC;
else error->all(FLERR,"Incorrect basis type passed to ComputePressureBocs\n");
p_match_flag = 1;
@ -446,7 +433,5 @@ void ComputePressureBocs::virial_compute(int n, int ndiag)
void ComputePressureBocs::reset_extra_compute_fix(const char *id_new)
{
delete [] id_temp;
int n = strlen(id_new) + 1;
id_temp = new char[n];
strcpy(id_temp,id_new);
id_temp = utils::strdup(id_new);
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -10,74 +10,73 @@
See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------
USER-BOCS written by: Nicholas J. H. Dunn and Michael R. DeLyser
BOCS written by: Nicholas J. H. Dunn and Michael R. DeLyser
from The Pennsylvania State University
------------------------------------------------------------------------- */
#ifdef COMPUTE_CLASS
ComputeStyle(PRESSURE/BOCS,ComputePressureBocs)
// clang-format off
ComputeStyle(PRESSURE/BOCS,ComputePressureBocs);
// clang-format on
#else
#ifndef LMP_COMPUTE_PRESSURE_BOCS_H
#define LMP_COMPUTE_PRESSURE_BOCS_H
#include "compute.h"
namespace LAMMPS_NS {
// Enumerate the p_basis_type magic values to improve readability:
enum{BASIS_ANALYTIC, BASIS_LINEAR_SPLINE, BASIS_CUBIC_SPLINE};
// Enumerate the data file column names to improve readability
enum{VOLUME, PRESSURE_CORRECTION};
// Declare names for the number of columns in the splines data structure to improve readability
const int NUM_LINEAR_SPLINE_COLUMNS = 2; // linear spline columns passed to compute
const int NUM_CUBIC_SPLINE_COLUMNS = 5; // cubic spline columns passed to compute
// Enumerate the p_basis_type magic values to improve readability:
enum { BASIS_ANALYTIC, BASIS_LINEAR_SPLINE, BASIS_CUBIC_SPLINE };
// Enumerate the data file column names to improve readability
enum { VOLUME, PRESSURE_CORRECTION };
// Declare names for the number of columns in the splines data structure to improve readability
const int NUM_LINEAR_SPLINE_COLUMNS = 2; // linear spline columns passed to compute
const int NUM_CUBIC_SPLINE_COLUMNS = 5; // cubic spline columns passed to compute
// ComputePressure -> ComputePressureBocs MRD NJD
// ComputePressure -> ComputePressureBocs MRD NJD
class ComputePressureBocs : public Compute {
public:
ComputePressureBocs(class LAMMPS *, int, char **);
virtual ~ComputePressureBocs();
virtual void init();
virtual double compute_scalar();
virtual void compute_vector();
void reset_extra_compute_fix(const char *);
~ComputePressureBocs() override;
void init() override;
double compute_scalar() override;
void compute_vector() override;
void reset_extra_compute_fix(const char *) override;
double compute_cg_scalar();
double get_cg_p_corr(int, double *, int, double, double);
double get_cg_fluct(double, double);
void send_cg_info(int, int, double*, int, double);
void send_cg_info(int, int, double *, int, double);
void send_cg_info(int, double **, int);
double get_cg_p_corr(double **, int, double);
double find_index(double* , double);
double find_index(double *, double);
protected:
double boltz,nktv2p,inv_volume;
int nvirial,dimension;
double boltz, nktv2p, inv_volume;
int nvirial, dimension;
double **vptr;
double *kspace_virial;
Compute *temperature;
char *id_temp;
double virial[6];
int keflag,pairflag,bondflag,angleflag,dihedralflag,improperflag;
int fixflag,kspaceflag;
int keflag, pairflag, bondflag, angleflag, dihedralflag, improperflag;
int fixflag, kspaceflag;
// NJD MRD
// NJD MRD
int p_basis_type;
int p_match_flag;
double vavg;
int N_mol;
int N_basis;
double *phi_coeff;
double ** splines;
double **splines;
int spline_length;
void virial_compute(int, int);
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -10,17 +11,12 @@
See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------
USER-BOCS written by: Nicholas J. H. Dunn and Michael R. DeLyser
BOCS written by: Nicholas J. H. Dunn and Michael R. DeLyser
from The Pennsylvania State University
------------------------------------------------------------------------- */
#include "fix_bocs.h"
#include <cstring>
#include <cmath>
#include <vector>
#include "atom.h"
#include "citeme.h"
#include "comm.h"
@ -29,7 +25,6 @@
#include "domain.h"
#include "error.h"
#include "fix_deform.h"
#include "force.h"
#include "group.h"
#include "irregular.h"
@ -40,11 +35,14 @@
#include "respa.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
static const char cite_user_bocs_package[] =
"USER-BOCS package:\n\n"
"BOCS package:\n\n"
"@Article{Dunn2018,\n"
" author = {NJH Dunn, KM Lebold, MR DeLyser, JF Rudzinski, WG Noid},\n"
" title = {BOCS: Bottom-Up Open-Source Coarse-Graining Software},\n"
@ -70,7 +68,8 @@ const int NUM_INPUT_DATA_COLUMNS = 2; // columns in the pressure correction
FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg),
rfix(nullptr), id_dilate(nullptr), irregular(nullptr), id_temp(nullptr), id_press(nullptr),
rfix(nullptr), id_dilate(nullptr), irregular(nullptr),
id_temp(nullptr), id_press(nullptr),
eta(nullptr), eta_dot(nullptr), eta_dotdot(nullptr),
eta_mass(nullptr), etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr),
etap_mass(nullptr)
@ -234,9 +233,7 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
iarg += 2;
} else if (strcmp(arg[iarg],"mtk") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command");
if (strcmp(arg[iarg+1],"yes") == 0) mtk_flag = 1;
else if (strcmp(arg[iarg+1],"no") == 0) mtk_flag = 0;
else error->all(FLERR,"Illegal fix bocs command");
mtk_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"tloop") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command");
@ -403,38 +400,16 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
int n = strlen(id) + 6;
id_temp = new char[n];
strcpy(id_temp,id);
strcat(id_temp,"_temp");
char **newarg = new char*[3];
newarg[0] = id_temp;
newarg[1] = (char *) "all";
newarg[2] = (char *) "temp";
modify->add_compute(3,newarg);
delete [] newarg;
id_temp = utils::strdup(std::string(id)+"_temp");
modify->add_compute(fmt::format("{} all temp",id_temp));
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
n = strlen(id) + 7;
id_press = new char[n];
strcpy(id_press,id);
strcat(id_press,"_press");
newarg = new char*[4];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "PRESSURE/BOCS";
newarg[3] = id_temp;
modify->add_compute(4,newarg);
delete [] newarg;
id_press = utils::strdup(std::string(id)+"_press");
modify->add_compute(fmt::format("{} all PRESSURE/BOCS {}",id_press,id_temp));
pcomputeflag = 1;
/*~ MRD End of stuff copied from fix_npt.cpp~*/
@ -514,7 +489,7 @@ void FixBocs::init()
{
for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"deform") == 0) {
int *dimflag = ((FixDeform *) modify->fix[i])->dimflag;
int *dimflag = (dynamic_cast<FixDeform *>( modify->fix[i]))->dimflag;
if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) ||
(p_flag[2] && dimflag[2]) || (p_flag[3] && dimflag[3]) ||
(p_flag[4] && dimflag[4]) || (p_flag[5] && dimflag[5]))
@ -548,12 +523,12 @@ void FixBocs::init()
{
if (p_basis_type == BASIS_ANALYTIC)
{
((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type,
(dynamic_cast<ComputePressureBocs *>(pressure))->send_cg_info(p_basis_type,
N_p_match, p_match_coeffs, N_mol, vavg);
}
else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE)
{
((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type,
(dynamic_cast<ComputePressureBocs *>(pressure))->send_cg_info(p_basis_type,
splines, spline_length);
}
}
@ -613,9 +588,9 @@ void FixBocs::init()
if (force->kspace) kspace_flag = 1;
else kspace_flag = 0;
if (strstr(update->integrate_style,"respa")) {
nlevels_respa = ((Respa *) update->integrate)->nlevels;
step_respa = ((Respa *) update->integrate)->step;
if (utils::strmatch(update->integrate_style,"^respa")) {
nlevels_respa = (dynamic_cast<Respa *>( update->integrate))->nlevels;
step_respa = (dynamic_cast<Respa *>( update->integrate))->step;
dto = 0.5*step_respa[0];
}
@ -652,7 +627,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
// NB: LAMMPS coding guidelines prefer cstdio so we are intentionally
// foregoing reading with getline
if (comm->me == 0) {
error->message(FLERR, fmt::format("INFO: About to read data file: {}", filename));
error->message(FLERR, "INFO: About to read data file: {}", filename);
}
// Data file lines hold two floating point numbers.
@ -662,13 +637,13 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
char line[MAX_F_TABLE_LINE_LENGTH];
std::vector<std::string> inputLines;
while (fgets(line, MAX_F_TABLE_LINE_LENGTH, fpi)) {
inputLines.push_back(std::string(line));
inputLines.emplace_back(line);
}
fclose(fpi);
numEntries = inputLines.size();
if (comm->me == 0) {
error->message(FLERR, fmt::format("INFO: Read {} lines from file", numEntries));
error->message(FLERR, "INFO: Read {} lines from file", numEntries);
}
@ -693,34 +668,23 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
test_sscanf = sscanf(inputLines.at(i).c_str()," %f , %f ",&f1, &f2);
if (test_sscanf == 2)
{
//if (comm->me == 0) {
// error->message(FLERR, fmt::format("INFO: f1 = {}, f2 = {}", f1, f2));
//}
data[VOLUME][i] = (double)f1;
data[PRESSURE_CORRECTION][i] = (double)f2;
if (i == 1)
{
// second entry is used to compute the validation interval used below
stdVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1];
//if (comm->me == 0) {
// error->message(FLERR, fmt::format("INFO: standard volume interval computed: {}", stdVolumeInterval));
//}
}
else if (i > 1)
{
// after second entry, all intervals are validated
currVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1];
//if (comm->me == 0) {
// error->message(FLERR, fmt::format("INFO: current volume interval: {}", currVolumeInterval));
//}
if (fabs(currVolumeInterval - stdVolumeInterval) > volumeIntervalTolerance) {
if (comm->me == 0) {
message = fmt::format("Bad volume interval. Spline analysis requires uniform"
" volume distribution, found inconsistent volume"
" differential, line {} of file {}\n\tline: {}",
lineNum, filename, inputLines.at(i));
error->warning(FLERR, message);
}
if (comm->me == 0)
error->warning(FLERR,"Bad volume interval. Spline analysis requires uniform"
" volume distribution, found inconsistent volume"
" differential, line {} of file {}\nWARNING:\tline: {}",
lineNum, filename, inputLines.at(i));
badInput = true;
numBadVolumeIntervals++;
}
@ -729,12 +693,10 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
}
else
{
if (comm->me == 0) {
message = fmt::format("Bad input format: did not find 2 comma separated numeric"
" values in line {} of file {}\n\tline: {}",
lineNum, filename, inputLines.at(i));
error->warning(FLERR, message);
}
if (comm->me == 0)
error->warning(FLERR,"Bad input format: did not find 2 comma separated numeric"
" values in line {} of file {}\nWARNING:\tline: {}",
lineNum, filename, inputLines.at(i));
badInput = true;
}
if (badInput)
@ -744,15 +706,15 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
}
if (numBadVolumeIntervals > 0 && comm->me == 0) {
error->message(FLERR, fmt::format("INFO: total number bad volume intervals = {}", numBadVolumeIntervals));
error->message(FLERR, "INFO: total number bad volume intervals = {}", numBadVolumeIntervals);
}
}
else {
error->all(FLERR,fmt::format("ERROR: Unable to open file: {}", filename));
error->all(FLERR,"ERROR: Unable to open file: {}", filename);
}
if (badInput && comm->me == 0) {
error->warning(FLERR,fmt::format("Bad volume / pressure-correction data: {}\nSee details above", filename));
error->warning(FLERR,"Bad volume / pressure-correction data: {}\nSee details above", filename);
}
if (p_basis_type == BASIS_LINEAR_SPLINE)
@ -767,7 +729,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
}
else
{
error->all(FLERR,fmt::format("ERROR: invalid p_basis_type value of {} in read_F_table", p_basis_type));
error->all(FLERR,"ERROR: invalid p_basis_type value of {} in read_F_table", p_basis_type);
}
memory->destroy(data);
@ -775,9 +737,6 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
}
int FixBocs::build_linear_splines(double **data) {
//if (comm->me == 0) {
//error->message(FLERR, fmt::format("INFO: entering build_linear_splines, spline_length = {}", spline_length));
//}
splines = (double **) calloc(NUM_LINEAR_SPLINE_COLUMNS,sizeof(double *));
splines[VOLUME] = (double *) calloc(spline_length,sizeof(double));
splines[PRESSURE_CORRECTION] = (double *) calloc(spline_length,sizeof(double));
@ -789,7 +748,7 @@ int FixBocs::build_linear_splines(double **data) {
}
if (comm->me == 0) {
error->message(FLERR, fmt::format("INFO: leaving build_linear_splines, spline_length = {}", spline_length));
error->message(FLERR, "INFO: leaving build_linear_splines, spline_length = {}", spline_length);
}
return spline_length;
@ -797,9 +756,6 @@ int FixBocs::build_linear_splines(double **data) {
int FixBocs::build_cubic_splines(double **data)
{
//if (comm->me == 0) {
//error->message(FLERR, fmt::format("INFO: entering build_cubic_splines, spline_length = {}", spline_length));
//}
int n = spline_length;
double *a, *b, *d, *h, *alpha, *c, *l, *mu, *z;
// 2020-07-17 ag:
@ -890,7 +846,7 @@ int FixBocs::build_cubic_splines(double **data)
memory->destroy(z);
if (comm->me == 0) {
error->message(FLERR, fmt::format("INFO: leaving build_cubic_splines, numSplines = {}", numSplines));
error->message(FLERR, "INFO: leaving build_cubic_splines, numSplines = {}", numSplines);
}
// Tell the caller how many splines we created
@ -1141,7 +1097,12 @@ void FixBocs::initial_integrate_respa(int /*vflag*/, int ilevel, int /*iloop*/)
nve_x();
if (pstat_flag) remap();
}
}
/* ---------------------------------------------------------------------- */
void FixBocs::pre_force_respa(int /*vflag*/, int ilevel, int /*iloop*/)
{
// if barostat, redo KSpace coeffs at outermost level,
// since volume has changed
@ -1491,7 +1452,7 @@ int FixBocs::pack_restart_data(double *list)
void FixBocs::restart(char *buf)
{
int n = 0;
double *list = (double *) buf;
auto list = (double *) buf;
int flag = static_cast<int> (list[n++]);
if (flag) {
int m = static_cast<int> (list[n++]);
@ -1548,9 +1509,7 @@ int FixBocs::modify_param(int narg, char **arg)
tcomputeflag = 0;
}
delete [] id_temp;
int n = strlen(arg[1]) + 1;
id_temp = new char[n];
strcpy(id_temp,arg[1]);
id_temp = utils::strdup(arg[1]);
int icompute = modify->find_compute(arg[1]);
if (icompute < 0)
@ -1582,9 +1541,7 @@ int FixBocs::modify_param(int narg, char **arg)
pcomputeflag = 0;
}
delete [] id_press;
int n = strlen(arg[1]) + 1;
id_press = new char[n];
strcpy(id_press,arg[1]);
id_press = utils::strdup(arg[1]);
int icompute = modify->find_compute(arg[1]);
if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID");
@ -1594,12 +1551,12 @@ int FixBocs::modify_param(int narg, char **arg)
{
if (p_basis_type == BASIS_ANALYTIC)
{
((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, N_p_match,
(dynamic_cast<ComputePressureBocs *>(pressure))->send_cg_info(p_basis_type, N_p_match,
p_match_coeffs, N_mol, vavg);
}
else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE )
{
((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, splines, spline_length );
(dynamic_cast<ComputePressureBocs *>(pressure))->send_cg_info(p_basis_type, splines, spline_length );
}
}
@ -1877,7 +1834,7 @@ void FixBocs::reset_dt()
// If using respa, then remap is performed in innermost level
if (strstr(update->integrate_style,"respa"))
if (utils::strmatch(update->integrate_style,"^respa"))
dto = 0.5*step_respa[0];
if (pstat_flag)

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -10,15 +10,14 @@
See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------
USER-BOCS written by: Nicholas J. H. Dunn and Michael R. DeLyser
BOCS written by: Nicholas J. H. Dunn and Michael R. DeLyser
from The Pennsylvania State University
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(bocs,FixBocs)
// clang-format off
FixStyle(bocs,FixBocs);
// clang-format on
#else
#ifndef LMP_FIX_BOCS_H
@ -30,119 +29,118 @@ namespace LAMMPS_NS {
class FixBocs : public Fix {
public:
FixBocs(class LAMMPS *, int, char **); // MRD NJD
virtual ~FixBocs(); // MRD NJD
int setmask();
virtual void init();
virtual void setup(int);
virtual void initial_integrate(int);
virtual void final_integrate();
void initial_integrate_respa(int, int, int);
void final_integrate_respa(int, int);
virtual void pre_exchange();
double compute_scalar();
virtual double compute_vector(int);
void write_restart(FILE *);
virtual int pack_restart_data(double *); // pack restart data
virtual void restart(char *);
int modify_param(int, char **);
void reset_target(double);
void reset_dt();
virtual void *extract(const char*,int &);
double memory_usage();
FixBocs(class LAMMPS *, int, char **); // MRD NJD
~FixBocs() override; // MRD NJD
int setmask() override;
void init() override;
void setup(int) override;
void initial_integrate(int) override;
void final_integrate() override;
void initial_integrate_respa(int, int, int) override;
void pre_force_respa(int, int, int) override;
void final_integrate_respa(int, int) override;
void pre_exchange() override;
double compute_scalar() override;
double compute_vector(int) override;
void write_restart(FILE *) override;
virtual int pack_restart_data(double *); // pack restart data
void restart(char *) override;
int modify_param(int, char **) override;
void reset_target(double) override;
void reset_dt() override;
void *extract(const char *, int &) override;
double memory_usage() override;
protected:
int dimension,which;
double dtv,dtf,dthalf,dt4,dt8,dto;
double boltz,nktv2p,tdof;
double vol0; // reference volume
double t0; // reference temperature
// used for barostat mass
double t_start,t_stop;
double t_current,t_target,ke_target;
int dimension, which;
double dtv, dtf, dthalf, dt4, dt8, dto;
double boltz, nktv2p, tdof;
double vol0; // reference volume
double t0; // reference temperature
// used for barostat mass
double t_start, t_stop;
double t_current, t_target, ke_target;
double t_freq;
int tstat_flag; // 1 if control T
int pstat_flag; // 1 if control P
int tstat_flag; // 1 if control T
int pstat_flag; // 1 if control P
int pstyle,pcouple,allremap;
int p_flag[6]; // 1 if control P on this dim, 0 if not
double p_start[6],p_stop[6];
double p_freq[6],p_target[6];
double omega[6],omega_dot[6];
int pstyle, pcouple, allremap;
int p_flag[6]; // 1 if control P on this dim, 0 if not
double p_start[6], p_stop[6];
double p_freq[6], p_target[6];
double omega[6], omega_dot[6];
double omega_mass[6];
double p_current[6];
double drag,tdrag_factor; // drag factor on particle thermostat
double pdrag_factor; // drag factor on barostat
int kspace_flag; // 1 if KSpace invoked, 0 if not
int nrigid; // number of rigid fixes
int dilate_group_bit; // mask for dilation group
int *rfix; // indices of rigid fixes
char *id_dilate; // group name to dilate
class Irregular *irregular; // for migrating atoms after box flips
double drag, tdrag_factor; // drag factor on particle thermostat
double pdrag_factor; // drag factor on barostat
int kspace_flag; // 1 if KSpace invoked, 0 if not
int nrigid; // number of rigid fixes
int dilate_group_bit; // mask for dilation group
int *rfix; // indices of rigid fixes
char *id_dilate; // group name to dilate
class Irregular *irregular; // for migrating atoms after box flips
// MRD NJD
// MRD NJD
int p_basis_type;
int p_match_flag;
double vavg;
int N_mol;
int N_p_match;
double *p_match_coeffs;
double ** splines;
double **splines;
int spline_length;
int nlevels_respa;
double *step_respa;
char *id_temp,*id_press;
class Compute *temperature,*pressure;
int tcomputeflag,pcomputeflag; // 1 = compute was created by fix
// 0 = created externally
char *id_temp, *id_press;
class Compute *temperature, *pressure;
int tcomputeflag, pcomputeflag; // 1 = compute was created by fix
// 0 = created externally
double *eta,*eta_dot; // chain thermostat for particles
double *eta, *eta_dot; // chain thermostat for particles
double *eta_dotdot;
double *eta_mass;
int mtchain; // length of chain
int mtchain_default_flag; // 1 = mtchain is default
int mtchain; // length of chain
int mtchain_default_flag; // 1 = mtchain is default
double *etap; // chain thermostat for barostat
double *etap; // chain thermostat for barostat
double *etap_dot;
double *etap_dotdot;
double *etap_mass;
int mpchain; // length of chain
int mpchain; // length of chain
int mtk_flag; // 0 if using Hoover barostat
int pdim; // number of barostatted dims
double p_freq_max; // maximum barostat frequency
int mtk_flag; // 0 if using Hoover barostat
int pdim; // number of barostatted dims
double p_freq_max; // maximum barostat frequency
double p_hydro; // hydrostatic target pressure
double p_hydro; // hydrostatic target pressure
int nc_tchain,nc_pchain;
int nc_tchain, nc_pchain;
double factor_eta;
double sigma[6]; // scaled target stress
double fdev[6]; // deviatoric force on barostat
int deviatoric_flag; // 0 if target stress tensor is hydrostatic
double h0_inv[6]; // h_inv of reference (zero strain) box
int nreset_h0; // interval for resetting h0
double sigma[6]; // scaled target stress
double fdev[6]; // deviatoric force on barostat
int deviatoric_flag; // 0 if target stress tensor is hydrostatic
double h0_inv[6]; // h_inv of reference (zero strain) box
int nreset_h0; // interval for resetting h0
double mtk_term1,mtk_term2; // Martyna-Tobias-Klein corrections
double mtk_term1, mtk_term2; // Martyna-Tobias-Klein corrections
int eta_mass_flag; // 1 if eta_mass updated, 0 if not.
int omega_mass_flag; // 1 if omega_mass updated, 0 if not.
int etap_mass_flag; // 1 if etap_mass updated, 0 if not.
int dipole_flag; // 1 if dipole is updated, 0 if not.
int dlm_flag; // 1 if using the DLM rotational integrator, 0 if not
int eta_mass_flag; // 1 if eta_mass updated, 0 if not.
int omega_mass_flag; // 1 if omega_mass updated, 0 if not.
int etap_mass_flag; // 1 if etap_mass updated, 0 if not.
int dipole_flag; // 1 if dipole is updated, 0 if not.
int dlm_flag; // 1 if using the DLM rotational integrator, 0 if not
int scaleyz; // 1 if yz scaled with lz
int scalexz; // 1 if xz scaled with lz
int scalexy; // 1 if xy scaled with ly
int flipflag; // 1 if box flips are invoked as needed
int scaleyz; // 1 if yz scaled with lz
int scalexz; // 1 if xz scaled with lz
int scalexy; // 1 if xy scaled with ly
int flipflag; // 1 if box flips are invoked as needed
int pre_exchange_flag; // set if pre_exchange needed for box flips
int pre_exchange_flag; // set if pre_exchange needed for box flips
double fixedpoint[3]; // location of dilation fixed-point
double fixedpoint[3]; // location of dilation fixed-point
void couple();
virtual void remap();
@ -153,7 +151,7 @@ class FixBocs : public Fix {
int build_linear_splines(double **);
int build_cubic_splines(double **);
virtual void nve_x(); // may be overwritten by child classes
virtual void nve_x(); // may be overwritten by child classes
virtual void nve_v();
virtual void nh_v_press();
virtual void nh_v_temp();
@ -167,7 +165,7 @@ class FixBocs : public Fix {
void nh_omega_dot();
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,44 +12,44 @@
------------------------------------------------------------------------- */
#ifdef BODY_CLASS
BodyStyle(nparticle,BodyNparticle)
// clang-format off
BodyStyle(nparticle,BodyNparticle);
// clang-format on
#else
#ifndef LMP_BODY_NPARTICLE_H
#define LMP_BODY_NPARTICLE_H
#include "body.h"
#include "atom_vec_body.h"
#include "body.h"
namespace LAMMPS_NS {
class BodyNparticle : public Body {
public:
BodyNparticle(class LAMMPS *, int, char **);
~BodyNparticle();
~BodyNparticle() override;
int nsub(struct AtomVecBody::Bonus *);
double *coords(struct AtomVecBody::Bonus *);
int pack_border_body(struct AtomVecBody::Bonus *, double *);
int unpack_border_body(struct AtomVecBody::Bonus *, double *);
void data_body(int, int, int, int *, double *);
int pack_data_body(tagint, int, double *);
int write_data_body(FILE *, double *);
double radius_body(int, int, int *, double *);
int pack_border_body(struct AtomVecBody::Bonus *, double *) override;
int unpack_border_body(struct AtomVecBody::Bonus *, double *) override;
void data_body(int, int, int, int *, double *) override;
int pack_data_body(tagint, int, double *) override;
int write_data_body(FILE *, double *) override;
double radius_body(int, int, int *, double *) override;
int noutrow(int);
int noutcol();
void output(int, int, double *);
int image(int, double, double, int *&, double **&);
int noutrow(int) override;
int noutcol() override;
void output(int, int, double *) override;
int image(int, double, double, int *&, double **&) override;
private:
int *imflag;
double **imdata;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,23 +12,23 @@
------------------------------------------------------------------------- */
#ifdef BODY_CLASS
BodyStyle(rounded/polygon,BodyRoundedPolygon)
// clang-format off
BodyStyle(rounded/polygon,BodyRoundedPolygon);
// clang-format on
#else
#ifndef LMP_BODY_ROUNDED_POLYGON_H
#define LMP_BODY_ROUNDED_POLYGON_H
#include "body.h"
#include "atom_vec_body.h"
#include "body.h"
namespace LAMMPS_NS {
class BodyRoundedPolygon : public Body {
public:
BodyRoundedPolygon(class LAMMPS *, int, char **);
~BodyRoundedPolygon();
~BodyRoundedPolygon() override;
int nsub(struct AtomVecBody::Bonus *);
double *coords(struct AtomVecBody::Bonus *);
int nedges(struct AtomVecBody::Bonus *);
@ -36,24 +36,24 @@ class BodyRoundedPolygon : public Body {
double enclosing_radius(struct AtomVecBody::Bonus *);
double rounded_radius(struct AtomVecBody::Bonus *);
int pack_border_body(struct AtomVecBody::Bonus *, double *);
int unpack_border_body(struct AtomVecBody::Bonus *, double *);
void data_body(int, int, int, int *, double *);
int pack_data_body(tagint, int, double *);
int write_data_body(FILE *, double *);
double radius_body(int, int, int *, double *);
int pack_border_body(struct AtomVecBody::Bonus *, double *) override;
int unpack_border_body(struct AtomVecBody::Bonus *, double *) override;
void data_body(int, int, int, int *, double *) override;
int pack_data_body(tagint, int, double *) override;
int write_data_body(FILE *, double *) override;
double radius_body(int, int, int *, double *) override;
int noutrow(int);
int noutcol();
void output(int, int, double *);
int image(int, double, double, int *&, double **&);
int noutrow(int) override;
int noutcol() override;
void output(int, int, double *) override;
int image(int, double, double, int *&, double **&) override;
private:
int *imflag;
double **imdata;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,23 +12,23 @@
------------------------------------------------------------------------- */
#ifdef BODY_CLASS
BodyStyle(rounded/polyhedron,BodyRoundedPolyhedron)
// clang-format off
BodyStyle(rounded/polyhedron,BodyRoundedPolyhedron);
// clang-format on
#else
#ifndef LMP_BODY_ROUNDED_POLYHEDRON_H
#define LMP_BODY_ROUNDED_POLYHEDRON_H
#include "body.h"
#include "atom_vec_body.h"
#include "body.h"
namespace LAMMPS_NS {
class BodyRoundedPolyhedron : public Body {
public:
BodyRoundedPolyhedron(class LAMMPS *, int, char **);
~BodyRoundedPolyhedron();
~BodyRoundedPolyhedron() override;
int nsub(struct AtomVecBody::Bonus *);
double *coords(struct AtomVecBody::Bonus *);
int nedges(struct AtomVecBody::Bonus *);
@ -38,24 +38,24 @@ class BodyRoundedPolyhedron : public Body {
double enclosing_radius(struct AtomVecBody::Bonus *);
double rounded_radius(struct AtomVecBody::Bonus *);
int pack_border_body(struct AtomVecBody::Bonus *, double *);
int unpack_border_body(struct AtomVecBody::Bonus *, double *);
void data_body(int, int, int, int *, double *);
int pack_data_body(tagint, int, double *);
int write_data_body(FILE *, double *);
double radius_body(int, int, int *, double *);
int pack_border_body(struct AtomVecBody::Bonus *, double *) override;
int unpack_border_body(struct AtomVecBody::Bonus *, double *) override;
void data_body(int, int, int, int *, double *) override;
int pack_data_body(tagint, int, double *) override;
int write_data_body(FILE *, double *) override;
double radius_body(int, int, int *, double *) override;
int noutrow(int);
int noutcol();
void output(int, int, double *);
int image(int, double, double, int *&, double **&);
int noutrow(int) override;
int noutcol() override;
void output(int, int, double *) override;
int image(int, double, double, int *&, double **&) override;
private:
int *imflag;
double **imdata;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -52,7 +53,7 @@ ComputeBodyLocal::ComputeBodyLocal(LAMMPS *lmp, int narg, char **arg) :
}
}
avec = (AtomVecBody *) atom->style_match("body");
avec = dynamic_cast<AtomVecBody *>( atom->style_match("body"));
if (!avec) error->all(FLERR,"Compute body/local requires atom style body");
bptr = avec->bptr;
@ -152,7 +153,7 @@ int ComputeBodyLocal::compute_body(int flag)
// perform computation and fill output vector/array
int m,n,ibonus;
double *values = new double[bptr->noutcol()];
auto values = new double[bptr->noutcol()];
double **x = atom->x;
tagint *tag = atom->tag;

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef COMPUTE_CLASS
ComputeStyle(body/local,ComputeBodyLocal)
// clang-format off
ComputeStyle(body/local,ComputeBodyLocal);
// clang-format on
#else
#ifndef LMP_COMPUTE_BODY_LOCAL_H
@ -27,14 +27,14 @@ namespace LAMMPS_NS {
class ComputeBodyLocal : public Compute {
public:
ComputeBodyLocal(class LAMMPS *, int, char **);
~ComputeBodyLocal();
void init();
void compute_local();
double memory_usage();
~ComputeBodyLocal() override;
void init() override;
void compute_local() override;
double memory_usage() override;
private:
int nvalues;
int *which,*index;
int *which, *index;
int nmax;
@ -45,7 +45,7 @@ class ComputeBodyLocal : public Compute {
void reallocate(int);
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -56,9 +57,7 @@ ComputeTempBody::ComputeTempBody(LAMMPS *lmp, int narg, char **arg) :
if (iarg+2 > narg)
error->all(FLERR,"Illegal compute temp/body command");
tempbias = 1;
int n = strlen(arg[iarg+1]) + 1;
id_bias = new char[n];
strcpy(id_bias,arg[iarg+1]);
id_bias = utils::strdup(arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"dof") == 0) {
if (iarg+2 > narg)
@ -88,7 +87,7 @@ void ComputeTempBody::init()
{
// error check
avec = (AtomVecBody *) atom->style_match("body");
avec = dynamic_cast<AtomVecBody *>( atom->style_match("body"));
if (!avec)
error->all(FLERR,"Compute temp/body requires atom style body");

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef COMPUTE_CLASS
ComputeStyle(temp/body,ComputeTempBody)
// clang-format off
ComputeStyle(temp/body,ComputeTempBody);
// clang-format on
#else
#ifndef LMP_COMPUTE_TEMP_BODY_H
@ -27,26 +27,26 @@ namespace LAMMPS_NS {
class ComputeTempBody : public Compute {
public:
ComputeTempBody(class LAMMPS *, int, char **);
~ComputeTempBody();
void init();
void setup();
double compute_scalar();
void compute_vector();
~ComputeTempBody() override;
void init() override;
void setup() override;
double compute_scalar() override;
void compute_vector() override;
void remove_bias(int, double *);
void restore_bias(int, double *);
void remove_bias(int, double *) override;
void restore_bias(int, double *) override;
private:
int mode;
double tfactor;
char *id_bias;
class Compute *tbias; // ptr to additional bias compute
class Compute *tbias; // ptr to additional bias compute
class AtomVecBody *avec;
void dof_compute();
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -36,7 +37,7 @@ FixNHBody::FixNHBody(LAMMPS *lmp, int narg, char **arg) :
void FixNHBody::init()
{
avec = (AtomVecBody *) atom->style_match("body");
avec = dynamic_cast<AtomVecBody *>( atom->style_match("body"));
if (!avec)
error->all(FLERR,
"Compute nvt/nph/npt body requires atom style body");

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -21,19 +21,18 @@ namespace LAMMPS_NS {
class FixNHBody : public FixNH {
public:
FixNHBody(class LAMMPS *, int, char **);
virtual ~FixNHBody() {}
void init();
void init() override;
protected:
double dtq;
class AtomVecBody *avec;
void nve_v();
void nve_x();
void nh_v_temp();
void nve_v() override;
void nve_x() override;
void nh_v_temp() override;
};
}
} // namespace LAMMPS_NS
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -16,12 +17,9 @@
------------------------------------------------------------------------- */
#include "fix_nph_body.h"
#include <cstring>
#include "group.h"
#include "modify.h"
#include "error.h"
#include "modify.h"
using namespace LAMMPS_NS;
using namespace FixConst;
@ -41,22 +39,15 @@ FixNPHBody::FixNPHBody(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp");
id_temp = new char[tcmd.size()+1];
strcpy(id_temp,tcmd.c_str());
tcmd += fmt::format(" {} temp/body",group->names[igroup]);
modify->add_compute(tcmd);
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} all temp/body",id_temp));
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press");
id_press = new char[pcmd.size()+1];
strcpy(id_press,pcmd.c_str());
modify->add_compute(pcmd + " all pressure " + std::string(id_temp));
id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
pcomputeflag = 1;
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nph/body,FixNPHBody)
// clang-format off
FixStyle(nph/body,FixNPHBody);
// clang-format on
#else
#ifndef LMP_FIX_NPH_BODY_H
@ -27,10 +27,9 @@ namespace LAMMPS_NS {
class FixNPHBody : public FixNHBody {
public:
FixNPHBody(class LAMMPS *, int, char **);
~FixNPHBody() {}
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -16,12 +17,9 @@
------------------------------------------------------------------------- */
#include "fix_npt_body.h"
#include <cstring>
#include "group.h"
#include "modify.h"
#include "error.h"
#include "modify.h"
using namespace LAMMPS_NS;
using namespace FixConst;
@ -41,22 +39,15 @@ FixNPTBody::FixNPTBody(LAMMPS *lmp, int narg, char **arg) :
// compute group = all since pressure is always global (group all)
// and thus its KE/temperature contribution should use group all
std::string tcmd = id + std::string("_temp");
id_temp = new char[tcmd.size()+1];
strcpy(id_temp,tcmd.c_str());
tcmd += fmt::format(" {} temp/body",group->names[igroup]);
modify->add_compute(tcmd);
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} all temp/body",id_temp));
tcomputeflag = 1;
// create a new compute pressure style
// id = fix-ID + press, compute group = all
// pass id_temp as 4th arg to pressure constructor
std::string pcmd = id + std::string("_press");
id_press = new char[pcmd.size()+1];
strcpy(id_press,pcmd.c_str());
modify->add_compute(pcmd + " all pressure " + std::string(id_temp));
id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
pcomputeflag = 1;
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(npt/body,FixNPTBody)
// clang-format off
FixStyle(npt/body,FixNPTBody);
// clang-format on
#else
#ifndef LMP_FIX_NPT_BODY_H
@ -27,10 +27,9 @@ namespace LAMMPS_NS {
class FixNPTBody : public FixNHBody {
public:
FixNPTBody(class LAMMPS *, int, char **);
~FixNPTBody() {}
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -29,7 +30,7 @@ FixNVEBody::FixNVEBody(LAMMPS *lmp, int narg, char **arg) :
void FixNVEBody::init()
{
avec = (AtomVecBody *) atom->style_match("body");
avec = dynamic_cast<AtomVecBody *>( atom->style_match("body"));
if (!avec) error->all(FLERR,"Fix nve/body requires atom style body");
// check that all particles are bodies

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nve/body,FixNVEBody)
// clang-format off
FixStyle(nve/body,FixNVEBody);
// clang-format on
#else
#ifndef LMP_FIX_NVE_BODY_H
@ -27,16 +27,16 @@ namespace LAMMPS_NS {
class FixNVEBody : public FixNVE {
public:
FixNVEBody(class LAMMPS *, int, char **);
void init();
void initial_integrate(int);
void final_integrate();
void init() override;
void initial_integrate(int) override;
void final_integrate() override;
private:
double dtq;
class AtomVecBody *avec;
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -16,12 +17,10 @@
------------------------------------------------------------------------- */
#include "fix_nvt_body.h"
#include <cstring>
#include "error.h"
#include "group.h"
#include "modify.h"
#include "error.h"
using namespace LAMMPS_NS;
using namespace FixConst;
@ -39,11 +38,8 @@ FixNVTBody::FixNVTBody(LAMMPS *lmp, int narg, char **arg) :
// create a new compute temp style
// id = fix-ID + temp
std::string tcmd = id + std::string("_temp");
id_temp = new char[tcmd.size()+1];
strcpy(id_temp,tcmd.c_str());
tcmd += fmt::format(" {} temp/body",group->names[igroup]);
modify->add_compute(tcmd);
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} {} temp/body",
id_temp,group->names[igroup]));
tcomputeflag = 1;
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(nvt/body,FixNVTBody)
// clang-format off
FixStyle(nvt/body,FixNVTBody);
// clang-format on
#else
#ifndef LMP_FIX_NVT_BODY_H
@ -27,10 +27,9 @@ namespace LAMMPS_NS {
class FixNVTBody : public FixNHBody {
public:
FixNVTBody(class LAMMPS *, int, char **);
~FixNVTBody() {}
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -16,18 +17,20 @@
------------------------------------------------------------------------- */
#include "fix_wall_body_polygon.h"
#include <cmath>
#include <cstring>
#include "atom.h"
#include "atom_vec_body.h"
#include "body_rounded_polygon.h"
#include "domain.h"
#include "update.h"
#include "error.h"
#include "force.h"
#include "math_const.h"
#include "math_extra.h"
#include "memory.h"
#include "error.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
@ -97,7 +100,7 @@ FixWallBodyPolygon::FixWallBodyPolygon(LAMMPS *lmp, int narg, char **arg) :
lo = hi = 0.0;
cylradius = utils::numeric(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else error->all(FLERR,fmt::format("Unknown wall style {}",arg[iarg]));
} else error->all(FLERR,"Unknown wall style {}",arg[iarg]);
// check for trailing keyword/values
@ -176,13 +179,13 @@ void FixWallBodyPolygon::init()
{
dt = update->dt;
avec = (AtomVecBody *) atom->style_match("body");
avec = dynamic_cast<AtomVecBody *>( atom->style_match("body"));
if (!avec)
error->all(FLERR,"Pair body/rounded/polygon requires atom style body");
if (strcmp(avec->bptr->style,"rounded/polygon") != 0)
error->all(FLERR,"Pair body/rounded/polygon requires "
"body style rounded/polygon");
bptr = (BodyRoundedPolygon *) avec->bptr;
bptr = dynamic_cast<BodyRoundedPolygon *>( avec->bptr);
// set pairstyle from body/polygonular pair style
@ -195,7 +198,7 @@ void FixWallBodyPolygon::init()
void FixWallBodyPolygon::setup(int vflag)
{
if (strstr(update->integrate_style,"verlet"))
if (utils::strmatch(update->integrate_style,"^verlet"))
post_force(vflag);
}
@ -334,8 +337,7 @@ void FixWallBodyPolygon::post_force(int /*vflag*/)
num_contacts = 0;
facc[0] = facc[1] = facc[2] = 0;
vertex_against_wall(i, wall_pos, x, f, torque, side,
contact_list, num_contacts, facc);
vertex_against_wall(i, wall_pos, x, f, torque, side, contact_list, num_contacts, facc);
if (num_contacts >= 2) {

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(wall/body/polygon,FixWallBodyPolygon)
// clang-format off
FixStyle(wall/body/polygon,FixWallBodyPolygon);
// clang-format on
#else
#ifndef LMP_FIX_WALL_BODY_POLYGON_H
@ -27,74 +27,69 @@ namespace LAMMPS_NS {
class FixWallBodyPolygon : public Fix {
public:
FixWallBodyPolygon(class LAMMPS *, int, char **);
virtual ~FixWallBodyPolygon();
int setmask();
void init();
void setup(int);
virtual void post_force(int);
void reset_dt();
~FixWallBodyPolygon() override;
int setmask() override;
void init() override;
void setup(int) override;
void post_force(int) override;
void reset_dt() override;
struct Contact {
int ibody, jbody; // body (i.e. atom) indices (not tags)
int vertex; // vertex of the first polygon
int edge; // edge of the second polygon
double xv[3]; // coordinates of the vertex
double xe[3]; // coordinates of the projection of the vertex on the edge
double separation;// separation at contact
int ibody, jbody; // body (i.e. atom) indices (not tags)
int vertex; // vertex of the first polygon
int edge; // edge of the second polygon
double xv[3]; // coordinates of the vertex
double xe[3]; // coordinates of the projection of the vertex on the edge
double separation; // separation at contact
};
protected:
int wallstyle,pairstyle,wiggle,axis;
double kn; // normal repulsion strength
double c_n; // normal damping coefficient
double c_t; // tangential damping coefficient
double lo,hi,cylradius;
double amplitude,period,omega;
int wallstyle, pairstyle, wiggle, axis;
double kn; // normal repulsion strength
double c_n; // normal damping coefficient
double c_t; // tangential damping coefficient
double lo, hi, cylradius;
double amplitude, period, omega;
double dt;
int time_origin;
class AtomVecBody *avec;
class BodyRoundedPolygon *bptr;
double **discrete; // list of all sub-particles for all bodies
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
double **discrete; // list of all sub-particles for all bodies
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
double **edge; // list of all edge for all bodies
int nedge; // number of edge in list
int edmax; // allocated size of edge list
int *ednum; // number of edges per line, 0 if uninit
int *edfirst; // index of first edge per each line
int ednummax; // allocated size of ednum,edfirst vectors
double **edge; // list of all edge for all bodies
int nedge; // number of edge in list
int edmax; // allocated size of edge list
int *ednum; // number of edges per line, 0 if uninit
int *edfirst; // index of first edge per each line
int ednummax; // allocated size of ednum,edfirst vectors
double *enclosing_radius; // enclosing radii for all bodies
double *rounded_radius; // rounded radii for all bodies
double *enclosing_radius; // enclosing radii for all bodies
double *rounded_radius; // rounded radii for all bodies
void body2space(int);
int vertex_against_wall(int ibody, double wall_pos, double** x,
double** f, double** torque, int side,
Contact* contact_list, int &num_contacts,
double* facc);
int compute_distance_to_wall(double* x0, double rradi, double wall_pos,
int side, double &d, double hi[3], int &contact);
double contact_separation(const Contact& c1, const Contact& c2);
void contact_forces(Contact& contact, double j_a, double** x,
double** v, double** angmom, double** f, double** torque,
double* vwall, double* facc);
void sum_torque(double* xm, double *x, double fx,
double fy, double fz, double* torque);
void total_velocity(double* p, double *xcm, double* vcm, double *angmom,
double *inertia, double *quat, double* vi);
void distance(const double* x2, const double* x1, double& r);
int vertex_against_wall(int ibody, double wall_pos, double **x, double **f, double **torque,
int side, Contact *contact_list, int &num_contacts, double *facc);
int compute_distance_to_wall(double *x0, double rradi, double wall_pos, int side, double &d,
double hi[3], int &contact);
double contact_separation(const Contact &c1, const Contact &c2);
void contact_forces(Contact &contact, double j_a, double **x, double **v, double **angmom,
double **f, double **torque, double *vwall, double *facc);
void sum_torque(double *xm, double *x, double fx, double fy, double fz, double *torque);
void total_velocity(double *p, double *xcm, double *vcm, double *angmom, double *inertia,
double *quat, double *vi);
void distance(const double *x2, const double *x1, double &r);
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -99,7 +100,7 @@ FixWallBodyPolyhedron::FixWallBodyPolyhedron(LAMMPS *lmp, int narg, char **arg)
if (strcmp(arg[iarg+2],"NULL") == 0) hi = BIG;
else hi = utils::numeric(FLERR,arg[iarg+2],false,lmp);
iarg += 3;
} else error->all(FLERR,fmt::format("Unknown wall style {}",arg[iarg]));
} else error->all(FLERR,"Unknown wall style {}",arg[iarg]);
// check for trailing keyword/values
@ -183,13 +184,13 @@ void FixWallBodyPolyhedron::init()
{
dt = update->dt;
avec = (AtomVecBody *) atom->style_match("body");
avec = dynamic_cast<AtomVecBody *>( atom->style_match("body"));
if (!avec)
error->all(FLERR,"Pair body/rounded/polyhedron requires atom style body");
if (strcmp(avec->bptr->style,"rounded/polyhedron") != 0)
error->all(FLERR,"Pair body/rounded/polyhedron requires "
"body style rounded/polyhedron");
bptr = (BodyRoundedPolyhedron *) avec->bptr;
bptr = dynamic_cast<BodyRoundedPolyhedron *>( avec->bptr);
// set pairstyle from body/polyhedronular pair style
@ -202,7 +203,7 @@ void FixWallBodyPolyhedron::init()
void FixWallBodyPolyhedron::setup(int vflag)
{
if (strstr(update->integrate_style,"verlet"))
if (utils::strmatch(update->integrate_style,"^verlet"))
post_force(vflag);
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(wall/body/polyhedron,FixWallBodyPolyhedron)
// clang-format off
FixStyle(wall/body/polyhedron,FixWallBodyPolyhedron);
// clang-format on
#else
#ifndef LMP_FIX_WALL_BODY_POLYHERON_H
@ -27,86 +27,80 @@ namespace LAMMPS_NS {
class FixWallBodyPolyhedron : public Fix {
public:
FixWallBodyPolyhedron(class LAMMPS *, int, char **);
virtual ~FixWallBodyPolyhedron();
int setmask();
void init();
void setup(int);
virtual void post_force(int);
void reset_dt();
~FixWallBodyPolyhedron() override;
int setmask() override;
void init() override;
void setup(int) override;
void post_force(int) override;
void reset_dt() override;
struct Contact {
int ibody, jbody; // body (i.e. atom) indices (not tags)
int vertex; // vertex of the first polygon
int edge; // edge of the second polygon
double xv[3]; // coordinates of the vertex
double xe[3]; // coordinates of the projection of the vertex on the edge
double separation;// separation at contact
int ibody, jbody; // body (i.e. atom) indices (not tags)
int vertex; // vertex of the first polygon
int edge; // edge of the second polygon
double xv[3]; // coordinates of the vertex
double xe[3]; // coordinates of the projection of the vertex on the edge
double separation; // separation at contact
};
protected:
int wallstyle,pairstyle,wiggle,axis;
double kn,c_n,c_t;
double lo,hi,cylradius;
double amplitude,period,omega;
int wallstyle, pairstyle, wiggle, axis;
double kn, c_n, c_t;
double lo, hi, cylradius;
double amplitude, period, omega;
double dt;
int time_origin;
class AtomVecBody *avec;
class BodyRoundedPolyhedron *bptr;
double **discrete; // list of all sub-particles for all bodies
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
double **discrete; // list of all sub-particles for all bodies
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
double **edge; // list of all edge for all bodies
int nedge; // number of edge in list
int edmax; // allocated size of edge list
int *ednum; // number of edges per line, 0 if uninit
int *edfirst; // index of first edge per each line
int ednummax; // allocated size of ednum,edfirst vectors
double **edge; // list of all edge for all bodies
int nedge; // number of edge in list
int edmax; // allocated size of edge list
int *ednum; // number of edges per line, 0 if uninit
int *edfirst; // index of first edge per each line
int ednummax; // allocated size of ednum,edfirst vectors
double **face; // list of all edge for all bodies
int nface; // number of faces in list
int facmax; // allocated size of face list
int *facnum; // number of faces per line, 0 if uninit
int *facfirst; // index of first face per each line
int facnummax; // allocated size of facnum,facfirst vectors
double **face; // list of all edge for all bodies
int nface; // number of faces in list
int facmax; // allocated size of face list
int *facnum; // number of faces per line, 0 if uninit
int *facfirst; // index of first face per each line
int facnummax; // allocated size of facnum,facfirst vectors
double *enclosing_radius; // enclosing radii for all bodies
double *rounded_radius; // rounded radii for all bodies
double *enclosing_radius; // enclosing radii for all bodies
double *rounded_radius; // rounded radii for all bodies
void body2space(int);
int edge_against_wall(int ibody, double wall_pos, int side, double* vwall,
double** x, double** f, double** torque, Contact* contact_list,
int &num_contacts, double* facc);
int sphere_against_wall(int i, double wall_pos, int side, double* vwall,
double** x, double** v, double** f, double** angmom, double** torque);
int edge_against_wall(int ibody, double wall_pos, int side, double *vwall, double **x, double **f,
double **torque, Contact *contact_list, int &num_contacts, double *facc);
int sphere_against_wall(int i, double wall_pos, int side, double *vwall, double **x, double **v,
double **f, double **angmom, double **torque);
int compute_distance_to_wall(int ibody, int edge_index, double *xmi,
double rounded_radius_i, double wall_pos, int side,
double* vwall, int &contact);
double contact_separation(const Contact& c1, const Contact& c2);
void contact_forces(int ibody, double j_a, double *xi, double *xj,
double delx, double dely, double delz,
double fx, double fy, double fz, double** x, double** v,
double** angmom, double** f, double** torque, double* vwall);
void contact_forces(Contact& contact, double j_a, double** x,
double** v, double** angmom, double** f, double** torque,
double* vwall, double* facc);
void sum_torque(double* xm, double *x, double fx,
double fy, double fz, double* torque);
void total_velocity(double* p, double *xcm, double* vcm, double *angmom,
double *inertia, double *quat, double* vi);
void distance(const double* x2, const double* x1, double& r);
int compute_distance_to_wall(int ibody, int edge_index, double *xmi, double rounded_radius_i,
double wall_pos, int side, double *vwall, int &contact);
double contact_separation(const Contact &c1, const Contact &c2);
void contact_forces(int ibody, double j_a, double *xi, double *xj, double delx, double dely,
double delz, double fx, double fy, double fz, double **x, double **v,
double **angmom, double **f, double **torque, double *vwall);
void contact_forces(Contact &contact, double j_a, double **x, double **v, double **angmom,
double **f, double **torque, double *vwall, double *facc);
void sum_torque(double *xm, double *x, double fx, double fy, double fz, double *torque);
void total_velocity(double *p, double *xcm, double *vcm, double *angmom, double *inertia,
double *quat, double *vi);
void distance(const double *x2, const double *x1, double &r);
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,18 +13,19 @@
------------------------------------------------------------------------- */
#include "pair_body_nparticle.h"
#include <cmath>
#include <cstring>
#include "math_extra.h"
#include "atom.h"
#include "atom_vec_body.h"
#include "body_nparticle.h"
#include "force.h"
#include "neighbor.h"
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "force.h"
#include "math_extra.h"
#include "memory.h"
#include "neigh_list.h"
#include "neighbor.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
@ -322,8 +324,7 @@ void PairBodyNparticle::compute(int eflag, int vflag)
}
}
if (evflag) ev_tally(i,j,nlocal,newton_pair,
evdwl,0.0,fpair,delx,dely,delz);
if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz);
}
}
@ -415,13 +416,13 @@ void PairBodyNparticle::coeff(int narg, char **arg)
void PairBodyNparticle::init_style()
{
avec = (AtomVecBody *) atom->style_match("body");
avec = dynamic_cast<AtomVecBody *>( atom->style_match("body"));
if (!avec) error->all(FLERR,"Pair body/nparticle requires atom style body");
if (strcmp(avec->bptr->style,"nparticle") != 0)
error->all(FLERR,"Pair body/nparticle requires body style nparticle");
bptr = (BodyNparticle *) avec->bptr;
bptr = dynamic_cast<BodyNparticle *>( avec->bptr);
neighbor->request(this,instance_me);
neighbor->add_request(this);
}
/* ----------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(body/nparticle,PairBodyNparticle)
// clang-format off
PairStyle(body/nparticle,PairBodyNparticle);
// clang-format on
#else
#ifndef LMP_PAIR_BODY_NPARTICLE_H
@ -27,34 +27,34 @@ namespace LAMMPS_NS {
class PairBodyNparticle : public Pair {
public:
PairBodyNparticle(class LAMMPS *);
~PairBodyNparticle();
void compute(int, int);
void settings(int, char **);
void coeff(int, char **);
void init_style();
double init_one(int, int);
~PairBodyNparticle() override;
void compute(int, int) override;
void settings(int, char **) override;
void coeff(int, char **) override;
void init_style() override;
double init_one(int, int) override;
protected:
double cut_global;
double **cut;
double **epsilon,**sigma;
double **lj1,**lj2,**lj3,**lj4;
double **epsilon, **sigma;
double **lj1, **lj2, **lj3, **lj4;
class AtomVecBody *avec;
class BodyNparticle *bptr;
double **discrete; // list of all sub-particles for all bodies
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
double **discrete; // list of all sub-particles for all bodies
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
void allocate();
void body2space(int);
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -20,21 +21,21 @@
#include "pair_body_rounded_polygon.h"
#include <cmath>
#include <cstring>
#include "math_extra.h"
#include "atom.h"
#include "atom_vec_body.h"
#include "body_rounded_polygon.h"
#include "comm.h"
#include "force.h"
#include "fix.h"
#include "modify.h"
#include "neighbor.h"
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "fix.h"
#include "force.h"
#include "math_extra.h"
#include "memory.h"
#include "modify.h"
#include "neigh_list.h"
#include "neighbor.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
@ -206,8 +207,7 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag)
if (r > radi + radj + cut_inner) continue;
if (npi == 1 && npj == 1) {
sphere_against_sphere(i, j, delx, dely, delz, rsq,
k_nij, k_naij, x, v, f, evflag);
sphere_against_sphere(i, j, delx, dely, delz, rsq, k_nij, k_naij, x, v, f, evflag);
continue;
}
@ -411,13 +411,13 @@ void PairBodyRoundedPolygon::coeff(int narg, char **arg)
void PairBodyRoundedPolygon::init_style()
{
avec = (AtomVecBody *) atom->style_match("body");
avec = dynamic_cast<AtomVecBody *>( atom->style_match("body"));
if (!avec)
error->all(FLERR,"Pair body/rounded/polygon requires atom style body");
if (strcmp(avec->bptr->style,"rounded/polygon") != 0)
error->all(FLERR,"Pair body/rounded/polygon requires "
"body style rounded/polygon");
bptr = (BodyRoundedPolygon *) avec->bptr;
bptr = dynamic_cast<BodyRoundedPolygon *>( avec->bptr);
if (force->newton_pair == 0)
error->all(FLERR,"Pair style body/rounded/polygon requires "
@ -427,7 +427,7 @@ void PairBodyRoundedPolygon::init_style()
error->all(FLERR,"Pair body/rounded/polygon requires "
"ghost atoms store velocity");
neighbor->request(this);
neighbor->add_request(this);
// find the maximum enclosing radius for each atom type
@ -570,8 +570,8 @@ void PairBodyRoundedPolygon::body2space(int i)
}
if ((body_num_edges > 0) && (edge_ends == nullptr))
error->one(FLERR,fmt::format("Inconsistent edge data for body of atom {}",
atom->tag[i]));
error->one(FLERR,"Inconsistent edge data for body of atom {}",
atom->tag[i]);
for (int m = 0; m < body_num_edges; m++) {
edge[nedge][0] = static_cast<int>(edge_ends[2*m+0]);

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(body/rounded/polygon,PairBodyRoundedPolygon)
// clang-format off
PairStyle(body/rounded/polygon,PairBodyRoundedPolygon);
// clang-format on
#else
#ifndef LMP_PAIR_BODY_ROUNDED_POLYGON_H
@ -27,89 +27,84 @@ namespace LAMMPS_NS {
class PairBodyRoundedPolygon : public Pair {
public:
PairBodyRoundedPolygon(class LAMMPS *);
~PairBodyRoundedPolygon();
void compute(int, int);
void settings(int, char **);
void coeff(int, char **);
void init_style();
double init_one(int, int);
~PairBodyRoundedPolygon() override;
void compute(int, int) override;
void settings(int, char **) override;
void coeff(int, char **) override;
void init_style() override;
double init_one(int, int) override;
struct Contact {
int ibody, jbody; // body (i.e. atom) indices (not tags)
int vertex; // vertex of the first polygon
int edge; // edge of the second polygon
double xv[3]; // coordinates of the vertex
double xe[3]; // coordinates of the projection of the vertex on the edge
double separation;// separation at contact
int ibody, jbody; // body (i.e. atom) indices (not tags)
int vertex; // vertex of the first polygon
int edge; // edge of the second polygon
double xv[3]; // coordinates of the vertex
double xe[3]; // coordinates of the projection of the vertex on the edge
double separation; // separation at contact
};
protected:
double **k_n; // normal repulsion strength
double **k_na; // normal attraction strength
double c_n; // normal damping coefficient
double c_t; // tangential damping coefficient
double mu; // normal friction coefficient during gross sliding
double delta_ua; // contact line (area for 3D models) modification factor
double cut_inner; // cutoff for interaction between vertex-edge surfaces
double **k_n; // normal repulsion strength
double **k_na; // normal attraction strength
double c_n; // normal damping coefficient
double c_t; // tangential damping coefficient
double mu; // normal friction coefficient during gross sliding
double delta_ua; // contact line (area for 3D models) modification factor
double cut_inner; // cutoff for interaction between vertex-edge surfaces
class AtomVecBody *avec;
class BodyRoundedPolygon *bptr;
double **discrete; // list of all sub-particles for all bodies
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
double **discrete; // list of all sub-particles for all bodies
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
double **edge; // list of all edge for all bodies
int nedge; // number of edge in list
int edmax; // allocated size of edge list
int *ednum; // number of edges per line, 0 if uninit
int *edfirst; // index of first edge per each line
int ednummax; // allocated size of ednum,edfirst vectors
double **edge; // list of all edge for all bodies
int nedge; // number of edge in list
int edmax; // allocated size of edge list
int *ednum; // number of edges per line, 0 if uninit
int *edfirst; // index of first edge per each line
int ednummax; // allocated size of ednum,edfirst vectors
double *enclosing_radius; // enclosing radii for all bodies
double *rounded_radius; // rounded radii for all bodies
double *maxerad; // per-type maximum enclosing radius
double *enclosing_radius; // enclosing radii for all bodies
double *rounded_radius; // rounded radii for all bodies
double *maxerad; // per-type maximum enclosing radius
void allocate();
void body2space(int);
// sphere-sphere interaction
void sphere_against_sphere(int i, int j, double delx, double dely, double delz,
double rsq, double k_n, double k_na,
double** x, double** v, double** f, int evflag);
void sphere_against_sphere(int i, int j, double delx, double dely, double delz, double rsq,
double k_n, double k_na, double **x, double **v, double **f,
int evflag);
// vertex-edge interaction
int vertex_against_edge(int i, int j, double k_n, double k_na,
double** x, double** f, double** torque,
tagint* tag, Contact* contact_list,
int &num_contacts, double &evdwl, double* facc);
int vertex_against_edge(int i, int j, double k_n, double k_na, double **x, double **f,
double **torque, tagint *tag, Contact *contact_list, int &num_contacts,
double &evdwl, double *facc);
// compute distance between a point and an edge from another body
int compute_distance_to_vertex(int ibody, int edge_index, double* xmi,
double rounded_radius, double* x0,
double x0_rounded_radius, double cut_inner,
double &d, double hi[3], double &t,
int &contact);
int compute_distance_to_vertex(int ibody, int edge_index, double *xmi, double rounded_radius,
double *x0, double x0_rounded_radius, double cut_inner, double &d,
double hi[3], double &t, int &contact);
// compute contact forces if contact points are detected
void contact_forces(Contact& contact, double j_a,
double** x, double** v, double** angmom, double** f,
double** torque, double &evdwl, double* facc);
void contact_forces(Contact &contact, double j_a, double **x, double **v, double **angmom,
double **f, double **torque, double &evdwl, double *facc);
// compute the separation between two contacts
double contact_separation(const Contact& c1, const Contact& c2);
double contact_separation(const Contact &c1, const Contact &c2);
// accumulate torque to a body given a force at a given point
void sum_torque(double* xm, double *x, double fx,
double fy, double fz, double* torque);
void sum_torque(double *xm, double *x, double fx, double fy, double fz, double *torque);
// helper functions
int opposite_sides(double* x1, double* x2, double* a, double* b);
void total_velocity(double* p, double *xcm, double* vcm, double *angmom,
double *inertia, double *quat, double* vi);
inline void distance(const double* x2, const double* x1, double& r);
int opposite_sides(double *x1, double *x2, double *a, double *b);
void total_velocity(double *p, double *xcm, double *vcm, double *angmom, double *inertia,
double *quat, double *vi);
inline void distance(const double *x2, const double *x1, double &r);
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,6 +1,7 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -22,22 +23,22 @@
#include "pair_body_rounded_polyhedron.h"
#include <cmath>
#include <cstring>
#include "atom.h"
#include "atom_vec_body.h"
#include "body_rounded_polyhedron.h"
#include "comm.h"
#include "force.h"
#include "fix.h"
#include "modify.h"
#include "neighbor.h"
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "math_extra.h"
#include "fix.h"
#include "force.h"
#include "math_const.h"
#include "math_extra.h"
#include "memory.h"
#include "modify.h"
#include "neigh_list.h"
#include "neighbor.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace MathConst;
@ -389,13 +390,13 @@ void PairBodyRoundedPolyhedron::coeff(int narg, char **arg)
void PairBodyRoundedPolyhedron::init_style()
{
avec = (AtomVecBody *) atom->style_match("body");
avec = dynamic_cast<AtomVecBody *>( atom->style_match("body"));
if (!avec) error->all(FLERR,"Pair body/rounded/polyhedron requires "
"atom style body");
if (strcmp(avec->bptr->style,"rounded/polyhedron") != 0)
error->all(FLERR,"Pair body/rounded/polyhedron requires "
"body style rounded/polyhedron");
bptr = (BodyRoundedPolyhedron *) avec->bptr;
bptr = dynamic_cast<BodyRoundedPolyhedron *>( avec->bptr);
if (force->newton_pair == 0)
error->all(FLERR,"Pair style body/rounded/polyhedron requires "
@ -405,7 +406,7 @@ void PairBodyRoundedPolyhedron::init_style()
error->all(FLERR,"Pair body/rounded/polyhedron requires "
"ghost atoms store velocity");
neighbor->request(this);
neighbor->add_request(this);
// find the maximum enclosing radius for each atom type
@ -557,8 +558,8 @@ void PairBodyRoundedPolyhedron::body2space(int i)
}
if ((body_num_edges > 0) && (edge_ends == nullptr))
error->one(FLERR,fmt::format("Inconsistent edge data for body of atom {}",
atom->tag[i]));
error->one(FLERR,"Inconsistent edge data for body of atom {}",
atom->tag[i]);
for (int m = 0; m < body_num_edges; m++) {
edge[nedge][0] = static_cast<int>(edge_ends[2*m+0]);
@ -584,8 +585,8 @@ void PairBodyRoundedPolyhedron::body2space(int i)
}
if ((body_num_faces > 0) && (face_pts == nullptr))
error->one(FLERR,fmt::format("Inconsistent face data for body of atom {}",
atom->tag[i]));
error->one(FLERR,"Inconsistent face data for body of atom {}",
atom->tag[i]);
for (int m = 0; m < body_num_faces; m++) {
for (int k = 0; k < MAX_FACE_SIZE; k++)
@ -1211,10 +1212,7 @@ int PairBodyRoundedPolyhedron::interaction_edge_to_edge(int ibody,
contact_list[num_contacts].unique = 1;
num_contacts++;
}
} else {
}
return interact;
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,9 +12,9 @@
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(body/rounded/polyhedron,PairBodyRoundedPolyhedron)
// clang-format off
PairStyle(body/rounded/polyhedron,PairBodyRoundedPolyhedron);
// clang-format on
#else
#ifndef LMP_PAIR_BODY_ROUNDED_POLYHEDRON_H
@ -27,152 +27,138 @@ namespace LAMMPS_NS {
class PairBodyRoundedPolyhedron : public Pair {
public:
PairBodyRoundedPolyhedron(class LAMMPS *);
~PairBodyRoundedPolyhedron();
void compute(int, int);
void settings(int, char **);
void coeff(int, char **);
void init_style();
double init_one(int, int);
~PairBodyRoundedPolyhedron() override;
void compute(int, int) override;
void settings(int, char **) override;
void coeff(int, char **) override;
void init_style() override;
double init_one(int, int) override;
virtual void kernel_force(double R, int itype, int jtype,
double& energy, double& fpair);
virtual void kernel_force(double R, int itype, int jtype, double &energy, double &fpair);
struct Contact {
int ibody, jbody; // body (i.e. atom) indices (not tags)
int type; // 0 = VERTEX-FACE; 1 = EDGE-EDGE
double fx,fy,fz; // unscaled cohesive forces at contact
double xi[3]; // coordinates of the contact point on ibody
double xj[3]; // coordinates of the contact point on jbody
double separation; // contact surface separation
int ibody, jbody; // body (i.e. atom) indices (not tags)
int type; // 0 = VERTEX-FACE; 1 = EDGE-EDGE
double fx, fy, fz; // unscaled cohesive forces at contact
double xi[3]; // coordinates of the contact point on ibody
double xj[3]; // coordinates of the contact point on jbody
double separation; // contact surface separation
int unique;
};
protected:
double **k_n; // normal repulsion strength
double **k_na; // normal attraction strength
double c_n; // normal damping coefficient
double c_t; // tangential damping coefficient
double mu; // normal friction coefficient during gross sliding
double A_ua; // characteristic contact area
double cut_inner; // cutoff for interaction between vertex-edge surfaces
double **k_n; // normal repulsion strength
double **k_na; // normal attraction strength
double c_n; // normal damping coefficient
double c_t; // tangential damping coefficient
double mu; // normal friction coefficient during gross sliding
double A_ua; // characteristic contact area
double cut_inner; // cutoff for interaction between vertex-edge surfaces
class AtomVecBody *avec;
class BodyRoundedPolyhedron *bptr;
double **discrete; // list of all sub-particles for all bodies
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
double **discrete; // list of all sub-particles for all bodies
int ndiscrete; // number of discretes in list
int dmax; // allocated size of discrete list
int *dnum; // number of discretes per line, 0 if uninit
int *dfirst; // index of first discrete per each line
int nmax; // allocated size of dnum,dfirst vectors
double **edge; // list of all edge for all bodies
int nedge; // number of edge in list
int edmax; // allocated size of edge list
int *ednum; // number of edges per line, 0 if uninit
int *edfirst; // index of first edge per each line
int ednummax; // allocated size of ednum,edfirst vectors
double **edge; // list of all edge for all bodies
int nedge; // number of edge in list
int edmax; // allocated size of edge list
int *ednum; // number of edges per line, 0 if uninit
int *edfirst; // index of first edge per each line
int ednummax; // allocated size of ednum,edfirst vectors
double **face; // list of all edge for all bodies
int nface; // number of faces in list
int facmax; // allocated size of face list
int *facnum; // number of faces per line, 0 if uninit
int *facfirst; // index of first face per each line
int facnummax; // allocated size of facnum,facfirst vectors
double **face; // list of all edge for all bodies
int nface; // number of faces in list
int facmax; // allocated size of face list
int *facnum; // number of faces per line, 0 if uninit
int *facfirst; // index of first face per each line
int facnummax; // allocated size of facnum,facfirst vectors
double *enclosing_radius; // enclosing radii for all bodies
double *rounded_radius; // rounded radii for all bodies
double *maxerad; // per-type maximum enclosing radius
double *enclosing_radius; // enclosing radii for all bodies
double *rounded_radius; // rounded radii for all bodies
double *maxerad; // per-type maximum enclosing radius
void allocate();
void body2space(int);
// sphere-sphere interaction
void sphere_against_sphere(int ibody, int jbody, int itype, int jtype,
double delx, double dely, double delz, double rsq,
double** v, double** f, int evflag);
void sphere_against_sphere(int ibody, int jbody, int itype, int jtype, double delx, double dely,
double delz, double rsq, double **v, double **f, int evflag);
// sphere-edge interaction
void sphere_against_edge(int ibody, int jbody, int itype, int jtype,
double** x, double** v, double** f, double** torque,
double** angmom, int evflag);
void sphere_against_edge(int ibody, int jbody, int itype, int jtype, double **x, double **v,
double **f, double **torque, double **angmom, int evflag);
// sphere-face interaction
void sphere_against_face(int ibody, int jbody, int itype, int jtype,
double** x, double** v, double** f, double** torque,
double** angmom, int evflag);
void sphere_against_face(int ibody, int jbody, int itype, int jtype, double **x, double **v,
double **f, double **torque, double **angmom, int evflag);
// edge-edge interactions
int edge_against_edge(int ibody, int jbody, int itype, int jtype,
double** x,Contact* contact_list, int &num_contacts,
double &evdwl, double* facc);
int edge_against_edge(int ibody, int jbody, int itype, int jtype, double **x,
Contact *contact_list, int &num_contacts, double &evdwl, double *facc);
// edge-face interactions
int edge_against_face(int ibody, int jbody, int itype, int jtype,
double** x, Contact* contact_list, int &num_contacts,
double &evdwl, double* facc);
int edge_against_face(int ibody, int jbody, int itype, int jtype, double **x,
Contact *contact_list, int &num_contacts, double &evdwl, double *facc);
// a face vs. a single edge
int interaction_face_to_edge(int ibody, int face_index, double* xmi,
double rounded_radius_i, int jbody, int edge_index,
double* xmj, double rounded_radius_j,
int itype, int jtype, double cut_inner,
Contact* contact_list, int &num_contacts,
double& energy, double* facc);
int interaction_face_to_edge(int ibody, int face_index, double *xmi, double rounded_radius_i,
int jbody, int edge_index, double *xmj, double rounded_radius_j,
int itype, int jtype, double cut_inner, Contact *contact_list,
int &num_contacts, double &energy, double *facc);
// an edge vs. an edge from another body
int interaction_edge_to_edge(int ibody, int edge_index_i, double* xmi,
double rounded_radius_i, int jbody, int edge_index_j,
double* xmj, double rounded_radius_j,
int itype, int jtype, double cut_inner,
Contact* contact_list, int &num_contacts,
double& energy, double* facc);
int interaction_edge_to_edge(int ibody, int edge_index_i, double *xmi, double rounded_radius_i,
int jbody, int edge_index_j, double *xmj, double rounded_radius_j,
int itype, int jtype, double cut_inner, Contact *contact_list,
int &num_contacts, double &energy, double *facc);
// compute contact forces if contact points are detected
void contact_forces(int ibody, int jbody, double *xi, double *xj,
double delx, double dely, double delz, double fx, double fy, double fz,
double** x, double** v, double** angmom, double** f, double** torque,
double* facc);
void contact_forces(int ibody, int jbody, double *xi, double *xj, double delx, double dely,
double delz, double fx, double fy, double fz, double **x, double **v,
double **angmom, double **f, double **torque, double *facc);
// compute force and torque between two bodies given a pair of interacting points
void pair_force_and_torque(int ibody, int jbody, double* pi, double* pj,
double r, double contact_dist, int itype, int jtype,
double** x, double** v, double** f, double** torque,
double** angmom, int jflag, double& energy, double* facc);
void pair_force_and_torque(int ibody, int jbody, double *pi, double *pj, double r,
double contact_dist, int itype, int jtype, double **x, double **v,
double **f, double **torque, double **angmom, int jflag,
double &energy, double *facc);
// rescale the cohesive forces if a contact area is detected
void rescale_cohesive_forces(double** x, double** f, double** torque,
Contact* contact_list, int &num_contacts,
int itype, int jtype, double* facc);
void rescale_cohesive_forces(double **x, double **f, double **torque, Contact *contact_list,
int &num_contacts, int itype, int jtype, double *facc);
// compute the separation between two contacts
double contact_separation(const Contact& c1, const Contact& c2);
double contact_separation(const Contact &c1, const Contact &c2);
// detect the unique contact points (as there may be double counts)
void find_unique_contacts(Contact* contact_list, int& num_contacts);
void find_unique_contacts(Contact *contact_list, int &num_contacts);
// accumulate torque to a body given a force at a given point
void sum_torque(double* xm, double *x, double fx, double fy, double fz, double* torque);
void sum_torque(double *xm, double *x, double fx, double fy, double fz, double *torque);
// find the intersection point (if any) between an edge and a face
int edge_face_intersect(double* x1, double* x2, double* x3, double* a, double* b,
double* hi1, double* hi2, double& d1, double& d2,
int& inside_a, int& inside_b);
int edge_face_intersect(double *x1, double *x2, double *x3, double *a, double *b, double *hi1,
double *hi2, double &d1, double &d2, int &inside_a, int &inside_b);
// helper functions
int opposite_sides(double* n, double* x0, double* a, double* b);
void project_pt_plane(const double* q, const double* p,
const double* n, double* q_proj, double &d);
void project_pt_plane(const double* q, const double* x1, const double* x2,
const double* x3, double* q_proj, double &d, int& inside);
void project_pt_line(const double* q, const double* xi1, const double* xi2,
double* h, double& d, double& t);
void inside_polygon(int ibody, int face_index, double* xmi,
const double* q1, const double* q2, int& inside1, int& inside2);
int opposite_sides(double *n, double *x0, double *a, double *b);
void project_pt_plane(const double *q, const double *p, const double *n, double *q_proj,
double &d);
void project_pt_plane(const double *q, const double *x1, const double *x2, const double *x3,
double *q_proj, double &d, int &inside);
void project_pt_line(const double *q, const double *xi1, const double *xi2, double *h, double &d,
double &t);
void inside_polygon(int ibody, int face_index, double *xmi, const double *q1, const double *q2,
int &inside1, int &inside2);
void distance_bt_edges(const double* x1, const double* x2,
const double* x3, const double* x4,
double* h1, double* h2, double& t1, double& t2, double& r);
void total_velocity(double* p, double *xcm, double* vcm, double *angmom,
double *inertia, double *quat, double* vi);
void distance_bt_edges(const double *x1, const double *x2, const double *x3, const double *x4,
double *h1, double *h2, double &t1, double &t2, double &r);
void total_velocity(double *p, double *xcm, double *vcm, double *angmom, double *inertia,
double *quat, double *vi);
void sanity_check();
};
}
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -0,0 +1,248 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "atom_vec_bpm_sphere.h"
#include "atom.h"
#include "comm.h"
#include "error.h"
#include "fix.h"
#include "fix_adapt.h"
#include "math_const.h"
#include "modify.h"
#include "utils.h"
#include <cstring>
using namespace LAMMPS_NS;
using MathConst::MY_PI;
/* ---------------------------------------------------------------------- */
AtomVecBPMSphere::AtomVecBPMSphere(LAMMPS *_lmp) : AtomVec(_lmp)
{
mass_type = PER_ATOM;
molecular = Atom::MOLECULAR;
bonds_allow = 1;
atom->molecule_flag = 1;
atom->sphere_flag = 1;
atom->radius_flag = atom->rmass_flag = atom->omega_flag = atom->torque_flag = atom->quat_flag = 1;
// strings with peratom variables to include in each AtomVec method
// strings cannot contain fields in corresponding AtomVec default strings
// order of fields in a string does not matter
// except: fields_data_atom & fields_data_vel must match data file
fields_grow = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial", "special",
"radius", "rmass", "omega", "torque", "quat"};
fields_copy = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial",
"special", "radius", "rmass", "omega", "quat"};
fields_comm_vel = {"omega", "quat"};
fields_reverse = {"torque"};
fields_border = {"molecule", "radius", "rmass"};
fields_border_vel = {"molecule", "radius", "rmass", "omega", "quat"};
fields_exchange = {"molecule", "num_bond", "bond_type", "bond_atom", "nspecial",
"special", "radius", "rmass", "omega", "quat"};
fields_restart = {"molecule", "num_bond", "bond_type", "bond_atom",
"radius", "rmass", "omega", "quat"};
fields_create = {"molecule", "num_bond", "nspecial", "radius", "rmass", "omega", "quat"};
fields_data_atom = {"id", "molecule", "type", "radius", "rmass", "x"};
fields_data_vel = {"id", "v", "omega"};
bond_per_atom = 0;
bond_negative = NULL;
}
/* ----------------------------------------------------------------------
process sub-style args
optional arg = 0/1 for static/dynamic particle radii
------------------------------------------------------------------------- */
void AtomVecBPMSphere::process_args(int narg, char **arg)
{
if (narg != 0 && narg != 1) error->all(FLERR, "Illegal atom_style bpm/sphere command");
radvary = 0;
if (narg == 1) {
radvary = utils::numeric(FLERR, arg[0], true, lmp);
if (radvary < 0 || radvary > 1) error->all(FLERR, "Illegal atom_style bpm/sphere command");
}
// dynamic particle radius and mass must be communicated every step
if (radvary) {
fields_comm = {"radius", "rmass"};
fields_comm_vel = {"radius", "rmass", "omega"};
}
// delay setting up of fields until now
setup_fields();
}
/* ---------------------------------------------------------------------- */
void AtomVecBPMSphere::init()
{
AtomVec::init();
// check if optional radvary setting should have been set to 1
for (auto ifix : modify->get_fix_by_style("^adapt")) {
if (radvary == 0) {
if ((strcmp(ifix->style, "adapt") == 0) && (dynamic_cast<FixAdapt *>(ifix)->diamflag))
error->all(FLERR, "Fix adapt changes atom radii but atom_style bpm/sphere is not dynamic");
// cannot properly check for fix adapt/fep since its header is optional
if ((strcmp(ifix->style, "adapt/fep") == 0) && (comm->me == 0))
error->warning(
FLERR, "Fix adapt/fep may change atom radii but atom_style bpm/sphere is not dynamic");
}
}
}
/* ----------------------------------------------------------------------
set local copies of all grow ptrs used by this class, except defaults
needed in replicate when 2 atom classes exist and it calls pack_restart()
------------------------------------------------------------------------- */
void AtomVecBPMSphere::grow_pointers()
{
radius = atom->radius;
rmass = atom->rmass;
omega = atom->omega;
quat = atom->quat;
num_bond = atom->num_bond;
bond_type = atom->bond_type;
nspecial = atom->nspecial;
}
/* ----------------------------------------------------------------------
initialize non-zero atom quantities
------------------------------------------------------------------------- */
void AtomVecBPMSphere::create_atom_post(int ilocal)
{
radius[ilocal] = 0.5;
rmass[ilocal] = 4.0 * MY_PI / 3.0 * 0.5 * 0.5 * 0.5;
quat[ilocal][0] = 1.0;
quat[ilocal][1] = 0.0;
quat[ilocal][2] = 0.0;
quat[ilocal][3] = 0.0;
}
/* ----------------------------------------------------------------------
modify values for AtomVec::pack_restart() to pack
------------------------------------------------------------------------- */
void AtomVecBPMSphere::pack_restart_pre(int ilocal)
{
// insure bond_negative vector is needed length
if (bond_per_atom < atom->bond_per_atom) {
delete[] bond_negative;
bond_per_atom = atom->bond_per_atom;
bond_negative = new int[bond_per_atom];
}
// flip any negative types to positive and flag which ones
any_bond_negative = 0;
for (int m = 0; m < num_bond[ilocal]; m++) {
if (bond_type[ilocal][m] < 0) {
bond_negative[m] = 1;
bond_type[ilocal][m] = -bond_type[ilocal][m];
any_bond_negative = 1;
} else
bond_negative[m] = 0;
}
}
/* ----------------------------------------------------------------------
unmodify values packed by AtomVec::pack_restart()
------------------------------------------------------------------------- */
void AtomVecBPMSphere::pack_restart_post(int ilocal)
{
// restore the flagged types to their negative values
if (any_bond_negative) {
for (int m = 0; m < num_bond[ilocal]; m++)
if (bond_negative[m]) bond_type[ilocal][m] = -bond_type[ilocal][m];
}
}
/* ----------------------------------------------------------------------
initialize other atom quantities after AtomVec::unpack_restart()
------------------------------------------------------------------------- */
void AtomVecBPMSphere::unpack_restart_init(int ilocal)
{
nspecial[ilocal][0] = 0;
nspecial[ilocal][1] = 0;
nspecial[ilocal][2] = 0;
}
/* ----------------------------------------------------------------------
modify what AtomVec::data_atom() just unpacked
or initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecBPMSphere::data_atom_post(int ilocal)
{
radius_one = 0.5 * atom->radius[ilocal];
radius[ilocal] = radius_one;
if (radius_one > 0.0) rmass[ilocal] *= 4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one;
if (rmass[ilocal] <= 0.0) error->one(FLERR, "Invalid density in Atoms section of data file");
omega[ilocal][0] = 0.0;
omega[ilocal][1] = 0.0;
omega[ilocal][2] = 0.0;
quat[ilocal][0] = 1.0;
quat[ilocal][1] = 0.0;
quat[ilocal][2] = 0.0;
quat[ilocal][3] = 0.0;
num_bond[ilocal] = 0;
nspecial[ilocal][0] = 0;
nspecial[ilocal][1] = 0;
nspecial[ilocal][2] = 0;
}
/* ----------------------------------------------------------------------
modify values for AtomVec::pack_data() to pack
------------------------------------------------------------------------- */
void AtomVecBPMSphere::pack_data_pre(int ilocal)
{
radius_one = radius[ilocal];
rmass_one = rmass[ilocal];
radius[ilocal] *= 2.0;
if (radius_one != 0.0)
rmass[ilocal] = rmass_one / (4.0 * MY_PI / 3.0 * radius_one * radius_one * radius_one);
}
/* ----------------------------------------------------------------------
unmodify values packed by AtomVec::pack_data()
------------------------------------------------------------------------- */
void AtomVecBPMSphere::pack_data_post(int ilocal)
{
radius[ilocal] = radius_one;
rmass[ilocal] = rmass_one;
}

View File

@ -0,0 +1,82 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef ATOM_CLASS
// clang-format off
AtomStyle(bpm/sphere,AtomVecBPMSphere);
// clang-format on
#else
#ifndef LMP_ATOM_VEC_BPM_SPHERE_H
#define LMP_ATOM_VEC_BPM_SPHERE_H
#include "atom_vec.h"
namespace LAMMPS_NS {
class AtomVecBPMSphere : public AtomVec {
public:
AtomVecBPMSphere(class LAMMPS *);
void process_args(int, char **) override;
void init() override;
void grow_pointers() override;
void create_atom_post(int) override;
void pack_restart_pre(int) override;
void pack_restart_post(int) override;
void unpack_restart_init(int) override;
void data_atom_post(int) override;
void pack_data_pre(int) override;
void pack_data_post(int) override;
private:
int *num_bond;
int **bond_type;
int **nspecial;
double *radius, *rmass;
double **omega, **quat;
int any_bond_negative;
int bond_per_atom;
int *bond_negative;
int radvary;
double radius_one, rmass_one;
};
} // namespace LAMMPS_NS
#endif
#endif
/* ERROR/WARNING messages:
E: Per-processor system is too big
The number of owned atoms plus ghost atoms on a single
processor must fit in 32-bit integer.
E: Invalid atom type in Atoms section of data file
Atom types must range from 1 to specified # of types.
E: Invalid radius in Atoms section of data file
Radius must be >= 0.0.
E: Invalid density in Atoms section of data file
Density value cannot be <= 0.0.
*/

415
src/BPM/bond_bpm.cpp Normal file
View File

@ -0,0 +1,415 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "bond_bpm.h"
#include "atom.h"
#include "domain.h"
#include "error.h"
#include "fix_bond_history.h"
#include "fix_store_local.h"
#include "fix_update_special_bonds.h"
#include "force.h"
#include "memory.h"
#include "modify.h"
#include "update.h"
#include <vector>
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
BondBPM::BondBPM(LAMMPS *_lmp) :
Bond(_lmp), id_fix_dummy(nullptr), id_fix_dummy2(nullptr), id_fix_update(nullptr),
id_fix_bond_history(nullptr), id_fix_store_local(nullptr), id_fix_prop_atom(nullptr),
fix_store_local(nullptr), fix_bond_history(nullptr), fix_update_special_bonds(nullptr),
pack_choice(nullptr), output_data(nullptr)
{
overlay_flag = 0;
prop_atom_flag = 0;
nvalues = 0;
r0_max_estimate = 0.0;
max_stretch = 1.0;
// create dummy fix as placeholder for FixUpdateSpecialBonds & BondHistory
// this is so final order of Modify:fix will conform to input script
// BondHistory technically only needs this if updateflag = 1
id_fix_dummy = utils::strdup("BPM_DUMMY");
modify->add_fix(fmt::format("{} all DUMMY ", id_fix_dummy));
id_fix_dummy2 = utils::strdup("BPM_DUMMY2");
modify->add_fix(fmt::format("{} all DUMMY ", id_fix_dummy2));
}
/* ---------------------------------------------------------------------- */
BondBPM::~BondBPM()
{
delete[] pack_choice;
if (id_fix_dummy) modify->delete_fix(id_fix_dummy);
if (id_fix_dummy2) modify->delete_fix(id_fix_dummy2);
if (id_fix_update) modify->delete_fix(id_fix_update);
if (id_fix_bond_history) modify->delete_fix(id_fix_bond_history);
if (id_fix_store_local) modify->delete_fix(id_fix_store_local);
if (id_fix_prop_atom) modify->delete_fix(id_fix_prop_atom);
delete[] id_fix_dummy;
delete[] id_fix_dummy2;
delete[] id_fix_update;
delete[] id_fix_bond_history;
delete[] id_fix_store_local;
delete[] id_fix_prop_atom;
memory->destroy(output_data);
}
/* ---------------------------------------------------------------------- */
void BondBPM::init_style()
{
if (id_fix_store_local) {
auto ifix = modify->get_fix_by_id(id_fix_store_local);
if (!ifix) error->all(FLERR, "Cannot find fix store/local");
if (strcmp(ifix->style, "STORE_LOCAL") != 0)
error->all(FLERR, "Incorrect fix style matched, not store/local");
fix_store_local = dynamic_cast<FixStoreLocal *>(ifix);
fix_store_local->nvalues = nvalues;
}
if (overlay_flag) {
if (force->special_lj[1] != 1.0)
error->all(FLERR,
"With overlay/pair, BPM bond styles require special_bonds weight of 1.0 for "
"first neighbors");
if (id_fix_update) {
modify->delete_fix(id_fix_update);
delete[] id_fix_update;
id_fix_update = nullptr;
}
} else {
// Require atoms know about all of their bonds and if they break
if (force->newton_bond)
error->all(FLERR, "Without overlay/pair, BPM bond styles require Newton bond off");
// special lj must be 0 1 1 to censor pair forces between bonded particles
// special coulomb must be 1 1 1 to ensure all pairs are included in the
// neighbor list and 1-3 and 1-4 special bond lists are skipped
if (force->special_lj[1] != 0.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0)
error->all(FLERR,
"Without overlay/pair, BPM bond sytles requires special LJ weights = 0,1,1");
if (force->special_coul[1] != 1.0 || force->special_coul[2] != 1.0 ||
force->special_coul[3] != 1.0)
error->all(FLERR,
"Without overlay/pair, BPM bond sytles requires special Coulomb weights = 1,1,1");
if (id_fix_dummy) {
id_fix_update = utils::strdup("BPM_UPDATE_SPECIAL_BONDS");
fix_update_special_bonds = dynamic_cast<FixUpdateSpecialBonds *>(modify->replace_fix(
id_fix_dummy, fmt::format("{} all UPDATE_SPECIAL_BONDS", id_fix_update), 1));
delete[] id_fix_dummy;
id_fix_dummy = nullptr;
}
}
if (force->angle || force->dihedral || force->improper)
error->all(FLERR, "Bond style bpm cannot be used with 3,4-body interactions");
if (atom->molecular == 2)
error->all(FLERR, "Bond style bpm cannot be used with atom style template");
// special 1-3 and 1-4 weights must be 1 to prevent building 1-3 and 1-4 special bond lists
if (force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0 || force->special_coul[2] != 1.0 ||
force->special_coul[3] != 1.0)
error->all(FLERR, "Bond style bpm requires 1-3 and 1-4 special weights of 1.0");
}
/* ----------------------------------------------------------------------
global settings
All args before store/local command are saved for potential args
for specific bond BPM substyles
All args after optional store/local command are variables stored
in the compute store/local
------------------------------------------------------------------------- */
void BondBPM::settings(int narg, char **arg)
{
leftover_iarg.clear();
int iarg = 0;
while (iarg < narg) {
if (strcmp(arg[iarg], "store/local") == 0) {
nvalues = 0;
id_fix_store_local = utils::strdup(arg[iarg + 1]);
store_local_freq = utils::inumeric(FLERR, arg[iarg + 2], false, lmp);
pack_choice = new FnPtrPack[narg - iarg - 1];
iarg += 3;
while (iarg < narg) {
if (strcmp(arg[iarg], "id1") == 0) {
pack_choice[nvalues++] = &BondBPM::pack_id1;
} else if (strcmp(arg[iarg], "id2") == 0) {
pack_choice[nvalues++] = &BondBPM::pack_id2;
} else if (strcmp(arg[iarg], "time") == 0) {
pack_choice[nvalues++] = &BondBPM::pack_time;
} else if (strcmp(arg[iarg], "x") == 0) {
pack_choice[nvalues++] = &BondBPM::pack_x;
} else if (strcmp(arg[iarg], "y") == 0) {
pack_choice[nvalues++] = &BondBPM::pack_y;
} else if (strcmp(arg[iarg], "z") == 0) {
pack_choice[nvalues++] = &BondBPM::pack_z;
} else if (strcmp(arg[iarg], "x/ref") == 0) {
pack_choice[nvalues++] = &BondBPM::pack_x_ref;
prop_atom_flag = 1;
} else if (strcmp(arg[iarg], "y/ref") == 0) {
pack_choice[nvalues++] = &BondBPM::pack_y_ref;
prop_atom_flag = 1;
} else if (strcmp(arg[iarg], "z/ref") == 0) {
pack_choice[nvalues++] = &BondBPM::pack_z_ref;
prop_atom_flag = 1;
} else {
break;
}
iarg++;
}
} else if (strcmp(arg[iarg], "overlay/pair") == 0) {
overlay_flag = 1;
iarg++;
} else {
leftover_iarg.push_back(iarg);
iarg++;
}
}
if (id_fix_store_local) {
if (nvalues == 0)
error->all(FLERR, "Storing local data must include at least one value to output");
memory->create(output_data, nvalues, "bond/bpm:output_data");
auto ifix = modify->get_fix_by_id(id_fix_store_local);
if (!ifix)
ifix = modify->add_fix(
fmt::format("{} all STORE_LOCAL {} {}", id_fix_store_local, store_local_freq, nvalues));
fix_store_local = dynamic_cast<FixStoreLocal *>(ifix);
// Use property/atom to save reference positions as it can transfer to ghost atoms
// This won't work for instances where bonds are added (e.g. fix pour) but in those cases
// a reference state isn't well defined
if (prop_atom_flag == 1) {
id_fix_prop_atom = utils::strdup("BPM_property_atom");
char *x_ref_id = utils::strdup("BPM_X_REF");
char *y_ref_id = utils::strdup("BPM_Y_REF");
char *z_ref_id = utils::strdup("BPM_Z_REF");
ifix = modify->get_fix_by_id(id_fix_prop_atom);
if (!ifix)
ifix = modify->add_fix(fmt::format("{} all property/atom {} {} {} ghost yes",
id_fix_prop_atom, x_ref_id, y_ref_id, z_ref_id));
int type_flag;
int col_flag;
index_x_ref = atom->find_custom(x_ref_id, type_flag, col_flag);
index_y_ref = atom->find_custom(y_ref_id, type_flag, col_flag);
index_z_ref = atom->find_custom(z_ref_id, type_flag, col_flag);
delete[] x_ref_id;
delete[] y_ref_id;
delete[] z_ref_id;
if (ifix->restart_reset) {
ifix->restart_reset = 0;
} else {
double *x_ref = atom->dvector[index_x_ref];
double *y_ref = atom->dvector[index_y_ref];
double *z_ref = atom->dvector[index_z_ref];
double **x = atom->x;
for (int i = 0; i < atom->nlocal; i++) {
x_ref[i] = x[i][0];
y_ref[i] = x[i][1];
z_ref[i] = x[i][2];
}
}
}
}
}
/* ----------------------------------------------------------------------
used to check bond communiction cutoff - not perfect, estimates based on local-local only
------------------------------------------------------------------------- */
double BondBPM::equilibrium_distance(int /*i*/)
{
// Ghost atoms may not yet be communicated, this may only be an estimate
if (r0_max_estimate == 0) {
int type, j;
double delx, dely, delz, r;
double **x = atom->x;
for (int i = 0; i < atom->nlocal; i++) {
for (int m = 0; m < atom->num_bond[i]; m++) {
type = atom->bond_type[i][m];
if (type == 0) continue;
j = atom->map(atom->bond_atom[i][m]);
if (j == -1) continue;
delx = x[i][0] - x[j][0];
dely = x[i][1] - x[j][1];
delz = x[i][2] - x[j][2];
domain->minimum_image(delx, dely, delz);
r = sqrt(delx * delx + dely * dely + delz * delz);
if (r > r0_max_estimate) r0_max_estimate = r;
}
}
double temp;
MPI_Allreduce(&r0_max_estimate, &temp, 1, MPI_DOUBLE, MPI_MAX, world);
r0_max_estimate = temp;
}
// Divide out heuristic prefactor added in comm class
return max_stretch * r0_max_estimate / 1.5;
}
/* ---------------------------------------------------------------------- */
void BondBPM::process_broken(int i, int j)
{
if (fix_store_local) {
for (int n = 0; n < nvalues; n++) (this->*pack_choice[n])(n, i, j);
fix_store_local->add_data(output_data, i, j);
}
if (fix_update_special_bonds) fix_update_special_bonds->add_broken_bond(i, j);
// Manually search and remove from atom arrays
// need to remove in case special bonds arrays rebuilt
int m, n;
int nlocal = atom->nlocal;
tagint *tag = atom->tag;
tagint **bond_atom = atom->bond_atom;
int **bond_type = atom->bond_type;
int *num_bond = atom->num_bond;
if (i < nlocal) {
for (m = 0; m < num_bond[i]; m++) {
if (bond_atom[i][m] == tag[j]) {
bond_type[i][m] = 0;
n = num_bond[i];
bond_type[i][m] = bond_type[i][n - 1];
bond_atom[i][m] = bond_atom[i][n - 1];
fix_bond_history->shift_history(i, m, n - 1);
fix_bond_history->delete_history(i, n - 1);
num_bond[i]--;
break;
}
}
}
if (j < nlocal) {
for (m = 0; m < num_bond[j]; m++) {
if (bond_atom[j][m] == tag[i]) {
bond_type[j][m] = 0;
n = num_bond[j];
bond_type[j][m] = bond_type[j][n - 1];
bond_atom[j][m] = bond_atom[j][n - 1];
fix_bond_history->shift_history(j, m, n - 1);
fix_bond_history->delete_history(j, n - 1);
num_bond[j]--;
break;
}
}
}
}
/* ----------------------------------------------------------------------
one method for every keyword bond bpm can output
the atom property is packed into array or vector
------------------------------------------------------------------------- */
void BondBPM::pack_id1(int n, int i, int /*j*/)
{
tagint *tag = atom->tag;
output_data[n] = tag[i];
}
/* ---------------------------------------------------------------------- */
void BondBPM::pack_id2(int n, int /*i*/, int j)
{
tagint *tag = atom->tag;
output_data[n] = tag[j];
}
/* ---------------------------------------------------------------------- */
void BondBPM::pack_time(int n, int /*i*/, int /*j*/)
{
bigint time = update->ntimestep;
output_data[n] = time;
}
/* ---------------------------------------------------------------------- */
void BondBPM::pack_x(int n, int i, int j)
{
double **x = atom->x;
output_data[n] = (x[i][0] + x[j][0]) * 0.5;
}
/* ---------------------------------------------------------------------- */
void BondBPM::pack_y(int n, int i, int j)
{
double **x = atom->x;
output_data[n] = (x[i][1] + x[j][1]) * 0.5;
}
/* ---------------------------------------------------------------------- */
void BondBPM::pack_z(int n, int i, int j)
{
double **x = atom->x;
output_data[n] = (x[i][2] + x[j][2]) * 0.5;
}
/* ---------------------------------------------------------------------- */
void BondBPM::pack_x_ref(int n, int i, int j)
{
double *x = atom->dvector[index_x_ref];
output_data[n] = (x[i] + x[j]) * 0.5;
}
/* ---------------------------------------------------------------------- */
void BondBPM::pack_y_ref(int n, int i, int j)
{
double *y = atom->dvector[index_y_ref];
output_data[n] = (y[i] + y[j]) * 0.5;
}
/* ---------------------------------------------------------------------- */
void BondBPM::pack_z_ref(int n, int i, int j)
{
double *z = atom->dvector[index_z_ref];
output_data[n] = (z[i] + z[j]) * 0.5;
}

98
src/BPM/bond_bpm.h Normal file
View File

@ -0,0 +1,98 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifndef LMP_BOND_BPM_H
#define LMP_BOND_BPM_H
#include "bond.h"
#include <vector>
namespace LAMMPS_NS {
class BondBPM : public Bond {
public:
BondBPM(class LAMMPS *);
~BondBPM() override;
void compute(int, int) override = 0;
void coeff(int, char **) override = 0;
void init_style() override;
void settings(int, char **) override;
double equilibrium_distance(int) override;
void write_restart(FILE *) override{};
void read_restart(FILE *) override{};
void write_data(FILE *) override{};
double single(int, double, int, int, double &) override = 0;
protected:
double r0_max_estimate;
double max_stretch;
int store_local_freq;
std::vector<int> leftover_iarg;
char *id_fix_dummy, *id_fix_dummy2;
char *id_fix_update, *id_fix_bond_history;
char *id_fix_store_local, *id_fix_prop_atom;
class FixStoreLocal *fix_store_local;
class FixBondHistory *fix_bond_history;
class FixUpdateSpecialBonds *fix_update_special_bonds;
void process_broken(int, int);
typedef void (BondBPM::*FnPtrPack)(int, int, int);
FnPtrPack *pack_choice; // ptrs to pack functions
double *output_data;
int prop_atom_flag, nvalues, overlay_flag;
int index_x_ref, index_y_ref, index_z_ref;
void pack_id1(int, int, int);
void pack_id2(int, int, int);
void pack_time(int, int, int);
void pack_x(int, int, int);
void pack_y(int, int, int);
void pack_z(int, int, int);
void pack_x_ref(int, int, int);
void pack_y_ref(int, int, int);
void pack_z_ref(int, int, int);
};
} // namespace LAMMPS_NS
#endif
/* ERROR/WARNING messages:
E: Cannot find fix store/local
Fix id cannot be found.
E: Illegal bond_style command
Self-explanatory.
E: Bond style bpm must include at least one value to output
Must include at least one bond property to store in fix store/local
E: Bond style bpm cannot be used with 3,4-body interactions
No angle, dihedral, or improper styles can be defined when using
bond style bpm.
E: Bond style bpm cannot be used with atom style template
This bond style can change the bond topology which is not
allowed with this atom style.
*/

View File

@ -0,0 +1,796 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "bond_bpm_rotational.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "fix_bond_history.h"
#include "force.h"
#include "math_const.h"
#include "math_extra.h"
#include "memory.h"
#include "modify.h"
#include "neighbor.h"
#include <cmath>
#define EPSILON 1e-10
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
BondBPMRotational::BondBPMRotational(LAMMPS *_lmp) : BondBPM(_lmp)
{
Kr = nullptr;
Ks = nullptr;
Kt = nullptr;
Kb = nullptr;
Fcr = nullptr;
Fcs = nullptr;
Tct = nullptr;
Tcb = nullptr;
gnorm = nullptr;
gslide = nullptr;
groll = nullptr;
gtwist = nullptr;
partial_flag = 1;
smooth_flag = 1;
}
/* ---------------------------------------------------------------------- */
BondBPMRotational::~BondBPMRotational()
{
if (allocated) {
memory->destroy(setflag);
memory->destroy(Kr);
memory->destroy(Ks);
memory->destroy(Kt);
memory->destroy(Kb);
memory->destroy(Fcr);
memory->destroy(Fcs);
memory->destroy(Tct);
memory->destroy(Tcb);
memory->destroy(gnorm);
memory->destroy(gslide);
memory->destroy(groll);
memory->destroy(gtwist);
}
}
/* ---------------------------------------------------------------------- */
double BondBPMRotational::acos_limit(double c)
{
if (c > 1.0) c = 1.0;
if (c < -1.0) c = -1.0;
return acos(c);
}
/* ----------------------------------------------------------------------
Store data for a single bond - if bond added after LAMMPS init (e.g. pour)
------------------------------------------------------------------------- */
double BondBPMRotational::store_bond(int n, int i, int j)
{
double delx, dely, delz, r, rinv;
double **x = atom->x;
tagint *tag = atom->tag;
double **bondstore = fix_bond_history->bondstore;
if (tag[i] < tag[j]) {
delx = x[i][0] - x[j][0];
dely = x[i][1] - x[j][1];
delz = x[i][2] - x[j][2];
} else {
delx = x[j][0] - x[i][0];
dely = x[j][1] - x[i][1];
delz = x[j][2] - x[i][2];
}
r = sqrt(delx * delx + dely * dely + delz * delz);
rinv = 1.0 / r;
bondstore[n][0] = r;
bondstore[n][1] = delx * rinv;
bondstore[n][2] = dely * rinv;
bondstore[n][3] = delz * rinv;
if (i < atom->nlocal) {
for (int m = 0; m < atom->num_bond[i]; m++) {
if (atom->bond_atom[i][m] == tag[j]) {
fix_bond_history->update_atom_value(i, m, 0, r);
fix_bond_history->update_atom_value(i, m, 1, delx * rinv);
fix_bond_history->update_atom_value(i, m, 2, dely * rinv);
fix_bond_history->update_atom_value(i, m, 3, delz * rinv);
}
}
}
if (j < atom->nlocal) {
for (int m = 0; m < atom->num_bond[j]; m++) {
if (atom->bond_atom[j][m] == tag[i]) {
fix_bond_history->update_atom_value(j, m, 0, r);
fix_bond_history->update_atom_value(j, m, 1, delx * rinv);
fix_bond_history->update_atom_value(j, m, 2, dely * rinv);
fix_bond_history->update_atom_value(j, m, 3, delz * rinv);
}
}
}
return r;
}
/* ----------------------------------------------------------------------
Store data for all bonds called once
------------------------------------------------------------------------- */
void BondBPMRotational::store_data()
{
int i, j, m, type;
double delx, dely, delz, r, rinv;
double **x = atom->x;
int **bond_type = atom->bond_type;
tagint *tag = atom->tag;
for (i = 0; i < atom->nlocal; i++) {
for (m = 0; m < atom->num_bond[i]; m++) {
type = bond_type[i][m];
//Skip if bond was turned off
if (type < 0) continue;
// map to find index n for tag
j = atom->map(atom->bond_atom[i][m]);
if (j == -1) error->one(FLERR, "Atom missing in BPM bond");
// Save orientation as pointing towards small tag
if (tag[i] < tag[j]) {
delx = x[i][0] - x[j][0];
dely = x[i][1] - x[j][1];
delz = x[i][2] - x[j][2];
} else {
delx = x[j][0] - x[i][0];
dely = x[j][1] - x[i][1];
delz = x[j][2] - x[i][2];
}
// Get closest image in case bonded with ghost
domain->minimum_image(delx, dely, delz);
r = sqrt(delx * delx + dely * dely + delz * delz);
rinv = 1.0 / r;
fix_bond_history->update_atom_value(i, m, 0, r);
fix_bond_history->update_atom_value(i, m, 1, delx * rinv);
fix_bond_history->update_atom_value(i, m, 2, dely * rinv);
fix_bond_history->update_atom_value(i, m, 3, delz * rinv);
}
}
fix_bond_history->post_neighbor();
}
/* ----------------------------------------------------------------------
Calculate forces using formulation in:
1) Y. Wang Acta Geotechnica 2009
2) P. Mora & Y. Wang Advances in Geomcomputing 2009
---------------------------------------------------------------------- */
double BondBPMRotational::elastic_forces(int i1, int i2, int type, double &Fr, double r_mag,
double r0_mag, double r_mag_inv, double * /*rhat*/,
double *r, double *r0, double *force1on2,
double *torque1on2, double *torque2on1)
{
double breaking, temp, r0_dot_rb, c, gamma;
double psi, theta, cos_phi, sin_phi;
double mag_in_plane, mag_out_plane;
double Fs_mag, Tt_mag, Tb_mag;
double q1[4], q2[4];
double q2inv[4], mq[4], mqinv[4], qp21[4], q21[4], qtmp[4];
double rb[3], rb_x_r0[3], s[3], t[3];
double Fs[3], Fsp[3], F_rot[3], Ftmp[3];
double Ts[3], Tb[3], Tt[3], Tbp[3], Ttp[3], Tsp[3], T_rot[3], Ttmp[3];
double **quat = atom->quat;
q1[0] = quat[i1][0];
q1[1] = quat[i1][1];
q1[2] = quat[i1][2];
q1[3] = quat[i1][3];
q2[0] = quat[i2][0];
q2[1] = quat[i2][1];
q2[2] = quat[i2][2];
q2[3] = quat[i2][3];
// Calculate normal forces, rb = bond vector in particle 1's frame
MathExtra::qconjugate(q2, q2inv);
MathExtra::quatrotvec(q2inv, r, rb);
Fr = Kr[type] * (r_mag - r0_mag);
MathExtra::scale3(Fr * r_mag_inv, rb, F_rot);
// Calculate forces due to tangential displacements (no rotation)
r0_dot_rb = MathExtra::dot3(r0, rb);
c = r0_dot_rb * r_mag_inv / r0_mag;
gamma = acos_limit(c);
MathExtra::cross3(rb, r0, rb_x_r0);
MathExtra::cross3(rb, rb_x_r0, s);
MathExtra::norm3(s);
MathExtra::scale3(Ks[type] * r_mag * gamma, s, Fs);
// Calculate torque due to tangential displacements
MathExtra::cross3(r0, rb, t);
MathExtra::norm3(t);
MathExtra::scale3(0.5 * r_mag * Ks[type] * r_mag * gamma, t, Ts);
// Relative rotation force/torque
// Use representation of X'Y'Z' rotations from Wang, Mora 2009
temp = r_mag + rb[2];
if (temp < 0.0) temp = 0.0;
mq[0] = sqrt(2) * 0.5 * sqrt(temp * r_mag_inv);
temp = sqrt(rb[0] * rb[0] + rb[1] * rb[1]);
if (temp != 0.0) {
mq[1] = -sqrt(2) * 0.5 / temp;
temp = r_mag - rb[2];
if (temp < 0.0) temp = 0.0;
mq[1] *= sqrt(temp * r_mag_inv);
mq[2] = -mq[1];
mq[1] *= rb[1];
mq[2] *= rb[0];
} else {
// If aligned along z axis, x,y terms zero (r_mag-rb[2] = 0)
mq[1] = 0.0;
mq[2] = 0.0;
}
mq[3] = 0.0;
// qp21 = opposite of r^\circ_21 in Wang
// q21 = opposite of r_21 in Wang
MathExtra::quatquat(q2inv, q1, qp21);
MathExtra::qconjugate(mq, mqinv);
MathExtra::quatquat(mqinv, qp21, qtmp);
MathExtra::quatquat(qtmp, mq, q21);
temp = sqrt(q21[0] * q21[0] + q21[3] * q21[3]);
if (temp != 0.0) {
c = q21[0] / temp;
psi = 2.0 * acos_limit(c);
} else {
c = 0.0;
psi = 0.0;
}
// Map negative rotations
if (q21[3] < 0.0) // sin = q21[3]/temp
psi = -psi;
if (q21[3] == 0.0) psi = 0.0;
c = q21[0] * q21[0] - q21[1] * q21[1] - q21[2] * q21[2] + q21[3] * q21[3];
theta = acos_limit(c);
// Separately calculte magnitude of quaternion in x-y and out of x-y planes
// to avoid dividing by zero
mag_out_plane = (q21[0] * q21[0] + q21[3] * q21[3]);
mag_in_plane = (q21[1] * q21[1] + q21[2] * q21[2]);
if (mag_in_plane == 0.0) {
// No rotation => no bending/shear torque or extra shear force
// achieve by setting cos/sin = 0
cos_phi = 0.0;
sin_phi = 0.0;
} else if (mag_out_plane == 0.0) {
// Calculate angle in plane
cos_phi = q21[2] / sqrt(mag_in_plane);
sin_phi = -q21[1] / sqrt(mag_in_plane);
} else {
// Default equations in Mora, Wang 2009
cos_phi = q21[1] * q21[3] + q21[0] * q21[2];
sin_phi = q21[2] * q21[3] - q21[0] * q21[1];
cos_phi /= sqrt(mag_out_plane * mag_in_plane);
sin_phi /= sqrt(mag_out_plane * mag_in_plane);
}
Tbp[0] = -Kb[type] * theta * sin_phi;
Tbp[1] = Kb[type] * theta * cos_phi;
Tbp[2] = 0.0;
Ttp[0] = 0.0;
Ttp[1] = 0.0;
Ttp[2] = Kt[type] * psi;
Fsp[0] = -0.5 * Ks[type] * r_mag * theta * cos_phi;
Fsp[1] = -0.5 * Ks[type] * r_mag * theta * sin_phi;
Fsp[2] = 0.0;
Tsp[0] = 0.25 * Ks[type] * r_mag * r_mag * theta * sin_phi;
Tsp[1] = -0.25 * Ks[type] * r_mag * r_mag * theta * cos_phi;
Tsp[2] = 0.0;
// Rotate forces/torques back to 1st particle's frame
MathExtra::quatrotvec(mq, Fsp, Ftmp);
MathExtra::quatrotvec(mq, Tsp, Ttmp);
for (int m = 0; m < 3; m++) {
Fs[m] += Ftmp[m];
Ts[m] += Ttmp[m];
}
MathExtra::quatrotvec(mq, Tbp, Tb);
MathExtra::quatrotvec(mq, Ttp, Tt);
// Sum forces and calculate magnitudes
F_rot[0] += Fs[0];
F_rot[1] += Fs[1];
F_rot[2] += Fs[2];
MathExtra::quatrotvec(q2, F_rot, force1on2);
T_rot[0] = Ts[0] + Tt[0] + Tb[0];
T_rot[1] = Ts[1] + Tt[1] + Tb[1];
T_rot[2] = Ts[2] + Tt[2] + Tb[2];
MathExtra::quatrotvec(q2, T_rot, torque1on2);
T_rot[0] = Ts[0] - Tt[0] - Tb[0];
T_rot[1] = Ts[1] - Tt[1] - Tb[1];
T_rot[2] = Ts[2] - Tt[2] - Tb[2];
MathExtra::quatrotvec(q2, T_rot, torque2on1);
Fs_mag = MathExtra::len3(Fs);
Tt_mag = MathExtra::len3(Tt);
Tb_mag = MathExtra::len3(Tb);
breaking = Fr / Fcr[type] + Fs_mag / Fcs[type] + Tb_mag / Tcb[type] + Tt_mag / Tct[type];
if (breaking < 0.0) breaking = 0.0;
return breaking;
}
/* ----------------------------------------------------------------------
Calculate damping using formulation in
Y. Wang, F. Alonso-Marroquin, W. Guo 2015
Note: n points towards 1 vs pointing towards 2
---------------------------------------------------------------------- */
void BondBPMRotational::damping_forces(int i1, int i2, int type, double &Fr, double *rhat,
double *r, double *force1on2, double *torque1on2,
double *torque2on1)
{
double v1dotr, v2dotr, w1dotr, w2dotr;
double s1[3], s2[3], tdamp[3], tmp[3];
double vn1[3], vn2[3], vt1[3], vt2[3], vroll[3];
double wxn1[3], wxn2[3], wn1[3], wn2[3];
double **v = atom->v;
double **omega = atom->omega;
// Damp normal velocity difference
v1dotr = MathExtra::dot3(v[i1], rhat);
v2dotr = MathExtra::dot3(v[i2], rhat);
MathExtra::scale3(v1dotr, rhat, vn1);
MathExtra::scale3(v2dotr, rhat, vn2);
MathExtra::sub3(vn1, vn2, tmp);
MathExtra::scale3(gnorm[type], tmp);
Fr = MathExtra::lensq3(tmp);
MathExtra::add3(force1on2, tmp, force1on2);
// Damp tangential objective velocities
MathExtra::sub3(v[i1], vn1, vt1);
MathExtra::sub3(v[i2], vn2, vt2);
MathExtra::sub3(vt2, vt1, tmp);
MathExtra::scale3(0.5, tmp);
MathExtra::cross3(omega[i1], r, s1);
MathExtra::scale3(-0.5, s1);
MathExtra::sub3(s1, tmp, s1); // Eq 12
MathExtra::cross3(omega[i2], r, s2);
MathExtra::scale3(0.5, s2);
MathExtra::add3(s2, tmp, s2); // Eq 13
MathExtra::sub3(s1, s2, tmp);
MathExtra::scale3(gslide[type], tmp);
MathExtra::add3(force1on2, tmp, force1on2);
// Apply corresponding torque
MathExtra::cross3(r, tmp, tdamp);
MathExtra::scale3(0.5, tdamp);
MathExtra::add3(torque1on2, tdamp, torque1on2);
MathExtra::add3(torque2on1, tdamp, torque2on1);
// Damp rolling
MathExtra::cross3(omega[i1], rhat, wxn1);
MathExtra::cross3(omega[i2], rhat, wxn2);
MathExtra::sub3(wxn1, wxn2, vroll); // Eq. 31
MathExtra::cross3(r, vroll, tdamp);
MathExtra::scale3(0.5 * groll[type], tdamp);
MathExtra::add3(torque1on2, tdamp, torque1on2);
MathExtra::scale3(-1.0, tdamp);
MathExtra::add3(torque2on1, tdamp, torque2on1);
// Damp twist
w1dotr = MathExtra::dot3(omega[i1], rhat);
w2dotr = MathExtra::dot3(omega[i2], rhat);
MathExtra::scale3(w1dotr, rhat, wn1);
MathExtra::scale3(w2dotr, rhat, wn2);
MathExtra::sub3(wn1, wn2, tdamp); // Eq. 38
MathExtra::scale3(0.5 * gtwist[type], tdamp);
MathExtra::add3(torque1on2, tdamp, torque1on2);
MathExtra::scale3(-1.0, tdamp);
MathExtra::add3(torque2on1, tdamp, torque2on1);
}
/* ---------------------------------------------------------------------- */
void BondBPMRotational::compute(int eflag, int vflag)
{
if (!fix_bond_history->stored_flag) {
fix_bond_history->stored_flag = true;
store_data();
}
int i1, i2, itmp, n, type;
double r[3], r0[3], rhat[3];
double rsq, r0_mag, r_mag, r_mag_inv;
double Fr, breaking, smooth;
double force1on2[3], torque1on2[3], torque2on1[3];
ev_init(eflag, vflag);
double **x = atom->x;
double **f = atom->f;
double **torque = atom->torque;
tagint *tag = atom->tag;
int **bondlist = neighbor->bondlist;
int nbondlist = neighbor->nbondlist;
int nlocal = atom->nlocal;
int newton_bond = force->newton_bond;
double **bondstore = fix_bond_history->bondstore;
for (n = 0; n < nbondlist; n++) {
// skip bond if already broken
if (bondlist[n][2] <= 0) continue;
i1 = bondlist[n][0];
i2 = bondlist[n][1];
type = bondlist[n][2];
r0_mag = bondstore[n][0];
// Ensure pair is always ordered such that r0 points in
// a consistent direction and to ensure numerical operations
// are identical to minimize the possibility that a bond straddling
// an mpi grid (newton off) doesn't break on one proc but not the other
if (tag[i2] < tag[i1]) {
itmp = i1;
i1 = i2;
i2 = itmp;
}
// If bond hasn't been set - should be initialized to zero
if (r0_mag < EPSILON || std::isnan(r0_mag)) r0_mag = store_bond(n, i1, i2);
r0[0] = bondstore[n][1];
r0[1] = bondstore[n][2];
r0[2] = bondstore[n][3];
MathExtra::scale3(r0_mag, r0);
// Note this is the reverse of Mora & Wang
MathExtra::sub3(x[i1], x[i2], r);
rsq = MathExtra::lensq3(r);
r_mag = sqrt(rsq);
r_mag_inv = 1.0 / r_mag;
MathExtra::scale3(r_mag_inv, r, rhat);
// ------------------------------------------------------//
// Calculate forces, check if bond breaks
// ------------------------------------------------------//
breaking = elastic_forces(i1, i2, type, Fr, r_mag, r0_mag, r_mag_inv, rhat, r, r0, force1on2,
torque1on2, torque2on1);
if (breaking >= 1.0) {
bondlist[n][2] = 0;
process_broken(i1, i2);
continue;
}
damping_forces(i1, i2, type, Fr, rhat, r, force1on2, torque1on2, torque2on1);
if (smooth_flag) {
smooth = breaking * breaking;
smooth = 1.0 - smooth * smooth;
} else {
smooth = 1.0;
}
// ------------------------------------------------------//
// Apply forces and torques to particles
// ------------------------------------------------------//
if (newton_bond || i1 < nlocal) {
f[i1][0] -= force1on2[0] * smooth;
f[i1][1] -= force1on2[1] * smooth;
f[i1][2] -= force1on2[2] * smooth;
torque[i1][0] += torque2on1[0] * smooth;
torque[i1][1] += torque2on1[1] * smooth;
torque[i1][2] += torque2on1[2] * smooth;
}
if (newton_bond || i2 < nlocal) {
f[i2][0] += force1on2[0] * smooth;
f[i2][1] += force1on2[1] * smooth;
f[i2][2] += force1on2[2] * smooth;
torque[i2][0] += torque1on2[0] * smooth;
torque[i2][1] += torque1on2[1] * smooth;
torque[i2][2] += torque1on2[2] * smooth;
}
if (evflag) ev_tally(i1, i2, nlocal, newton_bond, 0.0, Fr * smooth, r[0], r[1], r[2]);
}
}
/* ---------------------------------------------------------------------- */
void BondBPMRotational::allocate()
{
allocated = 1;
const int np1 = atom->nbondtypes + 1;
memory->create(Kr, np1, "bond:Kr");
memory->create(Ks, np1, "bond:Ks");
memory->create(Kt, np1, "bond:Kt");
memory->create(Kb, np1, "bond:Kb");
memory->create(Fcr, np1, "bond:Fcr");
memory->create(Fcs, np1, "bond:Fcs");
memory->create(Tct, np1, "bond:Tct");
memory->create(Tcb, np1, "bond:Tcb");
memory->create(gnorm, np1, "bond:gnorm");
memory->create(gslide, np1, "bond:gslide");
memory->create(groll, np1, "bond:groll");
memory->create(gtwist, np1, "bond:gtwist");
memory->create(setflag, np1, "bond:setflag");
for (int i = 1; i < np1; i++) setflag[i] = 0;
}
/* ----------------------------------------------------------------------
set coeffs for one or more types
------------------------------------------------------------------------- */
void BondBPMRotational::coeff(int narg, char **arg)
{
if (narg != 13) error->all(FLERR, "Incorrect args for bond coefficients");
if (!allocated) allocate();
int ilo, ihi;
utils::bounds(FLERR, arg[0], 1, atom->nbondtypes, ilo, ihi, error);
double Kr_one = utils::numeric(FLERR, arg[1], false, lmp);
double Ks_one = utils::numeric(FLERR, arg[2], false, lmp);
double Kt_one = utils::numeric(FLERR, arg[3], false, lmp);
double Kb_one = utils::numeric(FLERR, arg[4], false, lmp);
double Fcr_one = utils::numeric(FLERR, arg[5], false, lmp);
double Fcs_one = utils::numeric(FLERR, arg[6], false, lmp);
double Tct_one = utils::numeric(FLERR, arg[7], false, lmp);
double Tcb_one = utils::numeric(FLERR, arg[8], false, lmp);
double gnorm_one = utils::numeric(FLERR, arg[9], false, lmp);
double gslide_one = utils::numeric(FLERR, arg[10], false, lmp);
double groll_one = utils::numeric(FLERR, arg[11], false, lmp);
double gtwist_one = utils::numeric(FLERR, arg[12], false, lmp);
int count = 0;
for (int i = ilo; i <= ihi; i++) {
Kr[i] = Kr_one;
Ks[i] = Ks_one;
Kt[i] = Kt_one;
Kb[i] = Kb_one;
Fcr[i] = Fcr_one;
Fcs[i] = Fcs_one;
Tct[i] = Tct_one;
Tcb[i] = Tcb_one;
gnorm[i] = gnorm_one;
gslide[i] = gslide_one;
groll[i] = groll_one;
gtwist[i] = gtwist_one;
setflag[i] = 1;
count++;
if (Fcr[i] / Kr[i] > max_stretch) max_stretch = Fcr[i] / Kr[i];
}
if (count == 0) error->all(FLERR, "Incorrect args for bond coefficients");
}
/* ----------------------------------------------------------------------
check for correct settings and create fix
------------------------------------------------------------------------- */
void BondBPMRotational::init_style()
{
BondBPM::init_style();
if (!atom->quat_flag || !atom->sphere_flag)
error->all(FLERR, "Bond bpm/rotational requires atom style bpm/sphere");
if (comm->ghost_velocity == 0)
error->all(FLERR, "Bond bpm/rotational requires ghost atoms store velocity");
if (domain->dimension == 2)
error->warning(FLERR, "Bond style bpm/rotational not intended for 2d use");
if (!id_fix_bond_history) {
id_fix_bond_history = utils::strdup("HISTORY_BPM_ROTATIONAL");
fix_bond_history = dynamic_cast<FixBondHistory *>(modify->replace_fix(
id_fix_dummy2, fmt::format("{} all BOND_HISTORY 0 4", id_fix_bond_history), 1));
delete[] id_fix_dummy2;
id_fix_dummy2 = nullptr;
}
}
/* ---------------------------------------------------------------------- */
void BondBPMRotational::settings(int narg, char **arg)
{
BondBPM::settings(narg, arg);
int iarg;
for (std::size_t i = 0; i < leftover_iarg.size(); i++) {
iarg = leftover_iarg[i];
if (strcmp(arg[iarg], "smooth") == 0) {
if (iarg + 1 > narg) error->all(FLERR, "Illegal bond bpm command");
smooth_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
i += 1;
} else {
error->all(FLERR, "Illegal bond_style command");
}
}
}
/* ----------------------------------------------------------------------
proc 0 writes out coeffs to restart file
------------------------------------------------------------------------- */
void BondBPMRotational::write_restart(FILE *fp)
{
fwrite(&Kr[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&Ks[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&Kt[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&Kb[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&Fcr[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&Fcs[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&Tct[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&Tcb[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&gnorm[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&gslide[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&groll[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&gtwist[1], sizeof(double), atom->nbondtypes, fp);
}
/* ----------------------------------------------------------------------
proc 0 reads coeffs from restart file, bcasts them
------------------------------------------------------------------------- */
void BondBPMRotational::read_restart(FILE *fp)
{
allocate();
if (comm->me == 0) {
utils::sfread(FLERR, &Kr[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &Ks[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &Kt[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &Kb[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &Fcr[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &Fcs[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &Tct[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &Tcb[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &gnorm[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &gslide[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &groll[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &gtwist[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
}
MPI_Bcast(&Kr[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&Ks[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&Kt[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&Kb[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&Fcr[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&Fcs[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&Tct[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&Tcb[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&gnorm[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&gslide[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&groll[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&gtwist[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
for (int i = 1; i <= atom->nbondtypes; i++) setflag[i] = 1;
}
/* ----------------------------------------------------------------------
proc 0 writes to data file
------------------------------------------------------------------------- */
void BondBPMRotational::write_data(FILE *fp)
{
for (int i = 1; i <= atom->nbondtypes; i++)
fprintf(fp, "%d %g %g %g %g %g %g %g %g %g %g %g %g\n", i, Kr[i], Ks[i], Kt[i], Kb[i], Fcr[i],
Fcs[i], Tct[i], Tcb[i], gnorm[i], gslide[i], groll[i], gtwist[i]);
}
/* ---------------------------------------------------------------------- */
double BondBPMRotational::single(int type, double rsq, int i, int j, double &fforce)
{
// Not yet enabled
if (type <= 0) return 0.0;
int itmp;
if (atom->tag[j] < atom->tag[i]) {
itmp = i;
i = j;
j = itmp;
}
double r0_mag, r_mag, r_mag_inv;
double r0[3], r[3], rhat[3];
for (int n = 0; n < atom->num_bond[i]; n++) {
if (atom->bond_atom[i][n] == atom->tag[j]) {
r0_mag = fix_bond_history->get_atom_value(i, n, 0);
r0[0] = fix_bond_history->get_atom_value(i, n, 1);
r0[1] = fix_bond_history->get_atom_value(i, n, 2);
r0[2] = fix_bond_history->get_atom_value(i, n, 3);
}
}
double **x = atom->x;
MathExtra::scale3(r0_mag, r0);
MathExtra::sub3(x[i], x[j], r);
r_mag = sqrt(rsq);
r_mag_inv = 1.0 / r_mag;
MathExtra::scale3(r_mag_inv, r, rhat);
double breaking, smooth, Fr;
double force1on2[3], torque1on2[3], torque2on1[3];
breaking = elastic_forces(i, j, type, Fr, r_mag, r0_mag, r_mag_inv, rhat, r, r0, force1on2,
torque1on2, torque2on1);
fforce = Fr;
damping_forces(i, j, type, Fr, rhat, r, force1on2, torque1on2, torque2on1);
fforce += Fr;
if (smooth_flag) {
smooth = breaking * breaking;
smooth = 1.0 - smooth * smooth;
fforce *= smooth;
}
return 0.0;
}

View File

@ -0,0 +1,83 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef BOND_CLASS
// clang-format off
BondStyle(bpm/rotational,BondBPMRotational);
// clang-format on
#else
#ifndef LMP_BOND_BPM_ROTATIONAL_H
#define LMP_BOND_BPM_ROTATIONAL_H
#include "bond_bpm.h"
namespace LAMMPS_NS {
class BondBPMRotational : public BondBPM {
public:
BondBPMRotational(class LAMMPS *);
~BondBPMRotational() override;
void compute(int, int) override;
void coeff(int, char **) override;
void init_style() override;
void settings(int, char **) override;
void write_restart(FILE *) override;
void read_restart(FILE *) override;
void write_data(FILE *) override;
double single(int, double, int, int, double &) override;
protected:
double *Kr, *Ks, *Kt, *Kb, *gnorm, *gslide, *groll, *gtwist;
double *Fcr, *Fcs, *Tct, *Tcb;
int smooth_flag;
double acos_limit(double);
double elastic_forces(int, int, int, double &, double, double, double, double *, double *,
double *, double *, double *, double *);
void damping_forces(int, int, int, double &, double *, double *, double *, double *, double *);
void allocate();
void store_data();
double store_bond(int, int, int);
};
} // namespace LAMMPS_NS
#endif
#endif
/* ERROR/WARNING messages:
E: Atom missing in BPM bond
Bonded atom cannot be found
E: Incorrect args for bond coefficients
Self-explanatory. Check the input script or data file.
E: Bond bpm/rotational requires atom style bpm/sphere
Self-explanatory.
E: Bond style bpm requires 1-3 and 1-4 special weights of 1.0
Self-explanatory.
W: Bond style bpm/rotational not intended for 2d use, may be inefficient
This bond style will perform a lot of unnecessary calculations in 2d
*/

380
src/BPM/bond_bpm_spring.cpp Normal file
View File

@ -0,0 +1,380 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "bond_bpm_spring.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "fix_bond_history.h"
#include "force.h"
#include "memory.h"
#include "modify.h"
#include "neighbor.h"
#define EPSILON 1e-10
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
BondBPMSpring::BondBPMSpring(LAMMPS *_lmp) : BondBPM(_lmp), k(nullptr), ecrit(nullptr), gamma(nullptr)
{
partial_flag = 1;
smooth_flag = 1;
}
/* ---------------------------------------------------------------------- */
BondBPMSpring::~BondBPMSpring()
{
if (allocated) {
memory->destroy(setflag);
memory->destroy(k);
memory->destroy(ecrit);
memory->destroy(gamma);
}
}
/* ----------------------------------------------------------------------
Store data for a single bond - if bond added after LAMMPS init (e.g. pour)
------------------------------------------------------------------------- */
double BondBPMSpring::store_bond(int n, int i, int j)
{
double delx, dely, delz, r;
double **x = atom->x;
double **bondstore = fix_bond_history->bondstore;
tagint *tag = atom->tag;
delx = x[i][0] - x[j][0];
dely = x[i][1] - x[j][1];
delz = x[i][2] - x[j][2];
r = sqrt(delx * delx + dely * dely + delz * delz);
bondstore[n][0] = r;
if (i < atom->nlocal) {
for (int m = 0; m < atom->num_bond[i]; m++) {
if (atom->bond_atom[i][m] == tag[j]) { fix_bond_history->update_atom_value(i, m, 0, r); }
}
}
if (j < atom->nlocal) {
for (int m = 0; m < atom->num_bond[j]; m++) {
if (atom->bond_atom[j][m] == tag[i]) { fix_bond_history->update_atom_value(j, m, 0, r); }
}
}
return r;
}
/* ----------------------------------------------------------------------
Store data for all bonds called once
------------------------------------------------------------------------- */
void BondBPMSpring::store_data()
{
int i, j, m, type;
double delx, dely, delz, r;
double **x = atom->x;
int **bond_type = atom->bond_type;
for (i = 0; i < atom->nlocal; i++) {
for (m = 0; m < atom->num_bond[i]; m++) {
type = bond_type[i][m];
//Skip if bond was turned off
if (type < 0) continue;
// map to find index n
j = atom->map(atom->bond_atom[i][m]);
if (j == -1) error->one(FLERR, "Atom missing in BPM bond");
delx = x[i][0] - x[j][0];
dely = x[i][1] - x[j][1];
delz = x[i][2] - x[j][2];
// Get closest image in case bonded with ghost
domain->minimum_image(delx, dely, delz);
r = sqrt(delx * delx + dely * dely + delz * delz);
fix_bond_history->update_atom_value(i, m, 0, r);
}
}
fix_bond_history->post_neighbor();
}
/* ---------------------------------------------------------------------- */
void BondBPMSpring::compute(int eflag, int vflag)
{
if (!fix_bond_history->stored_flag) {
fix_bond_history->stored_flag = true;
store_data();
}
int i1, i2, itmp, n, type;
double delx, dely, delz, delvx, delvy, delvz;
double e, rsq, r, r0, rinv, smooth, fbond, dot;
ev_init(eflag, vflag);
double **x = atom->x;
double **v = atom->v;
double **f = atom->f;
tagint *tag = atom->tag;
int **bondlist = neighbor->bondlist;
int nbondlist = neighbor->nbondlist;
int nlocal = atom->nlocal;
int newton_bond = force->newton_bond;
double **bondstore = fix_bond_history->bondstore;
for (n = 0; n < nbondlist; n++) {
// skip bond if already broken
if (bondlist[n][2] <= 0) continue;
i1 = bondlist[n][0];
i2 = bondlist[n][1];
type = bondlist[n][2];
r0 = bondstore[n][0];
// Ensure pair is always ordered to ensure numerical operations
// are identical to minimize the possibility that a bond straddling
// an mpi grid (newton off) doesn't break on one proc but not the other
if (tag[i2] < tag[i1]) {
itmp = i1;
i1 = i2;
i2 = itmp;
}
// If bond hasn't been set - should be initialized to zero
if (r0 < EPSILON || std::isnan(r0)) r0 = store_bond(n, i1, i2);
delx = x[i1][0] - x[i2][0];
dely = x[i1][1] - x[i2][1];
delz = x[i1][2] - x[i2][2];
rsq = delx * delx + dely * dely + delz * delz;
r = sqrt(rsq);
e = (r - r0) / r0;
if (fabs(e) > ecrit[type]) {
bondlist[n][2] = 0;
process_broken(i1, i2);
continue;
}
rinv = 1.0 / r;
fbond = k[type] * (r0 - r);
delvx = v[i1][0] - v[i2][0];
delvy = v[i1][1] - v[i2][1];
delvz = v[i1][2] - v[i2][2];
dot = delx * delvx + dely * delvy + delz * delvz;
fbond -= gamma[type] * dot * rinv;
fbond *= rinv;
if (smooth_flag) {
smooth = (r - r0) / (r0 * ecrit[type]);
smooth *= smooth;
smooth *= smooth;
smooth *= smooth;
smooth = 1 - smooth;
fbond *= smooth;
}
if (newton_bond || i1 < nlocal) {
f[i1][0] += delx * fbond;
f[i1][1] += dely * fbond;
f[i1][2] += delz * fbond;
}
if (newton_bond || i2 < nlocal) {
f[i2][0] -= delx * fbond;
f[i2][1] -= dely * fbond;
f[i2][2] -= delz * fbond;
}
if (evflag) ev_tally(i1, i2, nlocal, newton_bond, 0.0, fbond, delx, dely, delz);
}
}
/* ---------------------------------------------------------------------- */
void BondBPMSpring::allocate()
{
allocated = 1;
const int np1 = atom->nbondtypes + 1;
memory->create(k, np1, "bond:k");
memory->create(ecrit, np1, "bond:ecrit");
memory->create(gamma, np1, "bond:gamma");
memory->create(setflag, np1, "bond:setflag");
for (int i = 1; i < np1; i++) setflag[i] = 0;
}
/* ----------------------------------------------------------------------
set coeffs for one or more types
------------------------------------------------------------------------- */
void BondBPMSpring::coeff(int narg, char **arg)
{
if (narg != 4) error->all(FLERR, "Incorrect args for bond coefficients");
if (!allocated) allocate();
int ilo, ihi;
utils::bounds(FLERR, arg[0], 1, atom->nbondtypes, ilo, ihi, error);
double k_one = utils::numeric(FLERR, arg[1], false, lmp);
double ecrit_one = utils::numeric(FLERR, arg[2], false, lmp);
double gamma_one = utils::numeric(FLERR, arg[3], false, lmp);
int count = 0;
for (int i = ilo; i <= ihi; i++) {
k[i] = k_one;
ecrit[i] = ecrit_one;
gamma[i] = gamma_one;
setflag[i] = 1;
count++;
if (1.0 + ecrit[i] > max_stretch) max_stretch = 1.0 + ecrit[i];
}
if (count == 0) error->all(FLERR, "Incorrect args for bond coefficients");
}
/* ----------------------------------------------------------------------
check for correct settings and create fix
------------------------------------------------------------------------- */
void BondBPMSpring::init_style()
{
BondBPM::init_style();
if (comm->ghost_velocity == 0)
error->all(FLERR, "Bond bpm/spring requires ghost atoms store velocity");
if (!id_fix_bond_history) {
id_fix_bond_history = utils::strdup("HISTORY_BPM_SPRING");
fix_bond_history = dynamic_cast<FixBondHistory *>(modify->replace_fix(
id_fix_dummy2, fmt::format("{} all BOND_HISTORY 0 1", id_fix_bond_history), 1));
delete[] id_fix_dummy2;
id_fix_dummy2 = nullptr;
}
}
/* ---------------------------------------------------------------------- */
void BondBPMSpring::settings(int narg, char **arg)
{
BondBPM::settings(narg, arg);
int iarg;
for (std::size_t i = 0; i < leftover_iarg.size(); i++) {
iarg = leftover_iarg[i];
if (strcmp(arg[iarg], "smooth") == 0) {
if (iarg + 1 > narg) error->all(FLERR, "Illegal bond bpm command");
smooth_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
i += 1;
} else {
error->all(FLERR, "Illegal bond_style command");
}
}
}
/* ----------------------------------------------------------------------
proc 0 writes out coeffs to restart file
------------------------------------------------------------------------- */
void BondBPMSpring::write_restart(FILE *fp)
{
fwrite(&k[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&ecrit[1], sizeof(double), atom->nbondtypes, fp);
fwrite(&gamma[1], sizeof(double), atom->nbondtypes, fp);
}
/* ----------------------------------------------------------------------
proc 0 reads coeffs from restart file, bcasts them
------------------------------------------------------------------------- */
void BondBPMSpring::read_restart(FILE *fp)
{
allocate();
if (comm->me == 0) {
utils::sfread(FLERR, &k[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &ecrit[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
utils::sfread(FLERR, &gamma[1], sizeof(double), atom->nbondtypes, fp, nullptr, error);
}
MPI_Bcast(&k[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&ecrit[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
MPI_Bcast(&gamma[1], atom->nbondtypes, MPI_DOUBLE, 0, world);
for (int i = 1; i <= atom->nbondtypes; i++) setflag[i] = 1;
}
/* ----------------------------------------------------------------------
proc 0 writes to data file
------------------------------------------------------------------------- */
void BondBPMSpring::write_data(FILE *fp)
{
for (int i = 1; i <= atom->nbondtypes; i++)
fprintf(fp, "%d %g %g %g\n", i, k[i], ecrit[i], gamma[i]);
}
/* ---------------------------------------------------------------------- */
double BondBPMSpring::single(int type, double rsq, int i, int j, double &fforce)
{
if (type <= 0) return 0.0;
double r0;
for (int n = 0; n < atom->num_bond[i]; n++) {
if (atom->bond_atom[i][n] == atom->tag[j]) r0 = fix_bond_history->get_atom_value(i, n, 0);
}
double r = sqrt(rsq);
double rinv = 1.0 / r;
fforce = k[type] * (r0 - r);
double **x = atom->x;
double **v = atom->v;
double delx = x[i][0] - x[j][0];
double dely = x[i][1] - x[j][1];
double delz = x[i][2] - x[j][2];
double delvx = v[i][0] - v[j][0];
double delvy = v[i][1] - v[j][1];
double delvz = v[i][2] - v[j][2];
double dot = delx * delvx + dely * delvy + delz * delvz;
fforce -= gamma[type] * dot * rinv;
fforce *= rinv;
if (smooth_flag) {
double smooth = (r - r0) / (r0 * ecrit[type]);
smooth *= smooth;
smooth *= smooth;
smooth *= smooth;
smooth = 1 - smooth;
fforce *= smooth;
}
return 0.0;
}

68
src/BPM/bond_bpm_spring.h Normal file
View File

@ -0,0 +1,68 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef BOND_CLASS
// clang-format off
BondStyle(bpm/spring,BondBPMSpring);
// clang-format on
#else
#ifndef LMP_BOND_BPM_SPRING_H
#define LMP_BOND_BPM_SPRING_H
#include "bond_bpm.h"
namespace LAMMPS_NS {
class BondBPMSpring : public BondBPM {
public:
BondBPMSpring(class LAMMPS *);
~BondBPMSpring() override;
void compute(int, int) override;
void coeff(int, char **) override;
void init_style() override;
void settings(int, char **) override;
void write_restart(FILE *) override;
void read_restart(FILE *) override;
void write_data(FILE *) override;
double single(int, double, int, int, double &) override;
protected:
double *k, *ecrit, *gamma;
int smooth_flag;
void allocate();
void store_data();
double store_bond(int, int, int);
};
} // namespace LAMMPS_NS
#endif
#endif
/* ERROR/WARNING messages:
E: Atom missing in BPM bond
Bonded atom cannot be found
E: Incorrect args for bond coefficients
Self-explanatory. Check the input script or data file.
E: Bond style bpm requires 1-3 and 1-4 special weights of 1.0
Self-explanatory.
*/

View File

@ -0,0 +1,145 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "compute_nbond_atom.h"
#include "atom.h"
#include "comm.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "update.h"
#include <string.h>
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeNBondAtom::ComputeNBondAtom(LAMMPS *_lmp, int narg, char **arg) :
Compute(_lmp, narg, arg), nbond(nullptr)
{
if (narg < 3) error->all(FLERR, "Illegal compute nbond/atom command");
peratom_flag = 1;
size_peratom_cols = 0;
peatomflag = 1;
timeflag = 1;
comm_reverse = 1;
nmax = 0;
}
/* ---------------------------------------------------------------------- */
ComputeNBondAtom::~ComputeNBondAtom()
{
memory->destroy(nbond);
}
/* ---------------------------------------------------------------------- */
void ComputeNBondAtom::compute_peratom()
{
invoked_peratom = update->ntimestep;
if (update->eflag_atom != invoked_peratom)
error->all(FLERR, "Per-atom nbond was not tallied on needed timestep");
// grow local nbond array if necessary
// needs to be atom->nmax in length
if (atom->nmax > nmax) {
memory->destroy(nbond);
nmax = atom->nmax;
memory->create(nbond, nmax, "nbond/atom:nbond");
vector_atom = nbond;
}
// npair includes ghosts if either newton flag is set
// b/c some bonds/dihedrals call pair::ev_tally with pairwise info
// nbond includes ghosts if newton_bond is set
// ntotal includes ghosts if either newton flag is set
// KSpace includes ghosts if tip4pflag is set
int nlocal = atom->nlocal;
tagint **bond_atom = atom->bond_atom;
int **bond_type = atom->bond_type;
int ntotal = nlocal;
if (force->newton) ntotal += atom->nghost;
// set local nbond array
int i, j, k;
int *num_bond = atom->num_bond;
int newton_bond = force->newton_bond;
for (i = 0; i < ntotal; i++) nbond[i] = 0;
for (i = 0; i < nlocal; i++) {
for (j = 0; j < num_bond[i]; j++) {
if (bond_type[i][j] <= 0) continue;
k = atom->map(bond_atom[i][j]);
if (k < 0) continue;
nbond[i] += 1;
if (newton_bond) nbond[k] += 1;
}
}
// communicate ghost nbond between neighbor procs
if (force->newton) comm->reverse_comm(this);
// zero nbond of atoms not in group
// only do this after comm since ghost contributions must be included
int *mask = atom->mask;
for (i = 0; i < nlocal; i++)
if (!(mask[i] & groupbit)) nbond[i] = 0.0;
}
/* ---------------------------------------------------------------------- */
int ComputeNBondAtom::pack_reverse_comm(int n, int first, double *buf)
{
int i, m, last;
m = 0;
last = first + n;
for (i = first; i < last; i++) buf[m++] = nbond[i];
return m;
}
/* ---------------------------------------------------------------------- */
void ComputeNBondAtom::unpack_reverse_comm(int n, int *list, double *buf)
{
int i, j, m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
nbond[j] += buf[m++];
}
}
/* ----------------------------------------------------------------------
memory usage of local atom-based array
------------------------------------------------------------------------- */
double ComputeNBondAtom::memory_usage()
{
double bytes = nmax * sizeof(double);
return bytes;
}

View File

@ -0,0 +1,61 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef COMPUTE_CLASS
// clang-format off
ComputeStyle(nbond/atom,ComputeNBondAtom);
// clang-format on
#else
#ifndef LMP_COMPUTE_NBOND_ATOM_H
#define LMP_COMPUTE_NBOND_ATOM_H
#include "compute.h"
namespace LAMMPS_NS {
class ComputeNBondAtom : public Compute {
public:
ComputeNBondAtom(class LAMMPS *, int, char **);
~ComputeNBondAtom() override;
void init() override {}
void compute_peratom() override;
int pack_reverse_comm(int, int, double *) override;
void unpack_reverse_comm(int, int *, double *) override;
double memory_usage() override;
private:
int nmax;
double *nbond;
};
} // namespace LAMMPS_NS
#endif
#endif
/* ERROR/WARNING messages:
E: Illegal ... command
Self-explanatory. Check the input script syntax and compare to the
documentation for the command. You can use -echo screen as a
command-line option when running LAMMPS to see the offending line.
E: Per-atom energy was not tallied on needed timestep
You are using a thermo keyword that requires potentials to
have tallied energy, but they didn't on this timestep. See the
variable doc page for ideas on how to make this work.
*/

View File

@ -0,0 +1,157 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "fix_nve_bpm_sphere.h"
#include "atom.h"
#include "atom_vec.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "math_extra.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
using namespace MathExtra;
/* ---------------------------------------------------------------------- */
FixNVEBPMSphere::FixNVEBPMSphere(LAMMPS *_lmp, int narg, char **arg) : FixNVE(_lmp, narg, arg)
{
if (narg < 3) error->all(FLERR, "Illegal fix nve/bpm/sphere command");
time_integrate = 1;
// process extra keywords
// inertia = moment of inertia prefactor for sphere or disc
inertia = 0.4;
int iarg = 3;
while (iarg < narg) {
if (strcmp(arg[iarg], "disc") == 0) {
inertia = 0.5;
if (domain->dimension != 2)
error->all(FLERR, "Fix nve/bpm/sphere disc requires 2d simulation");
iarg++;
} else
error->all(FLERR, "Illegal fix nve/bpm/sphere command");
}
inv_inertia = 1.0 / inertia;
// error checks
if (!atom->quat_flag || !atom->sphere_flag)
error->all(FLERR, "Fix nve/bpm/sphere requires atom style bpm/sphere");
}
/* ---------------------------------------------------------------------- */
void FixNVEBPMSphere::init()
{
FixNVE::init();
// check that all particles are finite-size spheres
// no point particles allowed
double *radius = atom->radius;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit)
if (radius[i] == 0.0) error->one(FLERR, "Fix nve/bpm/sphere requires extended particles");
}
/* ---------------------------------------------------------------------- */
void FixNVEBPMSphere::initial_integrate(int /*vflag*/)
{
double dtq, dtfm, dtirotate, particle_inertia;
double **x = atom->x;
double **v = atom->v;
double **f = atom->f;
double **omega = atom->omega;
double **torque = atom->torque;
double **quat = atom->quat;
double *radius = atom->radius;
double *rmass = atom->rmass;
int *mask = atom->mask;
int nlocal = atom->nlocal;
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
// set timestep here since dt may have changed or come via rRESPA
dtq = 0.5 * dtv;
// update v,x,omega,quat for all particles
// d_omega/dt = torque / inertia
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];
x[i][0] += dtv * v[i][0];
x[i][1] += dtv * v[i][1];
x[i][2] += dtv * v[i][2];
particle_inertia = inertia * (radius[i] * radius[i] * rmass[i]);
dtirotate = dtf / particle_inertia;
omega[i][0] += dtirotate * torque[i][0];
omega[i][1] += dtirotate * torque[i][1];
omega[i][2] += dtirotate * torque[i][2];
MathExtra::richardson_sphere(quat[i], omega[i], dtq);
}
}
}
/* ---------------------------------------------------------------------- */
void FixNVEBPMSphere::final_integrate()
{
double dtfm, dtirotate, particle_inertia;
double **v = atom->v;
double **f = atom->f;
double **omega = atom->omega;
double **torque = atom->torque;
double *rmass = atom->rmass;
double *radius = atom->radius;
int *mask = atom->mask;
int nlocal = atom->nlocal;
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
// update v,omega for all particles
// d_omega/dt = torque / inertia
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];
particle_inertia = inertia * (radius[i] * radius[i] * rmass[i]);
dtirotate = dtf / particle_inertia;
omega[i][0] += dtirotate * torque[i][0];
omega[i][1] += dtirotate * torque[i][1];
omega[i][2] += dtirotate * torque[i][2];
}
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,50 +12,33 @@
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(propel/self,FixPropelSelf)
// clang-format off
FixStyle(nve/bpm/sphere,FixNVEBPMSphere);
// clang-format on
#else
#ifndef LMP_FIX_PROPEL_SELF_H
#define LMP_FIX_PROPEL_SELF_H
#ifndef LMP_FIX_NVE_BPM_SPHERE_H
#define LMP_FIX_NVE_BPM_SPHERE_H
#include "fix.h"
#include "fix_nve.h"
namespace LAMMPS_NS {
class FixPropelSelf : public Fix {
class FixNVEBPMSphere : public FixNVE {
public:
FixNVEBPMSphere(class LAMMPS *, int, char **);
FixPropelSelf(class LAMMPS *, int, char **);
virtual ~FixPropelSelf();
virtual int setmask();
virtual void post_force(int);
double memory_usage();
void init() override;
void initial_integrate(int) override;
void final_integrate() override;
protected:
enum operation_modes {
VELOCITY = 0,
QUATERNION = 1
};
private:
double magnitude;
int mode;
// If 0, apply fix to everything in group. If > 0, apply only to those
// types i for which i <= n_types_filter _and_ apply_to_type[i] == 1:
int n_types_filter;
int *apply_to_type; //< Specifies, per type, if the fix applies to it or not.
int atoms_have_quaternion();
template <int filter_by_type> void post_force_velocity(int);
template <int filter_by_type> void post_force_quaternion(int);
double inertia, inv_inertia;
int extra;
int dlm;
};
}
} // namespace LAMMPS_NS
#endif
#endif
@ -68,4 +51,21 @@ Self-explanatory. Check the input script syntax and compare to the
documentation for the command. You can use -echo screen as a
command-line option when running LAMMPS to see the offending line.
E: Fix nve/bpm/sphere disc requires 2d simulation
UNDOCUMENTED
E: Fix nve/bpm/sphere requires atom style bpm/sphere
Self-explanatory.
E: Fix nve/bpm/sphere update dipole requires atom attribute mu
An atom style with this attribute is needed.
E: Fix nve/bpm/sphere requires extended particles
This fix can only be used for particles of a finite size.
*/

326
src/BPM/pair_bpm_spring.cpp Normal file
View File

@ -0,0 +1,326 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "pair_bpm_spring.h"
#include "atom.h"
#include "comm.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "neigh_list.h"
#include "neighbor.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
PairBPMSpring::PairBPMSpring(LAMMPS *_lmp) : Pair(_lmp)
{
writedata = 1;
}
/* ---------------------------------------------------------------------- */
PairBPMSpring::~PairBPMSpring()
{
if (allocated) {
memory->destroy(setflag);
memory->destroy(cutsq);
memory->destroy(k);
memory->destroy(cut);
memory->destroy(gamma);
}
}
/* ---------------------------------------------------------------------- */
void PairBPMSpring::compute(int eflag, int vflag)
{
int i, j, ii, jj, inum, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz, evdwl, fpair;
double r, rsq, rinv, factor_lj;
int *ilist, *jlist, *numneigh, **firstneigh;
double vxtmp, vytmp, vztmp, delvx, delvy, delvz, dot, smooth;
evdwl = 0.0;
if (eflag || vflag)
ev_setup(eflag, vflag);
else
evflag = vflag_fdotr = 0;
double **x = atom->x;
double **v = atom->v;
double **f = atom->f;
int *type = atom->type;
int nlocal = atom->nlocal;
int newton_pair = force->newton_pair;
double *special_lj = force->special_lj;
inum = list->inum;
ilist = list->ilist;
numneigh = list->numneigh;
firstneigh = list->firstneigh;
// 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];
vxtmp = v[i][0];
vytmp = v[i][1];
vztmp = v[i][2];
itype = type[i];
jlist = firstneigh[i];
jnum = numneigh[i];
for (jj = 0; jj < jnum; jj++) {
j = jlist[jj];
factor_lj = special_lj[sbmask(j)];
if (factor_lj == 0) continue;
j &= NEIGHMASK;
delx = xtmp - x[j][0];
dely = ytmp - x[j][1];
delz = ztmp - x[j][2];
rsq = delx * delx + dely * dely + delz * delz;
jtype = type[j];
if (rsq < cutsq[itype][jtype]) {
r = sqrt(rsq);
rinv = 1.0 / r;
fpair = k[itype][jtype] * (cut[itype][jtype] - r);
smooth = rsq / cutsq[itype][jtype];
smooth *= smooth;
smooth *= smooth;
smooth = 1.0 - smooth;
delvx = vxtmp - v[j][0];
delvy = vytmp - v[j][1];
delvz = vztmp - v[j][2];
dot = delx * delvx + dely * delvy + delz * delvz;
fpair -= gamma[itype][jtype] * dot * smooth * rinv;
fpair *= factor_lj * rinv;
if (eflag) evdwl = 0.0;
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 (evflag) ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, delx, dely, delz);
}
}
}
if (vflag_fdotr) virial_fdotr_compute();
}
/* ----------------------------------------------------------------------
allocate all arrays
------------------------------------------------------------------------- */
void PairBPMSpring::allocate()
{
allocated = 1;
const int np1 = atom->ntypes + 1;
memory->create(setflag, np1, np1, "pair:setflag");
for (int i = 1; i < np1; i++)
for (int j = i; j < np1; j++) setflag[i][j] = 0;
memory->create(cutsq, np1, np1, "pair:cutsq");
memory->create(k, np1, np1, "pair:k");
memory->create(cut, np1, np1, "pair:cut");
memory->create(gamma, np1, np1, "pair:gamma");
}
/* ----------------------------------------------------------------------
global settings
------------------------------------------------------------------------- */
void PairBPMSpring::settings(int narg, char ** /*arg*/)
{
if (narg != 0) error->all(FLERR, "Illegal pair_style command");
}
/* ----------------------------------------------------------------------
set coeffs for one or more type pairs
------------------------------------------------------------------------- */
void PairBPMSpring::coeff(int narg, char **arg)
{
if (narg != 5) error->all(FLERR, "Incorrect args for pair coefficients");
if (!allocated) allocate();
int ilo, ihi, jlo, jhi;
utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error);
utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error);
double k_one = utils::numeric(FLERR, arg[2], false, lmp);
double cut_one = utils::numeric(FLERR, arg[3], false, lmp);
double gamma_one = utils::numeric(FLERR, arg[4], false, lmp);
if (cut_one <= 0.0) error->all(FLERR, "Incorrect args for pair coefficients");
int count = 0;
for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo, i); j <= jhi; j++) {
k[i][j] = k_one;
cut[i][j] = cut_one;
gamma[i][j] = gamma_one;
setflag[i][j] = 1;
count++;
}
}
if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
}
/* ----------------------------------------------------------------------
init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */
double PairBPMSpring::init_one(int i, int j)
{
if (setflag[i][j] == 0) {
cut[i][j] = mix_distance(cut[i][i], cut[j][j]);
k[i][j] = mix_energy(k[i][i], k[j][j], cut[i][i], cut[j][j]);
gamma[i][j] = mix_energy(gamma[i][i], gamma[j][j], cut[i][i], cut[j][j]);
}
cut[j][i] = cut[i][j];
k[j][i] = k[i][j];
gamma[j][i] = gamma[i][j];
return cut[i][j];
}
/* ----------------------------------------------------------------------
proc 0 writes to restart file
------------------------------------------------------------------------- */
void PairBPMSpring::write_restart(FILE *fp)
{
write_restart_settings(fp);
int i, j;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) {
fwrite(&setflag[i][j], sizeof(int), 1, fp);
if (setflag[i][j]) {
fwrite(&k[i][j], sizeof(double), 1, fp);
fwrite(&cut[i][j], sizeof(double), 1, fp);
fwrite(&gamma[i][j], sizeof(double), 1, fp);
}
}
}
/* ----------------------------------------------------------------------
proc 0 reads from restart file, bcasts
------------------------------------------------------------------------- */
void PairBPMSpring::read_restart(FILE *fp)
{
read_restart_settings(fp);
allocate();
int i, j;
int me = comm->me;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) {
if (me == 0) utils::sfread(FLERR, &setflag[i][j], sizeof(int), 1, fp, nullptr, error);
MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world);
if (setflag[i][j]) {
if (me == 0) {
utils::sfread(FLERR, &k[i][j], sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR, &cut[i][j], sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR, &gamma[i][j], sizeof(double), 1, fp, nullptr, error);
}
MPI_Bcast(&k[i][j], 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&gamma[i][j], 1, MPI_DOUBLE, 0, world);
}
}
}
/* ----------------------------------------------------------------------
proc 0 writes to data file
------------------------------------------------------------------------- */
void PairBPMSpring::write_data(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
fprintf(fp, "%d %g %g %g\n", i, k[i][i], cut[i][i], gamma[i][i]);
}
/* ----------------------------------------------------------------------
proc 0 writes all pairs to data file
------------------------------------------------------------------------- */
void PairBPMSpring::write_data_all(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++)
fprintf(fp, "%d %d %g %g %g\n", i, j, k[i][j], cut[i][j], gamma[i][j]);
}
/* ---------------------------------------------------------------------- */
double PairBPMSpring::single(int i, int j, int itype, int jtype, double rsq, double /*factor_coul*/,
double factor_lj, double &fforce)
{
double fpair, r, rinv;
double delx, dely, delz, delvx, delvy, delvz, dot, smooth;
if (rsq > cutsq[itype][jtype]) return 0.0;
double **x = atom->x;
double **v = atom->v;
r = sqrt(rsq);
rinv = 1.0 / r;
fpair = k[itype][jtype] * (cut[itype][jtype] - r);
smooth = rsq / cutsq[itype][jtype];
smooth *= smooth;
smooth = 1.0 - smooth;
delx = x[i][0] - x[j][0];
dely = x[i][1] - x[j][1];
delz = x[i][2] - x[j][2];
delvx = v[i][0] - v[j][0];
delvy = v[i][1] - v[j][1];
delvz = v[i][2] - v[j][2];
dot = delx * delvx + dely * delvy + delz * delvz;
fpair -= gamma[itype][jtype] * dot * rinv * smooth;
fpair *= factor_lj;
fforce = fpair;
return 0.0;
}

64
src/BPM/pair_bpm_spring.h Normal file
View File

@ -0,0 +1,64 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
// clang-format off
PairStyle(bpm/spring,PairBPMSpring);
// clang-format on
#else
#ifndef LMP_PAIR_BPM_SPRING_H
#define LMP_PAIR_BPM_SPRING_H
#include "pair.h"
namespace LAMMPS_NS {
class PairBPMSpring : public Pair {
public:
PairBPMSpring(class LAMMPS *);
~PairBPMSpring() override;
void compute(int, int) override;
void settings(int, char **) override;
void coeff(int, char **) override;
double init_one(int, int) override;
void write_restart(FILE *) override;
void read_restart(FILE *) override;
void write_data(FILE *) override;
void write_data_all(FILE *) override;
double single(int, int, int, int, double, double, double, double &) override;
protected:
double **k, **cut, **gamma;
void allocate();
};
} // namespace LAMMPS_NS
#endif
#endif
/* ERROR/WARNING messages:
E: Illegal ... command
Self-explanatory. Check the input script syntax and compare to the
documentation for the command. You can use -echo screen as a
command-line option when running LAMMPS to see the offending line.
E: Incorrect args for pair coefficients
Self-explanatory. Check the input script or data file.
*/

Some files were not shown because too many files have changed in this diff Show More