diff --git a/pysd/py_backend/functions.py b/pysd/py_backend/functions.py index 8c6930dd..8ca97014 100644 --- a/pysd/py_backend/functions.py +++ b/pysd/py_backend/functions.py @@ -744,9 +744,9 @@ def _integrate(self, time_steps, capture_elements, return_timestamps): return outputs -def ramp(slope, start, finish): +def ramp(slope, start, finish=0): """ - Implements vensim's RAMP function + Implements vensim's and xmile's RAMP function Parameters ---------- @@ -755,7 +755,7 @@ def ramp(slope, start, finish): start: float Time at which the ramp begins finish: float - Time at which the ramo ends + Optional. Time at which the ramp ends Returns ------- @@ -770,10 +770,13 @@ def ramp(slope, start, finish): t = time() if t < start: return 0 - elif t > finish: - return slope * (finish - start) else: - return slope * (t - start) + if finish <= 0: + return slope * (t - start) + elif t > finish: + return slope * (finish - start) + else: + return slope * (t - start) def step(value, tstep): diff --git a/pysd/py_backend/xmile/SMILE2Py.py b/pysd/py_backend/xmile/SMILE2Py.py index 465c8f8d..8be5061f 100644 --- a/pysd/py_backend/xmile/SMILE2Py.py +++ b/pysd/py_backend/xmile/SMILE2Py.py @@ -79,8 +79,7 @@ "pulse": "functions.pulse_magnitude", "step": "functions.step", - - # "ramp" !TODO! + "ramp" "functions.ramp", # === # 3.5.5 Time Functions