Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2001-2024 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 49 : MSCFModel_KraussPS::MSCFModel_KraussPS(const MSVehicleType* vtype) : 36 49 : MSCFModel_Krauss(vtype) { 37 49 : } 38 : 39 : 40 98 : MSCFModel_KraussPS::~MSCFModel_KraussPS() {} 41 : 42 : 43 : double 44 45740009 : MSCFModel_KraussPS::maxNextSpeed(double speed, const MSVehicle* const veh) const { 45 45740009 : const double aMax = MAX2(0., getMaxAccel() - GRAVITY * sin(DEG2RAD(veh->getSlope()))); 46 : // assuming drag force is proportional to the square of speed 47 45740009 : const double vMax = MAX2( 48 45740009 : sqrt(aMax / getMaxAccel()) * myType->getMaxSpeed(), 49 : // prevent emergency braking when inclination changes suddenly (momentum) 50 45740009 : speed - ACCEL2SPEED(getMaxDecel())); 51 45740009 : return MAX2( 52 : // prevent stalling at low speed 53 : getMaxAccel() / 2, 54 45740009 : MIN2(speed + ACCEL2SPEED(aMax), vMax)); 55 : } 56 : 57 : 58 : MSCFModel* 59 0 : MSCFModel_KraussPS::duplicate(const MSVehicleType* vtype) const { 60 0 : return new MSCFModel_KraussPS(vtype); 61 : } 62 : 63 : 64 : /****************************************************************************/