Commit a64f3607 authored by carlos's avatar carlos

implemented Krausz Model as a identic copy of GCFM Model

parent f97bf4c6
......@@ -335,7 +335,7 @@ set(source_files
poly2tri/sweep/cdt.cpp
events/EventManager.cpp
events/Event.cpp
)
math/KrauszModel.cpp)
set(header_files
routing/ffRouter.h
......
......@@ -34,6 +34,7 @@
#include "IniFileParser.h"
#include "../pedestrian/Pedestrian.h"
#include "../math/GCFMModel.h"
#include "../math/KrauszModel.h"
#include "../math/GompertzModel.h"
#include "../math/GradientModel.h"
#include "../math/VelocityModel.h"
......@@ -292,10 +293,21 @@ bool IniFileParser::Parse(std::string iniFile)
parsingModelSuccessful = true;
break;
}
if ((_model==MODEL_KRAUSZ) && (model_id==MODEL_KRAUSZ)) {
if (modelName!="krausz") {
Log->Write("ERROR: \t mismatch model ID and description. Did you mean krausz?");
return false;
}
if (!ParseKrauszModel(xModel, xMainNode))
return false;
parsingModelSuccessful = true;
//only parsing one model
break;
}
}
if (!parsingModelSuccessful) {
Log->Write("ERROR: \tWrong model id [%d]. Choose 1 (GCFM) or 2 (Gompertz) or 3 (Tordeux2015)", _model);
Log->Write("ERROR: \tWrong model id [%d]. Choose 1 (GCFM), 2 (Gompertz), 3 (Tordeux2015) or 4 (Krausz)", _model);
Log->Write("ERROR: \tPlease make sure that all models are specified in the operational_models section");
Log->Write("ERROR: \tand make sure to use the same ID in the agent section");
return false;
......@@ -402,6 +414,97 @@ bool IniFileParser::ParseGCFMModel(TiXmlElement* xGCFM, TiXmlElement* xMainNode)
return true;
}
bool IniFileParser::ParseKrauszModel(TiXmlElement* xKrausz, TiXmlElement* xMainNode)
{
Log->Write("\nINFO:\tUsing the Krausz model");
Log->Write("INFO:\tParsing the model parameters");
TiXmlNode* xModelPara = xKrausz->FirstChild("model_parameters");
if (!xModelPara) {
Log->Write("ERROR: \t !!!! Changes in the operational model section !!!");
Log->Write("ERROR: \t !!!! The new version is in inputfiles/ship_msw/ini_ship2.xml !!!");
return false;
}
// For convenience. This moved to the header as it is not model specific
if (xModelPara->FirstChild("tmax")) {
Log->Write(
"ERROR: \tthe maximal simulation time section moved to the header!!!");
Log->Write("ERROR: \t\t <max_sim_time> </max_sim_time>\n");
return false;
}
//solver
if (!ParseNodeToSolver(*xModelPara))
return false;
//stepsize
if (!ParseStepSize(*xModelPara))
return false;
//exit crossing strategy
if (!ParseStrategyNodeToObject(*xModelPara))
return false;
//linked-cells
if (!ParseLinkedCells(*xModelPara))
return false;
//force_ped
if (xModelPara->FirstChild("force_ped")) {
string nu = xModelPara->FirstChildElement("force_ped")->Attribute("nu");
string dist_max = xModelPara->FirstChildElement("force_ped")->Attribute(
"dist_max");
string disteff_max =
xModelPara->FirstChildElement("force_ped")->Attribute(
"disteff_max"); // @todo: rename disteff_max to force_max
string interpolation_width =
xModelPara->FirstChildElement("force_ped")->Attribute(
"interpolation_width");
_config->SetMaxFPed(atof(dist_max.c_str()));
_config->SetNuPed(atof(nu.c_str()));
_config->SetDistEffMaxPed(atof(disteff_max.c_str()));
_config->SetIntPWidthPed(atof(interpolation_width.c_str()));
Log->Write(
"INFO: \tfrep_ped nu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
interpolation_width.c_str(), nu.c_str(), dist_max.c_str(), disteff_max.c_str(), interpolation_width.c_str());
}
//force_wall
if (xModelPara->FirstChild("force_wall")) {
string nu = xModelPara->FirstChildElement("force_wall")->Attribute("nu");
string dist_max = xModelPara->FirstChildElement("force_wall")->Attribute(
"dist_max");
string disteff_max =
xModelPara->FirstChildElement("force_wall")->Attribute(
"disteff_max");
string interpolation_width =
xModelPara->FirstChildElement("force_wall")->Attribute(
"interpolation_width");
_config->SetMaxFWall(atof(dist_max.c_str()));
_config->SetNuWall(atof(nu.c_str()));
_config->SetDistEffMaxWall(atof(disteff_max.c_str()));
_config->SetIntPWidthWall(atof(interpolation_width.c_str()));
Log->Write(
"INFO: \tfrep_wall mu=%.3f, dist_max=%.3f, disteff_max=%.3f, interpolation_width=%.3f",
nu.c_str(), dist_max.c_str(), disteff_max.c_str(), interpolation_width.c_str());
}
//Parsing the agent parameters
TiXmlNode* xAgentDistri = xMainNode->FirstChild("agents")->FirstChild("agents_distribution");
ParseAgentParameters(xKrausz, xAgentDistri);
//TODO: models do not belong in a configuration container [gl march '16]
_config->SetModel(std::shared_ptr<OperationalModel>(new KrauszModel(_exit_strategy, _config->GetNuPed(),
_config->GetNuWall(), _config->GetDistEffMaxPed(),
_config->GetDistEffMaxWall(), _config->GetIntPWidthPed(),
_config->GetIntPWidthWall(), _config->GetMaxFPed(),
_config->GetMaxFWall())));
return true;
}
bool IniFileParser::ParseGompertzModel(TiXmlElement* xGompertz, TiXmlElement* xMainNode)
{
//parsing the model parameters
......
......@@ -45,6 +45,8 @@ public:
private:
bool ParseGCFMModel(TiXmlElement* xGCFM, TiXmlElement* xMain);
bool ParseKrauszModel(TiXmlElement* xKrausz, TiXmlElement* xMain);
bool ParseGompertzModel(TiXmlElement* xGompertz, TiXmlElement* xMain);
bool ParseGradientModel(TiXmlElement* xGradient, TiXmlElement* xMain);
......
......@@ -134,7 +134,8 @@ enum OperativModels {
MODEL_GFCM=1,
MODEL_GOMPERTZ,
MODEL_VELOCITY,
MODEL_GRADIENT
MODEL_GRADIENT,
MODEL_KRAUSZ
// MODEL_ORCA,
// MODEL_CFM,
// MODEL_GNM
......
This diff is collapsed.
/**
* \file KrauszModel.h
* \date Jul 19, 2016
* \version v0.7
* \copyright <2009-2015> Forschungszentrum Jülich GmbH. All rights reserved.
*
* \section License
* This file is part of JuPedSim.
*
* JuPedSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* JuPedSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JuPedSim. If not, see <http://www.gnu.org/licenses/>.
*
* \section Description
* Implementation of classes for force-based models.
* Actually we've got two different models:
* 1. Generalized Centrifugal Force Model
*
*
**/
#ifndef KrauszMODEL_H_
#define KrauszMODEL_H_
#include <vector>
#include "../geometry/Building.h"
#include "OperationalModel.h"
//forward declaration
class Pedestrian;
class DirectionStrategy;
class KrauszModel : public OperationalModel
{
public:
KrauszModel(std::shared_ptr<DirectionStrategy> dir, double nuped, double nuwall, double dist_effPed, double dist_effWall,
double intp_widthped, double intp_widthwall, double maxfped, double maxfwall);
virtual ~KrauszModel(void);
// Getter
std::shared_ptr<DirectionStrategy> GetDirection() const;
double GetNuPed() const;
double GetNuWall() const;
double GetDistEffMax() const;
double GetIntpWidthPed() const;
double GetIntpWidthWall() const;
double GetMaxFPed() const;
double GetMaxFWall() const;
double GetDistEffMaxPed() const;
double GetDistEffMaxWall() const;
/**
* Compute the next simulation step
* Solve the differential equations and update the positions and velocities
* @param current the actual time
* @param deltaT the next timestep
* @param building the geometry object
*/
virtual void ComputeNextTimeStep(double current, double deltaT, Building* building, int periodic);
virtual std::string GetDescription() ;
virtual bool Init (Building* building);
private:
/// define the strategy for crossing a door (used for calculating the driving force)
std::shared_ptr<DirectionStrategy> _direction;
// Modellparameter
double _nuPed; /**< strength of the pedestrian repulsive force */
double _nuWall; /**< strength of the wall repulsive force */
double _intp_widthPed; /**< Interpolation cutoff radius (in cm) */
double _intp_widthWall; /**< Interpolation cutoff radius (in cm) */
double _maxfPed;
double _maxfWall;
double _distEffMaxPed; // maximal effective distance
double _distEffMaxWall; // maximal effective distance
// Private Funktionen
/**
* Driving force \f$ F_i =\frac{\mathbf{v_0}-\mathbf{v_i}}{\tau}\f$
*
* @param ped Pointer to Pedestrians
* @param room Pointer to Room
*
* @return Point
*/
Point ForceDriv(Pedestrian* ped, Room* room) const;
/**
* Repulsive force between two pedestrians ped1 and ped2 according to
* the Generalized Centrifugal Force Model (chraibi2010a)
*
* @param ped1 Pointer to Pedestrian: First pedestrian
* @param ped2 Pointer to Pedestrian: Second pedestrian
*
* @return Point
*/
Point ForceRepPed(Pedestrian* ped1, Pedestrian* ped2) const;
/**
* Repulsive force acting on pedestrian <ped> from the walls in
* <subroom>. The sum of all repulsive forces of the walls in <subroom> is calculated
* @see ForceRepWall
* @param ped Pointer to Pedestrian
* @param subroom Pointer to SubRoom
*
* @return
*/
Point ForceRepRoom(Pedestrian* ped, SubRoom* subroom) const;
Point ForceRepWall(Pedestrian* ped, const Line& l) const;
Point ForceRepStatPoint(Pedestrian* ped, const Point& p, double l, double vn) const;
Point ForceInterpolation(double v0, double K_ij, const Point& e, double v, double d, double r, double l) const;
};
#endif /* KrauszMODEL_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment