From d0a8e6ac5142a1d3474d35e1ffc998ef56f59cfe Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Thu, 12 Nov 2020 17:36:03 +0100 Subject: [PATCH] update to the limit function for ps compatibility. The output will stay between the two limits given. Tere is no prescription which of the two is upper or lower. This function will not solve all PS-Spice compatible model convergence issues. We better look for a built-in function with smooth, steadily differentiable corners. --- src/frontend/inpcom.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index edfe6399b..c9b713d80 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -7636,7 +7636,9 @@ static struct card *pspice_compat(struct card *oldcard) new_str = copy(".param gmin = 1e-12"); nextcard = insert_new_line(nextcard, new_str, 3, 0); /* add funcs limit, pwr, pwrs, stp, if, int */ - new_str = copy(".func limit(x, a, b) { max(min(x, a), b) }"); + /* LIMIT( Output Expression, Limit1, Limit2) + Output will stay between the two limits given. */ + new_str = copy(".func limit(x, a, b) { ternary_fcn(a>b, max(min(x, a), b), max(min(x, b), a)) }"); nextcard = insert_new_line(nextcard, new_str, 4, 0); new_str = copy(".func pwr(x, a) { pow(x, a) }"); nextcard = insert_new_line(nextcard, new_str, 5, 0);