Skip to content

Commit

Permalink
Made virtual agent radius scale factor adjustable by user
Browse files Browse the repository at this point in the history
  • Loading branch information
nicogno committed Aug 7, 2024
1 parent 7e4b89e commit 782b5d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/interaction_force.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,19 @@ void InteractionForce::ForceBetweenSpheres(const Agent* sphere_lhs,
real_t ref_diameter = sphere_lhs->GetDiameter();
const Real3& nb_mass_location = sphere_rhs->GetPosition();
real_t nb_diameter = sphere_rhs->GetDiameter();
auto* sim = Simulation::GetActive();
auto* param = sim->GetParam();

auto c1 = ref_mass_location;
real_t r1 = 0.5 * ref_diameter;
auto c2 = nb_mass_location;
real_t r2 = 0.5 * nb_diameter;
// We take virtual bigger radii to have a distant interaction, to get a
// desired density. We assume an interaction distance 3% larger then the
// agent's radius
real_t additional_radius_scaling = 1.03;
r1 *= additional_radius_scaling;
r2 *= additional_radius_scaling;
// agent's radius by default

r1 *= param->virtual_agent_radius_scale_factor;
r2 *= param->virtual_agent_radius_scale_factor;
// the 3 components of the vector c2 -> c1
real_t comp1 = c1[0] - c2[0];
real_t comp2 = c1[1] - c2[1];
Expand Down
2 changes: 2 additions & 0 deletions src/core/param/param.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ void Param::AssignFromConfig(const std::shared_ptr<cpptoml::table>& config) {
BDM_ASSIGN_CONFIG_VALUE(diffusion_method, "simulation.diffusion_method");
BDM_ASSIGN_CONFIG_VALUE(calculate_gradients,
"simulation.calculate_gradients");
BDM_ASSIGN_CONFIG_VALUE(virtual_agent_radius_scale_factor,
"simulation.virtual_agent_radius_scale_factor");
AssignBoundSpaceMode(config, this);
AssignThreadSafetyMechanism(config, this);

Expand Down
8 changes: 8 additions & 0 deletions src/core/param/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ struct Param {
/// calculate_gradients = true
bool calculate_gradients = true;

/// Scale agent's virtual radius to enable distant interactions.\n
/// TOML config file:
/// Default value: `"1.03"`\n TOML
///
/// [simulation]
/// virtual_agent_radius_scale_factor = 1.03
real_t virtual_agent_radius_scale_factor = 1.03;

/// List of thread-safety mechanisms \n
/// `kNone`: \n
/// `kUserSpecified`: The user has to define all agent that must
Expand Down

0 comments on commit 782b5d4

Please sign in to comment.