Some code clean-up, added safety check in post_force_velocity.

This commit is contained in:
Stefan Paquay 2019-08-29 09:41:50 -04:00 committed by Pierre de Buyl
parent 074dfd8651
commit 3144b91fb3
4 changed files with 144 additions and 24 deletions

View File

@ -0,0 +1,37 @@
dimension 2
boundary p p p
variable L equal 20
region total block -$L $L -$L $L -0.5 0.5
lattice hex 0.3
create_box 2 total
create_atoms 1 box
# Set random fraction to passive:
set type 1 type/fraction 2 0.5 1337
# Purely repulsive particles:
variable rc equal "2^(1.0/6.0)"
pair_style lj/cut ${rc}
pair_coeff * * 1.0 1.0
pair_modify shift yes
mass * 1.0
fix step all nve
fix temp all langevin 1.0 1.0 1.0 13
fix twod all enforce2d
neighbor 0.6 bin
dump traj all custom 250 2d_active.dump.bin id type x y z
thermo_style custom time step pe ke etotal temp
thermo 1000
run 25000
fix active all propel/self velocity 1.0
# With active force there is more motion so increase bin size:
neighbor 1.0 bin
run 25000

View File

@ -0,0 +1,37 @@
dimension 2
boundary p p p
variable L equal 20
region total block -$L $L -$L $L -0.5 0.5
lattice hex 0.3
create_box 2 total
create_atoms 1 box
# Set random fraction to passive:
set type 1 type/fraction 2 0.5 1337
# Purely repulsive particles:
variable rc equal "2^(1.0/6.0)"
pair_style lj/cut ${rc}
pair_coeff * * 1.0 1.0
pair_modify shift yes
mass * 1.0
fix step all nve
fix twod all enforce2d
neighbor 0.6 bin
dump traj all custom 250 2d_active.dump.bin id type x y z
thermo_style custom time step pe ke etotal temp
thermo 1000
run 25000
fix active all propel/self velocity 1.0
fix fric all viscous 1.0
# With active force there is more motion so increase bin size:
neighbor 1.0 bin
run 25000

View File

@ -0,0 +1,40 @@
dimension 3
boundary p p p
atom_style ellipsoid
variable L equal 20
region total block -$L $L -$L $L -$L $L
lattice sc 0.1
create_box 2 total
create_atoms 1 box
# Set random fraction to passive:
set type 1 type/fraction 2 0.5 1337
# Purely repulsive particles:
variable rc equal "2^(1.0/6.0)"
pair_style lj/cut ${rc}
pair_coeff * * 1.0 1.0
pair_modify shift yes
# mass * 1.0
set type * density 1.0
set type * shape 1.0 1.0 1.0
set type * quat 0 0 1 0
fix step all nve
fix temp all langevin 1.0 1.0 1.0 13
neighbor 0.6 bin
dump traj all custom 100 3d_active.dump.bin id type x y z fx fy fz
thermo_style custom time step pe ke etotal temp
thermo 100
run 5000
fix active all propel/self quaternion 1.0
# With active force there is more motion so increase bin size:
neighbor 1.0 bin
run 5000

View File

@ -182,7 +182,13 @@ void FixPropelSelf::post_force_velocity(int /*vflag*/ )
const double *vi = v[i];
double f_act[3] = { vi[0], vi[1], vi[2] };
double nv2 = vi[0]*vi[0] + vi[1]*vi[1] + vi[2]*vi[2];
double fnorm = magnitude / sqrt(nv2);
double fnorm = 0.0;
constexpr const double TOL = 1e-14;
if (nv2 > TOL) {
// Without this check you can run into numerical issues
// because fnorm will blow up.
fnorm = magnitude / sqrt(nv2);
}
if (debug_out && comm->me == 0) {
// Magical reference particle: