From a77229768c5cea00fa8d07b685bad239cc844ce7 Mon Sep 17 00:00:00 2001 From: dapplion Date: Sun, 11 Aug 2019 23:53:01 +0200 Subject: [PATCH] Prevent p1 = p0 --- src/CurveDesignInputParams.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/CurveDesignInputParams.tsx b/src/CurveDesignInputParams.tsx index a81a5a2..7152279 100644 --- a/src/CurveDesignInputParams.tsx +++ b/src/CurveDesignInputParams.tsx @@ -24,9 +24,12 @@ export default function CurveDesignInputParams({ setVHalflife(curveParams.vHalflife); }, [curveParams]); + const maxReturnRate = 10; + const minP1P0Rate = 1.5; + function _setP0(newP0: number) { setP0(newP0); - if (p1 < newP0) setP1(newP0); + if (p1 < newP0 * minP1P0Rate) setP1(newP0 * minP1P0Rate); else if (p1 > newP0 * maxReturnRate) setP1(newP0 * maxReturnRate); } @@ -41,8 +44,6 @@ export default function CurveDesignInputParams({ })); } - const maxReturnRate = 10; - const inputFields: InputFieldInterface[] = [ { label: parameterDescriptions.theta.name, @@ -74,7 +75,7 @@ export default function CurveDesignInputParams({ description: parameterDescriptions.p1.text, value: p1, setter: setP1, - min: p0 || 0.1, + min: Number((minP1P0Rate * (p0 || 0.1)).toFixed(2)), max: Number((maxReturnRate * p0).toFixed(2)), step: 0.01, toText: (n: number) => String(+n.toFixed(2)),