Skip to content

Commit

Permalink
Merge pull request #283 from jdegraaf/master
Browse files Browse the repository at this point in the history
ENGINE feature: corrected problems with the parsing of v_swim, which …
  • Loading branch information
fweik committed May 24, 2015
2 parents 877efb3 + 7b84bbe commit 1a8b3af
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/core/lb.cpp
Expand Up @@ -2848,9 +2848,9 @@ inline void lb_viscous_coupling(Particle *p, double force[3]) {
#ifdef ENGINE
if ( p->swim.swimming )
{
velocity[0] -= p->swim.v_swim*p->r.quatu[0];
velocity[1] -= p->swim.v_swim*p->r.quatu[1];
velocity[2] -= p->swim.v_swim*p->r.quatu[2];
velocity[0] -= (p->swim.v_swim*time_step)*p->r.quatu[0];
velocity[1] -= (p->swim.v_swim*time_step)*p->r.quatu[1];
velocity[2] -= (p->swim.v_swim*time_step)*p->r.quatu[2];
p->swim.v_center[0] = interpolated_u[0];
p->swim.v_center[1] = interpolated_u[1];
p->swim.v_center[2] = interpolated_u[2];
Expand Down
12 changes: 6 additions & 6 deletions src/core/lbgpu_cuda.cu
Expand Up @@ -1653,9 +1653,9 @@ __device__ void calc_viscous_force_three_point_couple(LB_nodes_gpu n_a, float *d
interpolation_three_point_coupling(n_a, position, node_index, d_v, delta, interpolated_u);

#ifdef ENGINE
velocity[0] -= particle_data[part_index].swim.v_swim*particle_data[part_index].swim.quatu[0];
velocity[1] -= particle_data[part_index].swim.v_swim*particle_data[part_index].swim.quatu[1];
velocity[2] -= particle_data[part_index].swim.v_swim*particle_data[part_index].swim.quatu[2];
velocity[0] -= (particle_data[part_index].swim.v_swim*para.time_step)*particle_data[part_index].swim.quatu[0];
velocity[1] -= (particle_data[part_index].swim.v_swim*para.time_step)*particle_data[part_index].swim.quatu[1];
velocity[2] -= (particle_data[part_index].swim.v_swim*para.time_step)*particle_data[part_index].swim.quatu[2];

// The first three components are v_center, the last three v_source
// Do not use within LB, because these have already been converted back to MD units
Expand Down Expand Up @@ -1948,9 +1948,9 @@ __device__ void calc_viscous_force(LB_nodes_gpu n_a, float *delta, float * partg
interpolation_two_point_coupling(n_a, position, node_index, mode, d_v, delta, interpolated_u);

#ifdef ENGINE
velocity[0] -= particle_data[part_index].swim.v_swim*particle_data[part_index].swim.quatu[0];
velocity[1] -= particle_data[part_index].swim.v_swim*particle_data[part_index].swim.quatu[1];
velocity[2] -= particle_data[part_index].swim.v_swim*particle_data[part_index].swim.quatu[2];
velocity[0] -= (particle_data[part_index].swim.v_swim*para.time_step)*particle_data[part_index].swim.quatu[0];
velocity[1] -= (particle_data[part_index].swim.v_swim*para.time_step)*particle_data[part_index].swim.quatu[1];
velocity[2] -= (particle_data[part_index].swim.v_swim*para.time_step)*particle_data[part_index].swim.quatu[2];

// The first three components are v_center, the last three v_source
// Do not use within LB, because these have already been converted back to MD units
Expand Down
2 changes: 1 addition & 1 deletion src/core/thermostat.hpp
Expand Up @@ -214,7 +214,7 @@ inline void friction_thermo_langevin(Particle *p)
for (int i = 0; i < 3; i++) {
velocity[i] = p->m.v[i];
#ifdef ENGINE
velocity[i] -= p->swim.v_swim*p->r.quatu[i];
velocity[i] -= (p->swim.v_swim*time_step)*p->r.quatu[i];
#endif
}

Expand Down
6 changes: 2 additions & 4 deletions src/tcl/particle_data_tcl.cpp
Expand Up @@ -176,13 +176,13 @@ void tclcommand_part_print_swimming(Particle *part, char *buffer, Tcl_Interp *in
#if defined(LB) || defined(LB_GPU)
sprintf(buffer, " swimming %s %f %f %d %f %f",
part->swim.swimming?"on":"off",
part->swim.v_swim/time_step, part->swim.f_swim,
part->swim.v_swim, part->swim.f_swim,
part->swim.push_pull, part->swim.dipole_length,
part->swim.rotational_friction);
#else
sprintf(buffer, " swimming %s %f %f %s %s %s",
part->swim.swimming?"on":"off",
part->swim.v_swim/time_step, part->swim.f_swim,
part->swim.v_swim, part->swim.f_swim,
"n/a", "n/a", "n/a");
#endif
}
Expand Down Expand Up @@ -1493,8 +1493,6 @@ int tclcommand_part_parse_swimming(Tcl_Interp *interp, int argc, char **argv,
} else if ( p.swim.f_swim > 0.0 || p.swim.f_swim < 0.0 ) {
printf("You can't set v_swim and f_swim at the same time!\n");
return TCL_ERROR;
} else {
p.swim.v_swim *= time_step;
}
} else if ( ARG_IS_S(*change,"f_swim") ) {
if ( !ARG_IS_D(++(*change),p.swim.f_swim) ) {
Expand Down

0 comments on commit 1a8b3af

Please sign in to comment.