From 29f99705fdfc4a72281988ad0fab2f8f42921923 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 13 Oct 2009 07:28:59 -0400 Subject: [PATCH] Added inverse piston comments + whitespace in tension_balance() --- src/sawsim.nw | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/sawsim.nw b/src/sawsim.nw index c9b9a34..4f2e5c3 100644 --- a/src/sawsim.nw +++ b/src/sawsim.nw @@ -2447,9 +2447,11 @@ double tension_balance(int num_tension_groups, lb = x_xo_data.xi[0]- (x-last_x); /* apply all change to x0 */ ub = x_xo_data.xi[0]; } else { /* x == last_x */ +#ifdef DEBUG fprintf(stderr, "not moving\n"); - lb= x_xo_data.xi[0]; - ub= x_xo_data.xi[0]; +#endif + lb = x_xo_data.xi[0]; + ub = x_xo_data.xi[0]; } } #ifdef DEBUG @@ -4547,6 +4549,27 @@ double piston_tension_handler(double x, void *pdata) @ +We abuse [[x_of_xo()]] and [[oneD_solve()]] with this inverse +definition (see Section \ref{sec.tension_balance}), because the +$x(F=0)<=L$, but our function returns $x(F=0)=0$. This is fine when +the total extension \emph{is} zero, but cheats a bit when there is +some total extension. For any non-zero extension, the initial active +group produces some tension (we hope. True for all our other tension +models). This tension fully extends the piston group (of which there +should be only one, since all piston states can get lumped into the +same tension group.). If the total extension is $\le$ the target +extension, the full extension is accurate, so the inverse was valid +after all. If not, [[oneD_solve()]] will halve the extension of the +first group, reducing the overall tension. For total extension less +than the piston extension, this bisection continues for [[max_steps]], +leaving $x_0$ reduced by a factor of $2^\text{max\_steps}$, a very +small number. Because of this, the returned tension $F_0(x_0)$ is +very small, even though the total extension found by [[x_of_xo()]] +is still $>$ the piston length. + +While this works, it is clearly not the most elegant or robust +solution. TODO: think of (and implement) a better procedure. + <>= extern double inverse_piston_tension_handler(double x, void *pdata); @ -- 2.26.2