Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file MSCFModel_KraussPS.cpp
15 : /// @author Tobias Mayer
16 : /// @author Daniel Krajzewicz
17 : /// @author Jakob Erdmann
18 : /// @author Michael Behrisch
19 : /// @author Laura Bieker
20 : /// @date Mon, 04 Aug 2009
21 : ///
22 : // Krauss car-following model, changing accel and speed by slope
23 : /****************************************************************************/
24 : #include <config.h>
25 :
26 : #include <utils/geom/GeomHelper.h>
27 : #include <microsim/MSVehicle.h>
28 : #include <microsim/MSLane.h>
29 : #include "MSCFModel_KraussPS.h"
30 :
31 :
32 : // ===========================================================================
33 : // method definitions
34 : // ===========================================================================
35 131 : MSCFModel_KraussPS::MSCFModel_KraussPS(const MSVehicleType* vtype) :
36 131 : MSCFModel_Krauss(vtype) {
37 131 : }
38 :
39 :
40 262 : MSCFModel_KraussPS::~MSCFModel_KraussPS() {}
41 :
42 :
43 : double
44 45692996 : MSCFModel_KraussPS::maxNextSpeed(double speed, const MSVehicle* const veh) const {
45 45692996 : const double aBound = getCurrentAccel(speed);
46 45692996 : const double aMax = MAX2(0., aBound - GRAVITY * sin(DEG2RAD(veh->getSlope())));
47 : // special case for bicycles where getMaxSpeed() is not a a technical but a rather an individual power limit
48 45692996 : const double typeMax = myType->getMaxSpeed() * (veh->getVClass() == SVC_BICYCLE ? veh->getChosenSpeedFactor() : 1);
49 : // assuming drag force is proportional to the square of speed
50 45692996 : const double vMax = MAX2(
51 45692996 : sqrt(aMax / getMaxAccel()) * typeMax,
52 : // prevent emergency braking when inclination changes suddenly (momentum)
53 45692996 : speed - ACCEL2SPEED(getMaxDecel()));
54 45692996 : return MAX2(
55 : // prevent stalling at low speed
56 : aBound / 2,
57 45692996 : MIN2(speed + ACCEL2SPEED(aMax), vMax));
58 : }
59 :
60 :
61 : MSCFModel*
62 0 : MSCFModel_KraussPS::duplicate(const MSVehicleType* vtype) const {
63 0 : return new MSCFModel_KraussPS(vtype);
64 : }
65 :
66 :
67 : /****************************************************************************/
|