updated create_atoms.h/cpp with accumulated changes
This commit is contained in:
32
src/.clang-format
Normal file
32
src/.clang-format
Normal 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
|
||||
...
|
||||
452
src/.gitignore
vendored
452
src/.gitignore
vendored
@ -5,7 +5,9 @@
|
||||
/lmp_*
|
||||
|
||||
/style_*.h
|
||||
/packages_*.h
|
||||
/lmpinstalledpkgs.h
|
||||
/lmpgitversion.h
|
||||
|
||||
/*_gpu.h
|
||||
/*_gpu.cpp
|
||||
@ -25,11 +27,44 @@
|
||||
/*_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
|
||||
/kokkos.h
|
||||
/kokkos_type.h
|
||||
/kokkos_few.h
|
||||
/kokkos_base.h
|
||||
/kokkos_base_fft.h
|
||||
|
||||
/manifold*.cpp
|
||||
/manifold*.h
|
||||
@ -38,8 +73,16 @@
|
||||
|
||||
/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
|
||||
|
||||
/ptm_*.cpp
|
||||
/ptm_*.h
|
||||
@ -49,6 +92,17 @@
|
||||
/fix_qeq*.cpp
|
||||
/fix_qeq*.h
|
||||
|
||||
/fix_*cauchy.cpp
|
||||
/fix_*cauchy.h
|
||||
|
||||
/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
|
||||
@ -74,6 +128,15 @@
|
||||
/intel_preprocess.h
|
||||
/intel_simd.h
|
||||
|
||||
/atom_vec_sph.cpp
|
||||
/atom_vec_sph.h
|
||||
/compute_sph_*.cpp
|
||||
/compute_sph_*.h
|
||||
/fix_sph.cpp
|
||||
/fix_sph.h
|
||||
/fix_sph_stationary.cpp
|
||||
/fix_sph_stationary.h
|
||||
|
||||
/atom_vec_edpd.cpp
|
||||
/atom_vec_edpd.h
|
||||
/atom_vec_mdpd.cpp
|
||||
@ -109,6 +172,8 @@
|
||||
/compute_snad_atom.h
|
||||
/compute_snav_atom.cpp
|
||||
/compute_snav_atom.h
|
||||
/compute_snap.cpp
|
||||
/compute_snap.h
|
||||
/openmp_snap.h
|
||||
/pair_snap.cpp
|
||||
/pair_snap.h
|
||||
@ -138,27 +203,116 @@
|
||||
/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
|
||||
/compute_spin.h
|
||||
/fix_langevin_spin.cpp
|
||||
/fix_langevin_spin.h
|
||||
/fix_neb_spin.cpp
|
||||
/fix_neb_spin.h
|
||||
/fix_nve_spin.cpp
|
||||
/fix_nve_spin.h
|
||||
/fix_precession_spin.cpp
|
||||
/fix_precession_spin.h
|
||||
/fix_setforce_spin.cpp
|
||||
/fix_setforce_spin.h
|
||||
/min_spin.cpp
|
||||
/min_spin.h
|
||||
/min_spin_cg.cpp
|
||||
/min_spin_cg.h
|
||||
/min_spin_lbfgs.cpp
|
||||
/min_spin_lbfgs.h
|
||||
/neb_spin.cpp
|
||||
/neb_spin.h
|
||||
/pair_spin.cpp
|
||||
/pair_spin.h
|
||||
/pair_spin_dmi.cpp
|
||||
/pair_spin_dmi.h
|
||||
/pair_spin_dipole_cut.cpp
|
||||
/pair_spin_dipole_cut.h
|
||||
/pair_spin_dipole_long.cpp
|
||||
/pair_spin_dipole_long.h
|
||||
/pair_spin_exchange.cpp
|
||||
/pair_spin_exchange.h
|
||||
/pair_spin_exchange_biquadratic.cpp
|
||||
/pair_spin_exchange_biquadratic.h
|
||||
/pair_spin_magelec.cpp
|
||||
/pair_spin_magelec.h
|
||||
/pair_spin_neel.cpp
|
||||
/pair_spin_neel.h
|
||||
|
||||
/atom_vec_mesont.cpp
|
||||
/atom_vec_mesont.h
|
||||
/compute_mesont.cpp
|
||||
/compute_mesont.h
|
||||
/export_mesont.h
|
||||
/pair_mesont_tpm.cpp
|
||||
/pair_mesont_tpm.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_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
|
||||
@ -181,14 +335,20 @@
|
||||
/angle_cosine_shift_exp.h
|
||||
/angle_cosine_squared.cpp
|
||||
/angle_cosine_squared.h
|
||||
/angle_cross.cpp
|
||||
/angle_cross.h
|
||||
/angle_dipole.cpp
|
||||
/angle_dipole.h
|
||||
/angle_fourier.cpp
|
||||
/angle_fourier.h
|
||||
/angle_fourier_simple.cpp
|
||||
/angle_fourier_simple.h
|
||||
/angle_gaussian.cpp
|
||||
/angle_gaussian.h
|
||||
/angle_harmonic.cpp
|
||||
/angle_harmonic.h
|
||||
/angle_mm3.cpp
|
||||
/angle_mm3.h
|
||||
/angle_quartic.cpp
|
||||
/angle_quartic.h
|
||||
/angle_sdk.cpp
|
||||
@ -207,18 +367,16 @@
|
||||
/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
|
||||
/atom_vec_full_hars.h
|
||||
/atom_vec_granular.cpp
|
||||
/atom_vec_granular.h
|
||||
/atom_vec_meso.cpp
|
||||
/atom_vec_meso.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
|
||||
@ -235,6 +393,10 @@
|
||||
/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
|
||||
/bond_gromos.h
|
||||
/bond_harmonic.cpp
|
||||
@ -243,6 +405,8 @@
|
||||
/bond_harmonic_shift.h
|
||||
/bond_harmonic_shift_cut.cpp
|
||||
/bond_harmonic_shift_cut.h
|
||||
/bond_mm3.cpp
|
||||
/bond_mm3.h
|
||||
/bond_morse.cpp
|
||||
/bond_morse.h
|
||||
/bond_nonlinear.cpp
|
||||
@ -251,8 +415,12 @@
|
||||
/bond_oxdna_fene.h
|
||||
/bond_oxdna2_fene.cpp
|
||||
/bond_oxdna2_fene.h
|
||||
/bond_oxrna2_fene.cpp
|
||||
/bond_oxrna2_fene.h
|
||||
/bond_quartic.cpp
|
||||
/bond_quartic.h
|
||||
/bond_special.cpp
|
||||
/bond_special.h
|
||||
/bond_table.cpp
|
||||
/bond_table.h
|
||||
/cg_cmm_parms.cpp
|
||||
@ -261,6 +429,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
|
||||
@ -283,12 +453,20 @@
|
||||
/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_force_tally.cpp
|
||||
/compute_force_tally.h
|
||||
/compute_gyration_shape.cpp
|
||||
/compute_gyration_shape.h
|
||||
/compute_gyration_shape_chunk.cpp
|
||||
/compute_gyration_shape_chunk.h
|
||||
/compute_heat_flux_tally.cpp
|
||||
/compute_heat_flux_tally.h
|
||||
/compute_hma.cpp
|
||||
/compute_hma.h
|
||||
/compute_ke_atom_eff.cpp
|
||||
/compute_ke_atom_eff.h
|
||||
/compute_ke_eff.cpp
|
||||
@ -301,6 +479,8 @@
|
||||
/compute_meso_rho_atom.h
|
||||
/compute_meso_t_atom.cpp
|
||||
/compute_meso_t_atom.h
|
||||
/compute_momentum.cpp
|
||||
/compute_momentum.h
|
||||
/compute_msd_nongauss.cpp
|
||||
/compute_msd_nongauss.h
|
||||
/compute_pe_tally.cpp
|
||||
@ -341,6 +521,8 @@
|
||||
/compute_temp_rotate.h
|
||||
/compute_ti.cpp
|
||||
/compute_ti.h
|
||||
/compute_viscosity_cos.cpp
|
||||
/compute_viscosity_cos.h
|
||||
/compute_voronoi_atom.cpp
|
||||
/compute_voronoi_atom.h
|
||||
/dihedral_charmm.cpp
|
||||
@ -355,8 +537,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
|
||||
@ -371,22 +551,34 @@
|
||||
/dihedral_table.h
|
||||
/dihedral_table_cut.cpp
|
||||
/dihedral_table_cut.h
|
||||
/dump_atom_adios.cpp
|
||||
/dump_atom_adios.h
|
||||
/dump_atom_gz.cpp
|
||||
/dump_atom_gz.h
|
||||
/dump_xyz_gz.cpp
|
||||
/dump_xyz_gz.h
|
||||
/dump_atom_zstd.cpp
|
||||
/dump_atom_zstd.h
|
||||
/dump_atom_mpiio.cpp
|
||||
/dump_atom_mpiio.h
|
||||
/dump_cfg_gz.cpp
|
||||
/dump_cfg_gz.h
|
||||
/dump_cfg_mpiio.cpp
|
||||
/dump_cfg_mpiio.h
|
||||
/dump_cfg_zstd.cpp
|
||||
/dump_cfg_zstd.h
|
||||
/dump_custom_adios.cpp
|
||||
/dump_custom_adios.h
|
||||
/dump_custom_gz.cpp
|
||||
/dump_custom_gz.h
|
||||
/dump_custom_mpiio.cpp
|
||||
/dump_custom_mpiio.h
|
||||
/dump_custom_zstd.cpp
|
||||
/dump_custom_zstd.h
|
||||
/dump_h5md.cpp
|
||||
/dump_h5md.h
|
||||
/dump_local_gz.cpp
|
||||
/dump_local_gz.h
|
||||
/dump_local_zstd.cpp
|
||||
/dump_local_zstd.h
|
||||
/dump_netcdf.cpp
|
||||
/dump_netcdf.h
|
||||
/dump_netcdf_mpiio.cpp
|
||||
@ -395,12 +587,22 @@
|
||||
/dump_vtk.h
|
||||
/dump_xtc.cpp
|
||||
/dump_xtc.h
|
||||
/dump_xyz_gz.cpp
|
||||
/dump_xyz_gz.h
|
||||
/dump_xyz_mpiio.cpp
|
||||
/dump_xyz_mpiio.h
|
||||
/dump_xyz_zstd.cpp
|
||||
/dump_xyz_zstd.h
|
||||
/dynamical_matrix.cpp
|
||||
/dynamical_matrix.h
|
||||
/ewald.cpp
|
||||
/ewald.h
|
||||
/ewald_cg.cpp
|
||||
/ewald_cg.h
|
||||
/ewald_dipole.cpp
|
||||
/ewald_dipole.h
|
||||
/ewald_dipole_spin.cpp
|
||||
/ewald_dipole_spin.h
|
||||
/ewald_disp.cpp
|
||||
/ewald_disp.h
|
||||
/ewald_n.cpp
|
||||
@ -409,6 +611,10 @@
|
||||
/fft3d.h
|
||||
/fft3d_wrap.cpp
|
||||
/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
|
||||
@ -425,26 +631,28 @@
|
||||
/fix_bond_break.h
|
||||
/fix_bond_create.cpp
|
||||
/fix_bond_create.h
|
||||
/fix_bond_create_angle.cpp
|
||||
/fix_bond_create_angle.h
|
||||
/fix_bond_react.cpp
|
||||
/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
|
||||
/fix_electron_stopping_fit.h
|
||||
/fix_eos_cv.cpp
|
||||
/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
|
||||
@ -509,6 +717,8 @@
|
||||
/fix_meso_move.h
|
||||
/fix_meso_stationary.cpp
|
||||
/fix_meso_stationary.h
|
||||
/fix_momentum_chunk.cpp
|
||||
/fix_momentum_chunk.h
|
||||
/fix_mscg.cpp
|
||||
/fix_mscg.h
|
||||
/fix_msst.cpp
|
||||
@ -521,6 +731,8 @@
|
||||
/fix_nph_asphere.h
|
||||
/fix_npt_asphere.cpp
|
||||
/fix_npt_asphere.h
|
||||
/fix_npt_cauchy.cpp
|
||||
/fix_npt_cauchy.h
|
||||
/fix_nve_asphere.cpp
|
||||
/fix_nve_asphere.h
|
||||
/fix_nve_asphere_noforce.cpp
|
||||
@ -565,8 +777,12 @@
|
||||
/fix_oneway.h
|
||||
/fix_orient_bcc.cpp
|
||||
/fix_orient_bcc.h
|
||||
/fix_orient_eco.cpp
|
||||
/fix_orient_eco.h
|
||||
/fix_orient_fcc.cpp
|
||||
/fix_orient_fcc.h
|
||||
/fix_pair_tracker.cpp
|
||||
/fix_pair_tracker.h
|
||||
/fix_peri_neigh.cpp
|
||||
/fix_peri_neigh.h
|
||||
/fix_phonon.cpp
|
||||
@ -577,18 +793,18 @@
|
||||
/fix_pour.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
|
||||
@ -630,16 +846,20 @@
|
||||
/fix_spring_pull.h
|
||||
/fix_srd.cpp
|
||||
/fix_srd.h
|
||||
/fix_store_kim.cpp
|
||||
/fix_store_kim.h
|
||||
/fix_temp_rescale_eff.cpp
|
||||
/fix_temp_rescale_eff.h
|
||||
/fix_thermal_conductivity.cpp
|
||||
/fix_thermal_conductivity.h
|
||||
/fix_tgnh_drude.cpp
|
||||
/fix_tgnh_drude.h
|
||||
/fix_tgnpt_drude.cpp
|
||||
/fix_tgnpt_drude.h
|
||||
/fix_tgnvt_drude.cpp
|
||||
/fix_tgnvt_drude.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
|
||||
@ -652,6 +872,8 @@
|
||||
/fix_wall_ees.h
|
||||
/fix_wall_region_ees.cpp
|
||||
/fix_wall_region_ees.h
|
||||
/fix_wall_reflect_stochastic.cpp
|
||||
/fix_wall_reflect_stochastic.h
|
||||
/fix_wall_gran.cpp
|
||||
/fix_wall_gran.h
|
||||
/fix_wall_gran_region.cpp
|
||||
@ -660,11 +882,13 @@
|
||||
/fix_wall_piston.h
|
||||
/fix_wall_srd.cpp
|
||||
/fix_wall_srd.h
|
||||
/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
|
||||
@ -677,18 +901,21 @@
|
||||
/improper_cvff.h
|
||||
/improper_distance.cpp
|
||||
/improper_distance.h
|
||||
/improper_distharm.cpp
|
||||
/improper_distharm.h
|
||||
/improper_sqdistharm.cpp
|
||||
/improper_sqdistharm.h
|
||||
/improper_fourier.cpp
|
||||
/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
|
||||
@ -703,7 +930,6 @@
|
||||
/msm_cg.h
|
||||
/neb.cpp
|
||||
/neb.h
|
||||
|
||||
/pair_adp.cpp
|
||||
/pair_adp.h
|
||||
/pair_agni.cpp
|
||||
@ -760,22 +986,34 @@
|
||||
/pair_comb3.h
|
||||
/pair_colloid.cpp
|
||||
/pair_colloid.h
|
||||
/pair_cosine_squared.cpp
|
||||
/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
|
||||
/pair_coul_msm.h
|
||||
/pair_coul_shield.cpp
|
||||
/pair_coul_shield.h
|
||||
/pair_coul_slater_cut.cpp
|
||||
/pair_coul_slater_cut.h
|
||||
/pair_coul_slater_long.cpp
|
||||
/pair_coul_slater_long.h
|
||||
/pair_coul_tt.cpp
|
||||
/pair_coul_tt.h
|
||||
/pair_dipole_cut.cpp
|
||||
/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
|
||||
/pair_e3b.h
|
||||
/pair_drip.cpp
|
||||
/pair_drip.h
|
||||
/pair_eam.cpp
|
||||
/pair_eam.h
|
||||
/pair_eam_alloy.cpp
|
||||
@ -784,8 +1022,14 @@
|
||||
/pair_eam_cd.h
|
||||
/pair_eam_fs.cpp
|
||||
/pair_eam_fs.h
|
||||
/pair_eam_he.cpp
|
||||
/pair_eam_he.h
|
||||
/pair_lebedeva_z.cpp
|
||||
/pair_lebedeva_z.h
|
||||
/pair_lj_expand_coul_long.cpp
|
||||
/pair_lj_expand_coul_long.h
|
||||
/pair_local_density.cpp
|
||||
/pair_local_density.h
|
||||
/pair_edip.cpp
|
||||
/pair_edip.h
|
||||
/pair_edip_multi.cpp
|
||||
@ -799,6 +1043,8 @@
|
||||
/pair_gauss_cut.h
|
||||
/pair_gayberne.cpp
|
||||
/pair_gayberne.h
|
||||
/pair_granular.cpp
|
||||
/pair_granular.h
|
||||
/pair_gran_easy.cpp
|
||||
/pair_gran_easy.h
|
||||
/pair_gran_hertz_history.cpp
|
||||
@ -815,16 +1061,18 @@
|
||||
/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_kim.cpp
|
||||
/pair_kim.h
|
||||
/pair_kolmogorov_crespi_full.cpp
|
||||
/pair_kolmogorov_crespi_full.h
|
||||
/pair_kolmogorov_crespi_z.cpp
|
||||
/pair_kolmogorov_crespi_z.h
|
||||
/pair_lcbop.cpp
|
||||
/pair_lcbop.h
|
||||
/pair_lebedeva_z.cpp
|
||||
/pair_lebedeva_z.h
|
||||
/pair_line_lj.cpp
|
||||
/pair_line_lj.h
|
||||
/pair_list.cpp
|
||||
@ -843,8 +1091,14 @@
|
||||
/pair_lj_class2.h
|
||||
/pair_lj_class2_coul_cut.cpp
|
||||
/pair_lj_class2_coul_cut.h
|
||||
/pair_lj_class2_coul_cut_soft.cpp
|
||||
/pair_lj_class2_coul_cut_soft.h
|
||||
/pair_lj_class2_coul_long.cpp
|
||||
/pair_lj_class2_coul_long.h
|
||||
/pair_lj_class2_coul_long_soft.cpp
|
||||
/pair_lj_class2_coul_long_soft.h
|
||||
/pair_lj_class2_soft.cpp
|
||||
/pair_lj_class2_soft.h
|
||||
/pair_lj_coul.cpp
|
||||
/pair_lj_coul.h
|
||||
/pair_coul_cut_soft.cpp
|
||||
@ -889,6 +1143,8 @@
|
||||
/pair_lj_sdk_coul_msm.h
|
||||
/pair_lj_sf_dipole_sf.cpp
|
||||
/pair_lj_sf_dipole_sf.h
|
||||
/pair_lj_switch3_coulgauss_long.cpp
|
||||
/pair_lj_switch3_coulgauss_long.h
|
||||
/pair_lubricateU.cpp
|
||||
/pair_lubricateU.h
|
||||
/pair_lubricateU_poly.cpp
|
||||
@ -897,12 +1153,14 @@
|
||||
/pair_lubricate_poly.h
|
||||
/pair_lubricate.cpp
|
||||
/pair_lubricate.h
|
||||
/pair_meam.cpp
|
||||
/pair_meam.h
|
||||
/pair_meam_spline.cpp
|
||||
/pair_meam_spline.h
|
||||
/pair_meam_sw_spline.cpp
|
||||
/pair_meam_sw_spline.h
|
||||
/pair_mesocnt.cpp
|
||||
/pair_mesocnt.h
|
||||
/pair_mm3_switch3_coulgauss_long.cpp
|
||||
/pair_mm3_switch3_coulgauss_long.h
|
||||
/pair_morse_soft.cpp
|
||||
/pair_morse_soft.h
|
||||
/pair_nb3b_harmonic.cpp
|
||||
@ -913,11 +1171,17 @@
|
||||
/pair_nm_cut_coul_cut.h
|
||||
/pair_nm_cut_coul_long.cpp
|
||||
/pair_nm_cut_coul_long.h
|
||||
/pait_nm_cut_split.cpp
|
||||
/pait_nm_cut_split.h
|
||||
/pair_oxdna_*.cpp
|
||||
/pair_oxdna_*.h
|
||||
/pair_oxdna2_*.cpp
|
||||
/pair_oxdna2_*.h
|
||||
/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
|
||||
@ -928,8 +1192,8 @@
|
||||
/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
|
||||
@ -950,6 +1214,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
|
||||
@ -966,16 +1232,24 @@
|
||||
/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
|
||||
/pair_yukawa_colloid.h
|
||||
/pair_wf_cut.cpp
|
||||
/pair_wf_cut.h
|
||||
/pair_momb.cpp
|
||||
/pair_momb.h
|
||||
/pppm.cpp
|
||||
/pppm.h
|
||||
/pppm_cg.cpp
|
||||
/pppm_cg.h
|
||||
/pppm_dipole.cpp
|
||||
/pppm_dipole.h
|
||||
/pppm_dipole_spin.cpp
|
||||
/pppm_dipole_spin.h
|
||||
/pppm_disp.cpp
|
||||
/pppm_disp.h
|
||||
/pppm_disp_tip4p.cpp
|
||||
@ -997,64 +1271,45 @@
|
||||
/python_impl.cpp
|
||||
/python_impl.h
|
||||
/python_compat.h
|
||||
/python_utils.h
|
||||
/fix_python_move.cpp
|
||||
/fix_python_move.h
|
||||
/fix_python_invoke.cpp
|
||||
/fix_python_invoke.h
|
||||
/pair_python.cpp
|
||||
/pair_python.h
|
||||
/reader_adios.cpp
|
||||
/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
|
||||
/remap_wrap.h
|
||||
/restart_mpiio.cpp
|
||||
/restart_mpiio.h
|
||||
/rigid_const.h
|
||||
/scafacos.cpp
|
||||
/scafacos.h
|
||||
/server.cpp
|
||||
@ -1075,14 +1330,16 @@
|
||||
/temper_grem.h
|
||||
/temper_npt.cpp
|
||||
/temper_npt.h
|
||||
/third_order.cpp
|
||||
/third_order.h
|
||||
/thr_data.cpp
|
||||
/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
|
||||
@ -1148,6 +1405,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
|
||||
@ -1176,6 +1435,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
|
||||
@ -1214,16 +1477,26 @@
|
||||
/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
|
||||
/pair_lj_cut_coul_long_cs.h
|
||||
/pair_lj_class2_coul_long_cs.cpp
|
||||
/pair_lj_class2_coul_long_cs.h
|
||||
/pair_lj_mdf.cpp
|
||||
/pair_lj_mdf.h
|
||||
/pair_mgpt.cpp
|
||||
@ -1234,4 +1507,3 @@
|
||||
/pair_smtbq.h
|
||||
/pair_vashishta*.cpp
|
||||
/pair_vashishta*.h
|
||||
|
||||
|
||||
93
src/ADIOS/Install.sh
Normal file
93
src/ADIOS/Install.sh
Normal file
@ -0,0 +1,93 @@
|
||||
# Install/unInstall package files in LAMMPS
|
||||
# mode = 0/1/2 for uninstall/install/update
|
||||
|
||||
mode=$1
|
||||
|
||||
# arg1 = file, arg2 = file it depends on
|
||||
|
||||
action () {
|
||||
if (test $mode = 0) then
|
||||
rm -f ../$1
|
||||
elif (! cmp -s $1 ../$1) then
|
||||
if (test -z "$2" || test -e ../$2) then
|
||||
cp $1 ..
|
||||
if (test $mode = 2) then
|
||||
echo " updating src/$1"
|
||||
fi
|
||||
fi
|
||||
elif (test -n "$2") then
|
||||
if (test ! -e ../$2) then
|
||||
rm -f ../$1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
for file in *.cpp *.h; do
|
||||
action $file
|
||||
done
|
||||
|
||||
# edit 2 Makefile.package files to include/exclude package info
|
||||
|
||||
if (test $1 = 1) then
|
||||
|
||||
CONFIGSCRIPT=none
|
||||
if ( test `which adios2-config 2>> /dev/null` ) then
|
||||
CONFIGSCRIPT=adios2-config
|
||||
elif ( ! test -z "$ADIOS2_DIR" ) then
|
||||
if ( test `which $ADIOS2_DIR/bin/adios2-config` ) then
|
||||
CONFIGSCRIPT=$ADIOS2_DIR/bin/adios2-config
|
||||
else
|
||||
echo "ERROR: ADIOS2_DIR environment variable is set but" \
|
||||
"\$ADIOS2_DIR/bin/adios2-config does not exist"
|
||||
fi
|
||||
elif ( ! test -z "$ADIOS_DIR" ) then
|
||||
if ( test `which $ADIOS_DIR/bin/adios2-config` ) then
|
||||
CONFIGSCRIPT=$ADIOS_DIR/bin/adios2-config
|
||||
else
|
||||
echo "ERROR: ADIOS_DIR environment variable is set but" \
|
||||
"\$ADIOS_DIR/bin/adios2-config does not exist"
|
||||
fi
|
||||
else
|
||||
echo "ERROR: ADIOS2_DIR environment variable must point to ADIOS 2.x" \
|
||||
"installation directory or adios2-config should be in PATH"
|
||||
fi
|
||||
|
||||
if [ "$CONFIGSCRIPT" != "none" ]; then
|
||||
ADIOS2_INC=`$CONFIGSCRIPT --cxx-flags`
|
||||
ADIOS2_LIB=`$CONFIGSCRIPT --cxx-libs`
|
||||
|
||||
echo "adios_SYSINC=${ADIOS2_INC}
|
||||
adios_SYSLIB=${ADIOS2_LIB}
|
||||
" > Makefile.lammps
|
||||
|
||||
|
||||
if (test -e ../Makefile.package) then
|
||||
sed -i -e 's/[^ \t]*adios[^ \t]* //g' ../Makefile.package
|
||||
sed -i -e '/^adios_SYS.*$/d' ../Makefile.package
|
||||
sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(adios_SYSINC) |' ../Makefile.package
|
||||
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(adios_SYSLIB) |' ../Makefile.package
|
||||
fi
|
||||
|
||||
if (test -e ../Makefile.package.settings) then
|
||||
sed -i -e '/^include.*ADIOS.*$/d' ../Makefile.package.settings
|
||||
# multiline form needed for BSD sed on Macs
|
||||
sed -i -e '4 i \
|
||||
include ../ADIOS/Makefile.lammps
|
||||
' ../Makefile.package.settings
|
||||
fi
|
||||
fi
|
||||
|
||||
elif (test $1 = 0) then
|
||||
|
||||
if (test -e ../Makefile.package) then
|
||||
sed -i -e 's/[^ \t]*adios[^ \t]* //g' ../Makefile.package
|
||||
sed -i -e '/^adios_SYS.*$/d' ../Makefile.package
|
||||
fi
|
||||
|
||||
if (test -e ../Makefile.package.settings) then
|
||||
sed -i -e '/^include.*ADIOS.*$/d' ../Makefile.package.settings
|
||||
fi
|
||||
|
||||
rm -f Makefile.lammps
|
||||
|
||||
fi
|
||||
16
src/ADIOS/README
Normal file
16
src/ADIOS/README
Normal file
@ -0,0 +1,16 @@
|
||||
This package provides the adios dump and read_dump styles.
|
||||
|
||||
See the doc page for the "dump adios" and "read_dump ... format adios" commands.
|
||||
These styles require having ADIOS 2.x itself installed on your system.
|
||||
|
||||
Configure LAMMPS with CMake
|
||||
a. set the environment variable
|
||||
ADIOS2_DIR
|
||||
to the ADIOS 2.x installation path
|
||||
b. use the cmake option
|
||||
-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.
|
||||
https://www.olcf.ornl.gov/support/submit-ticket
|
||||
|
||||
356
src/ADIOS/dump_atom_adios.cpp
Normal file
356
src/ADIOS/dump_atom_adios.cpp
Normal file
@ -0,0 +1,356 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAX_TEXT_HEADER_SIZE 4096
|
||||
#define DUMP_BUF_CHUNK_SIZE 16384
|
||||
#define DUMP_BUF_INCREMENT_SIZE 4096
|
||||
|
||||
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)
|
||||
{
|
||||
internal = new DumpAtomADIOSInternal();
|
||||
try {
|
||||
internal->ad =
|
||||
new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
||||
} catch (std::ios_base::failure &e) {
|
||||
char str[256];
|
||||
snprintf(str, sizeof(str), "ADIOS initialization failed with error: %s",
|
||||
e.what());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
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
|
||||
char *filestar = strdup(filename);
|
||||
char *filecurrent = new char[strlen(filestar) + 16];
|
||||
char *ptr = strchr(filestar, '*');
|
||||
*ptr = '\0';
|
||||
if (padflag == 0)
|
||||
snprintf(filecurrent, sizeof(filecurrent), "%s" BIGINT_FORMAT "%s",
|
||||
filestar, update->ntimestep, ptr + 1);
|
||||
else {
|
||||
char bif[8], pad[16];
|
||||
strcpy(bif, BIGINT_FORMAT);
|
||||
snprintf(pad, sizeof(pad), "%%s%%0%d%s%%s", padflag, &bif[1]);
|
||||
snprintf(filecurrent, sizeof(filecurrent), pad, filestar,
|
||||
update->ntimestep, ptr + 1);
|
||||
}
|
||||
internal->fh =
|
||||
internal->io.Open(filecurrent, adios2::Mode::Write, world);
|
||||
if (!internal->fh) {
|
||||
char str[128];
|
||||
snprintf(str, sizeof(str), "Cannot open dump file %s", filecurrent);
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
free(filestar);
|
||||
delete[] filecurrent;
|
||||
} else {
|
||||
if (!singlefile_opened) {
|
||||
internal->fh =
|
||||
internal->io.Open(filename, adios2::Mode::Write, world);
|
||||
if (!internal->fh) {
|
||||
char str[128];
|
||||
snprintf(str, sizeof(str), "Cannot open dump file %s",
|
||||
filename);
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
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
|
||||
size_t nAtomsGlobal = static_cast<size_t>(ntotal);
|
||||
size_t startRow = static_cast<size_t>(atomOffset);
|
||||
size_t nAtomsLocal = static_cast<size_t>(nme);
|
||||
size_t 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
|
||||
int len = strlen(filename);
|
||||
char *ptr = strchr(filename, '%');
|
||||
if (ptr) {
|
||||
*ptr = '\0';
|
||||
char *s = new char[len - 1];
|
||||
snprintf(s, sizeof(s), "%s%s", filename, ptr + 1);
|
||||
strncpy(filename, s, len);
|
||||
}
|
||||
|
||||
// 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"};
|
||||
}
|
||||
|
||||
// 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;
|
||||
char nstreams[128];
|
||||
snprintf(nstreams, sizeof(nstreams), "%d", num_aggregators);
|
||||
internal->io.SetParameters({{"substreams", nstreams}});
|
||||
if (me == 0 && screen)
|
||||
fprintf(
|
||||
screen,
|
||||
"ADIOS method for %s is n-to-m (aggregation with %s 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);
|
||||
|
||||
size_t 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));
|
||||
|
||||
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});
|
||||
}
|
||||
60
src/ADIOS/dump_atom_adios.h
Normal file
60
src/ADIOS/dump_atom_adios.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* -*- 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 DUMP_CLASS
|
||||
// clang-format off
|
||||
DumpStyle(atom/adios, DumpAtomADIOS);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_DUMP_ATOM_ADIOS_H
|
||||
#define LMP_DUMP_ATOM_ADIOS_H
|
||||
|
||||
#include "dump_atom.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class DumpAtomADIOSInternal;
|
||||
|
||||
class DumpAtomADIOS : public DumpAtom {
|
||||
|
||||
public:
|
||||
DumpAtomADIOS(class LAMMPS *, int, char **);
|
||||
virtual ~DumpAtomADIOS();
|
||||
|
||||
protected:
|
||||
virtual void openfile();
|
||||
virtual void write();
|
||||
virtual void init_style();
|
||||
|
||||
private:
|
||||
DumpAtomADIOSInternal *internal;
|
||||
};
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Cannot open dump file %s
|
||||
|
||||
The output file for the dump command cannot be opened. Check that the
|
||||
path and name are correct.
|
||||
|
||||
E: Too much per-proc info for dump
|
||||
|
||||
Number of local atoms times number of columns must fit in a 32-bit
|
||||
integer for dump.
|
||||
|
||||
*/
|
||||
443
src/ADIOS/dump_custom_adios.cpp
Normal file
443
src/ADIOS/dump_custom_adios.cpp
Normal file
@ -0,0 +1,443 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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 "force.h"
|
||||
#include "group.h"
|
||||
#include "input.h"
|
||||
#include "memory.h"
|
||||
#include "modify.h"
|
||||
#include "region.h"
|
||||
#include "universe.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "adios2.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAX_TEXT_HEADER_SIZE 4096
|
||||
#define DUMP_BUF_CHUNK_SIZE 16384
|
||||
#define DUMP_BUF_INCREMENT_SIZE 4096
|
||||
|
||||
enum {
|
||||
ID,
|
||||
MOL,
|
||||
TYPE,
|
||||
ELEMENT,
|
||||
MASS,
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
XS,
|
||||
YS,
|
||||
ZS,
|
||||
XSTRI,
|
||||
YSTRI,
|
||||
ZSTRI,
|
||||
XU,
|
||||
YU,
|
||||
ZU,
|
||||
XUTRI,
|
||||
YUTRI,
|
||||
ZUTRI,
|
||||
XSU,
|
||||
YSU,
|
||||
ZSU,
|
||||
XSUTRI,
|
||||
YSUTRI,
|
||||
ZSUTRI,
|
||||
IX,
|
||||
IY,
|
||||
IZ,
|
||||
VX,
|
||||
VY,
|
||||
VZ,
|
||||
FX,
|
||||
FY,
|
||||
FZ,
|
||||
Q,
|
||||
MUX,
|
||||
MUY,
|
||||
MUZ,
|
||||
MU,
|
||||
RADIUS,
|
||||
DIAMETER,
|
||||
OMEGAX,
|
||||
OMEGAY,
|
||||
OMEGAZ,
|
||||
ANGMOMX,
|
||||
ANGMOMY,
|
||||
ANGMOMZ,
|
||||
TQX,
|
||||
TQY,
|
||||
TQZ,
|
||||
SPIN,
|
||||
ERADIUS,
|
||||
ERVEL,
|
||||
ERFORCE,
|
||||
COMPUTE,
|
||||
FIX,
|
||||
VARIABLE
|
||||
};
|
||||
enum { LT, LE, GT, GE, EQ, NEQ };
|
||||
enum { INT, DOUBLE, STRING, BIGINT }; // same as in DumpCustom
|
||||
|
||||
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)
|
||||
{
|
||||
internal = new DumpCustomADIOSInternal();
|
||||
try {
|
||||
internal->ad =
|
||||
new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
||||
} catch (std::ios_base::failure &e) {
|
||||
char str[256];
|
||||
snprintf(str, sizeof(str), "ADIOS initialization failed with error: %s",
|
||||
e.what());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
|
||||
// if (screen) fprintf(screen, "DumpCustomADIOS constructor: nvariable=%d
|
||||
// id_variable=%p, variables=%p, nfield=%d, earg=%p\n", nvariable,
|
||||
// id_variable, variable, nfield, earg);
|
||||
internal->columnNames.reserve(nfield);
|
||||
for (int i = 0; i < nfield; ++i) {
|
||||
internal->columnNames.push_back(earg[i]);
|
||||
// if (screen) fprintf(screen, "earg[%d] = '%s'\n", i, 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
|
||||
char *filestar = strdup(filename);
|
||||
char *filecurrent = new char[strlen(filestar) + 16];
|
||||
char *ptr = strchr(filestar, '*');
|
||||
*ptr = '\0';
|
||||
if (padflag == 0)
|
||||
sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar,
|
||||
update->ntimestep, ptr + 1);
|
||||
else {
|
||||
char bif[8], pad[16];
|
||||
strcpy(bif, BIGINT_FORMAT);
|
||||
sprintf(pad, "%%s%%0%d%s%%s", padflag, &bif[1]);
|
||||
sprintf(filecurrent, pad, filestar, update->ntimestep, ptr + 1);
|
||||
}
|
||||
internal->fh =
|
||||
internal->io.Open(filecurrent, adios2::Mode::Write, world);
|
||||
if (!internal->fh) {
|
||||
char str[128];
|
||||
sprintf(str, "Cannot open dump file %s", filecurrent);
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
free(filestar);
|
||||
delete[] filecurrent;
|
||||
} else {
|
||||
if (!singlefile_opened) {
|
||||
internal->fh =
|
||||
internal->io.Open(filename, adios2::Mode::Write, world);
|
||||
if (!internal->fh) {
|
||||
char str[128];
|
||||
sprintf(str, "Cannot open dump file %s", filename);
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
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
|
||||
size_t nAtomsGlobal = static_cast<size_t>(ntotal);
|
||||
size_t startRow = static_cast<size_t>(atomOffset);
|
||||
size_t nAtomsLocal = static_cast<size_t>(nme);
|
||||
size_t 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()
|
||||
{
|
||||
|
||||
// setup boundary string
|
||||
|
||||
domain->boundary_string(boundstr);
|
||||
|
||||
// remove % from filename since ADIOS always writes a global file with
|
||||
// data/metadata
|
||||
int len = strlen(filename);
|
||||
char *ptr = strchr(filename, '%');
|
||||
if (ptr) {
|
||||
*ptr = '\0';
|
||||
char *s = new char[len - 1];
|
||||
sprintf(s, "%s%s", filename, ptr + 1);
|
||||
strncpy(filename, s, len);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
char nstreams[128];
|
||||
sprintf(nstreams, "%d", num_aggregators);
|
||||
internal->io.SetParameters({{"substreams", nstreams}});
|
||||
if (me == 0 && screen)
|
||||
fprintf(
|
||||
screen,
|
||||
"ADIOS method for %s is n-to-m (aggregation with %s 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);
|
||||
|
||||
size_t 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});
|
||||
}
|
||||
85
src/ADIOS/dump_custom_adios.h
Normal file
85
src/ADIOS/dump_custom_adios.h
Normal file
@ -0,0 +1,85 @@
|
||||
/* -*- 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 DUMP_CLASS
|
||||
// clang-format off
|
||||
DumpStyle(custom/adios, DumpCustomADIOS);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_DUMP_CUSTOM_ADIOS_H
|
||||
#define LMP_DUMP_CUSTOM_ADIOS_H
|
||||
|
||||
#include "dump_custom.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class DumpCustomADIOSInternal;
|
||||
|
||||
class DumpCustomADIOS : public DumpCustom {
|
||||
public:
|
||||
DumpCustomADIOS(class LAMMPS *, int, char **);
|
||||
virtual ~DumpCustomADIOS();
|
||||
|
||||
protected:
|
||||
virtual void openfile();
|
||||
virtual void write();
|
||||
virtual void init_style();
|
||||
|
||||
private:
|
||||
DumpCustomADIOSInternal *internal;
|
||||
};
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Cannot open dump file %s
|
||||
|
||||
The output file for the dump command cannot be opened. Check that the
|
||||
path and name are correct.
|
||||
|
||||
E: Too much per-proc info for dump
|
||||
|
||||
Number of local atoms times number of columns must fit in a 32-bit
|
||||
integer for dump.
|
||||
|
||||
E: Dump_modify format string is too short
|
||||
|
||||
There are more fields to be dumped in a line of output than your
|
||||
format string specifies.
|
||||
|
||||
E: Could not find dump custom compute ID
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Could not find dump custom fix ID
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Dump custom and fix not computed at compatible times
|
||||
|
||||
The fix must produce per-atom quantities on timesteps that dump custom
|
||||
needs them.
|
||||
|
||||
E: Could not find dump custom variable name
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Region ID for dump custom does not exist
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
*/
|
||||
528
src/ADIOS/reader_adios.cpp
Normal file
528
src/ADIOS/reader_adios.cpp
Normal file
@ -0,0 +1,528 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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 "math_const.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
using namespace MathConst;
|
||||
|
||||
// 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
|
||||
|
||||
// true if the difference between two floats is "small".
|
||||
// cannot use fabsf() since it is not fully portable.
|
||||
static bool is_smalldiff(const float &val1, const float &val2)
|
||||
{
|
||||
return (fabs(static_cast<double>(val1 - val2)) < SMALL);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
internal = new ReadADIOSInternal();
|
||||
try {
|
||||
internal->ad =
|
||||
new adios2::ADIOS("adios2_config.xml", world, adios2::DebugON);
|
||||
} catch (std::ios_base::failure &e) {
|
||||
char str[256];
|
||||
snprintf(str, sizeof(str), "ADIOS initialization failed with error: %s",
|
||||
e.what());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
|
||||
/* 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 {
|
||||
char str[128];
|
||||
snprintf(str, sizeof(str),
|
||||
"Missing value for 'timeout' option for ADIOS "
|
||||
"read_dump command");
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
}
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
try to open given file
|
||||
Every process must call this Collective operation
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ReaderADIOS::open_file(const char *file)
|
||||
{
|
||||
int rv;
|
||||
char str[1024];
|
||||
|
||||
// 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) {
|
||||
char str[256];
|
||||
snprintf(str, sizeof(str), "%s", e.what());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
if (!internal->fh) {
|
||||
snprintf(str, sizeof(str), "Cannot open file %s using ADIOS", file);
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
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)
|
||||
{
|
||||
char str[1024];
|
||||
|
||||
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) {
|
||||
snprintf(str, sizeof(str),
|
||||
"Did not find 'ntimestep' variable in ADIOS file %s",
|
||||
internal->fh.Name().c_str());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
|
||||
ntimestep = static_cast<bigint>(internal->varNtimestep.Max());
|
||||
// std::cerr << " **** ReaderADIOS::read_time found step " << ntimestep
|
||||
// << " **** " << std::endl;
|
||||
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)
|
||||
{
|
||||
char str[1024];
|
||||
nid = 0;
|
||||
|
||||
// signal that we have no box info at all so far.
|
||||
|
||||
internal->varNatoms = internal->io.InquireVariable<uint64_t>("natoms");
|
||||
if (!internal->varNatoms) {
|
||||
snprintf(str, sizeof(str),
|
||||
"Did not find 'natoms' variable in ADIOS file %s",
|
||||
internal->fh.Name().c_str());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
|
||||
/* nAtoms */
|
||||
nAtomsTotal = internal->varNatoms.Max();
|
||||
uint64_t rem = nAtomsTotal % comm->nprocs;
|
||||
nAtoms = nAtomsTotal / comm->nprocs;
|
||||
atomOffset = comm->me * nAtoms;
|
||||
if (comm->me < rem) {
|
||||
++nAtoms;
|
||||
atomOffset += comm->me;
|
||||
} else {
|
||||
atomOffset += rem;
|
||||
}
|
||||
|
||||
/* triclinic */
|
||||
adios2::Attribute<int32_t> attTriclinic =
|
||||
internal->io.InquireAttribute<int32_t>("triclinic");
|
||||
if (!attTriclinic) {
|
||||
snprintf(str, sizeof(str),
|
||||
"Did not find 'triclinic' attribute in ADIOS file %s",
|
||||
internal->fh.Name().c_str());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
char str[1024];
|
||||
|
||||
/* 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 (n != nAtoms) {
|
||||
snprintf(
|
||||
str, sizeof(str),
|
||||
"ReaderADIOS::read_atoms() expects 'n=%d' equal to the number of "
|
||||
"atoms (=%" PRIu64 ") for process %d in ADIOS file %s.",
|
||||
n, nAtoms, comm->me, internal->fh.Name().c_str());
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
|
||||
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 (int 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)
|
||||
{
|
||||
std::map<std::string, int>::const_iterator it = labels.find(label);
|
||||
if (it != labels.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
69
src/ADIOS/reader_adios.h
Normal file
69
src/ADIOS/reader_adios.h
Normal 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 *);
|
||||
virtual ~ReaderADIOS();
|
||||
|
||||
virtual void settings(int, char **);
|
||||
|
||||
virtual int read_time(bigint &);
|
||||
virtual void skip();
|
||||
virtual bigint read_header(double[3][3], int &, int &, int, int, int *, char **, int, int, int &,
|
||||
int &, int &, int &);
|
||||
virtual void read_atoms(int, int, double **);
|
||||
|
||||
virtual void open_file(const char *);
|
||||
virtual void close_file();
|
||||
|
||||
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
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,8 +12,8 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <mpi.h>
|
||||
#include "compute_erotate_asphere.h"
|
||||
|
||||
#include "math_extra.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec_ellipsoid.h"
|
||||
@ -20,7 +21,6 @@
|
||||
#include "atom_vec_tri.h"
|
||||
#include "update.h"
|
||||
#include "force.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -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
|
||||
@ -37,7 +37,7 @@ class ComputeERotateAsphere : public Compute {
|
||||
class AtomVecTri *avec_tri;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,9 +16,9 @@
|
||||
Contributing author: Mike Brown (SNL)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <mpi.h>
|
||||
#include <cstring>
|
||||
#include "compute_temp_asphere.h"
|
||||
|
||||
#include <cstring>
|
||||
#include "math_extra.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec_ellipsoid.h"
|
||||
@ -26,7 +27,6 @@
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "group.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
@ -39,7 +39,7 @@ enum{ROTATE,ALL};
|
||||
|
||||
ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg),
|
||||
id_bias(NULL), tbias(NULL), avec(NULL)
|
||||
id_bias(nullptr), tbias(nullptr), avec(nullptr)
|
||||
{
|
||||
if (narg < 3) error->all(FLERR,"Illegal compute temp/asphere command");
|
||||
|
||||
@ -50,7 +50,7 @@ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
tempflag = 1;
|
||||
|
||||
tempbias = 0;
|
||||
id_bias = NULL;
|
||||
id_bias = nullptr;
|
||||
mode = ALL;
|
||||
|
||||
int iarg = 3;
|
||||
@ -59,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)
|
||||
@ -78,7 +76,7 @@ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
if (mode == ROTATE) extra_dof = 0;
|
||||
|
||||
vector = new double[6];
|
||||
vector = new double[size_vector];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
@ -42,13 +42,13 @@ class ComputeTempAsphere : public Compute {
|
||||
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
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,15 +16,10 @@
|
||||
Contributing author: Mike Brown (SNL)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include "math_extra.h"
|
||||
#include "fix_nh_asphere.h"
|
||||
#include "math_extra.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec_ellipsoid.h"
|
||||
#include "group.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -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
|
||||
@ -33,7 +33,7 @@ class FixNHAsphere : public FixNH {
|
||||
void nh_v_temp();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,10 +12,10 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstring>
|
||||
#include "fix_nph_asphere.h"
|
||||
#include "modify.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "modify.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
@ -35,35 +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
|
||||
|
||||
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/asphere";
|
||||
|
||||
modify->add_compute(3,newarg);
|
||||
delete [] newarg;
|
||||
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
|
||||
|
||||
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";
|
||||
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 {}",id_press, id_temp));
|
||||
pcomputeflag = 1;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -30,7 +30,7 @@ class FixNPHAsphere : public FixNHAsphere {
|
||||
~FixNPHAsphere() {}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,10 +12,10 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstring>
|
||||
#include "fix_npt_asphere.h"
|
||||
#include "modify.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "modify.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
@ -34,35 +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
|
||||
|
||||
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/asphere";
|
||||
|
||||
modify->add_compute(3,newarg);
|
||||
delete [] newarg;
|
||||
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
|
||||
|
||||
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";
|
||||
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 {}",id_press, id_temp));
|
||||
pcomputeflag = 1;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -30,7 +30,7 @@ class FixNPTAsphere : public FixNHAsphere {
|
||||
~FixNPTAsphere() {}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,17 +16,12 @@
|
||||
Contributing author: Mike Brown (SNL)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "fix_nve_asphere.h"
|
||||
#include "math_extra.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "atom_vec_ellipsoid.h"
|
||||
#include "force.h"
|
||||
#include "update.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "math_extra.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
@ -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
|
||||
@ -36,7 +36,7 @@ class FixNVEAsphere : public FixNVE {
|
||||
class AtomVecEllipsoid *avec;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,16 +12,10 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include "fix_nve_asphere_noforce.h"
|
||||
#include "math_extra.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec_ellipsoid.h"
|
||||
#include "group.h"
|
||||
#include "update.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -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
|
||||
@ -35,7 +35,7 @@ class FixNVEAsphereNoforce : public FixNVENoforce {
|
||||
class AtomVecEllipsoid *avec;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,9 +12,6 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "fix_nve_line.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec_line.h"
|
||||
|
||||
@ -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
|
||||
@ -34,11 +34,11 @@ class FixNVELine : public FixNVE {
|
||||
void final_integrate();
|
||||
|
||||
private:
|
||||
double MINUSPI,TWOPI;
|
||||
double MINUSPI, TWOPI;
|
||||
class AtomVecLine *avec;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,9 +12,6 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "fix_nve_tri.h"
|
||||
#include "math_extra.h"
|
||||
#include "atom.h"
|
||||
|
||||
@ -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
|
||||
@ -38,7 +38,7 @@ class FixNVETri : public FixNVE {
|
||||
class AtomVecTri *avec;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,11 +12,11 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstring>
|
||||
#include "fix_nvt_asphere.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "group.h"
|
||||
#include "modify.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
@ -33,17 +34,8 @@ FixNVTAsphere::FixNVTAsphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
// create a new compute temp style
|
||||
// id = fix-ID + temp
|
||||
|
||||
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] = group->names[igroup];
|
||||
newarg[2] = (char *) "temp/asphere";
|
||||
|
||||
modify->add_compute(3,newarg);
|
||||
delete [] newarg;
|
||||
id_temp = utils::strdup(std::string(id) + "_temp");
|
||||
modify->add_compute(fmt::format("{} {} temp/asphere",
|
||||
id_temp,group->names[igroup]));
|
||||
tcomputeflag = 1;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -30,7 +30,7 @@ class FixNVTAsphere : public FixNHAsphere {
|
||||
~FixNVTAsphere() {}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,11 +16,9 @@
|
||||
Contributing author: Mike Brown (SNL)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "pair_gayberne.h"
|
||||
|
||||
#include <cmath>
|
||||
#include "math_extra.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec_ellipsoid.h"
|
||||
@ -27,11 +26,11 @@
|
||||
#include "force.h"
|
||||
#include "neighbor.h"
|
||||
#include "neigh_list.h"
|
||||
#include "integrate.h"
|
||||
#include "citeme.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static const char cite_pair_gayberne[] =
|
||||
@ -94,8 +93,7 @@ void PairGayBerne::compute(int eflag, int vflag)
|
||||
double *iquat,*jquat;
|
||||
|
||||
evdwl = 0.0;
|
||||
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||
else evflag = vflag_fdotr = 0;
|
||||
ev_init(eflag,vflag);
|
||||
|
||||
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
|
||||
int *ellipsoid = atom->ellipsoid;
|
||||
@ -271,10 +269,10 @@ void PairGayBerne::settings(int narg, char **arg)
|
||||
{
|
||||
if (narg != 4) error->all(FLERR,"Illegal pair_style command");
|
||||
|
||||
gamma = force->numeric(FLERR,arg[0]);
|
||||
upsilon = force->numeric(FLERR,arg[1])/2.0;
|
||||
mu = force->numeric(FLERR,arg[2]);
|
||||
cut_global = force->numeric(FLERR,arg[3]);
|
||||
gamma = utils::numeric(FLERR,arg[0],false,lmp);
|
||||
upsilon = utils::numeric(FLERR,arg[1],false,lmp)/2.0;
|
||||
mu = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
cut_global = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
|
||||
// reset cutoffs that have been explicitly set
|
||||
|
||||
@ -297,20 +295,20 @@ void PairGayBerne::coeff(int narg, char **arg)
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi,jlo,jhi;
|
||||
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
|
||||
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi);
|
||||
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
|
||||
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
|
||||
|
||||
double epsilon_one = force->numeric(FLERR,arg[2]);
|
||||
double sigma_one = force->numeric(FLERR,arg[3]);
|
||||
double eia_one = force->numeric(FLERR,arg[4]);
|
||||
double eib_one = force->numeric(FLERR,arg[5]);
|
||||
double eic_one = force->numeric(FLERR,arg[6]);
|
||||
double eja_one = force->numeric(FLERR,arg[7]);
|
||||
double ejb_one = force->numeric(FLERR,arg[8]);
|
||||
double ejc_one = force->numeric(FLERR,arg[9]);
|
||||
double epsilon_one = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
double sigma_one = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
double eia_one = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
double eib_one = utils::numeric(FLERR,arg[5],false,lmp);
|
||||
double eic_one = utils::numeric(FLERR,arg[6],false,lmp);
|
||||
double eja_one = utils::numeric(FLERR,arg[7],false,lmp);
|
||||
double ejb_one = utils::numeric(FLERR,arg[8],false,lmp);
|
||||
double ejc_one = utils::numeric(FLERR,arg[9],false,lmp);
|
||||
|
||||
double cut_one = cut_global;
|
||||
if (narg == 11) cut_one = force->numeric(FLERR,arg[10]);
|
||||
if (narg == 11) cut_one = utils::numeric(FLERR,arg[10],false,lmp);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
@ -464,20 +462,20 @@ void PairGayBerne::read_restart(FILE *fp)
|
||||
int i,j;
|
||||
int me = comm->me;
|
||||
for (i = 1; i <= atom->ntypes; i++) {
|
||||
if (me == 0) fread(&setwell[i],sizeof(int),1,fp);
|
||||
if (me == 0) utils::sfread(FLERR,&setwell[i],sizeof(int),1,fp,nullptr,error);
|
||||
MPI_Bcast(&setwell[i],1,MPI_INT,0,world);
|
||||
if (setwell[i]) {
|
||||
if (me == 0) fread(&well[i][0],sizeof(double),3,fp);
|
||||
if (me == 0) utils::sfread(FLERR,&well[i][0],sizeof(double),3,fp,nullptr,error);
|
||||
MPI_Bcast(&well[i][0],3,MPI_DOUBLE,0,world);
|
||||
}
|
||||
for (j = i; j <= atom->ntypes; j++) {
|
||||
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp);
|
||||
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) {
|
||||
fread(&epsilon[i][j],sizeof(double),1,fp);
|
||||
fread(&sigma[i][j],sizeof(double),1,fp);
|
||||
fread(&cut[i][j],sizeof(double),1,fp);
|
||||
utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,nullptr,error);
|
||||
}
|
||||
MPI_Bcast(&epsilon[i][j],1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world);
|
||||
@ -509,12 +507,12 @@ void PairGayBerne::read_restart_settings(FILE *fp)
|
||||
{
|
||||
int me = comm->me;
|
||||
if (me == 0) {
|
||||
fread(&gamma,sizeof(double),1,fp);
|
||||
fread(&upsilon,sizeof(double),1,fp);
|
||||
fread(&mu,sizeof(double),1,fp);
|
||||
fread(&cut_global,sizeof(double),1,fp);
|
||||
fread(&offset_flag,sizeof(int),1,fp);
|
||||
fread(&mix_flag,sizeof(int),1,fp);
|
||||
utils::sfread(FLERR,&gamma,sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR,&upsilon,sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR,&mu,sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,nullptr,error);
|
||||
}
|
||||
MPI_Bcast(&gamma,1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&upsilon,1,MPI_DOUBLE,0,world);
|
||||
@ -647,10 +645,10 @@ double PairGayBerne::gayberne_analytic(const int i,const int j,double a1[3][3],
|
||||
dchi[2] = temp2*(iota[2]-temp1*r12hat[2]);
|
||||
|
||||
temp1 = -eta*u_r;
|
||||
temp2 = eta*chi;
|
||||
fforce[0] = temp1*dchi[0]-temp2*dUr[0];
|
||||
fforce[1] = temp1*dchi[1]-temp2*dUr[1];
|
||||
fforce[2] = temp1*dchi[2]-temp2*dUr[2];
|
||||
temp3 = eta*chi;
|
||||
fforce[0] = temp1*dchi[0]-temp3*dUr[0];
|
||||
fforce[1] = temp1*dchi[1]-temp3*dUr[1];
|
||||
fforce[2] = temp1*dchi[2]-temp3*dUr[2];
|
||||
|
||||
// torque for particle 1 and 2
|
||||
// compute dUr
|
||||
@ -671,18 +669,17 @@ double PairGayBerne::gayberne_analytic(const int i,const int j,double a1[3][3],
|
||||
|
||||
MathExtra::vecmat(iota,b1,tempv);
|
||||
MathExtra::cross3(tempv,iota,dchi);
|
||||
temp1 = -4.0/rsq;
|
||||
dchi[0] *= temp1;
|
||||
dchi[1] *= temp1;
|
||||
dchi[2] *= temp1;
|
||||
dchi[0] *= temp2;
|
||||
dchi[1] *= temp2;
|
||||
dchi[2] *= temp2;
|
||||
double dchi2[3];
|
||||
|
||||
if (newton_pair || j < nlocal) {
|
||||
MathExtra::vecmat(iota,b2,tempv);
|
||||
MathExtra::cross3(tempv,iota,dchi2);
|
||||
dchi2[0] *= temp1;
|
||||
dchi2[1] *= temp1;
|
||||
dchi2[2] *= temp1;
|
||||
dchi2[0] *= temp2;
|
||||
dchi2[1] *= temp2;
|
||||
dchi2[2] *= temp2;
|
||||
}
|
||||
|
||||
// compute d_eta
|
||||
|
||||
@ -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
|
||||
@ -41,38 +41,35 @@ class PairGayBerne : public Pair {
|
||||
void write_data_all(FILE *);
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,11 +12,8 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "pair_line_lj.h"
|
||||
#include <cmath>
|
||||
#include "atom.h"
|
||||
#include "atom_vec_line.h"
|
||||
#include "force.h"
|
||||
@ -24,6 +22,7 @@
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define DELTA 10000
|
||||
@ -33,8 +32,8 @@ using namespace LAMMPS_NS;
|
||||
PairLineLJ::PairLineLJ(LAMMPS *lmp) : Pair(lmp)
|
||||
{
|
||||
dmax = nmax = 0;
|
||||
discrete = NULL;
|
||||
dnum = dfirst = NULL;
|
||||
discrete = nullptr;
|
||||
dnum = dfirst = nullptr;
|
||||
|
||||
single_enable = 0;
|
||||
restartinfo = 0;
|
||||
@ -76,9 +75,7 @@ void PairLineLJ::compute(int eflag, int vflag)
|
||||
double xi[2],xj[2],fi[2],dxi,dxj,dyi,dyj;
|
||||
int *ilist,*jlist,*numneigh,**firstneigh;
|
||||
|
||||
evdwl = 0.0;
|
||||
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||
else evflag = vflag_fdotr = 0;
|
||||
ev_init(eflag,vflag);
|
||||
|
||||
double **x = atom->x;
|
||||
double **f = atom->f;
|
||||
@ -304,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,7 +344,7 @@ void PairLineLJ::settings(int narg, char **arg)
|
||||
{
|
||||
if (narg != 1) error->all(FLERR,"Illegal pair_style command");
|
||||
|
||||
cut_global = force->numeric(FLERR,arg[0]);
|
||||
cut_global = utils::numeric(FLERR,arg[0],false,lmp);
|
||||
|
||||
// reset cutoffs that have been explicitly set
|
||||
|
||||
@ -371,17 +367,17 @@ void PairLineLJ::coeff(int narg, char **arg)
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi,jlo,jhi;
|
||||
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
|
||||
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi);
|
||||
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
|
||||
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
|
||||
|
||||
double size_itype = force->numeric(FLERR,arg[2]);
|
||||
double size_jtype = force->numeric(FLERR,arg[3]);
|
||||
double epsilon_one = force->numeric(FLERR,arg[4]);
|
||||
double sigma_one = force->numeric(FLERR,arg[5]);
|
||||
double cutsub_one = force->numeric(FLERR,arg[6]);
|
||||
double size_itype = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
double size_jtype = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
double epsilon_one = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
double sigma_one = utils::numeric(FLERR,arg[5],false,lmp);
|
||||
double cutsub_one = utils::numeric(FLERR,arg[6],false,lmp);
|
||||
|
||||
double cut_one = cut_global;
|
||||
if (narg == 8) cut_one = force->numeric(FLERR,arg[7]);
|
||||
if (narg == 8) cut_one = utils::numeric(FLERR,arg[7],false,lmp);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
|
||||
@ -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
|
||||
@ -37,28 +37,28 @@ class PairLineLJ : public Pair {
|
||||
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
@ -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
|
||||
@ -39,19 +39,19 @@ class PairRESquared : public Pair {
|
||||
void read_restart_settings(FILE *);
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,11 +12,8 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "pair_tri_lj.h"
|
||||
#include <cmath>
|
||||
#include "math_extra.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec_tri.h"
|
||||
@ -25,6 +23,7 @@
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define DELTA 20
|
||||
@ -34,8 +33,8 @@ using namespace LAMMPS_NS;
|
||||
PairTriLJ::PairTriLJ(LAMMPS *lmp) : Pair(lmp)
|
||||
{
|
||||
dmax = nmax = 0;
|
||||
discrete = NULL;
|
||||
dnum = dfirst = NULL;
|
||||
discrete = nullptr;
|
||||
dnum = dfirst = nullptr;
|
||||
|
||||
single_enable = 0;
|
||||
restartinfo = 0;
|
||||
@ -76,9 +75,7 @@ void PairTriLJ::compute(int eflag, int vflag)
|
||||
double dc1[3],dc2[3],dc3[3];
|
||||
int *ilist,*jlist,*numneigh,**firstneigh;
|
||||
|
||||
evdwl = 0.0;
|
||||
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||
else evflag = vflag_fdotr = 0;
|
||||
ev_init(eflag,vflag);
|
||||
|
||||
AtomVecTri::Bonus *bonus = avec->bonus;
|
||||
double **x = atom->x;
|
||||
@ -378,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,7 +415,7 @@ void PairTriLJ::settings(int narg, char **arg)
|
||||
{
|
||||
if (narg != 1) error->all(FLERR,"Illegal pair_style command");
|
||||
|
||||
cut_global = force->numeric(FLERR,arg[0]);
|
||||
cut_global = utils::numeric(FLERR,arg[0],false,lmp);
|
||||
|
||||
// reset cutoffs that have been explicitly set
|
||||
|
||||
@ -442,14 +438,14 @@ void PairTriLJ::coeff(int narg, char **arg)
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi,jlo,jhi;
|
||||
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
|
||||
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi);
|
||||
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
|
||||
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
|
||||
|
||||
double epsilon_one = force->numeric(FLERR,arg[2]);
|
||||
double sigma_one = force->numeric(FLERR,arg[3]);
|
||||
double epsilon_one = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
double sigma_one = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
|
||||
double cut_one = cut_global;
|
||||
if (narg == 5) cut_one = force->numeric(FLERR,arg[4]);
|
||||
if (narg == 5) cut_one = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
|
||||
@ -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
|
||||
@ -37,26 +37,26 @@ class PairTriLJ : public Pair {
|
||||
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
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
www.cs.sandia.gov/~sjplimp/lammps.html
|
||||
https://www.lammps.org/
|
||||
Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
@ -11,22 +12,16 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
// LAMMPS
|
||||
#include "fix_atc.h"
|
||||
#include "fix_nve.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "update.h"
|
||||
#include "respa.h"
|
||||
#include "error.h"
|
||||
#include "neighbor.h"
|
||||
#include "neigh_request.h"
|
||||
#include "pointers.h"
|
||||
#include "comm.h"
|
||||
#include "error.h"
|
||||
#include "group.h"
|
||||
// ATC
|
||||
#include "neigh_request.h"
|
||||
#include "neighbor.h"
|
||||
|
||||
#include "ATC_Method.h"
|
||||
#include "ATC_Transfer.h"
|
||||
#include "ATC_TransferKernel.h"
|
||||
#include "ATC_TransferPartitionOfUnity.h"
|
||||
#include "ATC_CouplingEnergy.h"
|
||||
@ -34,17 +29,15 @@
|
||||
#include "ATC_CouplingMass.h"
|
||||
#include "ATC_CouplingMomentumEnergy.h"
|
||||
#include "LammpsInterface.h"
|
||||
// other
|
||||
#include <cstdio>
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
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
|
||||
@ -56,7 +49,7 @@ using std::string;
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
FixATC::FixATC(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
||||
lammps_(lmp), atc_(NULL)
|
||||
lammps_(lmp), atc_(nullptr)
|
||||
{
|
||||
// ID GROUP atc PHYSICSTYPE [PARAMETERFILE]
|
||||
if (narg < 4 || narg > 5) lmp->error->all(FLERR,"Illegal fix atc command");
|
||||
@ -125,7 +118,7 @@ FixATC::FixATC(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
||||
# be used as a localization function \n
|
||||
fix AtC kernel quartic_sphere 10.0 \n \n
|
||||
# create a uniform 1 x 1 x 1 mesh that covers region contain the group \n
|
||||
# with periodicity this effectively creats a system average \n
|
||||
# with periodicity this effectively creates a system average \n
|
||||
fix_modify AtC mesh create 1 1 1 box p p p \n\n
|
||||
# change from default lagrangian map to eulerian \n
|
||||
# refreshed every 100 steps \n
|
||||
@ -482,13 +475,11 @@ FixATC::FixATC(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
||||
throw;
|
||||
}
|
||||
|
||||
lmp->atom->add_callback(0);
|
||||
lmp->atom->add_callback(Atom::GROW);
|
||||
|
||||
// we write our own restart file
|
||||
restart_global = 0;
|
||||
|
||||
|
||||
|
||||
// Set output computation data based on transfer info
|
||||
scalar_flag = atc_->scalar_flag();
|
||||
vector_flag = atc_->vector_flag();
|
||||
@ -497,6 +488,7 @@ FixATC::FixATC(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
||||
extscalar = atc_->extscalar();
|
||||
extvector = atc_->extvector();
|
||||
extlist = atc_->extlist();
|
||||
energy_global_flag = 1;
|
||||
thermo_energy = atc_->thermo_energy_flag();
|
||||
|
||||
// set pointer for output
|
||||
@ -504,7 +496,6 @@ FixATC::FixATC(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
||||
size_peratom_cols = atc_->size_peratom_cols();
|
||||
peratom_freq = atc_->peratom_freq();
|
||||
|
||||
|
||||
// set comm size needed by this fix
|
||||
comm_forward = atc_->comm_forward();
|
||||
|
||||
@ -515,7 +506,7 @@ FixATC::FixATC(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
|
||||
/*----------------------------------------------------------------------- */
|
||||
FixATC::~FixATC()
|
||||
{
|
||||
if (lmp->atom) lmp->atom->delete_callback(id,0);
|
||||
if (lmp->atom) lmp->atom->delete_callback(id,Atom::GROW);
|
||||
if (atc_) delete atc_;
|
||||
}
|
||||
|
||||
@ -535,7 +526,6 @@ int FixATC::setmask()
|
||||
mask |= MIN_PRE_NEIGHBOR;
|
||||
mask |= MIN_PRE_FORCE;
|
||||
mask |= MIN_POST_FORCE;
|
||||
mask |= THERMO_ENERGY;
|
||||
mask |= POST_RUN;
|
||||
mask |= END_OF_STEP;
|
||||
return mask;
|
||||
@ -583,7 +573,7 @@ void FixATC::min_setup(int vflag)
|
||||
setup(vflag);
|
||||
}
|
||||
|
||||
void FixATC::setup(int vflag)
|
||||
void FixATC::setup(int /* vflag */)
|
||||
{
|
||||
comm->forward_comm_fix(this);
|
||||
|
||||
@ -635,7 +625,7 @@ void FixATC::min_pre_exchange()
|
||||
|
||||
double FixATC::memory_usage()
|
||||
{
|
||||
double bytes = (double) atc_->memory_usage() * sizeof(double);
|
||||
double bytes = atc_->memory_usage() * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -644,7 +634,7 @@ void FixATC::grow_arrays(int nmax)
|
||||
atc_->grow_arrays(nmax);
|
||||
}
|
||||
|
||||
void FixATC::copy_arrays(int i, int j, int delflag)
|
||||
void FixATC::copy_arrays(int i, int j, int /* delflag */)
|
||||
{
|
||||
atc_->copy_arrays(i,j);
|
||||
}
|
||||
@ -677,7 +667,7 @@ void FixATC::unpack_forward_comm(int n, int first, double *buf)
|
||||
pack values in local atom-based arrays for restart file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int FixATC::pack_restart(int i, double *buf){
|
||||
int FixATC::pack_restart(int /* i */, double * /* buf */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -685,14 +675,14 @@ int FixATC::pack_restart(int i, double *buf){
|
||||
unpack values from atom->extra array to restart the fix
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixATC::unpack_restart(int nlocal, int nth){
|
||||
void FixATC::unpack_restart(int /* nlocal */, int /* nth */) {
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
maxsize of any atom's restart data
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int FixATC::maxsize_restart(){
|
||||
int FixATC::maxsize_restart() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -700,7 +690,7 @@ int FixATC::maxsize_restart(){
|
||||
size of atom nlocal's restart data
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int FixATC::size_restart(int nlocal){
|
||||
int FixATC::size_restart(int /* nlocal */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -708,51 +698,45 @@ int FixATC::size_restart(int nlocal){
|
||||
pack entire state of Fix into one write
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixATC::write_restart(FILE *fp){
|
||||
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];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
use state info from restart file to restart the Fix
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixATC::restart(char *buf){
|
||||
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];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
allow for both per-type and per-atom mass
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixATC::initial_integrate(int vflag)
|
||||
void FixATC::initial_integrate(int /* vflag */)
|
||||
{
|
||||
try {
|
||||
atc_->pre_init_integrate();
|
||||
@ -838,7 +822,7 @@ void FixATC::pre_neighbor()
|
||||
}
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
void FixATC::pre_force(int vflag)
|
||||
void FixATC::pre_force(int /* vflag */)
|
||||
{
|
||||
|
||||
try {
|
||||
@ -850,7 +834,7 @@ void FixATC::pre_force(int vflag)
|
||||
}
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
void FixATC::post_force(int vflag)
|
||||
void FixATC::post_force(int /* vflag */)
|
||||
{
|
||||
|
||||
try {
|
||||
@ -886,7 +870,7 @@ void FixATC::setup_pre_neighbor()
|
||||
}
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
void FixATC::min_pre_force(int vflag)
|
||||
void FixATC::min_pre_force(int /* vflag */)
|
||||
{
|
||||
try {
|
||||
atc_->min_pre_force();
|
||||
@ -898,7 +882,7 @@ void FixATC::min_pre_force(int vflag)
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
void FixATC::min_post_force(int vflag)
|
||||
void FixATC::min_post_force(int /* vflag */)
|
||||
{
|
||||
try {
|
||||
atc_->min_post_force();
|
||||
142
src/ATC/fix_atc.h
Normal file
142
src/ATC/fix_atc.h
Normal 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();
|
||||
|
||||
/** initialization functions */
|
||||
void init();
|
||||
void init_list(int id, NeighList *ptr);
|
||||
void setup(int vflag);
|
||||
void min_setup(int vflag);
|
||||
|
||||
/** setmask: tell LAMMPS which fix methods to call */
|
||||
int setmask();
|
||||
|
||||
/** initial_integrate */
|
||||
void initial_integrate(int vflag);
|
||||
|
||||
/** after first integrate phase */
|
||||
void post_integrate();
|
||||
|
||||
/** final_integrate */
|
||||
void final_integrate();
|
||||
|
||||
/** end of step for run or minimize */
|
||||
void end_of_step();
|
||||
|
||||
/** pre_exchange is used to modify fix-specific data
|
||||
and is called before domain->pbc() and comm->exchange(). */
|
||||
void setup_pre_exchange();
|
||||
void pre_exchange();
|
||||
void min_pre_exchange();
|
||||
|
||||
double memory_usage();
|
||||
void grow_arrays(int);
|
||||
void copy_arrays(int, int, int);
|
||||
|
||||
/** 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 *);
|
||||
|
||||
/** 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 *);
|
||||
|
||||
/** pack_comm called from comm->forward_comm_fix and
|
||||
packs fix-specific data for a given ghost atom
|
||||
from exchange with another proc */
|
||||
int pack_forward_comm(int, int *, double *, int, int *);
|
||||
|
||||
/** unpack_comm called from comm->forward_comm_fix and
|
||||
unpacks fix-specific data for a given ghost atom
|
||||
from exchange with another proc */
|
||||
void unpack_forward_comm(int, int, double *);
|
||||
|
||||
/** pre_neighbor is used to modify fix-specific data
|
||||
and is called before neighbor list is built in
|
||||
neighbor->build(). */
|
||||
void pre_neighbor();
|
||||
void setup_pre_neighbor();
|
||||
|
||||
/** pre/post_force is used to modify fix-specific data
|
||||
and is before/after the various force computations. */
|
||||
void pre_force(int vflag);
|
||||
void post_force(int vflag);
|
||||
|
||||
/** post_run is called after a run completes */
|
||||
void post_run();
|
||||
|
||||
/** min_pre_force is called before forces are calculated in minimize */
|
||||
void min_pre_force(int vflag);
|
||||
|
||||
/** min_post_force is called after forces are calculated in minimize */
|
||||
void min_post_force(int vflag);
|
||||
|
||||
/** modify atc parameters (parser) */
|
||||
int modify_param(int narg, char **arg);
|
||||
|
||||
/** calls ATC_Method to handle restarting/checkpointing */
|
||||
/** these four methods are for writing per-atom quantities */
|
||||
int pack_restart(int, double *);
|
||||
void unpack_restart(int, int);
|
||||
int size_restart(int);
|
||||
int maxsize_restart();
|
||||
/** these two methods are for writing all other quantities */
|
||||
void write_restart(FILE *);
|
||||
void restart(char *);
|
||||
|
||||
/** accessor function for ATC_Method class pointer */
|
||||
const ATC::ATC_Method *atc() { return atc_; }
|
||||
|
||||
protected:
|
||||
LAMMPS *lammps_;
|
||||
|
||||
/** functions for "thermo" output */
|
||||
virtual double compute_scalar();
|
||||
virtual double compute_vector(int n);
|
||||
virtual double compute_array(int irow, int icol);
|
||||
double dtv, dtf;
|
||||
ATC::ATC_Method *atc_;
|
||||
};
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -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
|
||||
@ -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
|
||||
@ -16,7 +16,7 @@ installed.
|
||||
The person who created this package is Ilya Valuev at the JIHT in
|
||||
Russia (valuev at physik.hu-berlin.de). Contact him directly if you
|
||||
have questions.
|
||||
|
||||
|
||||
----------------------
|
||||
|
||||
ACKNOWLEDGMENTS:
|
||||
160
src/AWPMD/atom_vec_wavepacket.cpp
Normal file
160
src/AWPMD/atom_vec_wavepacket.cpp
Normal file
@ -0,0 +1,160 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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: Ilya Valuev (JIHT, Moscow, Russia)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "atom_vec_wavepacket.h"
|
||||
|
||||
#include "atom.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecWavepacket::AtomVecWavepacket(LAMMPS *lmp) : AtomVec(lmp)
|
||||
{
|
||||
mass_type = PER_TYPE;
|
||||
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;
|
||||
|
||||
// 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";
|
||||
|
||||
setup_fields();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
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 AtomVecWavepacket::grow_pointers()
|
||||
{
|
||||
q = atom->q;
|
||||
spin = atom->spin;
|
||||
eradius = atom->eradius;
|
||||
ervel = atom->ervel;
|
||||
erforce = atom->erforce;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
clear extra forces starting at atom N
|
||||
nbytes = # of bytes to clear for a per-atom vector
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecWavepacket::force_clear(int n, size_t nbytes)
|
||||
{
|
||||
memset(&erforce[n],0,nbytes);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize non-zero atom quantities
|
||||
make each atom a proton
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecWavepacket::create_atom_post(int ilocal)
|
||||
{
|
||||
q[ilocal] = 1.0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify what AtomVec::data_atom() just unpacked
|
||||
or initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecWavepacket::data_atom_post(int ilocal)
|
||||
{
|
||||
ervel[ilocal] = 0.0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
assign an index to named atom property and return index
|
||||
return -1 if name is unknown to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecWavepacket::property_atom(char *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;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack per-atom data into buf for ComputePropertyAtom
|
||||
index maps to data specific to this atom style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
n += nvalues;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
@ -11,34 +11,36 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef FIX_CLASS
|
||||
|
||||
FixStyle(reax/c/bonds/kk,FixReaxCBondsKokkos)
|
||||
FixStyle(reax/c/bonds/kk/device,FixReaxCBondsKokkos)
|
||||
FixStyle(reax/c/bonds/kk/host,FixReaxCBondsKokkos)
|
||||
|
||||
#ifdef ATOM_CLASS
|
||||
// clang-format off
|
||||
AtomStyle(wavepacket,AtomVecWavepacket);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_FIX_REAXC_BONDS_KOKKOS_H
|
||||
#define LMP_FIX_REAXC_BONDS_KOKKOS_H
|
||||
#ifndef LMP_ATOM_VEC_WAVEPACKET_H
|
||||
#define LMP_ATOM_VEC_WAVEPACKET_H
|
||||
|
||||
#include "fix_reaxc_bonds.h"
|
||||
#include "kokkos_type.h"
|
||||
#include "atom_vec.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class FixReaxCBondsKokkos : public FixReaxCBonds {
|
||||
class AtomVecWavepacket : public AtomVec {
|
||||
public:
|
||||
FixReaxCBondsKokkos(class LAMMPS *, int, char **);
|
||||
virtual ~FixReaxCBondsKokkos();
|
||||
void init();
|
||||
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);
|
||||
|
||||
private:
|
||||
int nbuf;
|
||||
void Output_ReaxC_Bonds(bigint, FILE *);
|
||||
double memory_usage();
|
||||
int *spin;
|
||||
double *q, *eradius, *ervel, *erforce;
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,16 +16,15 @@
|
||||
Contributing author: Ilya Valuev (JIHT, Moscow, Russia)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "fix_nve_awpmd.h"
|
||||
#include "pair_awpmd_cut.h"
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "update.h"
|
||||
#include "respa.h"
|
||||
#include "error.h"
|
||||
|
||||
|
||||
#include "TCP/wpmd_split.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
@ -37,8 +37,6 @@ FixNVEAwpmd::FixNVEAwpmd(LAMMPS *lmp, int narg, char **arg) :
|
||||
{
|
||||
if (!atom->wavepacket_flag)
|
||||
error->all(FLERR,"Fix nve/awpmd requires atom style wavepacket");
|
||||
//if (!atom->mass_type != 1)
|
||||
// error->all(FLERR,"Fix nve/awpmd requires per type mass");
|
||||
|
||||
time_integrate = 1;
|
||||
}
|
||||
@ -62,7 +60,7 @@ void FixNVEAwpmd::init()
|
||||
dtv = update->dt;
|
||||
dtf = 0.5 * update->dt * force->ftm2v;
|
||||
|
||||
if (strstr(update->integrate_style,"respa"))
|
||||
if (utils::strmatch(update->integrate_style,"^respa"))
|
||||
step_respa = ((Respa *) update->integrate)->step;
|
||||
|
||||
awpmd_pair=(PairAWPMDCut *)force->pair;
|
||||
@ -73,10 +71,8 @@ void FixNVEAwpmd::init()
|
||||
allow for only per-type mass
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixNVEAwpmd::initial_integrate(int vflag)
|
||||
void FixNVEAwpmd::initial_integrate(int /* vflag */)
|
||||
{
|
||||
|
||||
|
||||
// update v,vr and x,radius of atoms in group
|
||||
|
||||
double **x = atom->x;
|
||||
@ -85,7 +81,7 @@ void FixNVEAwpmd::initial_integrate(int vflag)
|
||||
double *ervel = atom->ervel;
|
||||
double **f = atom->f;
|
||||
double *erforce = atom->erforce;
|
||||
double *vforce=atom->vforce;
|
||||
double **vforce=atom->vforce;
|
||||
double *ervelforce=atom->ervelforce;
|
||||
|
||||
double *mass = atom->mass;
|
||||
@ -101,8 +97,8 @@ void FixNVEAwpmd::initial_integrate(int vflag)
|
||||
if (mask[i] & groupbit) {
|
||||
double dtfm = dtf / mass[type[i]];
|
||||
double dtfmr=dtfm;
|
||||
for(int j=0;j<3;j++){
|
||||
x[i][j] += dtv*vforce[3*i+j];
|
||||
for (int j=0;j<3;j++) {
|
||||
x[i][j] += dtv*vforce[i][j];
|
||||
v[i][j] += dtfm*f[i][j];
|
||||
}
|
||||
eradius[i]+= dtv*ervelforce[i];
|
||||
@ -114,11 +110,11 @@ void FixNVEAwpmd::initial_integrate(int vflag)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixNVEAwpmd::final_integrate(){}
|
||||
void FixNVEAwpmd::final_integrate() {}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixNVEAwpmd::initial_integrate_respa(int vflag, int ilevel, int iloop)
|
||||
void FixNVEAwpmd::initial_integrate_respa(int vflag, int ilevel, int /* iloop */)
|
||||
{
|
||||
dtv = step_respa[ilevel];
|
||||
dtf = 0.5 * step_respa[ilevel] * force->ftm2v;
|
||||
@ -132,7 +128,7 @@ void FixNVEAwpmd::initial_integrate_respa(int vflag, int ilevel, int iloop)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixNVEAwpmd::final_integrate_respa(int ilevel, int iloop)
|
||||
void FixNVEAwpmd::final_integrate_respa(int ilevel, int /* iloop */)
|
||||
{
|
||||
dtf = 0.5 * step_respa[ilevel] * force->ftm2v;
|
||||
final_integrate();
|
||||
@ -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,16 +16,15 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef FIX_CLASS
|
||||
|
||||
FixStyle(nve/awpmd,FixNVEAwpmd)
|
||||
|
||||
// clang-format off
|
||||
FixStyle(nve/awpmd,FixNVEAwpmd);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_FIX_NVE_awpmd_H
|
||||
#define LMP_FIX_NVE_awpmd_H
|
||||
|
||||
#include "fix.h"
|
||||
#include "pair_awpmd_cut.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
@ -41,14 +40,14 @@ class FixNVEAwpmd : public Fix {
|
||||
void reset_dt();
|
||||
|
||||
protected:
|
||||
double dtv,dtf;
|
||||
double dtv, dtf;
|
||||
double *step_respa;
|
||||
int mass_require;
|
||||
|
||||
PairAWPMDCut *awpmd_pair;
|
||||
class PairAWPMDCut *awpmd_pair;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,25 +16,30 @@
|
||||
Contributing author: Ilya Valuev (JIHT, Moscow, Russia)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "pair_awpmd_cut.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "min.h"
|
||||
#include "domain.h"
|
||||
#include "comm.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "force.h"
|
||||
#include "neighbor.h"
|
||||
#include "memory.h"
|
||||
#include "min.h"
|
||||
#include "neigh_list.h"
|
||||
#include "neigh_request.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "neighbor.h"
|
||||
#include "update.h"
|
||||
|
||||
#include "logexc.h"
|
||||
#include "vector_3.h"
|
||||
#include "TCP/wpmd.h"
|
||||
#include "TCP/wpmd_split.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -43,8 +49,8 @@ PairAWPMDCut::PairAWPMDCut(LAMMPS *lmp) : Pair(lmp)
|
||||
single_enable = 0;
|
||||
|
||||
nmax = 0;
|
||||
min_var = NULL;
|
||||
min_varforce = NULL;
|
||||
min_var = nullptr;
|
||||
min_varforce = nullptr;
|
||||
nextra = 4;
|
||||
pvector = new double[nextra];
|
||||
|
||||
@ -76,21 +82,21 @@ PairAWPMDCut::~PairAWPMDCut()
|
||||
struct cmp_x{
|
||||
double **xx;
|
||||
double tol;
|
||||
cmp_x(double **xx_=NULL, double tol_=1e-12):xx(xx_),tol(tol_){}
|
||||
cmp_x(double **xx_=nullptr, double tol_=1e-12):xx(xx_),tol(tol_) {}
|
||||
bool operator()(const pair<int,int> &left, const pair<int,int> &right) const {
|
||||
if(left.first==right.first){
|
||||
if (left.first==right.first) {
|
||||
double d=xx[left.second][0]-xx[right.second][0];
|
||||
if(d<-tol)
|
||||
if (d<-tol)
|
||||
return true;
|
||||
else if(d>tol)
|
||||
else if (d>tol)
|
||||
return false;
|
||||
d=xx[left.second][1]-xx[right.second][1];
|
||||
if(d<-tol)
|
||||
if (d<-tol)
|
||||
return true;
|
||||
else if(d>tol)
|
||||
else if (d>tol)
|
||||
return false;
|
||||
d=xx[left.second][2]-xx[right.second][2];
|
||||
if(d<-tol)
|
||||
if (d<-tol)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@ -108,10 +114,7 @@ void PairAWPMDCut::compute(int eflag, int vflag)
|
||||
// pvector = [KE, Pauli, ecoul, radial_restraint]
|
||||
for (int i=0; i<4; i++) pvector[i] = 0.0;
|
||||
|
||||
if (eflag || vflag)
|
||||
ev_setup(eflag,vflag);
|
||||
else
|
||||
evflag = vflag_fdotr = 0; //??
|
||||
ev_init(eflag,vflag);
|
||||
|
||||
double **x = atom->x;
|
||||
double **f = atom->f;
|
||||
@ -136,7 +139,7 @@ void PairAWPMDCut::compute(int eflag, int vflag)
|
||||
|
||||
|
||||
// width pbc
|
||||
if(width_pbc<0)
|
||||
if (width_pbc<0)
|
||||
wpmd->Lextra=2*half_box_length;
|
||||
else
|
||||
wpmd->Lextra=width_pbc;
|
||||
@ -147,7 +150,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];
|
||||
@ -160,7 +163,7 @@ void PairAWPMDCut::compute(int eflag, int vflag)
|
||||
for (int jj = 0; jj < jnum; jj++) {
|
||||
int j = jlist[jj];
|
||||
j &= NEIGHMASK;
|
||||
if(j>=nlocal){ // this is a ghost
|
||||
if (j>=nlocal) { // this is a ghost
|
||||
Vector_3 rj=Vector_3(x[j][0],x[j][1],x[j][2]);
|
||||
int jtype = type[j];
|
||||
double rsq=(ri-rj).norm2();
|
||||
@ -183,9 +186,9 @@ void PairAWPMDCut::compute(int eflag, int vflag)
|
||||
// local particles are all there
|
||||
idmap[make_pair(atom->tag[i],i)]=i;
|
||||
bool i_local= i<nlocal ? true : false;
|
||||
if(i_local)
|
||||
if (i_local)
|
||||
gmap[i]=0;
|
||||
else if(gmap[i]==0) // this is a ghost which already has been tested
|
||||
else if (gmap[i]==0) // this is a ghost which already has been tested
|
||||
continue;
|
||||
Vector_3 ri=Vector_3(x[i][0],x[i][1],x[i][2]);
|
||||
int itype = type[i];
|
||||
@ -197,19 +200,19 @@ void PairAWPMDCut::compute(int eflag, int vflag)
|
||||
|
||||
pair<map_t::iterator,bool> res=idmap.insert(make_pair(make_pair(atom->tag[j],j),j));
|
||||
bool have_it=!res.second;
|
||||
if(have_it){ // the clone of this particle is already listed
|
||||
if(res.first->second!=j) // check that was not the very same particle
|
||||
if (have_it) { // the clone of this particle is already listed
|
||||
if (res.first->second!=j) // check that was not the very same particle
|
||||
gmap[j]=-1; // filter out
|
||||
continue;
|
||||
}
|
||||
|
||||
bool j_local= j<nlocal ? true : false;
|
||||
if((i_local && !j_local) || (j_local && !i_local)){ // some of them is a ghost
|
||||
if ((i_local && !j_local) || (j_local && !i_local)) { // some of them is a ghost
|
||||
Vector_3 rj=Vector_3(x[j][0],x[j][1],x[j][2]);
|
||||
int jtype = type[j];
|
||||
double rsq=(ri-rj).norm2();
|
||||
if (rsq < cutsq[itype][jtype]){
|
||||
if(!i_local){
|
||||
if (rsq < cutsq[itype][jtype]) {
|
||||
if (!i_local) {
|
||||
gmap[i]=0; //bingo, this ghost is really needed
|
||||
break; // don't need to continue j loop
|
||||
}
|
||||
@ -223,41 +226,41 @@ 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];
|
||||
if(gmap[i]<0) // this particle was filtered out
|
||||
if (gmap[i]<0) // this particle was filtered out
|
||||
continue;
|
||||
if(spin[i]==0) // this is an ion
|
||||
if (spin[i]==0) // this is an ion
|
||||
gmap[i]=wpmd->add_ion(q[i], Vector_3(x[i][0],x[i][1],x[i][2]),i<nlocal ? atom->tag[i] : -atom->tag[i]);
|
||||
else if(spin[i]==1 || spin[i]==-1){ // electron, sort them according to the tag
|
||||
else if (spin[i]==1 || spin[i]==-1) { // electron, sort them according to the tag
|
||||
etmap[etag[i]].push_back(i);
|
||||
}
|
||||
else
|
||||
error->all(FLERR,fmt("Invalid spin value (%d) for particle %d !",spin[i],i));
|
||||
error->all(FLERR,logfmt("Invalid spin value (%d) for particle %d !",spin[i],i));
|
||||
}
|
||||
// ion force vector
|
||||
Vector_3 *fi=NULL;
|
||||
if(wpmd->ni)
|
||||
Vector_3 *fi=nullptr;
|
||||
if (wpmd->ni)
|
||||
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;
|
||||
if(!el.size()) // should not happen
|
||||
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;
|
||||
wpmd->add_electron(s); // starts adding the spits
|
||||
for(size_t k=0;k<el.size();k++){
|
||||
for (size_t k=0;k<el.size();k++) {
|
||||
int i=el[k];
|
||||
if(spin[el[0]]!=spin[i])
|
||||
error->all(FLERR,fmt("WP splits for one electron should have the same spin (at particles %d, %d)!",el[0],i));
|
||||
if (spin[el[0]]!=spin[i])
|
||||
error->all(FLERR,logfmt("WP splits for one electron should have the same spin (at particles %d, %d)!",el[0],i));
|
||||
double m= atom->mass ? atom->mass[type[i]] : force->e_mass;
|
||||
Vector_3 xx=Vector_3(x[i][0],x[i][1],x[i][2]);
|
||||
Vector_3 rv=m*Vector_3(v[i][0],v[i][1],v[i][2]);
|
||||
double pv=ermscale*m*atom->ervel[i];
|
||||
Vector_2 cc=Vector_2(atom->cs[2*i],atom->cs[2*i+1]);
|
||||
Vector_2 cc=Vector_2(atom->cs[i][0],atom->cs[i][1]);
|
||||
gmap[i]=wpmd->add_split(xx,rv,atom->eradius[i],pv,cc,1.,atom->q[i],i<nlocal ? atom->tag[i] : -atom->tag[i]);
|
||||
// resetting for the case constraints were applied
|
||||
v[i][0]=rv[0]/m;
|
||||
@ -266,13 +269,13 @@ void PairAWPMDCut::compute(int eflag, int vflag)
|
||||
atom->ervel[i]=pv/(m*ermscale);
|
||||
}
|
||||
}
|
||||
wpmd->set_pbc(NULL); // not required for LAMMPS
|
||||
wpmd->set_pbc(nullptr); // not required for LAMMPS
|
||||
wpmd->interaction(0x1|0x4|0x10,fi);
|
||||
|
||||
// get forces from the AWPMD solver object
|
||||
for (int ii = 0; ii < inum; ii++) {
|
||||
int i = ilist[ii];
|
||||
if(gmap[i]<0) // this particle was filtered out
|
||||
if (gmap[i]<0) // this particle was filtered out
|
||||
continue;
|
||||
if (spin[i]==0) { // this is an ion, copying forces
|
||||
int ion=gmap[i];
|
||||
@ -282,16 +285,16 @@ void PairAWPMDCut::compute(int eflag, int vflag)
|
||||
} else { // electron
|
||||
int iel=gmap[i];
|
||||
int s=spin[i] >0 ? 0 : 1;
|
||||
wpmd->get_wp_force(s,iel,(Vector_3 *)f[i],(Vector_3 *)(atom->vforce+3*i),atom->erforce+i,atom->ervelforce+i,(Vector_2 *)(atom->csforce+2*i));
|
||||
wpmd->get_wp_force(s,iel,(Vector_3 *)f[i],(Vector_3 *)(atom->vforce[i]),atom->erforce+i,atom->ervelforce+i,(Vector_2 *)(atom->csforce[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if(fi)
|
||||
if (fi)
|
||||
delete [] fi;
|
||||
|
||||
// update LAMMPS energy
|
||||
if (eflag_either) {
|
||||
if (eflag_global){
|
||||
if (eflag_global) {
|
||||
eng_coul+= wpmd->get_energy();
|
||||
// pvector = [KE, Pauli, ecoul, radial_restraint]
|
||||
pvector[0] = wpmd->Ee[0]+wpmd->Ee[1];
|
||||
@ -402,54 +405,54 @@ void PairAWPMDCut::allocate()
|
||||
// [flex_press] -- set flexible pressure flag
|
||||
// -1 for length means default setting (L/2 for cutoff and L for width PBC)
|
||||
|
||||
void PairAWPMDCut::settings(int narg, char **arg){
|
||||
void PairAWPMDCut::settings(int narg, char **arg) {
|
||||
if (narg < 1) error->all(FLERR,"Illegal pair_style command");
|
||||
|
||||
cut_global = force->numeric(FLERR,arg[0]);
|
||||
cut_global = utils::numeric(FLERR,arg[0],false,lmp);
|
||||
|
||||
ermscale=1.;
|
||||
width_pbc=0.;
|
||||
|
||||
for(int i=1;i<narg;i++){
|
||||
for (int i=1;i<narg;i++) {
|
||||
// reading commands
|
||||
if(!strcmp(arg[i],"hartree"))
|
||||
if (!strcmp(arg[i],"hartree"))
|
||||
wpmd->approx=AWPMD::HARTREE;
|
||||
else if(!strcmp(arg[i],"dproduct"))
|
||||
else if (!strcmp(arg[i],"dproduct"))
|
||||
wpmd->approx=AWPMD::DPRODUCT;
|
||||
else if(!strcmp(arg[i],"uhf"))
|
||||
else if (!strcmp(arg[i],"uhf"))
|
||||
wpmd->approx=AWPMD::UHF;
|
||||
else if(!strcmp(arg[i],"free"))
|
||||
else if (!strcmp(arg[i],"free"))
|
||||
wpmd->constraint=AWPMD::NONE;
|
||||
else if(!strcmp(arg[i],"fix")){
|
||||
else if (!strcmp(arg[i],"fix")) {
|
||||
wpmd->constraint=AWPMD::FIX;
|
||||
i++;
|
||||
if(i>=narg)
|
||||
if (i>=narg)
|
||||
error->all(FLERR,"Setting 'fix' should be followed by a number in awpmd/cut");
|
||||
wpmd->w0=force->numeric(FLERR,arg[i]);
|
||||
wpmd->w0=utils::numeric(FLERR,arg[i],false,lmp);
|
||||
}
|
||||
else if(!strcmp(arg[i],"harm")){
|
||||
else if (!strcmp(arg[i],"harm")) {
|
||||
wpmd->constraint=AWPMD::HARM;
|
||||
i++;
|
||||
if(i>=narg)
|
||||
if (i>=narg)
|
||||
error->all(FLERR,"Setting 'harm' should be followed by a number in awpmd/cut");
|
||||
wpmd->w0=force->numeric(FLERR,arg[i]);
|
||||
wpmd->w0=utils::numeric(FLERR,arg[i],false,lmp);
|
||||
wpmd->set_harm_constr(wpmd->w0);
|
||||
}
|
||||
else if(!strcmp(arg[i],"pbc")){
|
||||
else if (!strcmp(arg[i],"pbc")) {
|
||||
i++;
|
||||
if(i>=narg)
|
||||
if (i>=narg)
|
||||
error->all(FLERR,"Setting 'pbc' should be followed by a number in awpmd/cut");
|
||||
width_pbc=force->numeric(FLERR,arg[i]);
|
||||
width_pbc=utils::numeric(FLERR,arg[i],false,lmp);
|
||||
}
|
||||
else if(!strcmp(arg[i],"relax"))
|
||||
else if (!strcmp(arg[i],"relax"))
|
||||
wpmd->constraint=AWPMD::RELAX;
|
||||
else if(!strcmp(arg[i],"ermscale")){
|
||||
else if (!strcmp(arg[i],"ermscale")) {
|
||||
i++;
|
||||
if(i>=narg)
|
||||
if (i>=narg)
|
||||
error->all(FLERR,"Setting 'ermscale' should be followed by a number in awpmd/cut");
|
||||
ermscale=force->numeric(FLERR,arg[i]);
|
||||
ermscale=utils::numeric(FLERR,arg[i],false,lmp);
|
||||
}
|
||||
else if(!strcmp(arg[i],"flex_press"))
|
||||
else if (!strcmp(arg[i],"flex_press"))
|
||||
flexible_pressure_flag = 1;
|
||||
}
|
||||
}
|
||||
@ -469,7 +472,7 @@ void PairAWPMDCut::coeff(int narg, char **arg)
|
||||
double delz = domain->boxhi[2]-domain->boxlo[2];
|
||||
half_box_length = 0.5 * MIN(delx, MIN(dely, delz));
|
||||
//}
|
||||
if(cut_global<0)
|
||||
if (cut_global<0)
|
||||
cut_global=half_box_length;
|
||||
|
||||
if (!allocated) {
|
||||
@ -482,11 +485,11 @@ void PairAWPMDCut::coeff(int narg, char **arg)
|
||||
}
|
||||
|
||||
int ilo,ihi,jlo,jhi;
|
||||
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
|
||||
force->bounds(FLERR,arg[1],atom->ntypes,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 cut_one = cut_global;
|
||||
if (narg == 3) cut_one = force->numeric(FLERR,arg[2]);
|
||||
if (narg == 3) cut_one = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
@ -514,7 +517,7 @@ void PairAWPMDCut::init_style()
|
||||
"q, spin, eradius, erforce");
|
||||
|
||||
/*
|
||||
if(vflag_atom){ // can't compute virial per atom
|
||||
if (vflag_atom) { // can't compute virial per atom
|
||||
//warning->
|
||||
error->all(FLERR,"Pair style awpmd can't compute per atom virials");
|
||||
}*/
|
||||
@ -547,7 +550,7 @@ void PairAWPMDCut::init_style()
|
||||
int irequest = neighbor->request(this,instance_me);
|
||||
neighbor->requests[irequest]->newton = 2;
|
||||
|
||||
if(force->e_mass==0. || force->hhmrr2e==0. || force->mvh2r==0.)
|
||||
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");
|
||||
|
||||
wpmd->me=force->e_mass;
|
||||
@ -599,10 +602,10 @@ void PairAWPMDCut::read_restart(FILE *fp)
|
||||
int me = comm->me;
|
||||
for (i = 1; i <= atom->ntypes; i++)
|
||||
for (j = i; j <= atom->ntypes; j++) {
|
||||
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp);
|
||||
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) fread(&cut[i][j],sizeof(double),1,fp);
|
||||
if (me == 0) utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,nullptr,error);
|
||||
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
|
||||
}
|
||||
}
|
||||
@ -626,9 +629,9 @@ void PairAWPMDCut::write_restart_settings(FILE *fp)
|
||||
void PairAWPMDCut::read_restart_settings(FILE *fp)
|
||||
{
|
||||
if (comm->me == 0) {
|
||||
fread(&cut_global,sizeof(double),1,fp);
|
||||
fread(&offset_flag,sizeof(int),1,fp);
|
||||
fread(&mix_flag,sizeof(int),1,fp);
|
||||
utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,nullptr,error);
|
||||
utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,nullptr,error);
|
||||
}
|
||||
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
|
||||
MPI_Bcast(&offset_flag,1,MPI_INT,0,world);
|
||||
@ -641,7 +644,7 @@ void PairAWPMDCut::read_restart_settings(FILE *fp)
|
||||
these arrays are stored locally by pair style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairAWPMDCut::min_xf_pointers(int ignore, double **xextra, double **fextra)
|
||||
void PairAWPMDCut::min_xf_pointers(int /* ignore */, double **xextra, double **fextra)
|
||||
{
|
||||
// grow arrays if necessary
|
||||
// need to be atom->nmax in length
|
||||
@ -664,16 +667,16 @@ void PairAWPMDCut::min_xf_pointers(int ignore, double **xextra, double **fextra)
|
||||
calculate and store in min_eradius and min_erforce
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairAWPMDCut::min_xf_get(int ignore)
|
||||
void PairAWPMDCut::min_xf_get(int /* ignore */)
|
||||
{
|
||||
double *eradius = atom->eradius;
|
||||
double *erforce = atom->erforce;
|
||||
double **v=atom->v;
|
||||
double *vforce=atom->vforce;
|
||||
double **vforce=atom->vforce;
|
||||
double *ervel=atom->ervel;
|
||||
double *ervelforce=atom->ervelforce;
|
||||
double *cs=atom->cs;
|
||||
double *csforce=atom->csforce;
|
||||
double **cs=atom->cs;
|
||||
double **csforce=atom->csforce;
|
||||
|
||||
int *spin = atom->spin;
|
||||
int nlocal = atom->nlocal;
|
||||
@ -682,19 +685,19 @@ void PairAWPMDCut::min_xf_get(int ignore)
|
||||
if (spin[i]) {
|
||||
min_var[7*i] = log(eradius[i]);
|
||||
min_varforce[7*i] = eradius[i]*erforce[i];
|
||||
for(int j=0;j<3;j++){
|
||||
for (int j=0;j<3;j++) {
|
||||
min_var[7*i+1+3*j] = v[i][j];
|
||||
min_varforce[7*i+1+3*j] = vforce[3*i+j];
|
||||
min_varforce[7*i+1+3*j] = vforce[i][j];
|
||||
}
|
||||
min_var[7*i+4] = ervel[i];
|
||||
min_varforce[7*i+4] = ervelforce[i];
|
||||
min_var[7*i+5] = cs[2*i];
|
||||
min_varforce[7*i+5] = csforce[2*i];
|
||||
min_var[7*i+6] = cs[2*i+1];
|
||||
min_varforce[7*i+6] = csforce[2*i+1];
|
||||
min_var[7*i+5] = cs[i][0];
|
||||
min_varforce[7*i+5] = csforce[i][0];
|
||||
min_var[7*i+6] = cs[i][1];
|
||||
min_varforce[7*i+6] = csforce[i][1];
|
||||
|
||||
} else {
|
||||
for(int j=0;j<7;j++)
|
||||
for (int j=0;j<7;j++)
|
||||
min_var[7*i+j] = min_varforce[7*i+j] = 0.0;
|
||||
}
|
||||
}
|
||||
@ -703,24 +706,24 @@ void PairAWPMDCut::min_xf_get(int ignore)
|
||||
propagate the minimizer values to the atom values
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void PairAWPMDCut::min_x_set(int ignore)
|
||||
void PairAWPMDCut::min_x_set(int /* ignore */)
|
||||
{
|
||||
double *eradius = atom->eradius;
|
||||
double **v=atom->v;
|
||||
double *ervel=atom->ervel;
|
||||
double *cs=atom->cs;
|
||||
double **cs=atom->cs;
|
||||
|
||||
int *spin = atom->spin;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (spin[i]){
|
||||
if (spin[i]) {
|
||||
eradius[i]=exp(min_var[7*i]);
|
||||
for(int j=0;j<3;j++)
|
||||
for (int j=0;j<3;j++)
|
||||
v[i][j]=min_var[7*i+1+3*j];
|
||||
ervel[i]=min_var[7*i+4];
|
||||
cs[2*i]=min_var[7*i+5];
|
||||
cs[2*i+1]=min_var[7*i+6];
|
||||
cs[i][0]=min_var[7*i+5];
|
||||
cs[i][1]=min_var[7*i+6];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -731,8 +734,8 @@ void PairAWPMDCut::min_x_set(int ignore)
|
||||
|
||||
double PairAWPMDCut::memory_usage()
|
||||
{
|
||||
double bytes = maxeatom * sizeof(double);
|
||||
bytes += maxvatom*6 * sizeof(double);
|
||||
bytes += 2 * nmax * sizeof(double);
|
||||
double bytes = (double)maxeatom * sizeof(double);
|
||||
bytes += (double)maxvatom*6 * sizeof(double);
|
||||
bytes += (double)2 * nmax * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
@ -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,14 +25,13 @@ 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();
|
||||
@ -54,28 +52,24 @@ class PairAWPMDCut : public Pair {
|
||||
double memory_usage();
|
||||
|
||||
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
|
||||
@ -1,13 +1,13 @@
|
||||
This user package implements the pressure correction to the barostat as
|
||||
This user package implements the pressure correction to the barostat as
|
||||
outlined in:
|
||||
|
||||
N. J. H. Dunn and W. G. Noid, "Bottom-up coarse-grained models that
|
||||
N. J. H. Dunn and W. G. Noid, "Bottom-up coarse-grained models that
|
||||
accurately describe the structure, pressure, and compressibility of
|
||||
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.
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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,28 +11,28 @@
|
||||
|
||||
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 <mpi.h>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include "compute_pressure_bocs.h"
|
||||
|
||||
#include "angle.h"
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "bond.h"
|
||||
#include "dihedral.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include "force.h"
|
||||
#include "pair.h"
|
||||
#include "bond.h"
|
||||
#include "angle.h"
|
||||
#include "dihedral.h"
|
||||
#include "improper.h"
|
||||
#include "kspace.h"
|
||||
#include "error.h"
|
||||
#include "modify.h"
|
||||
#include "pair.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -39,7 +40,7 @@ using namespace LAMMPS_NS;
|
||||
|
||||
ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg),
|
||||
vptr(NULL), id_temp(NULL)
|
||||
vptr(nullptr), id_temp(nullptr)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR,"Illegal compute pressure/bocs command");
|
||||
if (igroup) error->all(FLERR,"Compute pressure/bocs must use group all");
|
||||
@ -52,16 +53,14 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
timeflag = 1;
|
||||
|
||||
p_match_flag = 0;
|
||||
phi_coeff = NULL;
|
||||
phi_coeff = nullptr;
|
||||
|
||||
// store temperature ID used by pressure computation
|
||||
// insure it is valid for temperature computation
|
||||
|
||||
if (strcmp(arg[3],"NULL") == 0) id_temp = NULL;
|
||||
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)
|
||||
@ -104,13 +103,16 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// error check
|
||||
|
||||
if (keflag && id_temp == NULL)
|
||||
if (keflag && id_temp == nullptr)
|
||||
error->all(FLERR,"Compute pressure/bocs requires temperature ID "
|
||||
"to include kinetic energy");
|
||||
"to include kinetic energy");
|
||||
|
||||
vector = new double[6];
|
||||
vector = new double[size_vector];
|
||||
nvirial = 0;
|
||||
vptr = NULL;
|
||||
vptr = nullptr;
|
||||
|
||||
splines = nullptr;
|
||||
spline_length = 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -146,16 +148,21 @@ void ComputePressureBocs::init()
|
||||
|
||||
delete [] vptr;
|
||||
nvirial = 0;
|
||||
vptr = NULL;
|
||||
vptr = nullptr;
|
||||
|
||||
if (pairflag && force->pair) nvirial++;
|
||||
if (bondflag && atom->molecular && force->bond) nvirial++;
|
||||
if (angleflag && atom->molecular && force->angle) nvirial++;
|
||||
if (dihedralflag && atom->molecular && force->dihedral) nvirial++;
|
||||
if (improperflag && atom->molecular && force->improper) nvirial++;
|
||||
if (fixflag)
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (modify->fix[i]->virial_flag) nvirial++;
|
||||
if (atom->molecular != Atom::ATOMIC) {
|
||||
if (bondflag && force->bond) nvirial++;
|
||||
if (angleflag && force->angle) nvirial++;
|
||||
if (dihedralflag && force->dihedral) nvirial++;
|
||||
if (improperflag && force->improper) nvirial++;
|
||||
}
|
||||
if (fixflag) {
|
||||
Fix **fix = modify->fix;
|
||||
int nfix = modify->nfix;
|
||||
for (int i = 0; i < nfix; i++)
|
||||
if (fix[i]->thermo_virial) nvirial++;
|
||||
}
|
||||
|
||||
if (nvirial) {
|
||||
vptr = new double*[nvirial];
|
||||
@ -169,36 +176,34 @@ void ComputePressureBocs::init()
|
||||
vptr[nvirial++] = force->improper->virial;
|
||||
if (fixflag)
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (modify->fix[i]->virial_flag)
|
||||
if (modify->fix[i]->virial_global_flag && modify->fix[i]->thermo_virial)
|
||||
vptr[nvirial++] = modify->fix[i]->virial;
|
||||
}
|
||||
|
||||
// flag Kspace contribution separately, since not summed across procs
|
||||
|
||||
if (kspaceflag && force->kspace) kspace_virial = force->kspace->virial;
|
||||
else kspace_virial = NULL;
|
||||
else kspace_virial = nullptr;
|
||||
}
|
||||
|
||||
/* Extra functions added for BOCS */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Compute the pressure correction for the analytical basis set
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double ComputePressureBocs::get_cg_p_corr(int N_basis, double *phi_coeff,
|
||||
int N_mol, double vavg, double vCG)
|
||||
{
|
||||
double correction = 0.0;
|
||||
for (int i = 1; i <= N_basis; ++i)
|
||||
{
|
||||
correction -= phi_coeff[i-1] * ( N_mol * i / vavg ) *
|
||||
pow( ( 1 / vavg ) * ( vCG - vavg ),i-1);
|
||||
}
|
||||
pow( ( 1 / vavg ) * ( vCG - vavg ),i-1);
|
||||
return correction;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Find the relevant index position if using a spline basis set
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double ComputePressureBocs::find_index(double * grid, double value)
|
||||
{
|
||||
int i;
|
||||
@ -211,13 +216,11 @@ double ComputePressureBocs::find_index(double * grid, double value)
|
||||
|
||||
if (value >= grid[i] && value <= (grid[i] + spacing)) { return i; }
|
||||
|
||||
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]);
|
||||
}
|
||||
char * errmsg = (char *) calloc(100,sizeof(char));
|
||||
sprintf(errmsg,"Value %f does not fall within spline grid.\n",value);
|
||||
error->all(FLERR,errmsg);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
@ -227,17 +230,17 @@ double ComputePressureBocs::find_index(double * grid, double value)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double ComputePressureBocs::get_cg_p_corr(double ** grid, int basis_type,
|
||||
double vCG)
|
||||
double vCG)
|
||||
{
|
||||
int i = find_index(grid[0],vCG);
|
||||
double correction, deltax = vCG - grid[0][i];
|
||||
|
||||
if (basis_type == 1)
|
||||
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] );
|
||||
}
|
||||
else if (basis_type == 2)
|
||||
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));
|
||||
@ -253,10 +256,12 @@ double ComputePressureBocs::get_cg_p_corr(double ** grid, int basis_type,
|
||||
send cg info from fix_bocs to compute_pressure_bocs for the analytical
|
||||
basis set
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputePressureBocs::send_cg_info(int basis_type, int sent_N_basis,
|
||||
double *sent_phi_coeff, int sent_N_mol, double sent_vavg)
|
||||
double *sent_phi_coeff, int sent_N_mol,
|
||||
double sent_vavg)
|
||||
{
|
||||
if (basis_type == 0) { p_basis_type = 0; }
|
||||
if (basis_type == BASIS_ANALYTIC) { p_basis_type = BASIS_ANALYTIC; }
|
||||
else
|
||||
{
|
||||
error->all(FLERR,"Incorrect basis type passed to ComputePressureBocs\n");
|
||||
@ -277,11 +282,12 @@ void ComputePressureBocs::send_cg_info(int basis_type, int sent_N_basis,
|
||||
send cg info from fix_bocs to compute_pressure_bocs for a spline basis
|
||||
set
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputePressureBocs::send_cg_info(int basis_type,
|
||||
double ** in_splines, int gridsize)
|
||||
double ** in_splines, int gridsize)
|
||||
{
|
||||
if (basis_type == 1) { p_basis_type = 1; }
|
||||
else if (basis_type == 2) { p_basis_type = 2; }
|
||||
if (basis_type == BASIS_LINEAR_SPLINE) { p_basis_type = BASIS_LINEAR_SPLINE; }
|
||||
else if (basis_type == BASIS_CUBIC_SPLINE) { p_basis_type = BASIS_CUBIC_SPLINE; }
|
||||
else
|
||||
{
|
||||
error->all(FLERR,"Incorrect basis type passed to ComputePressureBocs\n");
|
||||
@ -296,6 +302,7 @@ void ComputePressureBocs::send_cg_info(int basis_type,
|
||||
/* ----------------------------------------------------------------------
|
||||
compute total pressure, averaged over Pxx, Pyy, Pzz
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double ComputePressureBocs::compute_scalar()
|
||||
{
|
||||
invoked_scalar = update->ntimestep;
|
||||
@ -317,11 +324,11 @@ double ComputePressureBocs::compute_scalar()
|
||||
volume = (domain->xprd * domain->yprd * domain->zprd);
|
||||
|
||||
/* MRD NJD if block */
|
||||
if ( p_basis_type == 0 )
|
||||
if (p_basis_type == BASIS_ANALYTIC)
|
||||
{
|
||||
correction = get_cg_p_corr(N_basis,phi_coeff,N_mol,vavg,volume);
|
||||
}
|
||||
else if ( p_basis_type == 1 || p_basis_type == 2 )
|
||||
else if (p_basis_type == BASIS_LINEAR_SPLINE || p_basis_type == BASIS_CUBIC_SPLINE)
|
||||
{
|
||||
correction = get_cg_p_corr(splines, p_basis_type, volume);
|
||||
}
|
||||
@ -365,7 +372,7 @@ void ComputePressureBocs::compute_vector()
|
||||
|
||||
if (force->kspace && kspace_virial && force->kspace->scalar_pressure_flag)
|
||||
error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' for "
|
||||
"tensor components with kspace_style msm");
|
||||
"tensor components with kspace_style msm");
|
||||
|
||||
// invoke temperature if it hasn't been already
|
||||
|
||||
@ -438,7 +445,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);
|
||||
}
|
||||
@ -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,23 +10,30 @@
|
||||
|
||||
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
|
||||
|
||||
// ComputePressure -> ComputePressureBocs MRD NJD
|
||||
class ComputePressureBocs : public Compute {
|
||||
public:
|
||||
@ -40,36 +47,36 @@ class ComputePressureBocs : public Compute {
|
||||
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
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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,39 +11,38 @@
|
||||
|
||||
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 <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include "fix_bocs.h"
|
||||
#include "math_extra.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "citeme.h"
|
||||
#include "comm.h"
|
||||
#include "compute.h"
|
||||
#include "compute_pressure_bocs.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "fix_deform.h"
|
||||
#include "force.h"
|
||||
#include "group.h"
|
||||
#include "comm.h"
|
||||
#include "neighbor.h"
|
||||
#include "irregular.h"
|
||||
#include "modify.h"
|
||||
#include "fix_deform.h"
|
||||
#include "compute.h"
|
||||
#include "kspace.h"
|
||||
#include "update.h"
|
||||
#include "respa.h"
|
||||
#include "domain.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "citeme.h"
|
||||
#include "modify.h"
|
||||
#include "neighbor.h"
|
||||
#include "respa.h"
|
||||
#include "update.h"
|
||||
|
||||
#include "compute_pressure_bocs.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"
|
||||
@ -60,16 +60,19 @@ enum{NOBIAS,BIAS};
|
||||
enum{NONE,XYZ,XY,YZ,XZ};
|
||||
enum{ISO,ANISO,TRICLINIC};
|
||||
|
||||
const int NUM_INPUT_DATA_COLUMNS = 2; // columns in the pressure correction file
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
NVT,NPH,NPT integrators for improved Nose-Hoover equations of motion
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg),
|
||||
rfix(NULL), id_dilate(NULL), irregular(NULL), id_temp(NULL), id_press(NULL),
|
||||
eta(NULL), eta_dot(NULL), eta_dotdot(NULL),
|
||||
eta_mass(NULL), etap(NULL), etap_dot(NULL), etap_dotdot(NULL),
|
||||
etap_mass(NULL)
|
||||
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)
|
||||
{
|
||||
if (lmp->citeme) lmp->citeme->add(cite_user_bocs_package);
|
||||
|
||||
@ -83,13 +86,14 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
global_freq = 1;
|
||||
extscalar = 1;
|
||||
extvector = 0;
|
||||
ecouple_flag = 1;
|
||||
|
||||
// default values
|
||||
|
||||
pcouple = NONE;
|
||||
drag = 0.0;
|
||||
allremap = 1;
|
||||
id_dilate = NULL;
|
||||
id_dilate = nullptr;
|
||||
mtchain = mpchain = 3;
|
||||
nc_tchain = nc_pchain = 1;
|
||||
mtk_flag = 1;
|
||||
@ -104,10 +108,13 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
tcomputeflag = 0;
|
||||
pcomputeflag = 0;
|
||||
id_temp = NULL;
|
||||
id_press = NULL;
|
||||
id_temp = nullptr;
|
||||
id_press = nullptr;
|
||||
|
||||
p_match_coeffs = NULL;
|
||||
p_match_coeffs = nullptr;
|
||||
|
||||
splines = nullptr;
|
||||
spline_length = 0;
|
||||
|
||||
// turn on tilt factor scaling, whenever applicable
|
||||
|
||||
@ -147,10 +154,10 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (strcmp(arg[iarg],"temp") == 0) {
|
||||
if (iarg+4 > narg) error->all(FLERR,"Illegal fix bocs command");
|
||||
tstat_flag = 1;
|
||||
t_start = force->numeric(FLERR,arg[iarg+1]);
|
||||
t_start = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||
t_target = t_start;
|
||||
t_stop = force->numeric(FLERR,arg[iarg+2]);
|
||||
t_period = force->numeric(FLERR,arg[iarg+3]);
|
||||
t_stop = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
t_period = utils::numeric(FLERR,arg[iarg+3],false,lmp);
|
||||
if (t_start <= 0.0 || t_stop <= 0.0)
|
||||
error->all(FLERR,
|
||||
"Target temperature for fix bocs cannot be 0.0");
|
||||
@ -165,11 +172,11 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
p_match_flag = 1;
|
||||
pcouple = XYZ;
|
||||
p_start[0] = p_start[1] = p_start[2] =
|
||||
force->numeric(FLERR,arg[iarg+1]);
|
||||
utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||
p_stop[0] = p_stop[1] = p_stop[2] =
|
||||
force->numeric(FLERR,arg[iarg+2]);
|
||||
utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
p_period[0] = p_period[1] = p_period[2] =
|
||||
force->numeric(FLERR,arg[iarg+3]);
|
||||
utils::numeric(FLERR,arg[iarg+3],false,lmp);
|
||||
|
||||
p_flag[0] = p_flag[1] = p_flag[2] = 1;
|
||||
p_flag[3] = p_flag[4] = p_flag[5] = 0; // MRD
|
||||
@ -179,72 +186,68 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
}
|
||||
iarg += 4;
|
||||
|
||||
if ( strcmp(arg[iarg], "analytic") == 0 ) {
|
||||
if (strcmp(arg[iarg], "analytic") == 0) {
|
||||
if (iarg + 4 > narg) {
|
||||
error->all(FLERR,"Illegal fix bocs command. basis type analytic"
|
||||
error->all(FLERR,"Illegal fix bocs command. Basis type analytic"
|
||||
" must be followed by: avg_vol n_mol n_pmatch_coeff");
|
||||
}
|
||||
p_basis_type = 0;
|
||||
vavg = force->numeric(FLERR,arg[iarg+1]);
|
||||
N_mol = force->inumeric(FLERR,arg[iarg+2]);
|
||||
N_p_match = force->inumeric(FLERR,arg[iarg+3]);
|
||||
p_basis_type = BASIS_ANALYTIC;
|
||||
vavg = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||
N_mol = utils::inumeric(FLERR,arg[iarg+2],false,lmp);
|
||||
N_p_match = utils::inumeric(FLERR,arg[iarg+3],false,lmp);
|
||||
p_match_coeffs = (double *) (calloc(N_p_match, sizeof(double)) );
|
||||
iarg += 4;
|
||||
if (iarg + N_p_match > narg)
|
||||
error->all(FLERR,"Illegal fix bocs command. Missing coeffs.");
|
||||
for (int pmatchi = 0; pmatchi < N_p_match; pmatchi++)
|
||||
p_match_coeffs[pmatchi] = force->numeric(FLERR,arg[iarg+pmatchi]);
|
||||
p_match_coeffs[pmatchi] = utils::numeric(FLERR,arg[iarg+pmatchi],false,lmp);
|
||||
iarg += (N_p_match);
|
||||
} else if (strcmp(arg[iarg], "linear_spline") == 0 ) {
|
||||
} else if (strcmp(arg[iarg], "linear_spline") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command. "
|
||||
"Supply a file name after linear_spline.");
|
||||
p_basis_type = 1;
|
||||
p_basis_type = BASIS_LINEAR_SPLINE;
|
||||
spline_length = read_F_table( arg[iarg+1], p_basis_type );
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg], "cubic_spline") == 0 ) {
|
||||
} else if (strcmp(arg[iarg], "cubic_spline") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command. "
|
||||
"Supply a file name after cubic_spline.");
|
||||
p_basis_type = 2;
|
||||
p_basis_type = BASIS_CUBIC_SPLINE;
|
||||
spline_length = read_F_table( arg[iarg+1], p_basis_type );
|
||||
iarg += 2;
|
||||
} else {
|
||||
char errmsg[256];
|
||||
snprintf(errmsg,256,"CG basis type %s is not recognized\nSupported "
|
||||
"basis types: analytic linear_spline cubic_spline",arg[iarg]);
|
||||
std::string errmsg = fmt::format("CG basis type {} is not recognized\nSupported "
|
||||
"basis types: analytic linear_spline cubic_spline",arg[iarg]);
|
||||
error->all(FLERR,errmsg);
|
||||
} // END NJD MRD
|
||||
} else if (strcmp(arg[iarg],"tchain") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command");
|
||||
mtchain = force->inumeric(FLERR,arg[iarg+1]);
|
||||
mtchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||
// used by FixNVTSllod to preserve non-default value
|
||||
mtchain_default_flag = 0;
|
||||
if (mtchain < 1) error->all(FLERR,"Illegal fix bocs command");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"pchain") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command");
|
||||
mpchain = force->inumeric(FLERR,arg[iarg+1]);
|
||||
mpchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||
if (mpchain < 0) error->all(FLERR,"Illegal fix bocs command");
|
||||
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");
|
||||
nc_tchain = force->inumeric(FLERR,arg[iarg+1]);
|
||||
nc_tchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||
if (nc_tchain < 0) error->all(FLERR,"Illegal fix bocs command");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"ploop") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command");
|
||||
nc_pchain = force->inumeric(FLERR,arg[iarg+1]);
|
||||
nc_pchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||
if (nc_pchain < 0) error->all(FLERR,"Illegal fix bocs command");
|
||||
iarg += 2;
|
||||
} else {
|
||||
char errmsg[128];
|
||||
snprintf(errmsg,128,"Illegal fix bocs command: unrecognized keyword %s"
|
||||
,arg[iarg]);
|
||||
std::string errmsg = fmt::format("Illegal fix bocs command: unrecognized keyword {}",
|
||||
arg[iarg]);
|
||||
error->all(FLERR,errmsg);
|
||||
}
|
||||
}
|
||||
@ -290,8 +293,12 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (p_flag[i]) pstat_flag = 1;
|
||||
|
||||
if (pstat_flag) {
|
||||
if (p_flag[0] || p_flag[1] || p_flag[2]) box_change_size = 1;
|
||||
if (p_flag[3] || p_flag[4] || p_flag[5]) box_change_shape = 1;
|
||||
if (p_flag[0]) box_change |= BOX_CHANGE_X;
|
||||
if (p_flag[1]) box_change |= BOX_CHANGE_Y;
|
||||
if (p_flag[2]) box_change |= BOX_CHANGE_Z;
|
||||
if (p_flag[3]) box_change |= BOX_CHANGE_YZ;
|
||||
if (p_flag[4]) box_change |= BOX_CHANGE_XZ;
|
||||
if (p_flag[5]) box_change |= BOX_CHANGE_XY;
|
||||
no_change_box = 1;
|
||||
if (allremap == 0) restart_pbc = 1;
|
||||
|
||||
@ -300,10 +307,10 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
// pre_exchange only required if flips can occur due to shape changes
|
||||
|
||||
if (flipflag && (p_flag[3] || p_flag[4] || p_flag[5]))
|
||||
pre_exchange_flag = 1;
|
||||
pre_exchange_flag = pre_exchange_migrate = 1;
|
||||
if (flipflag && (domain->yz != 0.0 || domain->xz != 0.0 ||
|
||||
domain->xy != 0.0))
|
||||
pre_exchange_flag = 1;
|
||||
pre_exchange_flag = pre_exchange_migrate = 1;
|
||||
}
|
||||
|
||||
// convert input periods to frequencies
|
||||
@ -371,10 +378,10 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) :
|
||||
}
|
||||
|
||||
nrigid = 0;
|
||||
rfix = NULL;
|
||||
rfix = nullptr;
|
||||
|
||||
if (pre_exchange_flag) irregular = new Irregular(lmp);
|
||||
else irregular = NULL;
|
||||
else irregular = nullptr;
|
||||
|
||||
// initialize vol0,t0 to zero to signal uninitialized
|
||||
// values then assigned in init(), if necessary
|
||||
@ -393,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~*/
|
||||
@ -465,6 +450,12 @@ FixBocs::~FixBocs()
|
||||
}
|
||||
}
|
||||
if (p_match_coeffs) free(p_match_coeffs);
|
||||
|
||||
// Free splines memory structure
|
||||
if (splines != nullptr) {
|
||||
memory->destroy(splines);
|
||||
spline_length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -474,7 +465,6 @@ int FixBocs::setmask()
|
||||
int mask = 0;
|
||||
mask |= INITIAL_INTEGRATE;
|
||||
mask |= FINAL_INTEGRATE;
|
||||
mask |= THERMO_ENERGY;
|
||||
mask |= INITIAL_INTEGRATE_RESPA;
|
||||
mask |= FINAL_INTEGRATE_RESPA;
|
||||
if (pre_exchange_flag) mask |= PRE_EXCHANGE;
|
||||
@ -531,12 +521,12 @@ void FixBocs::init()
|
||||
{
|
||||
if (pressure)
|
||||
{
|
||||
if (p_basis_type == 0)
|
||||
if (p_basis_type == BASIS_ANALYTIC)
|
||||
{
|
||||
((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type,
|
||||
N_p_match, p_match_coeffs, N_mol, vavg);
|
||||
}
|
||||
else if ( p_basis_type == 1 || p_basis_type == 2 )
|
||||
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);
|
||||
@ -598,7 +588,7 @@ void FixBocs::init()
|
||||
if (force->kspace) kspace_flag = 1;
|
||||
else kspace_flag = 0;
|
||||
|
||||
if (strstr(update->integrate_style,"respa")) {
|
||||
if (utils::strmatch(update->integrate_style,"^respa")) {
|
||||
nlevels_respa = ((Respa *) update->integrate)->nlevels;
|
||||
step_respa = ((Respa *) update->integrate)->step;
|
||||
dto = 0.5*step_respa[0];
|
||||
@ -609,7 +599,7 @@ void FixBocs::init()
|
||||
|
||||
delete [] rfix;
|
||||
nrigid = 0;
|
||||
rfix = NULL;
|
||||
rfix = nullptr;
|
||||
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (modify->fix[i]->rigid_flag) nrigid++;
|
||||
@ -624,112 +614,181 @@ void FixBocs::init()
|
||||
// NJD MRD 2 functions
|
||||
int FixBocs::read_F_table( char *filename, int p_basis_type )
|
||||
{
|
||||
FILE *fpi;
|
||||
int N_columns = 2, n_entries = 0, i;
|
||||
float f1, f2;
|
||||
int test_sscanf;
|
||||
double **data = (double **) calloc(N_columns,sizeof(double *));
|
||||
char * line = (char *) calloc(200,sizeof(char));
|
||||
|
||||
fpi = fopen(filename,"r");
|
||||
if (fpi)
|
||||
{
|
||||
while (fgets(line,199,fpi)) { ++n_entries; }
|
||||
fclose(fpi);
|
||||
for (i = 0; i < N_columns; ++i)
|
||||
{
|
||||
data[i] = (double *) calloc(n_entries,sizeof(double));
|
||||
}
|
||||
} else {
|
||||
char errmsg[128];
|
||||
snprintf(errmsg,128,"Unable to open file: %s\n",filename);
|
||||
error->all(FLERR,errmsg);
|
||||
}
|
||||
|
||||
n_entries = 0;
|
||||
fpi = fopen(filename,"r");
|
||||
std::string message;
|
||||
double **data;
|
||||
bool badInput = false;
|
||||
int numEntries = 0;
|
||||
FILE *fpi = fopen(filename,"r");
|
||||
if (fpi) {
|
||||
while( fgets(line,199,fpi)) {
|
||||
++n_entries;
|
||||
test_sscanf = sscanf(line," %f , %f ",&f1, &f2);
|
||||
// Old code read the input file twice. Now we simply
|
||||
// read all the lines from the input file into a string vector,
|
||||
// then work with the data in-memory rather than do a second pass
|
||||
// through the file.
|
||||
// NB: LAMMPS coding guidelines prefer cstdio so we are intentionally
|
||||
// foregoing reading with getline
|
||||
if (comm->me == 0) {
|
||||
error->message(FLERR, "INFO: About to read data file: {}", filename);
|
||||
}
|
||||
|
||||
// Data file lines hold two floating point numbers.
|
||||
// Line length we allocate should be long enough without being too long.
|
||||
// 128 seems safe for a line we expect to be < 30 chars.
|
||||
const int MAX_F_TABLE_LINE_LENGTH = 128;
|
||||
char line[MAX_F_TABLE_LINE_LENGTH];
|
||||
std::vector<std::string> inputLines;
|
||||
while (fgets(line, MAX_F_TABLE_LINE_LENGTH, fpi)) {
|
||||
inputLines.emplace_back(line);
|
||||
}
|
||||
fclose(fpi);
|
||||
|
||||
numEntries = inputLines.size();
|
||||
if (comm->me == 0) {
|
||||
error->message(FLERR, "INFO: Read {} lines from file", numEntries);
|
||||
}
|
||||
|
||||
|
||||
// Allocate memory for the two dimensional matrix
|
||||
// that holds data from the input file.
|
||||
memory->create(data, NUM_INPUT_DATA_COLUMNS, numEntries, "data");
|
||||
|
||||
double stdVolumeInterval = 0.0;
|
||||
double currVolumeInterval = 0.0;
|
||||
// When comparing doubles/floats, we need an Epsilon.
|
||||
// The literature indicates getting this value right in the
|
||||
// general case can be pretty complicated. I don't think it
|
||||
// needs to be complicated here, though. At least based on the
|
||||
// sample data I've seen where the volume values are fairly large.
|
||||
const double volumeIntervalTolerance = 0.001;
|
||||
int lineNum = 0; // this value is only for message
|
||||
int numBadVolumeIntervals = 0; // count these for message
|
||||
float f1, f2;
|
||||
int test_sscanf;
|
||||
for (int i = 0; i < (int)inputLines.size(); ++i) {
|
||||
lineNum++; // count each line processed now so lineNum messages can be 1-based
|
||||
test_sscanf = sscanf(inputLines.at(i).c_str()," %f , %f ",&f1, &f2);
|
||||
if (test_sscanf == 2)
|
||||
{
|
||||
data[0][n_entries-1] = (double) f1;
|
||||
data[1][n_entries-1] = (double) 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];
|
||||
}
|
||||
else if (i > 1)
|
||||
{
|
||||
// after second entry, all intervals are validated
|
||||
currVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1];
|
||||
if (fabs(currVolumeInterval - stdVolumeInterval) > volumeIntervalTolerance) {
|
||||
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++;
|
||||
}
|
||||
// no concluding else is intentional: i = 0, first line, no interval to validate
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"WARNING: did not find 2 comma separated values in "
|
||||
"line %d of file %s\n\tline: %s",n_entries,filename,line);
|
||||
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;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char errmsg[128];
|
||||
snprintf(errmsg,128,"Unable to open file: %s\n",filename);
|
||||
error->all(FLERR,errmsg);
|
||||
}
|
||||
fclose(fpi);
|
||||
|
||||
if (p_basis_type == 1)
|
||||
{
|
||||
splines = (double **) calloc(2,sizeof(double *));
|
||||
splines[0] = (double *) calloc(n_entries,sizeof(double));
|
||||
splines[1] = (double *) calloc(n_entries,sizeof(double));
|
||||
int idxa, idxb;
|
||||
for (idxa = 0; idxa < 2; ++idxa)
|
||||
{
|
||||
for (idxb = 0; idxb < n_entries; ++idxb)
|
||||
if (badInput)
|
||||
{
|
||||
splines[idxa][idxb] = data[idxa][idxb];
|
||||
numBadVolumeIntervals++;
|
||||
}
|
||||
}
|
||||
|
||||
if (numBadVolumeIntervals > 0 && comm->me == 0) {
|
||||
error->message(FLERR, "INFO: total number bad volume intervals = {}", numBadVolumeIntervals);
|
||||
}
|
||||
}
|
||||
else if (p_basis_type == 2)
|
||||
else {
|
||||
error->all(FLERR,"ERROR: Unable to open file: {}", filename);
|
||||
}
|
||||
|
||||
if (badInput && comm->me == 0) {
|
||||
error->warning(FLERR,"Bad volume / pressure-correction data: {}\nSee details above", filename);
|
||||
}
|
||||
|
||||
if (p_basis_type == BASIS_LINEAR_SPLINE)
|
||||
{
|
||||
spline_length = n_entries;
|
||||
build_cubic_splines(data);
|
||||
n_entries -= 1;
|
||||
spline_length = numEntries;
|
||||
numEntries = build_linear_splines(data);
|
||||
}
|
||||
else if (p_basis_type == BASIS_CUBIC_SPLINE)
|
||||
{
|
||||
spline_length = numEntries;
|
||||
numEntries = build_cubic_splines(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
char * errmsg = (char *) calloc(70,sizeof(char));
|
||||
sprintf(errmsg,"ERROR: invalid p_basis_type value "
|
||||
"of %d in read_F_table",p_basis_type);
|
||||
error->all(FLERR,errmsg);
|
||||
error->all(FLERR,"ERROR: invalid p_basis_type value of {} in read_F_table", p_basis_type);
|
||||
}
|
||||
return n_entries;
|
||||
|
||||
memory->destroy(data);
|
||||
return numEntries;
|
||||
}
|
||||
|
||||
void FixBocs::build_cubic_splines( double **data )
|
||||
int FixBocs::build_linear_splines(double **data) {
|
||||
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));
|
||||
|
||||
for (int i = 0; i < spline_length; ++i)
|
||||
{
|
||||
splines[VOLUME][i] = data[VOLUME][i];
|
||||
splines[PRESSURE_CORRECTION][i] = data[PRESSURE_CORRECTION][i];
|
||||
}
|
||||
|
||||
if (comm->me == 0) {
|
||||
error->message(FLERR, "INFO: leaving build_linear_splines, spline_length = {}", spline_length);
|
||||
}
|
||||
|
||||
return spline_length;
|
||||
}
|
||||
|
||||
int FixBocs::build_cubic_splines(double **data)
|
||||
{
|
||||
double *a, *b, *d, *h, *alpha, *c, *l, *mu, *z;
|
||||
int n = spline_length;
|
||||
double alpha_i;
|
||||
a = (double *) calloc(n,sizeof(double));
|
||||
b = (double *) calloc(n+1,sizeof(double));
|
||||
d = (double *) calloc(n+1,sizeof(double));
|
||||
h = (double *) calloc(n,sizeof(double));
|
||||
alpha = (double *) calloc(n,sizeof(double));
|
||||
c = (double *) calloc(n+1,sizeof(double));
|
||||
l = (double *) calloc(n,sizeof(double));
|
||||
mu = (double *) calloc(n,sizeof(double));
|
||||
z = (double *) calloc(n,sizeof(double));
|
||||
int idx;
|
||||
double *a, *b, *d, *h, *alpha, *c, *l, *mu, *z;
|
||||
// 2020-07-17 ag:
|
||||
// valgrind says that we read/write a[n] down in the
|
||||
// for (int j=n-1; j>=0; j--) loop below
|
||||
// and I agree.
|
||||
// So the size of a must be n+1, not n as was found
|
||||
// in the original code.
|
||||
memory->create(a, n+1, "a");
|
||||
memory->create(b, n+1, "b");
|
||||
memory->create(c, n+1, "c");
|
||||
memory->create(d, n+1, "d");
|
||||
|
||||
memory->create(h, n, "h");
|
||||
memory->create(alpha, n, "alpha");
|
||||
memory->create(l, n, "l");
|
||||
memory->create(mu, n, "mu");
|
||||
memory->create(z, n, "z");
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
a[i] = data[1][i];
|
||||
b[i] = 0.0;
|
||||
d[i] = 0.0;
|
||||
|
||||
if (i<(n-1))
|
||||
{
|
||||
h[i] = (data[0][i+1] - data[0][i]);
|
||||
}
|
||||
|
||||
double alpha_i;
|
||||
if (i>1 && i<(n-1))
|
||||
{
|
||||
alpha_i = (3.0 / h[i]) * ( data[1][i+1] - data[1][i]) - (3.0 / h[i-1] )
|
||||
* ( data[1][i] - data[1][i-1] );
|
||||
* ( data[1][i] - data[1][i-1] );
|
||||
alpha[i-1] = alpha_i;
|
||||
}
|
||||
}
|
||||
@ -747,11 +806,15 @@ void FixBocs::build_cubic_splines( double **data )
|
||||
mu[n-1] = 0.0;
|
||||
z[n-1] = 0.0;
|
||||
|
||||
c[n] = 0.0;
|
||||
// 2020-07-17 ag: We've been using an uninitialized value for a[n]
|
||||
// That seems like a bad idea. This may not be the right value
|
||||
// but its a value.
|
||||
a[n] = 0.0;
|
||||
b[n] = 0.0;
|
||||
c[n] = 0.0;
|
||||
d[n] = 0.0;
|
||||
|
||||
for(int j=n-1; j>=0; j--)
|
||||
for (int j=n-1; j>=0; j--)
|
||||
{
|
||||
c[j] = z[j] - mu[j]*c[j+1];
|
||||
|
||||
@ -759,21 +822,35 @@ void FixBocs::build_cubic_splines( double **data )
|
||||
|
||||
d[j] = (c[j+1]-c[j])/(3.0 * h[j]);
|
||||
}
|
||||
splines = (double **) calloc(5,sizeof(double *));
|
||||
|
||||
for ( idx = 0; idx < 5; ++idx)
|
||||
{
|
||||
splines[idx] = (double *) calloc(n-1,sizeof(double));
|
||||
}
|
||||
idx = 0;
|
||||
for ( idx = 0; idx < n - 1; ++idx)
|
||||
int numSplines = n - 1;
|
||||
memory->create(splines, NUM_CUBIC_SPLINE_COLUMNS, numSplines, "splines");
|
||||
for (int idx = 0; idx < numSplines; ++idx)
|
||||
{
|
||||
splines[0][idx] = data[0][idx];
|
||||
splines[1][idx] = a[idx];
|
||||
splines[2][idx] = b[idx];
|
||||
splines[3][idx] = c[idx];
|
||||
splines[4][idx] = d[idx];
|
||||
splines[0][idx] = data[0][idx];
|
||||
}
|
||||
|
||||
memory->destroy(a);
|
||||
memory->destroy(b);
|
||||
memory->destroy(c);
|
||||
memory->destroy(d);
|
||||
|
||||
memory->destroy(h);
|
||||
memory->destroy(alpha);
|
||||
memory->destroy(l);
|
||||
memory->destroy(mu);
|
||||
memory->destroy(z);
|
||||
|
||||
if (comm->me == 0) {
|
||||
error->message(FLERR, "INFO: leaving build_cubic_splines, numSplines = {}", numSplines);
|
||||
}
|
||||
|
||||
// Tell the caller how many splines we created
|
||||
return numSplines;
|
||||
}
|
||||
// END NJD MRD 2 functions
|
||||
|
||||
@ -792,7 +869,7 @@ void FixBocs::setup(int /*vflag*/)
|
||||
// If no thermostat or using fix nphug,
|
||||
// t_target must be defined by other means.
|
||||
|
||||
if (tstat_flag && strstr(style,"nphug") == NULL) {
|
||||
if (tstat_flag && strstr(style,"nphug") == nullptr) {
|
||||
compute_temp_target();
|
||||
} else if (pstat_flag) {
|
||||
|
||||
@ -1020,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
|
||||
|
||||
@ -1427,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)
|
||||
@ -1461,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");
|
||||
@ -1471,20 +1549,21 @@ int FixBocs::modify_param(int narg, char **arg)
|
||||
|
||||
if (p_match_flag) // NJD MRD
|
||||
{
|
||||
if ( p_basis_type == 0 )
|
||||
if (p_basis_type == BASIS_ANALYTIC)
|
||||
{
|
||||
((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, N_p_match,
|
||||
p_match_coeffs, N_mol, vavg);
|
||||
}
|
||||
else if ( p_basis_type == 1 || p_basis_type == 2 )
|
||||
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 );
|
||||
((ComputePressureBocs *)pressure)->send_cg_info(p_basis_type, splines, spline_length );
|
||||
}
|
||||
}
|
||||
|
||||
if (pressure->pressflag == 0)
|
||||
error->all(FLERR,"Fix_modify pressure ID does not compute pressure");
|
||||
{
|
||||
error->all(FLERR, "Fix_modify pressure ID does not compute pressure");
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -1755,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)
|
||||
@ -1797,7 +1876,7 @@ void *FixBocs::extract(const char *str, int &dim)
|
||||
} else if (pstat_flag && strcmp(str,"p_target") == 0) {
|
||||
return &p_target;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -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
|
||||
@ -26,124 +25,122 @@ FixStyle(bocs,FixBocs)
|
||||
|
||||
#include "fix.h"
|
||||
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class FixBocs : public Fix {
|
||||
public:
|
||||
FixBocs(class LAMMPS *, int, char **); // MRD NJD
|
||||
virtual ~FixBocs(); // MRD NJD
|
||||
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 pre_force_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 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 &);
|
||||
virtual void *extract(const char *, int &);
|
||||
double memory_usage();
|
||||
|
||||
|
||||
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();
|
||||
@ -151,9 +148,10 @@ class FixBocs : public Fix {
|
||||
void nhc_press_integrate();
|
||||
|
||||
int read_F_table(char *, int);
|
||||
void build_cubic_splines(double **);
|
||||
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
|
||||
@ -180,6 +178,10 @@ 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: CG basis type XXX is not recognized
|
||||
|
||||
See second line of message for supported basis types.
|
||||
|
||||
E: Target temperature for fix bocs cannot be 0.0
|
||||
|
||||
Self-explanatory.
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,14 +12,17 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstdlib>
|
||||
#include "body_nparticle.h"
|
||||
#include "math_extra.h"
|
||||
#include "atom_vec_body.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "memory.h"
|
||||
#include "atom_vec_body.h"
|
||||
#include "error.h"
|
||||
#include "math_extra.h"
|
||||
#include "math_eigen.h"
|
||||
#include "memory.h"
|
||||
#include "my_pool_chunk.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -28,12 +32,12 @@ enum{SPHERE,LINE,TRI}; // also in DumpImage
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
BodyNparticle::BodyNparticle(LAMMPS *lmp, int narg, char **arg) :
|
||||
Body(lmp, narg, arg), imflag(NULL), imdata(NULL)
|
||||
Body(lmp, narg, arg), imflag(nullptr), imdata(nullptr)
|
||||
{
|
||||
if (narg != 3) error->all(FLERR,"Invalid body nparticle command");
|
||||
|
||||
int nmin = force->inumeric(FLERR,arg[1]);
|
||||
int nmax = force->inumeric(FLERR,arg[2]);
|
||||
int nmin = utils::inumeric(FLERR,arg[1],false,lmp);
|
||||
int nmax = utils::inumeric(FLERR,arg[2],false,lmp);
|
||||
if (nmin <= 0 || nmin > nmax)
|
||||
error->all(FLERR,"Invalid body nparticle command");
|
||||
|
||||
@ -44,6 +48,7 @@ BodyNparticle::BodyNparticle(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
icp = new MyPoolChunk<int>(1,1);
|
||||
dcp = new MyPoolChunk<double>(3*nmin,3*nmax);
|
||||
maxexchange = 1 + 3*nmax; // icp max + dcp max
|
||||
|
||||
memory->create(imflag,nmax,"body/nparticle:imflag");
|
||||
memory->create(imdata,nmax,4,"body/nparticle:imdata");
|
||||
@ -100,7 +105,7 @@ int BodyNparticle::unpack_border_body(AtomVecBody::Bonus *bonus, double *buf)
|
||||
void BodyNparticle::data_body(int ibonus, int ninteger, int ndouble,
|
||||
int *ifile, double *dfile)
|
||||
{
|
||||
AtomVecBody::Bonus *bonus = &avec->bonus[ibonus];
|
||||
auto bonus = &avec->bonus[ibonus];
|
||||
|
||||
// set ninteger, ndouble in bonus and allocate 2 vectors of ints, doubles
|
||||
|
||||
@ -133,7 +138,7 @@ void BodyNparticle::data_body(int ibonus, int ninteger, int ndouble,
|
||||
|
||||
double *inertia = bonus->inertia;
|
||||
double evectors[3][3];
|
||||
int ierror = MathExtra::jacobi(tensor,inertia,evectors);
|
||||
int ierror = MathEigen::jacobi3(tensor,inertia,evectors);
|
||||
if (ierror) error->one(FLERR,
|
||||
"Insufficient Jacobi rotations for body nparticle");
|
||||
|
||||
@ -189,6 +194,95 @@ void BodyNparticle::data_body(int ibonus, int ninteger, int ndouble,
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data struct for one body into buf for writing to data file
|
||||
if buf is nullptr, just return buffer size
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int BodyNparticle::pack_data_body(tagint atomID, int ibonus, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
double values[3],p[3][3],pdiag[3][3],ispace[3][3];
|
||||
|
||||
AtomVecBody::Bonus *bonus = &avec->bonus[ibonus];
|
||||
|
||||
double *quat = bonus->quat;
|
||||
double *inertia = bonus->inertia;
|
||||
int *ivalue = bonus->ivalue;
|
||||
double *dvalue = bonus->dvalue;
|
||||
int nsub = ivalue[0];
|
||||
|
||||
if (buf) {
|
||||
|
||||
// line 1: ID ninteger ndouble
|
||||
|
||||
buf[m++] = ubuf(atomID).d;
|
||||
buf[m++] = ubuf(1).d;
|
||||
buf[m++] = ubuf(6 + 3*nsub).d;
|
||||
|
||||
// line 2: single integer nsub
|
||||
|
||||
buf[m++] = ubuf(nsub).d;
|
||||
|
||||
// line 3: 6 moments of inertia
|
||||
|
||||
MathExtra::quat_to_mat(quat,p);
|
||||
MathExtra::times3_diag(p,inertia,pdiag);
|
||||
MathExtra::times3_transpose(pdiag,p,ispace);
|
||||
|
||||
buf[m++] = ispace[0][0];
|
||||
buf[m++] = ispace[1][1];
|
||||
buf[m++] = ispace[2][2];
|
||||
buf[m++] = ispace[0][1];
|
||||
buf[m++] = ispace[0][2];
|
||||
buf[m++] = ispace[1][2];
|
||||
|
||||
// 3*nsub particle coords = displacement from COM in box frame
|
||||
|
||||
for (int i = 0; i < nsub; i++) {
|
||||
MathExtra::matvec(p,&dvalue[3*i],values);
|
||||
buf[m++] = values[0];
|
||||
buf[m++] = values[1];
|
||||
buf[m++] = values[2];
|
||||
}
|
||||
|
||||
} else m = 3 + 1 + 6 + 3*nsub;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
write info for one body to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int BodyNparticle::write_data_body(FILE *fp, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
// atomID ninteger ndouble
|
||||
|
||||
fmt::print(fp,"{} {} {}\n",ubuf(buf[m]).i,ubuf(buf[m+1]).i,ubuf(buf[m+2]).i);
|
||||
m += 3;
|
||||
|
||||
const int nsub = (int) ubuf(buf[m++]).i;
|
||||
fmt::print(fp,"{}\n",nsub);
|
||||
|
||||
// inertia
|
||||
|
||||
fmt::print(fp,"{} {} {} {} {} {}\n",
|
||||
buf[m+0],buf[m+1],buf[m+2],buf[m+3],buf[m+4],buf[m+5]);
|
||||
m += 6;
|
||||
|
||||
// nsub vertices
|
||||
|
||||
for (int i = 0; i < nsub; i++) {
|
||||
fmt::print(fp,"{} {} {}\n",buf[m],buf[m+1],buf[m+2]);
|
||||
m += 3;
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return radius of body particle defined by ifile/dfile params
|
||||
params are ordered as in data 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,16 +12,16 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#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 {
|
||||
|
||||
@ -35,6 +35,8 @@ class BodyNparticle : public Body {
|
||||
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 noutrow(int);
|
||||
@ -47,7 +49,7 @@ class BodyNparticle : public Body {
|
||||
double **imdata;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,15 +16,19 @@
|
||||
Contributing author: Trung Dac Nguyen (ndactrung@gmail.com)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstdlib>
|
||||
#include "body_rounded_polygon.h"
|
||||
#include "atom_vec_body.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "atom_vec_body.h"
|
||||
#include "domain.h"
|
||||
#include "math_extra.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "math_extra.h"
|
||||
#include "math_eigen.h"
|
||||
#include "memory.h"
|
||||
#include "my_pool_chunk.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -43,8 +48,8 @@ BodyRoundedPolygon::BodyRoundedPolygon(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// nmin and nmax are minimum and maximum number of vertices
|
||||
|
||||
int nmin = force->inumeric(FLERR,arg[1]);
|
||||
int nmax = force->inumeric(FLERR,arg[2]);
|
||||
int nmin = utils::inumeric(FLERR,arg[1],false,lmp);
|
||||
int nmax = utils::inumeric(FLERR,arg[2],false,lmp);
|
||||
if (nmin <= 0 || nmin > nmax)
|
||||
error->all(FLERR,"Invalid body rounded/polygon command");
|
||||
|
||||
@ -61,6 +66,7 @@ BodyRoundedPolygon::BodyRoundedPolygon(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
icp = new MyPoolChunk<int>(1,1);
|
||||
dcp = new MyPoolChunk<double>(3*nmin+2*nmin+1+1,3*nmax+2*nmax+1+1);
|
||||
maxexchange = 1 + 3*nmax+2*nmax+1+1; // icp max + dcp max
|
||||
|
||||
memory->create(imflag,nmax,"body/rounded/polygon:imflag");
|
||||
memory->create(imdata,nmax,7,"body/nparticle:imdata");
|
||||
@ -113,7 +119,7 @@ double BodyRoundedPolygon::enclosing_radius(struct AtomVecBody::Bonus *bonus)
|
||||
{
|
||||
int nvertices = bonus->ivalue[0];
|
||||
if (nvertices == 1 || nvertices == 2)
|
||||
return *(bonus->dvalue+3*nsub(bonus)+2);
|
||||
return *(bonus->dvalue+3*nsub(bonus)+2);
|
||||
return *(bonus->dvalue + 3*nsub(bonus) + 2*nsub(bonus));
|
||||
}
|
||||
|
||||
@ -123,7 +129,7 @@ double BodyRoundedPolygon::rounded_radius(struct AtomVecBody::Bonus *bonus)
|
||||
{
|
||||
int nvertices = bonus->ivalue[0];
|
||||
if (nvertices == 1 || nvertices == 2)
|
||||
return *(bonus->dvalue+3*nsub(bonus)+2+1);
|
||||
return *(bonus->dvalue+3*nsub(bonus)+2+1);
|
||||
return *(bonus->dvalue + 3*nsub(bonus) + 2*nsub(bonus)+1);
|
||||
}
|
||||
|
||||
@ -153,7 +159,7 @@ int BodyRoundedPolygon::unpack_border_body(AtomVecBody::Bonus *bonus,
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void BodyRoundedPolygon::data_body(int ibonus, int ninteger, int ndouble,
|
||||
int *ifile, double *dfile)
|
||||
int *ifile, double *dfile)
|
||||
{
|
||||
AtomVecBody::Bonus *bonus = &avec->bonus[ibonus];
|
||||
|
||||
@ -178,7 +184,8 @@ void BodyRoundedPolygon::data_body(int ibonus, int ninteger, int ndouble,
|
||||
bonus->ninteger = 1;
|
||||
bonus->ivalue = icp->get(bonus->iindex);
|
||||
bonus->ivalue[0] = nsub;
|
||||
bonus->ndouble = 3*nsub + 2*nsub + 1 + 1;
|
||||
if (nsub < 3) bonus->ndouble = 3*nsub + 2 + 1 + 1;
|
||||
else bonus->ndouble = 3*nsub + 2*nsub + 1 + 1;
|
||||
bonus->dvalue = dcp->get(bonus->ndouble,bonus->dindex);
|
||||
|
||||
// diagonalize inertia tensor
|
||||
@ -193,7 +200,7 @@ void BodyRoundedPolygon::data_body(int ibonus, int ninteger, int ndouble,
|
||||
|
||||
double *inertia = bonus->inertia;
|
||||
double evectors[3][3];
|
||||
int ierror = MathExtra::jacobi(tensor,inertia,evectors);
|
||||
int ierror = MathEigen::jacobi3(tensor,inertia,evectors);
|
||||
if (ierror) error->one(FLERR,
|
||||
"Insufficient Jacobi rotations for body nparticle");
|
||||
|
||||
@ -236,10 +243,13 @@ void BodyRoundedPolygon::data_body(int ibonus, int ninteger, int ndouble,
|
||||
// find the enclosing radius of the body from the maximum displacement
|
||||
|
||||
int i,m;
|
||||
double delta[3], rsq, erad, rrad;
|
||||
double erad2 = 0;
|
||||
double rsq,erad,rrad;
|
||||
double delta[3];
|
||||
|
||||
double erad2 = 0.0;
|
||||
int j = 6;
|
||||
int k = 0;
|
||||
|
||||
for (i = 0; i < nsub; i++) {
|
||||
delta[0] = dfile[j];
|
||||
delta[1] = dfile[j+1];
|
||||
@ -253,17 +263,17 @@ void BodyRoundedPolygon::data_body(int ibonus, int ninteger, int ndouble,
|
||||
k += 3;
|
||||
}
|
||||
|
||||
// .. the next 2*nsub elements are edge ends
|
||||
// the next 2 or 2*nsub elements are edge ends
|
||||
// the final two values are the enclosing radius and rounded radius
|
||||
// set atom->radius = enclosing + rounded radii (except for spheres)
|
||||
|
||||
int nedges;
|
||||
if (nsub == 1) { // spheres
|
||||
nedges = 0;
|
||||
// spheres have just 1 edge
|
||||
|
||||
if (nsub == 1) {
|
||||
bonus->dvalue[k] = 0;
|
||||
*(&bonus->dvalue[k]+1) = 0;
|
||||
bonus->dvalue[k+1] = 0;
|
||||
k += 2;
|
||||
|
||||
// the last element of bonus->dvalue is the rounded & enclosing radius
|
||||
|
||||
rrad = 0.5 * dfile[j];
|
||||
bonus->dvalue[k] = rrad;
|
||||
erad = rrad;
|
||||
@ -273,42 +283,36 @@ void BodyRoundedPolygon::data_body(int ibonus, int ninteger, int ndouble,
|
||||
|
||||
atom->radius[bonus->ilocal] = erad;
|
||||
|
||||
} else if (nsub == 2) { // rods
|
||||
nedges = 1;
|
||||
for (i = 0; i < nedges; i++) {
|
||||
bonus->dvalue[k] = 0;
|
||||
*(&bonus->dvalue[k]+1) = 1;
|
||||
k += 2;
|
||||
}
|
||||
// rods have just 1 edge
|
||||
|
||||
} else if (nsub == 2) {
|
||||
bonus->dvalue[k] = 0;
|
||||
bonus->dvalue[k+1] = 1;
|
||||
k += 2;
|
||||
|
||||
erad = sqrt(erad2);
|
||||
bonus->dvalue[k] = erad;
|
||||
|
||||
// the last element of bonus->dvalue is the rounded radius
|
||||
|
||||
rrad = 0.5 * dfile[j];
|
||||
k++;
|
||||
bonus->dvalue[k] = rrad;
|
||||
|
||||
atom->radius[bonus->ilocal] = erad + rrad;
|
||||
|
||||
} else { // polygons
|
||||
nedges = nsub;
|
||||
for (i = 0; i < nedges; i++) {
|
||||
// polygons have Nsub edges
|
||||
|
||||
} else {
|
||||
for (i = 0; i < nsub; i++) {
|
||||
bonus->dvalue[k] = i;
|
||||
m = i+1;
|
||||
if (m == nedges) m = 0;
|
||||
*(&bonus->dvalue[k]+1) = m;
|
||||
if (m == nsub) m = 0;
|
||||
bonus->dvalue[k+1] = m;
|
||||
k += 2;
|
||||
}
|
||||
|
||||
// the next to last element is the enclosing radius
|
||||
|
||||
erad = sqrt(erad2);
|
||||
bonus->dvalue[k] = erad;
|
||||
|
||||
// the last element of bonus->dvalue is the rounded radius
|
||||
|
||||
rrad = 0.5 * dfile[j];
|
||||
k++;
|
||||
bonus->dvalue[k] = rrad;
|
||||
@ -317,6 +321,108 @@ void BodyRoundedPolygon::data_body(int ibonus, int ninteger, int ndouble,
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data struct for one body into buf for writing to data file
|
||||
if buf is a null pointer, just return buffer size
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int BodyRoundedPolygon::pack_data_body(tagint atomID, int ibonus, double *buf)
|
||||
{
|
||||
int m,ilast;
|
||||
double values[3],p[3][3],pdiag[3][3],ispace[3][3];
|
||||
|
||||
AtomVecBody::Bonus *bonus = &avec->bonus[ibonus];
|
||||
|
||||
double *quat = bonus->quat;
|
||||
double *inertia = bonus->inertia;
|
||||
int *ivalue = bonus->ivalue;
|
||||
double *dvalue = bonus->dvalue;
|
||||
|
||||
int nsub = ivalue[0];
|
||||
|
||||
if (buf) {
|
||||
|
||||
// ID ninteger ndouble
|
||||
|
||||
m = 0;
|
||||
buf[m++] = ubuf(atomID).d;
|
||||
buf[m++] = ubuf(1).d;
|
||||
buf[m++] = ubuf(6 + 3*nsub + 1).d;
|
||||
|
||||
// single integer nsub
|
||||
|
||||
buf[m++] = ubuf(nsub).d;
|
||||
|
||||
// 6 moments of inertia
|
||||
|
||||
MathExtra::quat_to_mat(quat,p);
|
||||
MathExtra::times3_diag(p,inertia,pdiag);
|
||||
MathExtra::times3_transpose(pdiag,p,ispace);
|
||||
|
||||
buf[m++] = ispace[0][0];
|
||||
buf[m++] = ispace[1][1];
|
||||
buf[m++] = ispace[2][2];
|
||||
buf[m++] = ispace[0][1];
|
||||
buf[m++] = ispace[0][2];
|
||||
buf[m++] = ispace[1][2];
|
||||
|
||||
// 3*nsub particle coords = displacement from COM in box frame
|
||||
|
||||
for (int i = 0; i < nsub; i++) {
|
||||
MathExtra::matvec(p,&dvalue[3*i],values);
|
||||
buf[m++] = values[0];
|
||||
buf[m++] = values[1];
|
||||
buf[m++] = values[2];
|
||||
}
|
||||
|
||||
// rounded diameter = 2 * last dvalue = rounded radius
|
||||
// for nsub = 1,2: skip one edge and enclosing radius
|
||||
// for nsub > 2: skip Nsub edges and enclosing radius
|
||||
|
||||
if (nsub < 3) ilast = 3*nsub + 2 + 1;
|
||||
else ilast = 3*nsub + 2*nsub + 1;
|
||||
buf[m++] = 2.0 * dvalue[ilast];
|
||||
|
||||
} else m = 3 + 1 + 6 + 3*nsub + 1;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
write info for one body to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int BodyRoundedPolygon::write_data_body(FILE *fp, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
// atomID ninteger ndouble
|
||||
|
||||
fmt::print(fp,"{} {} {}\n",ubuf(buf[m]).i,ubuf(buf[m+1]).i,ubuf(buf[m+2]).i);
|
||||
m += 3;
|
||||
|
||||
const int nsub = (int) ubuf(buf[m++]).i;
|
||||
fmt::print(fp,"{}\n",nsub);
|
||||
|
||||
// inertia
|
||||
|
||||
fmt::print(fp,"{} {} {} {} {} {}\n",
|
||||
buf[m+0],buf[m+1],buf[m+2],buf[m+3],buf[m+4],buf[m+5]);
|
||||
m += 6;
|
||||
|
||||
// nsub vertices
|
||||
|
||||
for (int i = 0; i < nsub; i++, m+=3)
|
||||
fmt::print(fp,"{} {} {}\n",buf[m],buf[m+1],buf[m+2]);
|
||||
|
||||
// rounded diameter
|
||||
|
||||
double diameter = buf[m++];
|
||||
fmt::print(fp,"{}\n",diameter);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return radius of body particle defined by ifile/dfile params
|
||||
params are ordered as in data file
|
||||
@ -324,7 +430,7 @@ void BodyRoundedPolygon::data_body(int ibonus, int ninteger, int ndouble,
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double BodyRoundedPolygon::radius_body(int /*ninteger*/, int ndouble,
|
||||
int *ifile, double *dfile)
|
||||
int *ifile, double *dfile)
|
||||
{
|
||||
int nsub = ifile[0];
|
||||
if (nsub < 1)
|
||||
|
||||
@ -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,16 +12,16 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#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 {
|
||||
|
||||
@ -39,6 +39,8 @@ class BodyRoundedPolygon : public Body {
|
||||
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 noutrow(int);
|
||||
@ -51,7 +53,7 @@ class BodyRoundedPolygon : public Body {
|
||||
double **imdata;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,15 +16,18 @@
|
||||
Contributing author: Trung Dac Nguyen (ndactrung@gmail.com)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstdlib>
|
||||
#include "body_rounded_polyhedron.h"
|
||||
#include "atom_vec_body.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "domain.h"
|
||||
#include "math_extra.h"
|
||||
#include "memory.h"
|
||||
#include "atom_vec_body.h"
|
||||
#include "error.h"
|
||||
#include "math_extra.h"
|
||||
#include "math_eigen.h"
|
||||
#include "memory.h"
|
||||
#include "my_pool_chunk.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -41,18 +45,16 @@ BodyRoundedPolyhedron::BodyRoundedPolyhedron(LAMMPS *lmp, int narg, char **arg)
|
||||
|
||||
// nmin and nmax are minimum and maximum number of vertices
|
||||
|
||||
int nmin = force->inumeric(FLERR,arg[1]);
|
||||
int nmax = force->inumeric(FLERR,arg[2]);
|
||||
int nmin = utils::inumeric(FLERR,arg[1],false,lmp);
|
||||
int nmax = utils::inumeric(FLERR,arg[2],false,lmp);
|
||||
if (nmin <= 0 || nmin > nmax)
|
||||
error->all(FLERR,"Invalid body rounded/polyhedron command");
|
||||
|
||||
size_forward = 0;
|
||||
|
||||
// 3 integers: 1 for no. of vertices, 1 for no. of edges, 1 for no. of faces
|
||||
// 3*nmax doubles for vertex coordinates + 2*nmax doubles for edge ends +
|
||||
// (MAX_FACE_SIZE+1)*nmax for faces
|
||||
// 1 double for the enclosing radius
|
||||
// 1 double for the rounded radius
|
||||
// 3 integers: nvertices, nedges, nfaces
|
||||
// doubles = 3*nvertices + 2*nedge + MAX_FACE_SIZE*nfaces +
|
||||
// 1 double for enclosing radius + 1 double for rounded radius
|
||||
|
||||
size_border = 3 + 3*nmax + 2*nmax + MAX_FACE_SIZE*nmax + 1 + 1;
|
||||
|
||||
@ -61,6 +63,7 @@ BodyRoundedPolyhedron::BodyRoundedPolyhedron(LAMMPS *lmp, int narg, char **arg)
|
||||
icp = new MyPoolChunk<int>(1,3);
|
||||
dcp = new MyPoolChunk<double>(3*nmin+2+1+1,
|
||||
3*nmax+2*nmax+MAX_FACE_SIZE*nmax+1+1);
|
||||
maxexchange = 3 + 3*nmax+2*nmax+MAX_FACE_SIZE*nmax+1+1; // icp max + dcp max
|
||||
|
||||
memory->create(imflag,2*nmax,"body/rounded/polyhedron:imflag");
|
||||
memory->create(imdata,2*nmax,7,"body/polyhedron:imdata");
|
||||
@ -99,7 +102,7 @@ int BodyRoundedPolyhedron::nedges(AtomVecBody::Bonus *bonus)
|
||||
//int nfaces = bonus->ivalue[2];
|
||||
if (nvertices == 1) return 0;
|
||||
else if (nvertices == 2) return 1;
|
||||
return nedges; //(nvertices+nfaces-2); // Euler's polyon formula: V-E+F=2
|
||||
return nedges; //(nvertices+nfaces-2); // Euler formula: V-E+F=2
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -121,7 +124,7 @@ int BodyRoundedPolyhedron::nfaces(AtomVecBody::Bonus *bonus)
|
||||
double *BodyRoundedPolyhedron::faces(AtomVecBody::Bonus *bonus)
|
||||
{
|
||||
int nvertices = bonus->ivalue[0];
|
||||
if (nvertices == 1 || nvertices == 2) return NULL;
|
||||
if (nvertices == 1 || nvertices == 2) return nullptr;
|
||||
return bonus->dvalue+3*nsub(bonus)+2*nedges(bonus);
|
||||
}
|
||||
|
||||
@ -131,7 +134,7 @@ double BodyRoundedPolyhedron::enclosing_radius(struct AtomVecBody::Bonus *bonus)
|
||||
{
|
||||
int nvertices = bonus->ivalue[0];
|
||||
if (nvertices == 1 || nvertices == 2)
|
||||
return *(bonus->dvalue+3*nsub(bonus)+2);
|
||||
return *(bonus->dvalue+3*nsub(bonus)+2);
|
||||
return *(bonus->dvalue+3*nsub(bonus) + 2*nedges(bonus) +
|
||||
MAX_FACE_SIZE*nfaces(bonus));
|
||||
}
|
||||
@ -166,8 +169,7 @@ int BodyRoundedPolyhedron::pack_border_body(AtomVecBody::Bonus *bonus, double *b
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int BodyRoundedPolyhedron::unpack_border_body(AtomVecBody::Bonus *bonus,
|
||||
double *buf)
|
||||
int BodyRoundedPolyhedron::unpack_border_body(AtomVecBody::Bonus *bonus, double *buf)
|
||||
{
|
||||
int nsub = static_cast<int> (buf[0]);
|
||||
int ned = static_cast<int> (buf[1]);
|
||||
@ -187,7 +189,7 @@ int BodyRoundedPolyhedron::unpack_border_body(AtomVecBody::Bonus *bonus,
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void BodyRoundedPolyhedron::data_body(int ibonus, int ninteger, int ndouble,
|
||||
int *ifile, double *dfile)
|
||||
int *ifile, double *dfile)
|
||||
{
|
||||
AtomVecBody::Bonus *bonus = &avec->bonus[ibonus];
|
||||
|
||||
@ -204,29 +206,29 @@ void BodyRoundedPolyhedron::data_body(int ibonus, int ninteger, int ndouble,
|
||||
"Bodies section of data file");
|
||||
|
||||
// nentries = number of double entries to be read from Body section:
|
||||
// nsub == 1 || nsub == 2 || nsub == 3:
|
||||
// 6 for inertia + 3*nsub for vertex coords + 1 for rounded radius
|
||||
// nsub > 3:
|
||||
// 6 for inertia + 3*nsub for vertex coords + 2*nsub for edges +
|
||||
// 3*nfaces + 1 for rounded radius
|
||||
// nsub == 1,2:
|
||||
// 6 for inertia + 3*nsub + 1 for rounded radius
|
||||
// nsub > 2:
|
||||
// 6 for inertia + 3*nsub + 2*nedges + MAX_FACE_SIZE*nfaces + 1 for rounded radius
|
||||
|
||||
int nedges,nentries;
|
||||
if (nsub == 1 || nsub == 2) {
|
||||
if (nsub < 3) {
|
||||
nentries = 6 + 3*nsub + 1;
|
||||
} else {
|
||||
nedges = ned; //nsub + nfac - 2;
|
||||
nentries = 6 + 3*nsub + 2*nedges + MAX_FACE_SIZE*nfac + 1;
|
||||
}
|
||||
|
||||
if (ndouble != nentries)
|
||||
error->one(FLERR,"Incorrect # of floating-point values in "
|
||||
"Bodies section of data file");
|
||||
"Bodies section of data file");
|
||||
|
||||
bonus->ninteger = 3;
|
||||
bonus->ivalue = icp->get(bonus->iindex);
|
||||
bonus->ivalue[0] = nsub;
|
||||
bonus->ivalue[1] = ned;
|
||||
bonus->ivalue[2] = nfac;
|
||||
if (nsub == 1 || nsub == 2) bonus->ndouble = 3*nsub + 2*nsub + 1 + 1;
|
||||
if (nsub < 3) bonus->ndouble = 3*nsub + 2 + 1 + 1;
|
||||
else bonus->ndouble = 3*nsub + 2*nedges + MAX_FACE_SIZE*nfac + 1 + 1;
|
||||
bonus->dvalue = dcp->get(bonus->ndouble,bonus->dindex);
|
||||
|
||||
@ -242,7 +244,7 @@ void BodyRoundedPolyhedron::data_body(int ibonus, int ninteger, int ndouble,
|
||||
|
||||
double *inertia = bonus->inertia;
|
||||
double evectors[3][3];
|
||||
int ierror = MathExtra::jacobi(tensor,inertia,evectors);
|
||||
int ierror = MathEigen::jacobi3(tensor,inertia,evectors);
|
||||
if (ierror) error->one(FLERR,
|
||||
"Insufficient Jacobi rotations for body nparticle");
|
||||
|
||||
@ -302,51 +304,51 @@ void BodyRoundedPolyhedron::data_body(int ibonus, int ninteger, int ndouble,
|
||||
k += 3;
|
||||
}
|
||||
|
||||
// .. the next 2*nsub elements are edge ends
|
||||
// the next 2*nsub elements are edge ends
|
||||
// the final two values are the enclosing radius and rounded radius
|
||||
// set atom->radius = enclosing + rounded radii (except for spheres)
|
||||
|
||||
if (nsub == 1) { // spheres
|
||||
nedges = 0;
|
||||
// spheres have just 1 edge
|
||||
|
||||
if (nsub == 1) {
|
||||
bonus->dvalue[k] = 0;
|
||||
*(&bonus->dvalue[k]+1) = 0;
|
||||
bonus->dvalue[k+1] = 0;
|
||||
k += 2;
|
||||
|
||||
rrad = 0.5 * dfile[j];
|
||||
bonus->dvalue[k] = rrad;
|
||||
erad = rrad; // enclosing radius = rounded_radius
|
||||
|
||||
// the last element of bonus->dvalue is the rounded radius
|
||||
erad = rrad;
|
||||
|
||||
k++;
|
||||
bonus->dvalue[k] = rrad;
|
||||
|
||||
atom->radius[bonus->ilocal] = erad;
|
||||
|
||||
} else if (nsub == 2) { // rods
|
||||
nedges = 1;
|
||||
for (i = 0; i < nedges; i++) {
|
||||
bonus->dvalue[k] = 0;
|
||||
*(&bonus->dvalue[k]+1) = 1;
|
||||
k += 2;
|
||||
}
|
||||
// rods have just 1 edge
|
||||
|
||||
} else if (nsub == 2) {
|
||||
bonus->dvalue[k] = 0;
|
||||
bonus->dvalue[k+1] = 1;
|
||||
k += 2;
|
||||
|
||||
erad = sqrt(erad2);
|
||||
bonus->dvalue[k] = erad;
|
||||
|
||||
// the last element of bonus->dvalue is the rounded radius
|
||||
|
||||
rrad = 0.5 * dfile[j];
|
||||
k++;
|
||||
bonus->dvalue[k] = rrad;
|
||||
|
||||
atom->radius[bonus->ilocal] = erad + rrad;
|
||||
|
||||
} else { // polyhedra
|
||||
// polyhedra have Nedges and Nfaces
|
||||
|
||||
} else {
|
||||
|
||||
// edges
|
||||
|
||||
for (i = 0; i < nedges; i++) {
|
||||
bonus->dvalue[k] = dfile[j];
|
||||
*(&bonus->dvalue[k]+1) = dfile[j+1];
|
||||
bonus->dvalue[k+1] = dfile[j+1];
|
||||
k += 2;
|
||||
j += 2;
|
||||
}
|
||||
@ -355,18 +357,14 @@ void BodyRoundedPolyhedron::data_body(int ibonus, int ninteger, int ndouble,
|
||||
|
||||
for (i = 0; i < nfac; i++) {
|
||||
for (m = 0; m < MAX_FACE_SIZE; m++)
|
||||
*(&bonus->dvalue[k]+m) = dfile[j+m];
|
||||
bonus->dvalue[k+m] = dfile[j+m];
|
||||
k += MAX_FACE_SIZE;
|
||||
j += MAX_FACE_SIZE;
|
||||
}
|
||||
|
||||
// the next to last element is the enclosing radius
|
||||
|
||||
erad = sqrt(erad2);
|
||||
bonus->dvalue[k] = erad;
|
||||
|
||||
// the last element bonus-> dvalue is the rounded radius
|
||||
|
||||
rrad = 0.5 * dfile[j];
|
||||
k++;
|
||||
bonus->dvalue[k] = rrad;
|
||||
@ -375,6 +373,148 @@ void BodyRoundedPolyhedron::data_body(int ibonus, int ninteger, int ndouble,
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data struct for one body into buf for writing to data file
|
||||
if buf is a null pointer, just return buffer size
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int BodyRoundedPolyhedron::pack_data_body(tagint atomID, int ibonus, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
double values[3],p[3][3],pdiag[3][3],ispace[3][3];
|
||||
|
||||
AtomVecBody::Bonus *bonus = &avec->bonus[ibonus];
|
||||
|
||||
double *quat = bonus->quat;
|
||||
double *inertia = bonus->inertia;
|
||||
int *ivalue = bonus->ivalue;
|
||||
double *dvalue = bonus->dvalue;
|
||||
|
||||
int nsub = ivalue[0];
|
||||
int nedge = ivalue[1];
|
||||
int nface = ivalue[2];
|
||||
|
||||
if (buf) {
|
||||
|
||||
// ID ninteger ndouble
|
||||
|
||||
m = 0;
|
||||
buf[m++] = ubuf(atomID).d;
|
||||
buf[m++] = ubuf(3).d;
|
||||
if (nsub < 3) buf[m++] = ubuf(6 + 3*nsub + 1).d;
|
||||
else buf[m++] = ubuf(6 + 3*nsub + 2*nedge + MAX_FACE_SIZE*nface + 1).d;
|
||||
|
||||
// 3 integers nsub,nedge,nface
|
||||
|
||||
buf[m++] = ubuf(nsub).d;
|
||||
buf[m++] = ubuf(nedge).d;
|
||||
buf[m++] = ubuf(nface).d;
|
||||
|
||||
// 6 moments of inertia
|
||||
|
||||
MathExtra::quat_to_mat(quat,p);
|
||||
MathExtra::times3_diag(p,inertia,pdiag);
|
||||
MathExtra::times3_transpose(pdiag,p,ispace);
|
||||
|
||||
buf[m++] = ispace[0][0];
|
||||
buf[m++] = ispace[1][1];
|
||||
buf[m++] = ispace[2][2];
|
||||
buf[m++] = ispace[0][1];
|
||||
buf[m++] = ispace[0][2];
|
||||
buf[m++] = ispace[1][2];
|
||||
|
||||
// 3*nsub particle coords = displacement from COM in box frame
|
||||
|
||||
for (i = 0; i < nsub; i++) {
|
||||
MathExtra::matvec(p,&dvalue[3*i],values);
|
||||
buf[m++] = values[0];
|
||||
buf[m++] = values[1];
|
||||
buf[m++] = values[2];
|
||||
}
|
||||
|
||||
// 2*nedge edge indices
|
||||
// 4*nface face indices
|
||||
|
||||
j = 3*nsub;
|
||||
|
||||
if (nsub < 3) j += 2;
|
||||
else {
|
||||
for (i = 0; i < nedge; i++) {
|
||||
buf[m++] = static_cast<int> (dvalue[j++]);
|
||||
buf[m++] = static_cast<int> (dvalue[j++]);
|
||||
}
|
||||
for (i = 0; i < nface; i++) {
|
||||
buf[m++] = static_cast<int> (dvalue[j++]);
|
||||
buf[m++] = static_cast<int> (dvalue[j++]);
|
||||
buf[m++] = static_cast<int> (dvalue[j++]);
|
||||
buf[m++] = static_cast<int> (dvalue[j++]);
|
||||
}
|
||||
}
|
||||
|
||||
// rounded diameter = 2 * last dvalue = rounded radius
|
||||
// j+1 to skip enclosing radius
|
||||
|
||||
buf[m++] = 2.0 * dvalue[j+1];
|
||||
|
||||
} else {
|
||||
m = 3 + 3 + 6 + 3*nsub + 1;
|
||||
if (nsub > 2) m += 2*nedge + MAX_FACE_SIZE*nface;
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
write info for one body to data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int BodyRoundedPolyhedron::write_data_body(FILE *fp, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
|
||||
// atomID ninteger ndouble
|
||||
|
||||
fmt::print(fp,"{} {} {}\n",ubuf(buf[m]).i,ubuf(buf[m+1]).i,ubuf(buf[m+2]).i);
|
||||
m += 3;
|
||||
|
||||
// nvert, nedge, nface
|
||||
|
||||
const int nsub = (int) ubuf(buf[m++]).i;
|
||||
const int nedge = (int) ubuf(buf[m++]).i;
|
||||
const int nface = (int) ubuf(buf[m++]).i;
|
||||
fmt::print(fp,"{} {} {}\n",nsub,nedge,nface);
|
||||
|
||||
// inertia
|
||||
|
||||
fmt::print(fp,"{} {} {} {} {} {}\n",
|
||||
buf[m+0],buf[m+1],buf[m+2],buf[m+3],buf[m+4],buf[m+5]);
|
||||
m += 6;
|
||||
|
||||
// nsub vertices
|
||||
|
||||
for (int i = 0; i < nsub; i++, m+=3)
|
||||
fmt::print(fp,"{} {} {}\n",buf[m],buf[m+1],buf[m+2]);
|
||||
|
||||
// nedge 2-tuples and nface 4-tuples
|
||||
// unless nsub = 1 or 2
|
||||
|
||||
if (nsub > 2) {
|
||||
for (int i = 0; i < nedge; i++, m+=2)
|
||||
fmt::print(fp,"{} {}\n",static_cast<int> (buf[m]),static_cast<int> (buf[m+1]));
|
||||
for (int i = 0; i < nface; i++, m+=4)
|
||||
fmt::print(fp,"{} {} {} {}\n",
|
||||
static_cast<int> (buf[m]),static_cast<int> (buf[m+1]),
|
||||
static_cast<int> (buf[m+2]),static_cast<int> (buf[m+3]));
|
||||
}
|
||||
|
||||
// rounded diameter
|
||||
|
||||
double diameter = buf[m++];
|
||||
fmt::print(fp,"{}\n",diameter);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return radius of body particle defined by ifile/dfile params
|
||||
params are ordered as in data file
|
||||
@ -382,7 +522,7 @@ void BodyRoundedPolyhedron::data_body(int ibonus, int ninteger, int ndouble,
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double BodyRoundedPolyhedron::radius_body(int /*ninteger*/, int ndouble,
|
||||
int *ifile, double *dfile)
|
||||
int *ifile, double *dfile)
|
||||
{
|
||||
int nsub = ifile[0];
|
||||
int ned = ifile[1];
|
||||
|
||||
@ -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,16 +12,16 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#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 {
|
||||
|
||||
@ -41,6 +41,8 @@ class BodyRoundedPolyhedron : public Body {
|
||||
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 noutrow(int);
|
||||
@ -53,7 +55,7 @@ class BodyRoundedPolyhedron : public Body {
|
||||
double **imdata;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,18 +12,16 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include "compute_body_local.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "atom_vec_body.h"
|
||||
#include "body.h"
|
||||
#include "update.h"
|
||||
#include "domain.h"
|
||||
#include "force.h"
|
||||
#include "bond.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "memory.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -33,14 +32,12 @@ enum{ID,TYPE,INDEX};
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeBodyLocal::ComputeBodyLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg), which(NULL), index(NULL), avec(NULL), bptr(NULL)
|
||||
Compute(lmp, narg, arg), which(nullptr), index(nullptr), avec(nullptr), bptr(nullptr)
|
||||
{
|
||||
if (narg < 4) error->all(FLERR,"Illegal compute body/local command");
|
||||
|
||||
local_flag = 1;
|
||||
nvalues = narg - 3;
|
||||
if (nvalues == 1) size_local_cols = 0;
|
||||
else size_local_cols = nvalues;
|
||||
|
||||
which = new int[nvalues];
|
||||
index = new int[nvalues];
|
||||
@ -51,7 +48,7 @@ ComputeBodyLocal::ComputeBodyLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
else if (strcmp(arg[iarg],"type") == 0) which[nvalues++] = TYPE;
|
||||
else {
|
||||
which[nvalues] = INDEX;
|
||||
index[nvalues] = force->inumeric(FLERR,arg[iarg]) - 1;
|
||||
index[nvalues] = utils::inumeric(FLERR,arg[iarg],false,lmp) - 1;
|
||||
nvalues++;
|
||||
}
|
||||
}
|
||||
@ -66,9 +63,12 @@ ComputeBodyLocal::ComputeBodyLocal(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR,"Invalid index in compute body/local command");
|
||||
}
|
||||
|
||||
if (nvalues == 1) size_local_cols = 0;
|
||||
else size_local_cols = nvalues;
|
||||
|
||||
nmax = 0;
|
||||
vector = NULL;
|
||||
array = NULL;
|
||||
vector = nullptr;
|
||||
array = nullptr;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -124,7 +124,7 @@ void ComputeBodyLocal::compute_local()
|
||||
int ncount = compute_body(0);
|
||||
if (ncount > nmax) reallocate(ncount);
|
||||
size_local_rows = ncount;
|
||||
ncount = compute_body(1);
|
||||
compute_body(1);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -227,6 +227,6 @@ void ComputeBodyLocal::reallocate(int n)
|
||||
|
||||
double ComputeBodyLocal::memory_usage()
|
||||
{
|
||||
double bytes = nmax*nvalues * sizeof(double);
|
||||
double bytes = (double)nmax*nvalues * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -34,7 +34,7 @@ class ComputeBodyLocal : public Compute {
|
||||
|
||||
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
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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 +17,9 @@
|
||||
based on ComputeTempAsphere
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <mpi.h>
|
||||
#include <cstring>
|
||||
#include "compute_temp_body.h"
|
||||
|
||||
#include <cstring>
|
||||
#include "math_extra.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec_body.h"
|
||||
@ -27,7 +28,6 @@
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "group.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
@ -37,7 +37,7 @@ enum{ROTATE,ALL};
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeTempBody::ComputeTempBody(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg), id_bias(NULL), tbias(NULL), avec(NULL)
|
||||
Compute(lmp, narg, arg), id_bias(nullptr), tbias(nullptr), avec(nullptr)
|
||||
{
|
||||
if (narg < 3) error->all(FLERR,"Illegal compute temp/body command");
|
||||
|
||||
@ -48,7 +48,7 @@ ComputeTempBody::ComputeTempBody(LAMMPS *lmp, int narg, char **arg) :
|
||||
tempflag = 1;
|
||||
|
||||
tempbias = 0;
|
||||
id_bias = NULL;
|
||||
id_bias = nullptr;
|
||||
mode = ALL;
|
||||
|
||||
int iarg = 3;
|
||||
@ -57,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)
|
||||
@ -71,7 +69,7 @@ ComputeTempBody::ComputeTempBody(LAMMPS *lmp, int narg, char **arg) :
|
||||
} else error->all(FLERR,"Illegal compute temp/body command");
|
||||
}
|
||||
|
||||
vector = new double[6];
|
||||
vector = new double[size_vector];
|
||||
|
||||
}
|
||||
|
||||
@ -344,7 +342,6 @@ void ComputeTempBody::compute_vector()
|
||||
|
||||
inertia = bonus[body[i]].inertia;
|
||||
quat = bonus[body[i]].quat;
|
||||
massone = rmass[i];
|
||||
|
||||
// wbody = angular velocity in body frame
|
||||
|
||||
|
||||
@ -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
|
||||
@ -40,13 +40,13 @@ class ComputeTempBody : public Compute {
|
||||
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
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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,15 +17,10 @@
|
||||
based on FixNHAsphere
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include "math_extra.h"
|
||||
#include "fix_nh_body.h"
|
||||
#include "math_extra.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec_body.h"
|
||||
#include "group.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -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
|
||||
@ -33,7 +33,7 @@ class FixNHBody : public FixNH {
|
||||
void nh_v_temp();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,10 +16,10 @@
|
||||
Contributing author: Trung Dac Nguyen (ndactrung@gmail.com)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstring>
|
||||
#include "fix_nph_body.h"
|
||||
#include "modify.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "modify.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
@ -38,35 +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
|
||||
|
||||
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/body";
|
||||
|
||||
modify->add_compute(3,newarg);
|
||||
delete [] newarg;
|
||||
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
|
||||
|
||||
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";
|
||||
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 {}",id_press, id_temp));
|
||||
pcomputeflag = 1;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -30,7 +30,7 @@ class FixNPHBody : public FixNHBody {
|
||||
~FixNPHBody() {}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,10 +16,10 @@
|
||||
Contributing author: Trung Dac Nguyen (ndactrung@gmail.com)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstring>
|
||||
#include "fix_npt_body.h"
|
||||
#include "modify.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "modify.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
@ -38,35 +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
|
||||
|
||||
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/body";
|
||||
|
||||
modify->add_compute(3,newarg);
|
||||
delete [] newarg;
|
||||
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
|
||||
|
||||
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";
|
||||
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 {}",id_press, id_temp));
|
||||
pcomputeflag = 1;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -30,7 +30,7 @@ class FixNPTBody : public FixNHBody {
|
||||
~FixNPTBody() {}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,16 +12,10 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "fix_nve_body.h"
|
||||
#include "math_extra.h"
|
||||
#include "atom.h"
|
||||
#include "atom_vec_body.h"
|
||||
#include "force.h"
|
||||
#include "update.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -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
|
||||
@ -36,7 +36,7 @@ class FixNVEBody : public FixNVE {
|
||||
class AtomVecBody *avec;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,11 +16,11 @@
|
||||
Contributing author: Trung Dac Nguyen (ndactrung@gmail.com)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cstring>
|
||||
#include "fix_nvt_body.h"
|
||||
|
||||
#include "error.h"
|
||||
#include "group.h"
|
||||
#include "modify.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
@ -37,17 +38,8 @@ FixNVTBody::FixNVTBody(LAMMPS *lmp, int narg, char **arg) :
|
||||
// create a new compute temp style
|
||||
// id = fix-ID + temp
|
||||
|
||||
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] = group->names[igroup];
|
||||
newarg[2] = (char *) "temp/body";
|
||||
|
||||
modify->add_compute(3,newarg);
|
||||
delete [] newarg;
|
||||
id_temp = utils::strdup(std::string(id) + "_temp");
|
||||
modify->add_compute(fmt::format("{} {} temp/body",
|
||||
id_temp,group->names[igroup]));
|
||||
tcomputeflag = 1;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -30,7 +30,7 @@ class FixNVTBody : public FixNHBody {
|
||||
~FixNVTBody() {}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,23 +16,21 @@
|
||||
Contributing author: Trung Dac Nguyen (ndactrung@gmail.com)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "fix_wall_body_polygon.h"
|
||||
|
||||
#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 "pair.h"
|
||||
#include "modify.h"
|
||||
#include "respa.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;
|
||||
@ -63,14 +62,15 @@ FixWallBodyPolygon::FixWallBodyPolygon(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
restart_peratom = 1;
|
||||
create_attribute = 1;
|
||||
wallstyle = -1;
|
||||
|
||||
// wall/particle coefficients
|
||||
|
||||
kn = force->numeric(FLERR,arg[3]);
|
||||
kn = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
|
||||
c_n = force->numeric(FLERR,arg[4]);
|
||||
c_n = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
if (strcmp(arg[5],"NULL") == 0) c_t = 0.5 * c_n;
|
||||
else c_t = force->numeric(FLERR,arg[5]);
|
||||
else c_t = utils::numeric(FLERR,arg[5],false,lmp);
|
||||
|
||||
if (kn < 0.0 || c_n < 0.0 || c_t < 0.0)
|
||||
error->all(FLERR,"Illegal fix wall/body/polygon command");
|
||||
@ -82,25 +82,25 @@ FixWallBodyPolygon::FixWallBodyPolygon(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (narg < iarg+3) error->all(FLERR,"Illegal fix wall/body/polygon command");
|
||||
wallstyle = XPLANE;
|
||||
if (strcmp(arg[iarg+1],"NULL") == 0) lo = -BIG;
|
||||
else lo = force->numeric(FLERR,arg[iarg+1]);
|
||||
else lo = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||
if (strcmp(arg[iarg+2],"NULL") == 0) hi = BIG;
|
||||
else hi = force->numeric(FLERR,arg[iarg+2]);
|
||||
else hi = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
iarg += 3;
|
||||
} else if (strcmp(arg[iarg],"yplane") == 0) {
|
||||
if (narg < iarg+3) error->all(FLERR,"Illegal fix wall/body/polygon command");
|
||||
wallstyle = YPLANE;
|
||||
if (strcmp(arg[iarg+1],"NULL") == 0) lo = -BIG;
|
||||
else lo = force->numeric(FLERR,arg[iarg+1]);
|
||||
else lo = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||
if (strcmp(arg[iarg+2],"NULL") == 0) hi = BIG;
|
||||
else hi = force->numeric(FLERR,arg[iarg+2]);
|
||||
else hi = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
iarg += 3;
|
||||
} else if (strcmp(arg[iarg],"zcylinder") == 0) {
|
||||
if (narg < iarg+2) error->all(FLERR,"Illegal fix wall/body/polygon command");
|
||||
wallstyle = ZCYLINDER;
|
||||
lo = hi = 0.0;
|
||||
cylradius = force->numeric(FLERR,arg[iarg+1]);
|
||||
cylradius = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||
iarg += 2;
|
||||
}
|
||||
} else error->all(FLERR,"Unknown wall style {}",arg[iarg]);
|
||||
|
||||
// check for trailing keyword/values
|
||||
|
||||
@ -113,8 +113,8 @@ FixWallBodyPolygon::FixWallBodyPolygon(LAMMPS *lmp, int narg, char **arg) :
|
||||
else if (strcmp(arg[iarg+1],"y") == 0) axis = 1;
|
||||
else if (strcmp(arg[iarg+1],"z") == 0) axis = 2;
|
||||
else error->all(FLERR,"Illegal fix wall/body/polygon command");
|
||||
amplitude = force->numeric(FLERR,arg[iarg+2]);
|
||||
period = force->numeric(FLERR,arg[iarg+3]);
|
||||
amplitude = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
period = utils::numeric(FLERR,arg[iarg+3],false,lmp);
|
||||
wiggle = 1;
|
||||
iarg += 4;
|
||||
} else error->all(FLERR,"Illegal fix wall/body/polygon command");
|
||||
@ -137,15 +137,15 @@ FixWallBodyPolygon::FixWallBodyPolygon(LAMMPS *lmp, int narg, char **arg) :
|
||||
time_origin = update->ntimestep;
|
||||
|
||||
dmax = nmax = 0;
|
||||
discrete = NULL;
|
||||
dnum = dfirst = NULL;
|
||||
discrete = nullptr;
|
||||
dnum = dfirst = nullptr;
|
||||
|
||||
edmax = ednummax = 0;
|
||||
edge = NULL;
|
||||
ednum = edfirst = NULL;
|
||||
edge = nullptr;
|
||||
ednum = edfirst = nullptr;
|
||||
|
||||
enclosing_radius = NULL;
|
||||
rounded_radius = NULL;
|
||||
enclosing_radius = nullptr;
|
||||
rounded_radius = nullptr;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -198,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);
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ void FixWallBodyPolygon::post_force(int /*vflag*/)
|
||||
// dx,dy,dz = signed distance from wall
|
||||
// for rotating cylinder, reset vwall based on particle position
|
||||
// skip atom if not close enough to wall
|
||||
// if wall was set to NULL, it's skipped since lo/hi are infinity
|
||||
// if wall was set to a null pointer, it's skipped since lo/hi are infinity
|
||||
// compute force and torque on atom if close enough to wall
|
||||
// via wall potential matched to pair potential
|
||||
|
||||
@ -337,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) {
|
||||
|
||||
|
||||
@ -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
|
||||
@ -35,66 +35,61 @@ class FixWallBodyPolygon : public Fix {
|
||||
void reset_dt();
|
||||
|
||||
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
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -15,19 +16,15 @@
|
||||
Contributing author: Trung Dac Nguyen (ndactrung@gmail.com)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "fix_wall_body_polyhedron.h"
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include "atom.h"
|
||||
#include "atom_vec_body.h"
|
||||
#include "body_rounded_polyhedron.h"
|
||||
#include "domain.h"
|
||||
#include "update.h"
|
||||
#include "force.h"
|
||||
#include "pair.h"
|
||||
#include "modify.h"
|
||||
#include "respa.h"
|
||||
#include "math_const.h"
|
||||
#include "math_extra.h"
|
||||
#include "memory.h"
|
||||
@ -37,7 +34,7 @@ using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
using namespace MathConst;
|
||||
|
||||
enum{XPLANE=0,YPLANE=1,ZPLANE}; // XYZ PLANE need to be 0,1,2
|
||||
enum{XPLANE=0,YPLANE=1,ZPLANE=2}; // XYZ PLANE need to be 0,1,2
|
||||
enum{HOOKE,HOOKE_HISTORY};
|
||||
|
||||
enum {INVALID=0,NONE=1,VERTEX=2};
|
||||
@ -63,14 +60,15 @@ FixWallBodyPolyhedron::FixWallBodyPolyhedron(LAMMPS *lmp, int narg, char **arg)
|
||||
|
||||
restart_peratom = 1;
|
||||
create_attribute = 1;
|
||||
wallstyle = -1;
|
||||
|
||||
// wall/particle coefficients
|
||||
|
||||
kn = force->numeric(FLERR,arg[3]);
|
||||
kn = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
|
||||
c_n = force->numeric(FLERR,arg[4]);
|
||||
c_n = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
if (strcmp(arg[5],"NULL") == 0) c_t = 0.5 * c_n;
|
||||
else c_t = force->numeric(FLERR,arg[5]);
|
||||
else c_t = utils::numeric(FLERR,arg[5],false,lmp);
|
||||
|
||||
if (kn < 0.0 || c_n < 0.0 || c_t < 0.0)
|
||||
error->all(FLERR,"Illegal fix wall/body/polyhedron command");
|
||||
@ -82,27 +80,27 @@ FixWallBodyPolyhedron::FixWallBodyPolyhedron(LAMMPS *lmp, int narg, char **arg)
|
||||
if (narg < iarg+3) error->all(FLERR,"Illegal fix wall/body/polyhedron command");
|
||||
wallstyle = XPLANE;
|
||||
if (strcmp(arg[iarg+1],"NULL") == 0) lo = -BIG;
|
||||
else lo = force->numeric(FLERR,arg[iarg+1]);
|
||||
else lo = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||
if (strcmp(arg[iarg+2],"NULL") == 0) hi = BIG;
|
||||
else hi = force->numeric(FLERR,arg[iarg+2]);
|
||||
else hi = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
iarg += 3;
|
||||
} else if (strcmp(arg[iarg],"yplane") == 0) {
|
||||
if (narg < iarg+3) error->all(FLERR,"Illegal fix wall/body/polyhedron command");
|
||||
wallstyle = YPLANE;
|
||||
if (strcmp(arg[iarg+1],"NULL") == 0) lo = -BIG;
|
||||
else lo = force->numeric(FLERR,arg[iarg+1]);
|
||||
else lo = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||
if (strcmp(arg[iarg+2],"NULL") == 0) hi = BIG;
|
||||
else hi = force->numeric(FLERR,arg[iarg+2]);
|
||||
else hi = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
iarg += 3;
|
||||
} else if (strcmp(arg[iarg],"zplane") == 0) {
|
||||
if (narg < iarg+3) error->all(FLERR,"Illegal fix wall/body/polyhedron command");
|
||||
wallstyle = ZPLANE;
|
||||
if (strcmp(arg[iarg+1],"NULL") == 0) lo = -BIG;
|
||||
else lo = force->numeric(FLERR,arg[iarg+1]);
|
||||
else lo = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||
if (strcmp(arg[iarg+2],"NULL") == 0) hi = BIG;
|
||||
else hi = force->numeric(FLERR,arg[iarg+2]);
|
||||
else hi = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
iarg += 3;
|
||||
}
|
||||
} else error->all(FLERR,"Unknown wall style {}",arg[iarg]);
|
||||
|
||||
// check for trailing keyword/values
|
||||
|
||||
@ -115,8 +113,8 @@ FixWallBodyPolyhedron::FixWallBodyPolyhedron(LAMMPS *lmp, int narg, char **arg)
|
||||
else if (strcmp(arg[iarg+1],"y") == 0) axis = 1;
|
||||
else if (strcmp(arg[iarg+1],"z") == 0) axis = 2;
|
||||
else error->all(FLERR,"Illegal fix wall/body/polyhedron command");
|
||||
amplitude = force->numeric(FLERR,arg[iarg+2]);
|
||||
period = force->numeric(FLERR,arg[iarg+3]);
|
||||
amplitude = utils::numeric(FLERR,arg[iarg+2],false,lmp);
|
||||
period = utils::numeric(FLERR,arg[iarg+3],false,lmp);
|
||||
wiggle = 1;
|
||||
iarg += 4;
|
||||
} else error->all(FLERR,"Illegal fix wall/body/polyhedron command");
|
||||
@ -136,19 +134,19 @@ FixWallBodyPolyhedron::FixWallBodyPolyhedron(LAMMPS *lmp, int narg, char **arg)
|
||||
time_origin = update->ntimestep;
|
||||
|
||||
dmax = nmax = 0;
|
||||
discrete = NULL;
|
||||
dnum = dfirst = NULL;
|
||||
discrete = nullptr;
|
||||
dnum = dfirst = nullptr;
|
||||
|
||||
edmax = ednummax = 0;
|
||||
edge = NULL;
|
||||
ednum = edfirst = NULL;
|
||||
edge = nullptr;
|
||||
ednum = edfirst = nullptr;
|
||||
|
||||
facmax = facnummax = 0;
|
||||
face = NULL;
|
||||
facnum = facfirst = NULL;
|
||||
face = nullptr;
|
||||
facnum = facfirst = nullptr;
|
||||
|
||||
enclosing_radius = NULL;
|
||||
rounded_radius = NULL;
|
||||
enclosing_radius = nullptr;
|
||||
rounded_radius = nullptr;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -205,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);
|
||||
}
|
||||
|
||||
@ -237,7 +235,7 @@ void FixWallBodyPolyhedron::post_force(int /*vflag*/)
|
||||
// dx,dy,dz = signed distance from wall
|
||||
// for rotating cylinder, reset vwall based on particle position
|
||||
// skip atom if not close enough to wall
|
||||
// if wall was set to NULL, it's skipped since lo/hi are infinity
|
||||
// if wall was set to a null pointer, it's skipped since lo/hi are infinity
|
||||
// compute force and torque on atom if close enough to wall
|
||||
// via wall potential matched to pair potential
|
||||
|
||||
|
||||
@ -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
|
||||
@ -35,78 +35,72 @@ class FixWallBodyPolyhedron : public Fix {
|
||||
void reset_dt();
|
||||
|
||||
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
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -11,20 +12,20 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "pair_body_nparticle.h"
|
||||
#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;
|
||||
|
||||
@ -35,8 +36,8 @@ using namespace LAMMPS_NS;
|
||||
PairBodyNparticle::PairBodyNparticle(LAMMPS *lmp) : Pair(lmp)
|
||||
{
|
||||
dmax = nmax = 0;
|
||||
discrete = NULL;
|
||||
dnum = dfirst = NULL;
|
||||
discrete = nullptr;
|
||||
dnum = dfirst = nullptr;
|
||||
|
||||
single_enable = 0;
|
||||
restartinfo = 0;
|
||||
@ -77,8 +78,7 @@ void PairBodyNparticle::compute(int eflag, int vflag)
|
||||
int *ilist,*jlist,*numneigh,**firstneigh;
|
||||
|
||||
evdwl = 0.0;
|
||||
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||
else evflag = vflag_fdotr = 0;
|
||||
ev_init(eflag,vflag);
|
||||
|
||||
double **x = atom->x;
|
||||
double **f = atom->f;
|
||||
@ -324,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,7 +364,7 @@ void PairBodyNparticle::settings(int narg, char **arg)
|
||||
{
|
||||
if (narg != 1) error->all(FLERR,"Illegal pair_style command");
|
||||
|
||||
cut_global = force->numeric(FLERR,arg[0]);
|
||||
cut_global = utils::numeric(FLERR,arg[0],false,lmp);
|
||||
|
||||
// reset cutoffs that have been explicitly set
|
||||
|
||||
@ -388,14 +387,14 @@ void PairBodyNparticle::coeff(int narg, char **arg)
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi,jlo,jhi;
|
||||
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
|
||||
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi);
|
||||
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
|
||||
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
|
||||
|
||||
double epsilon_one = force->numeric(FLERR,arg[2]);
|
||||
double sigma_one = force->numeric(FLERR,arg[3]);
|
||||
double epsilon_one = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
double sigma_one = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
|
||||
double cut_one = cut_global;
|
||||
if (narg == 5) cut_one = force->numeric(FLERR,arg[4]);
|
||||
if (narg == 5) cut_one = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
|
||||
@ -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
|
||||
@ -37,24 +37,24 @@ class PairBodyNparticle : public Pair {
|
||||
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
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -18,23 +19,23 @@
|
||||
the contact history for friction forces.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "pair_body_rounded_polygon.h"
|
||||
#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;
|
||||
|
||||
@ -53,16 +54,16 @@ enum {INVALID=0,NONE=1,VERTEXI=2,VERTEXJ=3,EDGE=4};
|
||||
PairBodyRoundedPolygon::PairBodyRoundedPolygon(LAMMPS *lmp) : Pair(lmp)
|
||||
{
|
||||
dmax = nmax = 0;
|
||||
discrete = NULL;
|
||||
dnum = dfirst = NULL;
|
||||
discrete = nullptr;
|
||||
dnum = dfirst = nullptr;
|
||||
|
||||
edmax = ednummax = 0;
|
||||
edge = NULL;
|
||||
ednum = edfirst = NULL;
|
||||
edge = nullptr;
|
||||
ednum = edfirst = nullptr;
|
||||
|
||||
enclosing_radius = NULL;
|
||||
rounded_radius = NULL;
|
||||
maxerad = NULL;
|
||||
enclosing_radius = nullptr;
|
||||
rounded_radius = nullptr;
|
||||
maxerad = nullptr;
|
||||
|
||||
single_enable = 0;
|
||||
restartinfo = 0;
|
||||
@ -106,13 +107,12 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag)
|
||||
int ni,nj,npi,npj,ifirst,jfirst;
|
||||
int nei,nej,iefirst,jefirst;
|
||||
double xtmp,ytmp,ztmp,delx,dely,delz,evdwl;
|
||||
double rsq,rsqinv,r,radi,radj,eradi,eradj,rradi,rradj,k_nij,k_naij;
|
||||
double rsq,r,radi,radj,k_nij,k_naij;
|
||||
double facc[3];
|
||||
int *ilist,*jlist,*numneigh,**firstneigh;
|
||||
|
||||
evdwl = 0.0;
|
||||
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||
else evflag = vflag_fdotr = 0;
|
||||
ev_init(eflag,vflag);
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
@ -172,8 +172,6 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag)
|
||||
ifirst = dfirst[i];
|
||||
nei = ednum[i];
|
||||
iefirst = edfirst[i];
|
||||
eradi = enclosing_radius[i];
|
||||
rradi = rounded_radius[i];
|
||||
}
|
||||
|
||||
for (jj = 0; jj < jnum; jj++) {
|
||||
@ -199,8 +197,6 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag)
|
||||
jfirst = dfirst[j];
|
||||
nej = ednum[j];
|
||||
jefirst = edfirst[j];
|
||||
eradj = enclosing_radius[j];
|
||||
rradj = rounded_radius[j];
|
||||
|
||||
k_nij = k_n[itype][jtype];
|
||||
k_naij = k_na[itype][jtype];
|
||||
@ -209,11 +205,9 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag)
|
||||
|
||||
r = sqrt(rsq);
|
||||
if (r > radi + radj + cut_inner) continue;
|
||||
rsqinv = 1.0 / rsq;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -243,7 +237,7 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag)
|
||||
edge[jefirst+nj][4] = 0;
|
||||
}
|
||||
|
||||
int interact, num_contacts, done;
|
||||
int num_contacts, done;
|
||||
double delta_a, j_a;
|
||||
Contact contact_list[MAX_CONTACTS];
|
||||
|
||||
@ -251,15 +245,13 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag)
|
||||
|
||||
// check interaction between i's vertices and j' edges
|
||||
|
||||
interact = vertex_against_edge(i, j, k_nij, k_naij,
|
||||
x, f, torque, tag, contact_list,
|
||||
num_contacts, evdwl, facc);
|
||||
vertex_against_edge(i, j, k_nij, k_naij, x, f, torque, tag,
|
||||
contact_list, num_contacts, evdwl, facc);
|
||||
|
||||
// check interaction between j's vertices and i' edges
|
||||
|
||||
interact = vertex_against_edge(j, i, k_nij, k_naij,
|
||||
x, f, torque, tag, contact_list,
|
||||
num_contacts, evdwl, facc);
|
||||
vertex_against_edge(j, i, k_nij, k_naij, x, f, torque, tag,
|
||||
contact_list, num_contacts, evdwl, facc);
|
||||
|
||||
if (num_contacts >= 2) {
|
||||
|
||||
@ -374,11 +366,11 @@ void PairBodyRoundedPolygon::settings(int narg, char **arg)
|
||||
{
|
||||
if (narg < 5) error->all(FLERR,"Illegal pair_style command");
|
||||
|
||||
c_n = force->numeric(FLERR,arg[0]);
|
||||
c_t = force->numeric(FLERR,arg[1]);
|
||||
mu = force->numeric(FLERR,arg[2]);
|
||||
delta_ua = force->numeric(FLERR,arg[3]);
|
||||
cut_inner = force->numeric(FLERR,arg[4]);
|
||||
c_n = utils::numeric(FLERR,arg[0],false,lmp);
|
||||
c_t = utils::numeric(FLERR,arg[1],false,lmp);
|
||||
mu = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
delta_ua = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
cut_inner = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
|
||||
if (delta_ua < 0) delta_ua = 1;
|
||||
}
|
||||
@ -394,11 +386,11 @@ void PairBodyRoundedPolygon::coeff(int narg, char **arg)
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi,jlo,jhi;
|
||||
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
|
||||
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi);
|
||||
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
|
||||
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
|
||||
|
||||
double k_n_one = force->numeric(FLERR,arg[2]);
|
||||
double k_na_one = force->numeric(FLERR,arg[3]);
|
||||
double k_n_one = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
double k_na_one = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
@ -466,7 +458,7 @@ void PairBodyRoundedPolygon::init_style()
|
||||
for (i = 0; i < nlocal; i++)
|
||||
dnum[i] = ednum[i] = 0;
|
||||
|
||||
double *merad = NULL;
|
||||
double *merad = nullptr;
|
||||
memory->create(merad,ntypes+1,"pair:merad");
|
||||
for (i = 1; i <= ntypes; i++)
|
||||
maxerad[i] = merad[i] = 0;
|
||||
@ -577,6 +569,10 @@ void PairBodyRoundedPolygon::body2space(int i)
|
||||
memory->grow(edge,edmax,5,"pair:edge");
|
||||
}
|
||||
|
||||
if ((body_num_edges > 0) && (edge_ends == nullptr))
|
||||
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]);
|
||||
edge[nedge][1] = static_cast<int>(edge_ends[2*m+1]);
|
||||
@ -600,16 +596,13 @@ void PairBodyRoundedPolygon::sphere_against_sphere(int i, int j,
|
||||
double k_n, double k_na, double** /*x*/, double** v,
|
||||
double** f, int evflag)
|
||||
{
|
||||
double eradi,eradj,rradi,rradj;
|
||||
double rradi,rradj;
|
||||
double vr1,vr2,vr3,vnnr,vn1,vn2,vn3,vt1,vt2,vt3;
|
||||
double rij,rsqinv,R,fx,fy,fz,fn[3],ft[3],fpair,shift,energy;
|
||||
int nlocal = atom->nlocal;
|
||||
int newton_pair = force->newton_pair;
|
||||
|
||||
eradi = enclosing_radius[i];
|
||||
rradi = rounded_radius[i];
|
||||
|
||||
eradj = enclosing_radius[j];
|
||||
rradj = rounded_radius[j];
|
||||
|
||||
rsqinv = 1.0/rsq;
|
||||
@ -658,12 +651,16 @@ void PairBodyRoundedPolygon::sphere_against_sphere(int i, int j,
|
||||
fn[1] = -c_n * vn2;
|
||||
fn[2] = -c_n * vn3;
|
||||
|
||||
// tangential friction term at contact
|
||||
// excluding the tangential deformation term
|
||||
// tangential friction term at contact,
|
||||
// excluding the tangential deformation term for now
|
||||
|
||||
ft[0] = -c_t * vt1;
|
||||
ft[1] = -c_t * vt2;
|
||||
ft[2] = -c_t * vt3;
|
||||
|
||||
fx += fn[0] + ft[0];
|
||||
fy += fn[1] + ft[1];
|
||||
fz += fn[2] + ft[2];
|
||||
}
|
||||
|
||||
f[i][0] += fx;
|
||||
@ -705,20 +702,16 @@ int PairBodyRoundedPolygon::vertex_against_edge(int i, int j,
|
||||
int &num_contacts,
|
||||
double &evdwl, double* facc)
|
||||
{
|
||||
int ni, npi, ifirst, nei, iefirst;
|
||||
int nj, npj, jfirst, nej, jefirst;
|
||||
double xpi[3], xpj[3], dist, eradi, eradj, rradi, rradj;
|
||||
int ni, npi, ifirst;
|
||||
int nj, jfirst, nej, jefirst;
|
||||
double xpi[3], xpj[3], dist, eradj, rradi, rradj;
|
||||
double fx, fy, fz, energy;
|
||||
int interact;
|
||||
|
||||
npi = dnum[i];
|
||||
ifirst = dfirst[i];
|
||||
nei = ednum[i];
|
||||
iefirst = edfirst[i];
|
||||
eradi = enclosing_radius[i];
|
||||
rradi = rounded_radius[i];
|
||||
|
||||
npj = dnum[j];
|
||||
jfirst = dfirst[j];
|
||||
nej = ednum[j];
|
||||
jefirst = edfirst[j];
|
||||
@ -1376,4 +1369,3 @@ void PairBodyRoundedPolygon::distance(const double* x2, const double* x1,
|
||||
+ (x2[1] - x1[1]) * (x2[1] - x1[1])
|
||||
+ (x2[2] - x1[2]) * (x2[2] - x1[2]));
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
@ -35,81 +35,76 @@ class PairBodyRoundedPolygon : public Pair {
|
||||
double init_one(int, int);
|
||||
|
||||
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
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
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
|
||||
@ -20,28 +21,26 @@
|
||||
the contact history for friction forces.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "pair_body_rounded_polyhedron.h"
|
||||
#include "math_extra.h"
|
||||
|
||||
#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 MathExtra;
|
||||
using namespace MathConst;
|
||||
|
||||
#define DELTA 10000
|
||||
@ -60,20 +59,20 @@ enum {EF_INVALID=0,EF_NONE,EF_PARALLEL,EF_SAME_SIDE_OF_FACE,
|
||||
PairBodyRoundedPolyhedron::PairBodyRoundedPolyhedron(LAMMPS *lmp) : Pair(lmp)
|
||||
{
|
||||
dmax = nmax = 0;
|
||||
discrete = NULL;
|
||||
dnum = dfirst = NULL;
|
||||
discrete = nullptr;
|
||||
dnum = dfirst = nullptr;
|
||||
|
||||
edmax = ednummax = 0;
|
||||
edge = NULL;
|
||||
ednum = edfirst = NULL;
|
||||
edge = nullptr;
|
||||
ednum = edfirst = nullptr;
|
||||
|
||||
facmax = facnummax = 0;
|
||||
face = NULL;
|
||||
facnum = facfirst = NULL;
|
||||
face = nullptr;
|
||||
facnum = facfirst = nullptr;
|
||||
|
||||
enclosing_radius = NULL;
|
||||
rounded_radius = NULL;
|
||||
maxerad = NULL;
|
||||
enclosing_radius = nullptr;
|
||||
rounded_radius = nullptr;
|
||||
maxerad = nullptr;
|
||||
|
||||
single_enable = 0;
|
||||
restartinfo = 0;
|
||||
@ -83,8 +82,8 @@ PairBodyRoundedPolyhedron::PairBodyRoundedPolyhedron(LAMMPS *lmp) : Pair(lmp)
|
||||
mu = 0.0;
|
||||
A_ua = 1.0;
|
||||
|
||||
k_n = NULL;
|
||||
k_na = NULL;
|
||||
k_n = nullptr;
|
||||
k_na = nullptr;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -127,8 +126,7 @@ void PairBodyRoundedPolyhedron::compute(int eflag, int vflag)
|
||||
int *ilist,*jlist,*numneigh,**firstneigh;
|
||||
|
||||
evdwl = 0.0;
|
||||
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||
else evflag = vflag_fdotr = 0;
|
||||
ev_init(eflag,vflag);
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
@ -275,7 +273,7 @@ void PairBodyRoundedPolyhedron::compute(int eflag, int vflag)
|
||||
continue;
|
||||
}
|
||||
|
||||
int interact, num_contacts;
|
||||
int num_contacts;
|
||||
Contact contact_list[MAX_CONTACTS];
|
||||
|
||||
num_contacts = 0;
|
||||
@ -284,22 +282,22 @@ void PairBodyRoundedPolyhedron::compute(int eflag, int vflag)
|
||||
#ifdef _POLYHEDRON_DEBUG
|
||||
printf("INTERACTION between edges of %d vs. faces of %d:\n", i, j);
|
||||
#endif
|
||||
interact = edge_against_face(i, j, itype, jtype, x, contact_list,
|
||||
num_contacts, evdwl, facc);
|
||||
edge_against_face(i, j, itype, jtype, x, contact_list,
|
||||
num_contacts, evdwl, facc);
|
||||
|
||||
// check interaction between j's edges and i' faces
|
||||
#ifdef _POLYHEDRON_DEBUG
|
||||
printf("\nINTERACTION between edges of %d vs. faces of %d:\n", j, i);
|
||||
#endif
|
||||
interact = edge_against_face(j, i, jtype, itype, x, contact_list,
|
||||
num_contacts, evdwl, facc);
|
||||
edge_against_face(j, i, jtype, itype, x, contact_list,
|
||||
num_contacts, evdwl, facc);
|
||||
|
||||
// check interaction between i's edges and j' edges
|
||||
#ifdef _POLYHEDRON_DEBUG
|
||||
printf("INTERACTION between edges of %d vs. edges of %d:\n", i, j);
|
||||
#endif
|
||||
interact = edge_against_edge(i, j, itype, jtype, x, contact_list,
|
||||
num_contacts, evdwl, facc);
|
||||
edge_against_edge(i, j, itype, jtype, x, contact_list,
|
||||
num_contacts, evdwl, facc);
|
||||
|
||||
// estimate the contact area
|
||||
// also consider point contacts and line contacts
|
||||
@ -347,11 +345,11 @@ void PairBodyRoundedPolyhedron::settings(int narg, char **arg)
|
||||
{
|
||||
if (narg < 5) error->all(FLERR,"Illegal pair_style command");
|
||||
|
||||
c_n = force->numeric(FLERR,arg[0]);
|
||||
c_t = force->numeric(FLERR,arg[1]);
|
||||
mu = force->numeric(FLERR,arg[2]);
|
||||
A_ua = force->numeric(FLERR,arg[3]);
|
||||
cut_inner = force->numeric(FLERR,arg[4]);
|
||||
c_n = utils::numeric(FLERR,arg[0],false,lmp);
|
||||
c_t = utils::numeric(FLERR,arg[1],false,lmp);
|
||||
mu = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
A_ua = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
cut_inner = utils::numeric(FLERR,arg[4],false,lmp);
|
||||
|
||||
if (A_ua < 0) A_ua = 1;
|
||||
}
|
||||
@ -367,11 +365,11 @@ void PairBodyRoundedPolyhedron::coeff(int narg, char **arg)
|
||||
if (!allocated) allocate();
|
||||
|
||||
int ilo,ihi,jlo,jhi;
|
||||
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
|
||||
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi);
|
||||
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
|
||||
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
|
||||
|
||||
double k_n_one = force->numeric(FLERR,arg[2]);
|
||||
double k_na_one = force->numeric(FLERR,arg[3]);
|
||||
double k_n_one = utils::numeric(FLERR,arg[2],false,lmp);
|
||||
double k_na_one = utils::numeric(FLERR,arg[3],false,lmp);
|
||||
|
||||
int count = 0;
|
||||
for (int i = ilo; i <= ihi; i++) {
|
||||
@ -443,7 +441,7 @@ void PairBodyRoundedPolyhedron::init_style()
|
||||
for (i = 0; i < nlocal; i++)
|
||||
dnum[i] = ednum[i] = facnum[i] = 0;
|
||||
|
||||
double *merad = NULL;
|
||||
double *merad = nullptr;
|
||||
memory->create(merad,ntypes+1,"pair:merad");
|
||||
for (i = 1; i <= ntypes; i++)
|
||||
maxerad[i] = merad[i] = 0;
|
||||
@ -559,6 +557,10 @@ void PairBodyRoundedPolyhedron::body2space(int i)
|
||||
memory->grow(edge,edmax,6,"pair:edge");
|
||||
}
|
||||
|
||||
if ((body_num_edges > 0) && (edge_ends == nullptr))
|
||||
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]);
|
||||
edge[nedge][1] = static_cast<int>(edge_ends[2*m+1]);
|
||||
@ -582,6 +584,10 @@ void PairBodyRoundedPolyhedron::body2space(int i)
|
||||
memory->grow(face,facmax,MAX_FACE_SIZE,"pair:face");
|
||||
}
|
||||
|
||||
if ((body_num_faces > 0) && (face_pts == nullptr))
|
||||
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++)
|
||||
face[nface][k] = static_cast<int>(face_pts[MAX_FACE_SIZE*m+k]);
|
||||
@ -887,7 +893,7 @@ void PairBodyRoundedPolyhedron::sphere_against_face(int ibody, int jbody,
|
||||
|
||||
project_pt_plane(x[jbody], xi1, xi2, xi3, h, d, inside);
|
||||
|
||||
inside_polygon(ibody, ni, x[ibody], h, NULL, inside, tmp);
|
||||
inside_polygon(ibody, ni, x[ibody], h, nullptr, inside, tmp);
|
||||
if (inside == 0) continue;
|
||||
|
||||
delx = h[0] - x[jbody][0];
|
||||
@ -1206,10 +1212,7 @@ int PairBodyRoundedPolyhedron::interaction_edge_to_edge(int ibody,
|
||||
contact_list[num_contacts].unique = 1;
|
||||
num_contacts++;
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
return interact;
|
||||
}
|
||||
|
||||
@ -1883,7 +1886,7 @@ void PairBodyRoundedPolyhedron::project_pt_plane(const double* q,
|
||||
face_index = face index of the body
|
||||
xmi = atom i's coordinates
|
||||
q1 = tested point on the face (e.g. the projection of a point)
|
||||
q2 = another point (can be NULL) for face-edge intersection
|
||||
q2 = another point (can be a null pointer) for face-edge intersection
|
||||
Output:
|
||||
inside1 = 1 if q1 is inside the polygon, 0 otherwise
|
||||
inside2 = 1 if q2 is inside the polygon, 0 otherwise
|
||||
@ -1932,7 +1935,7 @@ void PairBodyRoundedPolyhedron::inside_polygon(int ibody, int face_index,
|
||||
anglesum1 += acos(costheta);
|
||||
}
|
||||
|
||||
if (q2 != NULL) {
|
||||
if (q2 != nullptr) {
|
||||
MathExtra::sub3(xi1,q2,u);
|
||||
MathExtra::sub3(xi2,q2,v);
|
||||
magu = MathExtra::len3(u);
|
||||
@ -1948,7 +1951,7 @@ void PairBodyRoundedPolyhedron::inside_polygon(int ibody, int face_index,
|
||||
if (fabs(anglesum1 - MY_2PI) < EPSILON) inside1 = 1;
|
||||
else inside1 = 0;
|
||||
|
||||
if (q2 != NULL) {
|
||||
if (q2 != nullptr) {
|
||||
if (fabs(anglesum2 - MY_2PI) < EPSILON) inside2 = 1;
|
||||
else inside2 = 0;
|
||||
}
|
||||
@ -2345,13 +2348,11 @@ void PairBodyRoundedPolyhedron::find_unique_contacts(Contact* contact_list,
|
||||
void PairBodyRoundedPolyhedron::sanity_check()
|
||||
{
|
||||
|
||||
double x1[3],x2[3],x3[3],x4[3],h_a[3],h_b[3],d_a,d_b;
|
||||
double x1[3],x2[3],h_a[3],h_b[3],d_a,d_b;
|
||||
double a[3],b[3],t_a,t_b;
|
||||
|
||||
x1[0] = 0; x1[1] = 3; x1[2] = 0;
|
||||
x2[0] = 3; x2[1] = 0; x2[2] = 0;
|
||||
x3[0] = 4; x3[1] = 3; x3[2] = 0;
|
||||
x4[0] = 5; x4[1] = 3; x4[2] = 0;
|
||||
|
||||
a[0] = 0; a[1] = 0; a[2] = 0;
|
||||
b[0] = 4; b[1] = 0; b[2] = 0;
|
||||
|
||||
@ -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
|
||||
@ -34,145 +34,131 @@ class PairBodyRoundedPolyhedron : public Pair {
|
||||
void init_style();
|
||||
double init_one(int, int);
|
||||
|
||||
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
|
||||
|
||||
130
src/BROWNIAN/fix_brownian.cpp
Normal file
130
src/BROWNIAN/fix_brownian.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Originally modified from CG-DNA/fix_nve_dotc_langevin.cpp.
|
||||
|
||||
Contributing author: Sam Cameron (University of Bristol)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_brownian.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "random_mars.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixBrownian::FixBrownian(LAMMPS *lmp, int narg, char **arg) : FixBrownianBase(lmp, narg, arg)
|
||||
{
|
||||
if (dipole_flag || gamma_t_eigen_flag || gamma_r_eigen_flag || gamma_r_flag) {
|
||||
error->all(FLERR, "Illegal fix brownian command.");
|
||||
}
|
||||
if (!gamma_t_flag) { error->all(FLERR, "Illegal fix brownian command."); }
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixBrownian::init()
|
||||
{
|
||||
FixBrownianBase::init();
|
||||
g1 /= gamma_t;
|
||||
g2 /= sqrt(gamma_t);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixBrownian::initial_integrate(int /*vflag */)
|
||||
{
|
||||
if (domain->dimension == 2) {
|
||||
if (!noise_flag) {
|
||||
initial_integrate_templated<0, 0, 1>();
|
||||
} else if (gaussian_noise_flag) {
|
||||
initial_integrate_templated<0, 1, 1>();
|
||||
} else {
|
||||
initial_integrate_templated<1, 0, 1>();
|
||||
}
|
||||
} else {
|
||||
if (!noise_flag) {
|
||||
initial_integrate_templated<0, 0, 0>();
|
||||
} else if (gaussian_noise_flag) {
|
||||
initial_integrate_templated<0, 1, 0>();
|
||||
} else {
|
||||
initial_integrate_templated<1, 0, 0>();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template <int Tp_UNIFORM, int Tp_GAUSS, int Tp_2D> void FixBrownian::initial_integrate_templated()
|
||||
{
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double **f = atom->f;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
|
||||
|
||||
double dx, dy, dz;
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
if (Tp_2D) {
|
||||
dz = 0;
|
||||
if (Tp_UNIFORM) {
|
||||
dx = dt * (g1 * f[i][0] + g2 * (rng->uniform() - 0.5));
|
||||
dy = dt * (g1 * f[i][1] + g2 * (rng->uniform() - 0.5));
|
||||
} else if (Tp_GAUSS) {
|
||||
dx = dt * (g1 * f[i][0] + g2 * rng->gaussian());
|
||||
dy = dt * (g1 * f[i][1] + g2 * rng->gaussian());
|
||||
} else {
|
||||
dx = dt * g1 * f[i][0];
|
||||
dy = dt * g1 * f[i][1];
|
||||
}
|
||||
} else {
|
||||
if (Tp_UNIFORM) {
|
||||
dx = dt * (g1 * f[i][0] + g2 * (rng->uniform() - 0.5));
|
||||
dy = dt * (g1 * f[i][1] + g2 * (rng->uniform() - 0.5));
|
||||
dz = dt * (g1 * f[i][2] + g2 * (rng->uniform() - 0.5));
|
||||
} else if (Tp_GAUSS) {
|
||||
dx = dt * (g1 * f[i][0] + g2 * rng->gaussian());
|
||||
dy = dt * (g1 * f[i][1] + g2 * rng->gaussian());
|
||||
dz = dt * (g1 * f[i][2] + g2 * rng->gaussian());
|
||||
} else {
|
||||
dx = dt * g1 * f[i][0];
|
||||
dy = dt * g1 * f[i][1];
|
||||
dz = dt * g1 * f[i][2];
|
||||
}
|
||||
}
|
||||
|
||||
x[i][0] += dx;
|
||||
v[i][0] = dx / dt;
|
||||
|
||||
x[i][1] += dy;
|
||||
v[i][1] = dy / dt;
|
||||
|
||||
x[i][2] += dz;
|
||||
v[i][2] = dz / dt;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
60
src/BROWNIAN/fix_brownian.h
Normal file
60
src/BROWNIAN/fix_brownian.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* -*- 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(brownian,FixBrownian);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_FIX_BROWNIAN_H
|
||||
#define LMP_FIX_BROWNIAN_H
|
||||
|
||||
#include "fix_brownian_base.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class FixBrownian : public FixBrownianBase {
|
||||
public:
|
||||
FixBrownian(class LAMMPS *, int, char **);
|
||||
virtual ~FixBrownian(){};
|
||||
void init();
|
||||
void initial_integrate(int);
|
||||
|
||||
private:
|
||||
template <int Tp_UNIFORM, int Tp_GAUSS, int Tp_2D> void initial_integrate_templated();
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal fix brownian command.
|
||||
|
||||
Wrong number/type of input arguments.
|
||||
|
||||
E: Fix brownian viscous drag coefficient must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian diffusion coefficient must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian seed must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
*/
|
||||
264
src/BROWNIAN/fix_brownian_asphere.cpp
Normal file
264
src/BROWNIAN/fix_brownian_asphere.cpp
Normal file
@ -0,0 +1,264 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Originally modified from CG-DNA/fix_nve_dotc_langevin.cpp.
|
||||
|
||||
Contributing author: Sam Cameron (University of Bristol)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_brownian_asphere.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "atom_vec_ellipsoid.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "math_extra.h"
|
||||
#include "random_mars.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixBrownianAsphere::FixBrownianAsphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
FixBrownianBase(lmp, narg, arg), avec(nullptr)
|
||||
{
|
||||
if (!gamma_t_eigen_flag || !gamma_r_eigen_flag) {
|
||||
error->all(FLERR, "Illegal fix brownian command.");
|
||||
}
|
||||
|
||||
if (gamma_t_flag || gamma_r_flag) error->all(FLERR, "Illegal fix brownian command.");
|
||||
|
||||
if (dipole_flag && !atom->mu_flag)
|
||||
error->all(FLERR, "Fix brownian/asphere dipole requires atom attribute mu");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixBrownianAsphere::init()
|
||||
{
|
||||
avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
|
||||
if (!avec) error->all(FLERR, "Compute brownian/asphere requires atom style ellipsoid");
|
||||
|
||||
// check that all particles are finite-size ellipsoids
|
||||
// no point particles allowed, spherical is OK
|
||||
|
||||
int *ellipsoid = atom->ellipsoid;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
if (ellipsoid[i] < 0) error->one(FLERR, "Fix brownian/asphere requires extended particles");
|
||||
|
||||
if (dipole_flag) {
|
||||
|
||||
double f_rot[3];
|
||||
double *quat;
|
||||
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
|
||||
|
||||
double Q[3][3];
|
||||
double **mu = atom->mu;
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
quat = bonus[ellipsoid[i]].quat;
|
||||
MathExtra::quat_to_mat(quat, Q);
|
||||
MathExtra::matvec(Q, dipole_body, f_rot);
|
||||
|
||||
mu[i][0] = f_rot[0];
|
||||
mu[i][1] = f_rot[1];
|
||||
mu[i][2] = f_rot[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FixBrownianBase::init();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixBrownianAsphere::initial_integrate(int /*vflag */)
|
||||
{
|
||||
if (domain->dimension == 2) {
|
||||
if (dipole_flag) {
|
||||
if (!noise_flag) {
|
||||
initial_integrate_templated<0, 0, 1, 1>();
|
||||
} else if (gaussian_noise_flag) {
|
||||
initial_integrate_templated<0, 1, 1, 1>();
|
||||
} else {
|
||||
initial_integrate_templated<1, 0, 1, 1>();
|
||||
}
|
||||
} else {
|
||||
if (!noise_flag) {
|
||||
initial_integrate_templated<0, 0, 0, 1>();
|
||||
} else if (gaussian_noise_flag) {
|
||||
initial_integrate_templated<0, 1, 0, 1>();
|
||||
} else {
|
||||
initial_integrate_templated<1, 0, 0, 1>();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (dipole_flag) {
|
||||
if (!noise_flag) {
|
||||
initial_integrate_templated<0, 0, 1, 0>();
|
||||
} else if (gaussian_noise_flag) {
|
||||
initial_integrate_templated<0, 1, 1, 0>();
|
||||
} else {
|
||||
initial_integrate_templated<1, 0, 1, 0>();
|
||||
}
|
||||
} else {
|
||||
if (!noise_flag) {
|
||||
initial_integrate_templated<0, 0, 0, 0>();
|
||||
} else if (gaussian_noise_flag) {
|
||||
initial_integrate_templated<0, 1, 0, 0>();
|
||||
} else {
|
||||
initial_integrate_templated<1, 0, 0, 0>();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template <int Tp_UNIFORM, int Tp_GAUSS, int Tp_DIPOLE, int Tp_2D>
|
||||
void FixBrownianAsphere::initial_integrate_templated()
|
||||
{
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double **f = atom->f;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
|
||||
|
||||
double **mu = atom->mu;
|
||||
double **torque = atom->torque;
|
||||
double qw[4];
|
||||
double *quat;
|
||||
int *ellipsoid = atom->ellipsoid;
|
||||
|
||||
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
|
||||
|
||||
// project dipole along x axis of quat
|
||||
double f_rot[3];
|
||||
double rotationmatrix_transpose[3][3];
|
||||
double tmp[3];
|
||||
double dv[3];
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
|
||||
// update orientation first
|
||||
|
||||
quat = bonus[ellipsoid[i]].quat;
|
||||
MathExtra::quat_to_mat_trans(quat, rotationmatrix_transpose);
|
||||
|
||||
// tmp holds angular velocity in body frame
|
||||
MathExtra::matvec(rotationmatrix_transpose, torque[i], tmp);
|
||||
|
||||
if (Tp_2D) {
|
||||
tmp[0] = tmp[1] = 0.0;
|
||||
if (Tp_UNIFORM) {
|
||||
tmp[2] = g1 * tmp[2] * gamma_r_inv[2] + gamma_r_invsqrt[2] * (rng->uniform() - 0.5) * g2;
|
||||
} else if (Tp_GAUSS) {
|
||||
tmp[2] = g1 * tmp[2] * gamma_r_inv[2] + gamma_r_invsqrt[2] * rng->gaussian() * g2;
|
||||
} else {
|
||||
tmp[2] = g1 * tmp[2] * gamma_r_inv[2];
|
||||
}
|
||||
} else {
|
||||
if (Tp_UNIFORM) {
|
||||
tmp[0] = g1 * tmp[0] * gamma_r_inv[0] + gamma_r_invsqrt[0] * (rng->uniform() - 0.5) * g2;
|
||||
tmp[1] = g1 * tmp[1] * gamma_r_inv[1] + gamma_r_invsqrt[1] * (rng->uniform() - 0.5) * g2;
|
||||
tmp[2] = g1 * tmp[2] * gamma_r_inv[2] + gamma_r_invsqrt[2] * (rng->uniform() - 0.5) * g2;
|
||||
} else if (Tp_GAUSS) {
|
||||
tmp[0] = g1 * tmp[0] * gamma_r_inv[0] + gamma_r_invsqrt[0] * rng->gaussian() * g2;
|
||||
tmp[1] = g1 * tmp[1] * gamma_r_inv[1] + gamma_r_invsqrt[1] * rng->gaussian() * g2;
|
||||
tmp[2] = g1 * tmp[2] * gamma_r_inv[2] + gamma_r_invsqrt[2] * rng->gaussian() * g2;
|
||||
} else {
|
||||
tmp[0] = g1 * tmp[0] * gamma_r_inv[0];
|
||||
tmp[1] = g1 * tmp[1] * gamma_r_inv[1];
|
||||
tmp[2] = g1 * tmp[2] * gamma_r_inv[2];
|
||||
}
|
||||
}
|
||||
|
||||
// convert body frame angular velocity to quaternion
|
||||
MathExtra::quatvec(quat, tmp, qw);
|
||||
quat[0] = quat[0] + 0.5 * dt * qw[0];
|
||||
quat[1] = quat[1] + 0.5 * dt * qw[1];
|
||||
quat[2] = quat[2] + 0.5 * dt * qw[2];
|
||||
quat[3] = quat[3] + 0.5 * dt * qw[3];
|
||||
|
||||
// normalisation introduces the stochastic drift term
|
||||
// to recover the Boltzmann distribution for the case of conservative torques
|
||||
MathExtra::qnormalize(quat);
|
||||
|
||||
// next, update centre of mass positions and velocities
|
||||
|
||||
// tmp now holds force in body frame
|
||||
MathExtra::matvec(rotationmatrix_transpose, f[i], tmp);
|
||||
// and then converts to gamma_t^{-1} * F (velocity) in body frame
|
||||
|
||||
if (Tp_2D) {
|
||||
tmp[2] = 0.0;
|
||||
if (Tp_UNIFORM) {
|
||||
tmp[0] = g1 * tmp[0] * gamma_t_inv[0] + gamma_t_invsqrt[0] * (rng->uniform() - 0.5) * g2;
|
||||
tmp[1] = g1 * tmp[1] * gamma_t_inv[1] + gamma_t_invsqrt[1] * (rng->uniform() - 0.5) * g2;
|
||||
} else if (Tp_GAUSS) {
|
||||
tmp[0] = g1 * tmp[0] * gamma_t_inv[0] + gamma_t_invsqrt[0] * rng->gaussian() * g2;
|
||||
tmp[1] = g1 * tmp[1] * gamma_t_inv[1] + gamma_t_invsqrt[1] * rng->gaussian() * g2;
|
||||
} else {
|
||||
tmp[0] = g1 * tmp[0] * gamma_t_inv[0];
|
||||
tmp[1] = g1 * tmp[1] * gamma_t_inv[1];
|
||||
}
|
||||
} else {
|
||||
if (Tp_UNIFORM) {
|
||||
tmp[0] = g1 * tmp[0] * gamma_t_inv[0] + gamma_t_invsqrt[0] * (rng->uniform() - 0.5) * g2;
|
||||
tmp[1] = g1 * tmp[1] * gamma_t_inv[1] + gamma_t_invsqrt[1] * (rng->uniform() - 0.5) * g2;
|
||||
tmp[2] = g1 * tmp[2] * gamma_t_inv[2] + gamma_t_invsqrt[2] * (rng->uniform() - 0.5) * g2;
|
||||
} else if (Tp_GAUSS) {
|
||||
tmp[0] = g1 * tmp[0] * gamma_t_inv[0] + gamma_t_invsqrt[0] * rng->gaussian() * g2;
|
||||
tmp[1] = g1 * tmp[1] * gamma_t_inv[1] + gamma_t_invsqrt[1] * rng->gaussian() * g2;
|
||||
tmp[2] = g1 * tmp[2] * gamma_t_inv[2] + gamma_t_invsqrt[2] * rng->gaussian() * g2;
|
||||
} else {
|
||||
tmp[0] = g1 * tmp[0] * gamma_t_inv[0];
|
||||
tmp[1] = g1 * tmp[1] * gamma_t_inv[1];
|
||||
tmp[2] = g1 * tmp[2] * gamma_t_inv[2];
|
||||
}
|
||||
}
|
||||
|
||||
// finally, convert this back to lab-frame velocity and store in dv
|
||||
MathExtra::transpose_matvec(rotationmatrix_transpose, tmp, dv);
|
||||
|
||||
v[i][0] = dv[0];
|
||||
v[i][1] = dv[1];
|
||||
v[i][2] = dv[2];
|
||||
|
||||
x[i][0] += dv[0] * dt;
|
||||
x[i][1] += dv[1] * dt;
|
||||
x[i][2] += dv[2] * dt;
|
||||
|
||||
if (Tp_DIPOLE) {
|
||||
MathExtra::quat_to_mat_trans(quat, rotationmatrix_transpose);
|
||||
MathExtra::transpose_matvec(rotationmatrix_transpose, dipole_body, f_rot);
|
||||
mu[i][0] = f_rot[0];
|
||||
mu[i][1] = f_rot[1];
|
||||
mu[i][2] = f_rot[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
81
src/BROWNIAN/fix_brownian_asphere.h
Normal file
81
src/BROWNIAN/fix_brownian_asphere.h
Normal file
@ -0,0 +1,81 @@
|
||||
/* -*- 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(brownian/asphere,FixBrownianAsphere);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_FIX_BROWNIAN_ASPHERE_H
|
||||
#define LMP_FIX_BROWNIAN_ASPHERE_H
|
||||
|
||||
#include "fix_brownian_base.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class FixBrownianAsphere : public FixBrownianBase {
|
||||
public:
|
||||
FixBrownianAsphere(class LAMMPS *, int, char **);
|
||||
virtual ~FixBrownianAsphere(){};
|
||||
void initial_integrate(int);
|
||||
void init();
|
||||
|
||||
protected:
|
||||
class AtomVecEllipsoid *avec;
|
||||
|
||||
private:
|
||||
template <int Tp_UNIFORM, int Tp_GAUSS, int Tp_DIPOLE, int Tp_2D>
|
||||
void initial_integrate_templated();
|
||||
};
|
||||
} // namespace LAMMPS_NS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal fix brownian/asphere command.
|
||||
|
||||
Wrong number/type of input arguments.
|
||||
|
||||
E: Compute brownian/asphere requires atom style sphere
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Compute brownian/asphere requires atom style ellipsoid
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Compute brownian/asphere dipole requires atom attribute mu
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian/asphere translational viscous drag coefficient must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian/asphere rotational viscous drag coefficient must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian/asphere translational diffusion coefficient must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian/asphere rotational diffusion coefficient must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian/asphere seed must be > 0.
|
||||
|
||||
*/
|
||||
216
src/BROWNIAN/fix_brownian_base.cpp
Normal file
216
src/BROWNIAN/fix_brownian_base.cpp
Normal file
@ -0,0 +1,216 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Originally modified from CG-DNA/fix_nve_dotc_langevin.cpp.
|
||||
|
||||
Contributing author: Sam Cameron (University of Bristol)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_brownian_base.h"
|
||||
|
||||
#include "comm.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "force.h"
|
||||
#include "random_mars.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixBrownianBase::FixBrownianBase(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
{
|
||||
time_integrate = 1;
|
||||
|
||||
noise_flag = 1;
|
||||
gaussian_noise_flag = 0;
|
||||
gamma_t_flag = gamma_r_flag = 0;
|
||||
gamma_t_eigen_flag = gamma_r_eigen_flag = 0;
|
||||
dipole_flag = 0;
|
||||
g2 = 0.0;
|
||||
|
||||
if (narg < 5) error->all(FLERR, "Illegal fix brownian command.");
|
||||
|
||||
temp = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
if (temp <= 0) error->all(FLERR, "Fix brownian temp must be > 0.");
|
||||
|
||||
seed = utils::inumeric(FLERR, arg[4], false, lmp);
|
||||
if (seed <= 0) error->all(FLERR, "Fix brownian seed must be > 0.");
|
||||
|
||||
int iarg = 5;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg], "rng") == 0) {
|
||||
if (narg == iarg + 1) error->all(FLERR, "Illegal fix brownian command.");
|
||||
if (strcmp(arg[iarg + 1], "uniform") == 0) {
|
||||
noise_flag = 1;
|
||||
} else if (strcmp(arg[iarg + 1], "gaussian") == 0) {
|
||||
noise_flag = 1;
|
||||
gaussian_noise_flag = 1;
|
||||
} else if (strcmp(arg[iarg + 1], "none") == 0) {
|
||||
noise_flag = 0;
|
||||
} else {
|
||||
error->all(FLERR, "Illegal fix brownian command.");
|
||||
}
|
||||
iarg = iarg + 2;
|
||||
} else if (strcmp(arg[iarg], "dipole") == 0) {
|
||||
if (narg == iarg + 3) error->all(FLERR, "Illegal fix brownian command.");
|
||||
|
||||
dipole_flag = 1;
|
||||
dipole_body = new double[3];
|
||||
|
||||
dipole_body[0] = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
|
||||
dipole_body[1] = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
|
||||
dipole_body[2] = utils::numeric(FLERR, arg[iarg + 3], false, lmp);
|
||||
iarg = iarg + 4;
|
||||
|
||||
} else if (strcmp(arg[iarg], "gamma_t_eigen") == 0) {
|
||||
if (narg == iarg + 3) error->all(FLERR, "Illegal fix brownian command.");
|
||||
|
||||
gamma_t_eigen_flag = 1;
|
||||
gamma_t_inv = new double[3];
|
||||
gamma_t_invsqrt = new double[3];
|
||||
gamma_t_inv[0] = 1. / utils::numeric(FLERR, arg[iarg + 1], false, lmp);
|
||||
gamma_t_inv[1] = 1. / utils::numeric(FLERR, arg[iarg + 2], false, lmp);
|
||||
|
||||
if (domain->dimension == 2) {
|
||||
if (strcmp(arg[iarg + 3], "inf") != 0) {
|
||||
error->all(FLERR, "Fix brownian gamma_t_eigen third value must be inf for 2D system.");
|
||||
}
|
||||
gamma_t_inv[2] = 0;
|
||||
} else {
|
||||
gamma_t_inv[2] = 1.0 / utils::numeric(FLERR, arg[iarg + 3], false, lmp);
|
||||
}
|
||||
|
||||
if (gamma_t_inv[0] < 0 || gamma_t_inv[1] < 0 || gamma_t_inv[2] < 0)
|
||||
error->all(FLERR, "Fix brownian gamma_t_eigen values must be > 0.");
|
||||
|
||||
gamma_t_invsqrt[0] = sqrt(gamma_t_inv[0]);
|
||||
gamma_t_invsqrt[1] = sqrt(gamma_t_inv[1]);
|
||||
gamma_t_invsqrt[2] = sqrt(gamma_t_inv[2]);
|
||||
iarg = iarg + 4;
|
||||
|
||||
} else if (strcmp(arg[iarg], "gamma_r_eigen") == 0) {
|
||||
if (narg == iarg + 3) error->all(FLERR, "Illegal fix brownian command.");
|
||||
|
||||
gamma_r_eigen_flag = 1;
|
||||
gamma_r_inv = new double[3];
|
||||
gamma_r_invsqrt = new double[3];
|
||||
|
||||
if (domain->dimension == 2) {
|
||||
if (strcmp(arg[iarg + 1], "inf") != 0) {
|
||||
error->all(FLERR, "Fix brownian gamma_r_eigen first value must be inf for 2D system.");
|
||||
}
|
||||
gamma_r_inv[0] = 0;
|
||||
|
||||
if (strcmp(arg[iarg + 2], "inf") != 0) {
|
||||
error->all(FLERR, "Fix brownian gamma_r_eigen second value must be inf for 2D system.");
|
||||
}
|
||||
gamma_r_inv[1] = 0;
|
||||
} else {
|
||||
|
||||
gamma_r_inv[0] = 1. / utils::numeric(FLERR, arg[iarg + 1], false, lmp);
|
||||
gamma_r_inv[1] = 1. / utils::numeric(FLERR, arg[iarg + 2], false, lmp);
|
||||
}
|
||||
|
||||
gamma_r_inv[2] = 1. / utils::numeric(FLERR, arg[iarg + 3], false, lmp);
|
||||
|
||||
if (gamma_r_inv[0] < 0 || gamma_r_inv[1] < 0 || gamma_r_inv[2] < 0)
|
||||
error->all(FLERR, "Fix brownian gamma_r_eigen values must be > 0.");
|
||||
|
||||
gamma_r_invsqrt[0] = sqrt(gamma_r_inv[0]);
|
||||
gamma_r_invsqrt[1] = sqrt(gamma_r_inv[1]);
|
||||
gamma_r_invsqrt[2] = sqrt(gamma_r_inv[2]);
|
||||
iarg = iarg + 4;
|
||||
|
||||
} else if (strcmp(arg[iarg], "gamma_t") == 0) {
|
||||
if (narg == iarg + 1) { error->all(FLERR, "Illegal fix brownian command."); }
|
||||
|
||||
gamma_t_flag = 1;
|
||||
gamma_t = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
|
||||
if (gamma_t <= 0) error->all(FLERR, "Fix brownian gamma_t must be > 0.");
|
||||
iarg = iarg + 2;
|
||||
|
||||
} else if (strcmp(arg[iarg], "gamma_r") == 0) {
|
||||
if (narg == iarg + 1) { error->all(FLERR, "Illegal fix brownian command."); }
|
||||
|
||||
gamma_r_flag = 1;
|
||||
gamma_r = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
|
||||
if (gamma_r <= 0) error->all(FLERR, "Fix brownian gamma_r must be > 0.");
|
||||
iarg = iarg + 2;
|
||||
|
||||
} else {
|
||||
error->all(FLERR, "Illegal fix brownian command.");
|
||||
}
|
||||
}
|
||||
|
||||
// initialize Marsaglia RNG with processor-unique seed
|
||||
rng = new RanMars(lmp, seed + comm->me);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int FixBrownianBase::setmask()
|
||||
{
|
||||
int mask = 0;
|
||||
mask |= INITIAL_INTEGRATE;
|
||||
return mask;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixBrownianBase::~FixBrownianBase()
|
||||
{
|
||||
|
||||
if (gamma_t_eigen_flag) {
|
||||
delete[] gamma_t_inv;
|
||||
delete[] gamma_t_invsqrt;
|
||||
}
|
||||
if (gamma_r_eigen_flag) {
|
||||
delete[] gamma_r_inv;
|
||||
delete[] gamma_r_invsqrt;
|
||||
}
|
||||
|
||||
if (dipole_flag) { delete[] dipole_body; }
|
||||
delete rng;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixBrownianBase::init()
|
||||
{
|
||||
dt = update->dt;
|
||||
sqrtdt = sqrt(dt);
|
||||
|
||||
g1 = force->ftm2v;
|
||||
if (noise_flag == 0) {
|
||||
g2 = 0.0;
|
||||
} else if (gaussian_noise_flag == 1) {
|
||||
g2 = sqrt(2 * force->boltz * temp / dt / force->mvv2e);
|
||||
} else {
|
||||
g2 = sqrt(24 * force->boltz * temp / dt / force->mvv2e);
|
||||
}
|
||||
}
|
||||
|
||||
void FixBrownianBase::reset_dt()
|
||||
{
|
||||
double sqrtdt_old = sqrtdt;
|
||||
dt = update->dt;
|
||||
sqrtdt = sqrt(dt);
|
||||
g2 *= sqrtdt_old / sqrtdt;
|
||||
}
|
||||
88
src/BROWNIAN/fix_brownian_base.h
Normal file
88
src/BROWNIAN/fix_brownian_base.h
Normal file
@ -0,0 +1,88 @@
|
||||
/* -*- 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_FIX_BROWNIAN_BASE_H
|
||||
#define LMP_FIX_BROWNIAN_BASE_H
|
||||
|
||||
#include "fix.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class FixBrownianBase : public Fix {
|
||||
public:
|
||||
FixBrownianBase(class LAMMPS *, int, char **);
|
||||
virtual ~FixBrownianBase();
|
||||
void init();
|
||||
int setmask();
|
||||
void reset_dt();
|
||||
|
||||
protected:
|
||||
int seed; // RNG seed
|
||||
double dt, sqrtdt; // time step interval and its sqrt
|
||||
int gamma_t_flag; // 0/1 if isotropic translational damping is unset/set
|
||||
int gamma_r_flag; // 0/1 if isotropic rotational damping is unset/set
|
||||
int gamma_t_eigen_flag; // 0/1 if anisotropic translational damping is unset/set
|
||||
int gamma_r_eigen_flag; // 0/1 if anisotropic rotational damping is unset/set
|
||||
|
||||
double gamma_t, gamma_r; // translational and rotational (isotropic) damping params
|
||||
double *gamma_t_inv; // anisotropic damping parameter eigenvalues
|
||||
double *gamma_r_inv;
|
||||
double *gamma_t_invsqrt;
|
||||
double *gamma_r_invsqrt;
|
||||
|
||||
int dipole_flag; // set if dipole is used for asphere
|
||||
double *dipole_body; // direction dipole is slaved to in body frame
|
||||
|
||||
int noise_flag; // 0/1 for noise off/on
|
||||
int gaussian_noise_flag; // 0/1 for uniform/gaussian noise
|
||||
|
||||
double temp; // temperature
|
||||
double g1, g2; // prefactors in time stepping
|
||||
|
||||
class RanMars *rng;
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal fix brownian command.
|
||||
|
||||
Wrong number/type of input arguments.
|
||||
|
||||
E: Fix brownian gamma_t_eigen values must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian gamma_r_eigen values must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian seed must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian temp must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian gamma_t must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian gamma_r must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
*/
|
||||
180
src/BROWNIAN/fix_brownian_sphere.cpp
Normal file
180
src/BROWNIAN/fix_brownian_sphere.cpp
Normal file
@ -0,0 +1,180 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Originally modified from CG-DNA/fix_nve_dotc_langevin.cpp.
|
||||
|
||||
Contributing author: Sam Cameron (University of Bristol)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_brownian_sphere.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "math_extra.h"
|
||||
#include "random_mars.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixBrownianSphere::FixBrownianSphere(LAMMPS *lmp, int narg, char **arg) :
|
||||
FixBrownianBase(lmp, narg, arg)
|
||||
{
|
||||
if (gamma_t_eigen_flag || gamma_r_eigen_flag) {
|
||||
error->all(FLERR, "Illegal fix brownian command.");
|
||||
}
|
||||
|
||||
if (!gamma_t_flag || !gamma_r_flag) { error->all(FLERR, "Illegal fix brownian command."); }
|
||||
if (!atom->mu_flag) error->all(FLERR, "Fix brownian/sphere requires atom attribute mu");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixBrownianSphere::init()
|
||||
{
|
||||
FixBrownianBase::init();
|
||||
|
||||
g3 = g1 / gamma_r;
|
||||
g4 = g2 / sqrt(gamma_r);
|
||||
g1 /= gamma_t;
|
||||
g2 /= sqrt(gamma_t);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixBrownianSphere::initial_integrate(int /*vflag */)
|
||||
{
|
||||
if (domain->dimension == 2) {
|
||||
if (!noise_flag) {
|
||||
initial_integrate_templated<0, 0, 1>();
|
||||
} else if (gaussian_noise_flag) {
|
||||
initial_integrate_templated<0, 1, 1>();
|
||||
} else {
|
||||
initial_integrate_templated<1, 0, 1>();
|
||||
}
|
||||
} else {
|
||||
if (!noise_flag) {
|
||||
initial_integrate_templated<0, 0, 0>();
|
||||
} else if (gaussian_noise_flag) {
|
||||
initial_integrate_templated<0, 1, 0>();
|
||||
} else {
|
||||
initial_integrate_templated<1, 0, 0>();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template <int Tp_UNIFORM, int Tp_GAUSS, int Tp_2D>
|
||||
void FixBrownianSphere::initial_integrate_templated()
|
||||
{
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double **f = atom->f;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
double wx, wy, wz;
|
||||
double **torque = atom->torque;
|
||||
double **mu = atom->mu;
|
||||
double mux, muy, muz, mulen;
|
||||
|
||||
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
|
||||
|
||||
double dx, dy, dz;
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
if (Tp_2D) {
|
||||
dz = 0;
|
||||
wx = wy = 0;
|
||||
if (Tp_UNIFORM) {
|
||||
dx = dt * (g1 * f[i][0] + g2 * (rng->uniform() - 0.5));
|
||||
dy = dt * (g1 * f[i][1] + g2 * (rng->uniform() - 0.5));
|
||||
wz = (rng->uniform() - 0.5) * g4;
|
||||
} else if (Tp_GAUSS) {
|
||||
dx = dt * (g1 * f[i][0] + g2 * rng->gaussian());
|
||||
dy = dt * (g1 * f[i][1] + g2 * rng->gaussian());
|
||||
wz = rng->gaussian() * g4;
|
||||
} else {
|
||||
dx = dt * g1 * f[i][0];
|
||||
dy = dt * g1 * f[i][1];
|
||||
wz = 0;
|
||||
}
|
||||
} else {
|
||||
if (Tp_UNIFORM) {
|
||||
dx = dt * (g1 * f[i][0] + g2 * (rng->uniform() - 0.5));
|
||||
dy = dt * (g1 * f[i][1] + g2 * (rng->uniform() - 0.5));
|
||||
dz = dt * (g1 * f[i][2] + g2 * (rng->uniform() - 0.5));
|
||||
wx = (rng->uniform() - 0.5) * g4;
|
||||
wy = (rng->uniform() - 0.5) * g4;
|
||||
wz = (rng->uniform() - 0.5) * g4;
|
||||
} else if (Tp_GAUSS) {
|
||||
dx = dt * (g1 * f[i][0] + g2 * rng->gaussian());
|
||||
dy = dt * (g1 * f[i][1] + g2 * rng->gaussian());
|
||||
dz = dt * (g1 * f[i][2] + g2 * rng->gaussian());
|
||||
wx = rng->gaussian() * g4;
|
||||
wy = rng->gaussian() * g4;
|
||||
wz = rng->gaussian() * g4;
|
||||
} else {
|
||||
dx = dt * g1 * f[i][0];
|
||||
dy = dt * g1 * f[i][1];
|
||||
dz = dt * g1 * f[i][2];
|
||||
wx = wy = wz = 0;
|
||||
}
|
||||
}
|
||||
|
||||
x[i][0] += dx;
|
||||
v[i][0] = dx / dt;
|
||||
|
||||
x[i][1] += dy;
|
||||
v[i][1] = dy / dt;
|
||||
|
||||
x[i][2] += dz;
|
||||
v[i][2] = dz / dt;
|
||||
|
||||
wx += g3 * torque[i][0];
|
||||
wy += g3 * torque[i][1];
|
||||
wz += g3 * torque[i][2];
|
||||
|
||||
// store length of dipole as we need to convert it to a unit vector and
|
||||
// then back again
|
||||
|
||||
mulen = sqrt(mu[i][0] * mu[i][0] + mu[i][1] * mu[i][1] + mu[i][2] * mu[i][2]);
|
||||
|
||||
// unit vector at time t
|
||||
mux = mu[i][0] / mulen;
|
||||
muy = mu[i][1] / mulen;
|
||||
muz = mu[i][2] / mulen;
|
||||
|
||||
// un-normalised unit vector at time t + dt
|
||||
mu[i][0] = mux + (wy * muz - wz * muy) * dt;
|
||||
mu[i][1] = muy + (wz * mux - wx * muz) * dt;
|
||||
mu[i][2] = muz + (wx * muy - wy * mux) * dt;
|
||||
|
||||
// normalisation introduces the stochastic drift term due to changing from
|
||||
// Stratonovich to Ito interpretation
|
||||
MathExtra::norm3(mu[i]);
|
||||
|
||||
// multiply by original magnitude to obtain dipole of same length
|
||||
mu[i][0] = mu[i][0] * mulen;
|
||||
mu[i][1] = mu[i][1] * mulen;
|
||||
mu[i][2] = mu[i][2] * mulen;
|
||||
}
|
||||
}
|
||||
}
|
||||
74
src/BROWNIAN/fix_brownian_sphere.h
Normal file
74
src/BROWNIAN/fix_brownian_sphere.h
Normal file
@ -0,0 +1,74 @@
|
||||
/* -*- 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(brownian/sphere,FixBrownianSphere);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_FIX_BROWNIAN_SPHERE_H
|
||||
#define LMP_FIX_BROWNIAN_SPHERE_H
|
||||
|
||||
#include "fix_brownian_base.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class FixBrownianSphere : public FixBrownianBase {
|
||||
public:
|
||||
FixBrownianSphere(class LAMMPS *, int, char **);
|
||||
virtual ~FixBrownianSphere(){};
|
||||
void init();
|
||||
void initial_integrate(int);
|
||||
|
||||
private:
|
||||
template <int Tp_UNIFORM, int Tp_GAUSS, int Tp_2D> void initial_integrate_templated();
|
||||
double g3, g4;
|
||||
};
|
||||
} // namespace LAMMPS_NS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal fix brownian/sphere command.
|
||||
|
||||
Wrong number/type of input arguments.
|
||||
|
||||
E: Compute brownian/sphere requires atom style sphere
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Compute brownian/sphere requires atom attribute mu
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian/sphere translational viscous drag coefficient must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian/sphere rotational viscous drag coefficient must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian/sphere translational diffusion coefficient must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian/sphere rotational diffusion coefficient must be > 0.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix brownian/sphere seed must be > 0.
|
||||
|
||||
*/
|
||||
300
src/BROWNIAN/fix_propel_self.cpp
Normal file
300
src/BROWNIAN/fix_propel_self.cpp
Normal file
@ -0,0 +1,300 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
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 Stefan Paquay @ Brandeis University
|
||||
|
||||
Thanks to Liesbeth Janssen @ Eindhoven University for useful discussions!
|
||||
|
||||
Current maintainer: Sam Cameron @ University of Bristol
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_propel_self.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "atom_vec_ellipsoid.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "math_extra.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
enum { DIPOLE, VELOCITY, QUAT };
|
||||
|
||||
#define TOL 1e-14
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixPropelSelf::FixPropelSelf(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), avec(nullptr)
|
||||
{
|
||||
|
||||
virial_global_flag = virial_peratom_flag = 1;
|
||||
|
||||
if (narg != 5 && narg != 9) error->all(FLERR, "Illegal fix propel/self command");
|
||||
|
||||
if (strcmp(arg[3], "velocity") == 0) {
|
||||
mode = VELOCITY;
|
||||
thermo_virial = 0;
|
||||
} else if (strcmp(arg[3], "dipole") == 0) {
|
||||
mode = DIPOLE;
|
||||
thermo_virial = 1;
|
||||
} else if (strcmp(arg[3], "quat") == 0) {
|
||||
mode = QUAT;
|
||||
thermo_virial = 1;
|
||||
} else {
|
||||
error->all(FLERR, "Illegal fix propel/self command");
|
||||
}
|
||||
|
||||
magnitude = utils::numeric(FLERR, arg[4], false, lmp);
|
||||
|
||||
// check for keyword
|
||||
|
||||
if (narg == 9) {
|
||||
if (mode != QUAT) { error->all(FLERR, "Illegal fix propel/self command"); }
|
||||
if (strcmp(arg[5], "qvector") == 0) {
|
||||
sx = utils::numeric(FLERR, arg[6], false, lmp);
|
||||
sy = utils::numeric(FLERR, arg[7], false, lmp);
|
||||
sz = utils::numeric(FLERR, arg[8], false, lmp);
|
||||
double snorm = sqrt(sx * sx + sy * sy + sz * sz);
|
||||
sx = sx / snorm;
|
||||
sy = sy / snorm;
|
||||
sz = sz / snorm;
|
||||
} else {
|
||||
error->all(FLERR, "Illegal fix propel/self command");
|
||||
}
|
||||
} else {
|
||||
sx = 1.0;
|
||||
sy = 0.0;
|
||||
sz = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int FixPropelSelf::setmask()
|
||||
{
|
||||
int mask = 0;
|
||||
mask |= POST_FORCE;
|
||||
return mask;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPropelSelf::init()
|
||||
{
|
||||
if (mode == DIPOLE && !atom->mu_flag)
|
||||
error->all(FLERR, "Fix propel/self requires atom attribute mu with option dipole");
|
||||
|
||||
if (mode == QUAT) {
|
||||
avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
|
||||
if (!avec) error->all(FLERR, "Fix propel/self requires atom style ellipsoid with option quat");
|
||||
|
||||
// check that all particles are finite-size ellipsoids
|
||||
// no point particles allowed, spherical is OK
|
||||
|
||||
int *ellipsoid = atom->ellipsoid;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
if (ellipsoid[i] < 0)
|
||||
error->one(FLERR, "Fix propel/self requires extended particles with option quat");
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPropelSelf::setup(int vflag)
|
||||
{
|
||||
post_force(vflag);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPropelSelf::post_force(int vflag)
|
||||
{
|
||||
if (mode == DIPOLE)
|
||||
post_force_dipole(vflag);
|
||||
else if (mode == VELOCITY)
|
||||
post_force_velocity(vflag);
|
||||
else if (mode == QUAT)
|
||||
post_force_quaternion(vflag);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPropelSelf::post_force_dipole(int vflag)
|
||||
{
|
||||
double **f = atom->f;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
double **x = atom->x;
|
||||
double **mu = atom->mu;
|
||||
double fx, fy, fz;
|
||||
|
||||
// energy and virial setup
|
||||
double vi[6];
|
||||
if (vflag)
|
||||
v_setup(vflag);
|
||||
else
|
||||
evflag = 0;
|
||||
|
||||
// if domain has PBC, need to unwrap for virial
|
||||
double unwrap[3];
|
||||
imageint *image = atom->image;
|
||||
|
||||
// Add the active force to the atom force:
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
|
||||
fx = magnitude * mu[i][0];
|
||||
fy = magnitude * mu[i][1];
|
||||
fz = magnitude * mu[i][2];
|
||||
f[i][0] += fx;
|
||||
f[i][1] += fy;
|
||||
f[i][2] += fz;
|
||||
|
||||
if (evflag) {
|
||||
domain->unmap(x[i], image[i], unwrap);
|
||||
vi[0] = fx * unwrap[0];
|
||||
vi[1] = fy * unwrap[1];
|
||||
vi[2] = fz * unwrap[2];
|
||||
vi[3] = fx * unwrap[1];
|
||||
vi[4] = fx * unwrap[2];
|
||||
vi[5] = fy * unwrap[2];
|
||||
v_tally(i, vi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPropelSelf::post_force_velocity(int vflag)
|
||||
{
|
||||
double **f = atom->f;
|
||||
double **v = atom->v;
|
||||
double **x = atom->x;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
double nv2, fnorm, fx, fy, fz;
|
||||
|
||||
// energy and virial setup
|
||||
double vi[6];
|
||||
if (vflag)
|
||||
v_setup(vflag);
|
||||
else
|
||||
evflag = 0;
|
||||
|
||||
// if domain has PBC, need to unwrap for virial
|
||||
double unwrap[3];
|
||||
imageint *image = atom->image;
|
||||
|
||||
// Add the active force to the atom force:
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
if (mask[i] & groupbit) {
|
||||
|
||||
nv2 = v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2];
|
||||
fnorm = 0.0;
|
||||
|
||||
if (nv2 > TOL) {
|
||||
|
||||
// Without this check you can run into numerical
|
||||
// issues because fnorm will blow up.
|
||||
|
||||
fnorm = magnitude / sqrt(nv2);
|
||||
}
|
||||
fx = fnorm * v[i][0];
|
||||
fy = fnorm * v[i][1];
|
||||
fz = fnorm * v[i][2];
|
||||
|
||||
f[i][0] += fx;
|
||||
f[i][1] += fy;
|
||||
f[i][2] += fz;
|
||||
|
||||
if (evflag) {
|
||||
domain->unmap(x[i], image[i], unwrap);
|
||||
vi[0] = fx * unwrap[0];
|
||||
vi[1] = fy * unwrap[1];
|
||||
vi[2] = fz * unwrap[2];
|
||||
vi[3] = fx * unwrap[1];
|
||||
vi[4] = fx * unwrap[2];
|
||||
vi[5] = fy * unwrap[2];
|
||||
v_tally(i, vi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixPropelSelf::post_force_quaternion(int vflag)
|
||||
{
|
||||
double **f = atom->f;
|
||||
double **x = atom->x;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
int *ellipsoid = atom->ellipsoid;
|
||||
|
||||
// ellipsoidal properties
|
||||
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
|
||||
double f_act[3] = {sx, sy, sz};
|
||||
double f_rot[3];
|
||||
double *quat;
|
||||
double Q[3][3];
|
||||
double fx, fy, fz;
|
||||
|
||||
// energy and virial setup
|
||||
double vi[6];
|
||||
if (vflag)
|
||||
v_setup(vflag);
|
||||
else
|
||||
evflag = 0;
|
||||
|
||||
// if domain has PBC, need to unwrap for virial
|
||||
double unwrap[3];
|
||||
imageint *image = atom->image;
|
||||
|
||||
// Add the active force to the atom force:
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
if (mask[i] & groupbit) {
|
||||
|
||||
quat = bonus[ellipsoid[i]].quat;
|
||||
MathExtra::quat_to_mat(quat, Q);
|
||||
MathExtra::matvec(Q, f_act, f_rot);
|
||||
|
||||
fx = magnitude * f_rot[0];
|
||||
fy = magnitude * f_rot[1];
|
||||
fz = magnitude * f_rot[2];
|
||||
|
||||
f[i][0] += fx;
|
||||
f[i][1] += fy;
|
||||
f[i][2] += fz;
|
||||
|
||||
if (evflag) {
|
||||
domain->unmap(x[i], image[i], unwrap);
|
||||
vi[0] = fx * unwrap[0];
|
||||
vi[1] = fy * unwrap[1];
|
||||
vi[2] = fz * unwrap[2];
|
||||
vi[3] = fx * unwrap[1];
|
||||
vi[4] = fx * unwrap[2];
|
||||
vi[5] = fy * unwrap[2];
|
||||
v_tally(i, vi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
src/BROWNIAN/fix_propel_self.h
Normal file
68
src/BROWNIAN/fix_propel_self.h
Normal 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 FIX_CLASS
|
||||
// clang-format off
|
||||
FixStyle(propel/self,FixPropelSelf);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_FIX_PROPEL_SELF_H
|
||||
#define LMP_FIX_PROPEL_SELF_H
|
||||
|
||||
#include "fix.h"
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class FixPropelSelf : public Fix {
|
||||
public:
|
||||
FixPropelSelf(class LAMMPS *, int, char **);
|
||||
virtual ~FixPropelSelf(){};
|
||||
void init();
|
||||
void post_force(int);
|
||||
void setup(int);
|
||||
int setmask();
|
||||
|
||||
private:
|
||||
double magnitude;
|
||||
double sx, sy, sz;
|
||||
int mode;
|
||||
|
||||
void post_force_dipole(int);
|
||||
void post_force_velocity(int);
|
||||
void post_force_quaternion(int);
|
||||
|
||||
class AtomVecEllipsoid *avec;
|
||||
};
|
||||
} // namespace LAMMPS_NS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal fix propel/self command.
|
||||
|
||||
Wrong number/type of input arguments.
|
||||
|
||||
E: Fix propel/self requires atom attribute mu with option dipole.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
E: Fix propel/self requires atom style ellipsoid with option quat.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
Fix propel/self requires extended particles with option quat.
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
*/
|
||||
@ -26,12 +26,31 @@ action () {
|
||||
fi
|
||||
}
|
||||
|
||||
# the CG-DNA package cannot be used without
|
||||
# the MOLECULE and ASPHERE packages installed.
|
||||
|
||||
if (test $1 = 1) then
|
||||
if (test ! -e ../bond_harmonic.cpp) then
|
||||
echo "Must install MOLECULE package with CG-DNA"
|
||||
exit 1
|
||||
fi
|
||||
if (test ! -e ../fix_nve_asphere.cpp) then
|
||||
echo "Must install ASPHERE package with CG-DNA"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# list of files with dependcies
|
||||
|
||||
action atom_vec_oxdna.cpp
|
||||
action atom_vec_oxdna.h
|
||||
action bond_oxdna_fene.cpp bond_fene.h
|
||||
action bond_oxdna2_fene.cpp bond_fene.h
|
||||
action bond_oxrna2_fene.cpp bond_fene.h
|
||||
action bond_oxdna_fene.h bond_fene.h
|
||||
action bond_oxdna2_fene.h bond_fene.h
|
||||
action bond_oxrna2_fene.h bond_fene.h
|
||||
action fix_nve_dotc_langevin.cpp atom_vec_ellipsoid.h
|
||||
action fix_nve_dotc_langevin.h atom_vec_ellipsoid.h
|
||||
action fix_nve_dot.cpp atom_vec_ellipsoid.h
|
||||
@ -43,15 +62,23 @@ action pair_oxdna_coaxstk.h atom_vec_ellipsoid.h
|
||||
action pair_oxdna2_coaxstk.h atom_vec_ellipsoid.h
|
||||
action pair_oxdna_excv.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxdna2_excv.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxrna2_excv.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxdna_excv.h atom_vec_ellipsoid.h
|
||||
action pair_oxdna2_excv.h atom_vec_ellipsoid.h
|
||||
action pair_oxrna2_excv.h atom_vec_ellipsoid.h
|
||||
action pair_oxdna_hbond.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxdna_hbond.h atom_vec_ellipsoid.h
|
||||
action pair_oxrna2_hbond.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxrna2_hbond.h atom_vec_ellipsoid.h
|
||||
action pair_oxdna_stk.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxdna2_stk.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxdna_stk.h atom_vec_ellipsoid.h
|
||||
action pair_oxdna2_stk.h atom_vec_ellipsoid.h
|
||||
action pair_oxrna2_stk.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxrna2_stk.h atom_vec_ellipsoid.h
|
||||
action pair_oxdna_xstk.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxdna_xstk.h atom_vec_ellipsoid.h
|
||||
action pair_oxrna2_xstk.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxrna2_xstk.h atom_vec_ellipsoid.h
|
||||
action pair_oxdna2_dh.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxdna2_dh.h atom_vec_ellipsoid.h
|
||||
action pair_oxrna2_dh.cpp atom_vec_ellipsoid.h
|
||||
action pair_oxrna2_dh.h atom_vec_ellipsoid.h
|
||||
105
src/CG-DNA/README.md
Normal file
105
src/CG-DNA/README.md
Normal file
@ -0,0 +1,105 @@
|
||||
This package contains a LAMMPS implementation of coarse-grained
|
||||
models of DNA, which can be used to model sequence-specific
|
||||
DNA strands.
|
||||
|
||||
Please cite
|
||||
|
||||
[](https://zenodo.org/badge/latestdoi/132764768)
|
||||
|
||||
as well as [1] and the relevant oxDNA, oxDNA2 and oxRNA2 articles
|
||||
in any publication that uses this package.
|
||||
|
||||
See the doc pages and [2,3,4,5,6] for the individual bond and pair styles.
|
||||
The packages contains also a new Langevin-type rigid-body integrator,
|
||||
which has also its own doc page and is explained in [7].
|
||||
|
||||
[1] O. Henrich, Y. A. Gutierrez-Fosado, T. Curk, T. E. Ouldridge,
|
||||
"Coarse-grained simulation of DNA using LAMMPS",
|
||||
Eur. Phys. J. E 41, 57 (2018).
|
||||
|
||||
[2] T. Ouldridge, A. Louis, J. Doye, "Structural, mechanical,
|
||||
and thermodynamic properties of a coarse-grained DNA model",
|
||||
J. Chem. Phys. 134, 085101 (2011).
|
||||
|
||||
[3] T.E. Ouldridge, "Coarse-grained modelling of DNA and DNA
|
||||
self-assembly", DPhil. University of Oxford (2011).
|
||||
|
||||
[4] B.E. Snodin, F. Randisi, M. Mosayebi, et al., "Introducing
|
||||
Improved structural properties and salt dependence into a coarse-grained
|
||||
model of DNA", J. Chem. Phys. 142, 234901 (2015).
|
||||
|
||||
[5] P. Sulc, F. Romano, T.E. Ouldridge, et al., "A nucleotide-level
|
||||
coarse-grained model of RNA", J. Chem. Phys. 140, 235102 (2014).
|
||||
|
||||
[6] P. Sulc, F. Romano, T.E. Ouldridge, et al., "Sequence-dependent
|
||||
thermodynamics of a coarse-grained DNA model",
|
||||
J. Chem. Phys. 137, 135101 (2012).
|
||||
|
||||
[7] R. Davidchack, T. Ouldridge, M. Tretyakov, "New Langevin and
|
||||
gradient thermostats for rigid body dynamics", J. Chem. Phys. 142,
|
||||
144114 (2015).
|
||||
|
||||
Example input and data files can be found in
|
||||
examples/PACKAGES/cgdna/examples/oxDNA/, /oxDNA2/ and /oxRNA2/.
|
||||
Python setup tools which create single straight or helical DNA or RNA
|
||||
strands as well as DNA or RNA duplexes or arrays of duplexes can be
|
||||
found in examples/PACKAGES/cgdna/util/. A technical report with more
|
||||
general information on the model, its implementation and performance
|
||||
as well as the structure of the data and input file can be found
|
||||
in doc/src/PDF/CG-DNA.pdf.
|
||||
|
||||
IMPORTANT NOTE: This package can only be used if LAMMPS is compiled
|
||||
with the MOLECULE and ASPHERE packages. These should be included in
|
||||
the LAMMPS build by typing "make yes-asphere yes-molecule" prior to
|
||||
the usual compilation (see the "Including/excluding packages" section
|
||||
of the LAMMPS manual).
|
||||
|
||||
The creator of this package is:
|
||||
|
||||
Dr Oliver Henrich
|
||||
University of Strathclyde, Glasgow, UK
|
||||
oliver d o t henrich a t strath d o t ac d o t uk
|
||||
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
** Bond styles provided by this package:
|
||||
|
||||
bond_oxdna_fene.cpp: backbone connectivity,
|
||||
a modified FENE potential (see [2,3])
|
||||
|
||||
bond_oxdna2_fene.cpp: corresponding bond style in oxDNA2 (see [4])
|
||||
|
||||
bond_oxrna2_fene.cpp: corresponding bond style in oxRNA2 (see [5])
|
||||
|
||||
** Pair styles provided by this package:
|
||||
|
||||
pair_oxdna_excv.cpp: excluded volume interaction between the nucleotides
|
||||
|
||||
pair_oxdna_stk.cpp: stacking interaction between consecutive nucleotides
|
||||
on the same strand
|
||||
|
||||
pair_oxdna_hbond.cpp: hydrogen-bonding interaction between complementary
|
||||
nucleotides on different strands, e.g. A-T and C-G
|
||||
|
||||
pair_oxdna_xstk.cpp: cross-stacking interaction between nucleotides
|
||||
|
||||
pair_oxdna_coaxstk.cpp: coaxial stacking interaction between nucleotides
|
||||
|
||||
pair_oxdna2_excv.cpp, pair_oxdna2_coaxstk.cpp:
|
||||
corresponding pair styles in oxDNA2 (see [4])
|
||||
|
||||
pair_oxrna2_excv.cpp, pair_oxrna2_stk.cpp, pair_oxrna2_hbond.cpp,
|
||||
pair_oxrna2_xstk.cpp:
|
||||
corresponding pair styles in oxDNA2 (see [5])
|
||||
|
||||
pair_oxdna2_dh.cpp, pair_oxrna2_dh.cpp:
|
||||
Debye-Hueckel electrostatic interaction between backbone sites
|
||||
|
||||
|
||||
** Fixes provided by this package:
|
||||
|
||||
fix_nve_dotc_langevin.cpp: fix for Langevin-type rigid body integrator "C"
|
||||
in above Ref. [7]
|
||||
|
||||
fix_nve_dot.cpp: NVE-type rigid body integrator without noise
|
||||
92
src/CG-DNA/atom_vec_oxdna.cpp
Normal file
92
src/CG-DNA/atom_vec_oxdna.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
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_oxdna.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "error.h"
|
||||
#include "force.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
AtomVecOxdna::AtomVecOxdna(LAMMPS *lmp) : AtomVec(lmp)
|
||||
{
|
||||
molecular = Atom::MOLECULAR;
|
||||
bonds_allow = 1;
|
||||
mass_type = PER_TYPE;
|
||||
|
||||
atom->molecule_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 *) "id5p";
|
||||
fields_copy = (char *) "id5p";
|
||||
fields_comm = (char *) "";
|
||||
fields_comm_vel = (char *) "";
|
||||
fields_reverse = (char *) "";
|
||||
fields_border = (char *) "id5p";
|
||||
fields_border_vel = (char *) "";
|
||||
fields_exchange = (char *) "id5p";
|
||||
fields_restart = (char *) "id5p";
|
||||
fields_create = (char *) "";
|
||||
fields_data_atom = (char *) "id type x";
|
||||
fields_data_vel = (char *) "id v";
|
||||
|
||||
setup_fields();
|
||||
|
||||
if (!force->newton_bond)
|
||||
error->warning(FLERR, "Write_data command requires newton on to preserve 3'->5' bond polarity");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
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 AtomVecOxdna::grow_pointers()
|
||||
{
|
||||
id5p = atom->id5p;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
initialize atom quantity 5' partner
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecOxdna::data_atom_post(int ilocal)
|
||||
{
|
||||
tagint *id5p = atom->id5p;
|
||||
id5p[ilocal] = -1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
process bond information as per data file
|
||||
store 5' partner to inform 3'->5' bond directionality
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecOxdna::data_bonds_post(int /*m*/, int /*num_bond*/, tagint atom1, tagint atom2,
|
||||
tagint id_offset)
|
||||
{
|
||||
int n;
|
||||
tagint *id5p = atom->id5p;
|
||||
|
||||
if (id_offset) {
|
||||
atom1 += id_offset;
|
||||
atom2 += id_offset;
|
||||
}
|
||||
|
||||
if ((n = atom->map(atom1)) >= 0) { id5p[n] = atom2; }
|
||||
}
|
||||
47
src/CG-DNA/atom_vec_oxdna.h
Normal file
47
src/CG-DNA/atom_vec_oxdna.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* -*- 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(oxdna,AtomVecOxdna);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_ATOM_VEC_OXDNA_H
|
||||
#define LMP_ATOM_VEC_OXDNA_H
|
||||
|
||||
#include "atom_vec.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AtomVecOxdna : public AtomVec {
|
||||
public:
|
||||
AtomVecOxdna(class LAMMPS *);
|
||||
~AtomVecOxdna() = default;
|
||||
|
||||
void grow_pointers();
|
||||
void data_atom_post(int);
|
||||
void data_bonds_post(int, int, tagint, tagint, tagint);
|
||||
|
||||
private:
|
||||
tagint *id5p;
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
*/
|
||||
@ -1,6 +1,6 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
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,36 +14,20 @@
|
||||
Contributing author: Oliver Henrich (University of Strathclyde, Glasgow)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include "bond_oxdna2_fene.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
BondOxdna2Fene::BondOxdna2Fene(LAMMPS *lmp) : BondOxdnaFene(lmp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
BondOxdna2Fene::~BondOxdna2Fene()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute vector COM-sugar-phosphate backbone interaction site in oxDNA2
|
||||
------------------------------------------------------------------------- */
|
||||
void BondOxdna2Fene::compute_interaction_sites(double e1[3],
|
||||
double e2[3], double r[3])
|
||||
void BondOxdna2Fene::compute_interaction_sites(double e1[3], double e2[3], double /*e3*/[3],
|
||||
double r[3]) const
|
||||
{
|
||||
double d_cs_x=-0.34, d_cs_y=+0.3408;
|
||||
|
||||
r[0] = d_cs_x*e1[0] + d_cs_y*e2[0];
|
||||
r[1] = d_cs_x*e1[1] + d_cs_y*e2[1];
|
||||
r[2] = d_cs_x*e1[2] + d_cs_y*e2[2];
|
||||
constexpr double d_cs_x = -0.34;
|
||||
constexpr double d_cs_y = +0.3408;
|
||||
|
||||
r[0] = d_cs_x * e1[0] + d_cs_y * e2[0];
|
||||
r[1] = d_cs_x * e1[1] + d_cs_y * e2[1];
|
||||
r[2] = d_cs_x * e1[2] + d_cs_y * e2[2];
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user