c3d / db48x

RPL runtime for the DM42 calculator, in the spirit of HP48/49/50
http://48calc.org
GNU Lesser General Public License v3.0
113 stars 13 forks source link

Integrals involving physical units doesn't evaluate: "Inconsistent units" #1314

Open Wiljea opened 2 weeks ago

Wiljea commented 2 weeks ago

In the Examples1 & 2 of the "Terminal Velocity" simulation, I added two new eqns (3) & (4), where the latter involves an integral (Δx=∫v·dt from 0 to tfr): "'(vt_(m/s))=√((2·(mkg)·Ⓒg)/(Cd·(ρ(kg/m^3))·(Ahcm^2)))' " "'v(m/s)=(vt_(m/s))·TANH((ts)·Ⓒg/(vt(m/s)))' " "'tfrs=ATANH(fr)/(Ⓒg/(vt(m/s)))' " "'xfrft=(vt(m/s))·∫(0_s;tfr_s;TANH((ts)·Ⓒg/(vt(m/s)));t)' "

Previously, MSOLVER worked fine for vt & v alone:

Cd=0.15  ρ=0.025_lb/ft^3  Ah=100000_in^2  m=1250_lb  t=5_s
@ Expecting [ vt=175.74722 3631 ft/s v=127.18655 2185 ft/s ]
@ C#18 MSOLVER: works fine for vt & v. I added 2 new eqns, therefore, it needs to be checked BUT integration with units don't work see ISSUE #1314
'ROOT(ⒺTerminal Velocity;[vt;v];[1_ft/s;1_ft/s])'

Then, I added a new variable fr: fraction of terminal velocity (fr=0.95) and two new unknowns: [tfr_s ; xfr_ft] (time required to reach the fraction fr of vt, displacement during tfr) with their respective eqns. Using them, I just calculated by hand the two required answers: @ Expecting [ tfr=10.00590 25332 s xfr=1 117.39339 246 ft ]

AND the problem lies with the integral using physical units (in the limits & variables): '(175.74722 3631_ft/s)·∫(0_s;10.00590 25332_s;TANH((t_s)·Ⓒg/(175.74722 3631_ft/s));t_s)' doesn't work

where in TANH, t_s needs to be in second in order to cancel units from the remaining factors of the argument. Indeed, after many attempts, I found the only way to obtain a valid answer with: '(175.747223631_ft)·∫(0;10.0059025332;TANH(t·Ⓒg/(175.747223631_ft/s)·(1_s));t)' =1 117.39339 246 ft=xfr providing that I cancel myself the remaining units of TANH. In other words, integration works ONLY WITHOUT physical units (I had also to remove them from the integration limits, which is not physically satisfactory). This is probably related to ISSUE #1307. The very same problem is encountered in 3 other cases. Everything is clearly documented in "equations.md".

Wiljea commented 6 days ago

As I commented elsewhere, the BASE function has to be applied to the integration LIMITS but also to the INTEGRAND itself. In the last version of the simulation with the recent equations.cc (simulator constructed from the EQNS branch) I tried the computation with no net units remaining in both limits & integrand. But to simplify these units either the algorithm has to execute BASE or the user has to do so with an algebraic form of BASE. This will be the simplest solution for the time being.

Wiljea commented 6 days ago

It is essential to cure this problem because we now have 1 (Black Body) + 2 (Terminal Velocity) + 2 (Buoyancy & Terminal Velocity) + 4 (Planck & Wien Comparison) + 4 (Planck & Rayleigh-Jeans Comparison) = 13 such integrals up to now in the Library Equation. And in all case this idea of algebraic BASE function should work without further modifications of the Romberg algorithm.