Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix repulsive forces #1370

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions libsimulator/src/GeneralizedCentrifugalForceModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,12 @@ void GeneralizedCentrifugalForceModel::CheckModelConstraint(
if(contanctDist >= distance) {
throw SimulationError(
"Model constraint violation: Agent {} too close to agent {}: distance {}, "
"contactDist {}, "
"effective distance {}",
agent.pos,
neighbor.pos,
distance,
contanctDist,
distance - contanctDist);
}
}
Expand Down Expand Up @@ -216,19 +218,19 @@ Point GeneralizedCentrifugalForceModel::ForceRepPed(
// 5 | 4 | 3 | 2 | 1

// If the pedestrian is outside the cutoff distance, the force is zero.
if(dist_eff >= maxNeighborRepulsionForce) {
if(dist_eff >= maxNeighborInteractionDistance) {
F_rep = Point(0.0, 0.0);
return F_rep;
}

const double mindist =
0.5; // for performance reasons, it is assumed that this distance is about 50 cm
const double dist_intpol_left =
mindist + maxNeighborInteractionDistance; // lower cut-off for Frep (modCFM)
mindist + maxNeighborInterpolationDistance; // lower cut-off for Frep (modCFM)
const double dist_intpol_right =
maxNeighborRepulsionForce -
maxNeighborInteractionDistance; // upper cut-off for Frep (modCFM)
const double smax = mindist - maxNeighborInteractionDistance; // max overlapping
maxNeighborInteractionDistance -
maxNeighborInterpolationDistance; // upper cut-off for Frep (modCFM)
const double smax = mindist - maxNeighborInterpolationDistance; // max overlapping
double f = 0.0f; // fuction value
double f1 = 0.0f; // derivative of function value

Expand Down Expand Up @@ -269,18 +271,18 @@ Point GeneralizedCentrifugalForceModel::ForceRepPed(
K_ij = sqrt(K_ij);
if(dist_eff <= smax) { // 5
f = -agent1_mass * K_ij * nom / dist_intpol_left;
F_rep = ep12 * maxNeighborInterpolationDistance * f;
F_rep = ep12 * maxNeighborRepulsionForce * f;
return F_rep;
}

// smax dist_intpol_left dist_intpol_right dist_eff_max
// ----|-------------|--------------------------|--------------|----
// 5 | 4 | 3 | 2 | 1

if(dist_eff >= dist_intpol_right) { // 2
f = -agent1_mass * K_ij * nom / dist_intpol_right; // abs(NR-Dv(i)+Sa)
f1 = -f / dist_intpol_right;
px = hermite_interp(dist_eff, dist_intpol_right, maxNeighborRepulsionForce, f, 0, f1, 0);
px = hermite_interp(
dist_eff, dist_intpol_right, maxNeighborInteractionDistance, f, 0, f1, 0);
F_rep = ep12 * px;
} else if(dist_eff >= dist_intpol_left) { // 3
f = -agent1_mass * K_ij * nom / fabs(dist_eff); // abs(NR-Dv(i)+Sa)
Expand All @@ -289,7 +291,7 @@ Point GeneralizedCentrifugalForceModel::ForceRepPed(
f = -agent1_mass * K_ij * nom / dist_intpol_left;
f1 = -f / dist_intpol_left;
px = hermite_interp(
dist_eff, smax, dist_intpol_left, maxNeighborInterpolationDistance * f, f, 0, f1);
dist_eff, smax, dist_intpol_left, maxNeighborRepulsionForce * f, f, 0, f1);
F_rep = ep12 * px;
}
if(F_rep.x != F_rep.x || F_rep.y != F_rep.y) {
Expand Down Expand Up @@ -417,9 +419,9 @@ Point GeneralizedCentrifugalForceModel::ForceInterpolation(
double nominator = strengthGeometryRepulsion * v0 + vn;
nominator *= nominator * K_ij;
double f = 0, f1 = 0; // function value and its derivative at the interpolation point
double smax = l - maxGeometryInteractionDistance; // max overlapping radius
double dist_intpol_left = l + maxGeometryInteractionDistance; // r_eps
double dist_intpol_right = maxGeometryRepulsionForce - maxGeometryInteractionDistance;
double smax = l - maxGeometryInterpolationDistance; // max overlapping radius
double dist_intpol_left = l + maxGeometryInterpolationDistance; // r_eps
double dist_intpol_right = maxGeometryInteractionDistance - maxGeometryInterpolationDistance;

double dist_eff = d - r;

Expand All @@ -428,7 +430,7 @@ Point GeneralizedCentrifugalForceModel::ForceInterpolation(
// 5 | 4 | 3 | 2 | 1

double px = 0; // value of the interpolated function
double tmp1 = maxGeometryRepulsionForce;
double tmp1 = maxGeometryInteractionDistance;
double tmp2 = dist_intpol_right;
double tmp3 = dist_intpol_left;
double tmp5 = smax + r;
Expand All @@ -439,14 +441,15 @@ Point GeneralizedCentrifugalForceModel::ForceInterpolation(
}

if(dist_eff <= tmp5) { // 5
F_rep = e * (-maxGeometryInterpolationDistance);
F_rep = e * (-maxGeometryRepulsionForce);
return F_rep;
}

if(dist_eff > tmp2) { // 2
f = -nominator / dist_intpol_right;
f1 = -f / dist_intpol_right; // nominator / (dist_intpol_right^2) = derivativ of f
px = hermite_interp(dist_eff, dist_intpol_right, maxGeometryRepulsionForce, f, 0, f1, 0);
px = hermite_interp(
dist_eff, dist_intpol_right, maxGeometryInteractionDistance, f, 0, f1, 0);
F_rep = e * px;
} else if(dist_eff >= tmp3) { // 3
f = -nominator / fabs(dist_eff); // devided by abs f the effective distance
Expand All @@ -455,7 +458,7 @@ Point GeneralizedCentrifugalForceModel::ForceInterpolation(
f = -nominator / dist_intpol_left;
f1 = -f / dist_intpol_left;
px = hermite_interp(
dist_eff, smax, dist_intpol_left, maxGeometryInterpolationDistance * f, f, 0, f1);
dist_eff, smax, dist_intpol_left, maxGeometryRepulsionForce * f, f, 0, f1);
F_rep = e * px;
}
return F_rep;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
class GeneralizedCentrifugalForceModel:
"""Parameters for Generalized Centrifugal Force Model

.. warning::
Unfortunately we broke the model before the 1.0 release and did not notice it in time.
For the time being please do not use this model.

We track the defect here: https://github.com/PedestrianDynamics/jupedsim/issues/1337

All attributes are initialized with reasonably good defaults.

Attributes:
Expand Down
Loading