Pro/Forums

Pro/Forums (http://forums.procooling.com/vbb/index.php)
-   Testing and Benchmarking (http://forums.procooling.com/vbb/forumdisplay.php?f=61)
-   -   Units Converter & Equation Solver (http://forums.procooling.com/vbb/showthread.php?t=12958)

bigben2k 03-20-2006 08:58 AM

Units Converter & Equation Solver
 
Units Converter & Equation Solver
(covers unit conversion and fluid properties)
http://www.enewsdepot.com/magazine/index.php?read=167

Located here:
http://www.lytron.com/support/tech_ref.htm
and downloadable here:
http://www.lytron.com/support/units_index.htm
(registration may be requested).
(requires Flash).

bobo5195 03-20-2006 01:33 PM

Re: Units Converter & Equation Solver
 
I would also recommend (hint Les) that people try to get a hold of a copy of MathCAD as it the best at this kind of things (scientific formula manipulation). It does cost alot of money though.

See
http://www.mathsoft.com/solutions/ca...te/mathcad.asp

This guy exaplains heat transfer really well using it (can still see pages without the software):

http://web.usna.navy.mil/~adams/index2.htm

Brians256 03-20-2006 06:01 PM

Re: Units Converter & Equation Solver
 
You can see the pages with links to the MathCad files, you mean. Right? All I can really see is the table of contents (which is nice, btw).

Long Haired Git 03-20-2006 06:57 PM

Re: Units Converter & Equation Solver
 
I've written a java app that takes a table of points and finds the equation of the best fit line. No clever maths, just pure grunt work (takes minutes to run, pure CPU bound so unless dual core nothing reponds etc).

Will convert to applet and host online if people interested.

Developed due to my need to have equations for pump, block etc curves for PQ.
Only handles straight lines and positive powers. Does not handle CW charts with their 1/x shape.

Brians256 03-21-2006 12:19 AM

Re: Units Converter & Equation Solver
 
Is that a simple n-poly fit or something more exotic?

bobo5195 03-21-2006 09:32 AM

Re: Units Converter & Equation Solver
 
My bad, I don’t actually have a computer without MathCAD on it so I didn’t realise it used its files instead of an editable Web page.

This is a viewer for the files.
http://www.ecs.soton.ac.uk/~msn/book/mcexp802.exe

It’s a very popular program so it should be easy to get access to.

The guy writing the heat transfer stuff has mucked up in places and covered text with formulas. Yes it is just links to the chapters.

bobo5195 03-21-2006 09:33 AM

Re: Units Converter & Equation Solver
 
Quote:

Originally Posted by Long Haired Git
I've written a java app that takes a table of points and finds the equation of the best fit line. No clever maths, just pure grunt work (takes minutes to run, pure CPU bound so unless dual core nothing reponds etc).

Will convert to applet and host online if people interested.

Developed due to my need to have equations for pump, block etc curves for PQ.
Only handles straight lines and positive powers. Does not handle CW charts with their 1/x shape.

Could always use w/c instead.

How on earth does it take that long? I'm assuming it trys everything then calculates the best result.

bigben2k 03-21-2006 03:01 PM

Re: Units Converter & Equation Solver
 
Quote:

Originally Posted by Long Haired Git
I've written a java app that takes a table of points and finds the equation of the best fit line. No clever maths, just pure grunt work (takes minutes to run, pure CPU bound so unless dual core nothing reponds etc).

Will convert to applet and host online if people interested.

Developed due to my need to have equations for pump, block etc curves for PQ.
Only handles straight lines and positive powers. Does not handle CW charts with their 1/x shape.

I'm interested. I can host it too, if you want (PM me for FTP info).

I was just looking at a similar program yesterday: http://silkscientific.com/ (pricey though)

bigben2k 03-21-2006 03:02 PM

Re: Units Converter & Equation Solver
 
All, since this is intended to be a sticky, be aware that I might clean it up, and consolidate the info within the first post.

Thank you!

Long Haired Git 03-21-2006 05:13 PM

Re: Units Converter & Equation Solver
 
Forums just ate my reply. %$#%#.

Anyhow, my method is brutal and not smart. Didn't consult any books or sites for "right way" or "smart way", just hacked up how I would do it when I was on the train to work as a way to make getting my approximator formulae.

I take the points, and substitute them into:
a.x.x.x + b.x.x + c.x + d = y

There's a checkbox to say that the point 0,0 (if supplied) is a "hard" point and that solves d = 0 immediately. All other points are assumed approximate (and 0,0 if checkbox not on) as I typically read my points off PQ graphs rather than real data.

So, I have a heap of formulae like:
{value}.a + {value}.b + {value}.c + {value} = 0

I then factor each where I can (ie, if each value is divisible by two etc) and only keep unique formulae.

Next, I substitute every formulae into every other formulae, factor and again only keep unique formulae created. I then repeat this again and again. Thus, my 6 or so points end up being, well, tens of thousands of formulae.

Next, I look for the formulae where a and b are near zero. These are then used to come up with a value for c by averaging all the c values. I then substitute the c value back into all the equations and go looking for where a is near zero and solve for b, and then repeat for a.

By "zero", I mean 0.000000001. I found this gives the same accuracy I need as using more decimal places but its much faster and using less decimals is no faster. On my computer on the day I mucked about.

So, supply it like 10 points and want cubic then I cap it at 100,000 formulae which it will get to.

Let me know if I am being dumb and there's a smarter way and if I get bored on the train, I may programme it up.

I've got some webspace now, but the issue is turning it into an applet (as in I have to find some train time).

Emailing you the code and classes BigBen2K, please don't distribute further, please don't post the source code, feel free to Applet-ise and host if you know java. Any other changes, please send them back so I can take advantage etc.

Brians256 03-21-2006 05:27 PM

Re: Units Converter & Equation Solver
 
Canonical approach to the problem you describe is Least Squares.

bobo5195 03-21-2006 06:30 PM

Re: Units Converter & Equation Solver
 
Hmmm thats one way of doing it.

A bit of mucking around and you should be able to find far better methods, method of least squares as one example.

Long Haired Git 03-22-2006 07:44 PM

Re: Units Converter & Equation Solver
 
My method works, so looking for something more accurate or faster.
The least squares thing is how you measure how good the curve was. not how to create it. I ignore least square and use abs-values as it is more important for me to match the curve near zero than at the extreme positive end (10LPM and more) as we're never there.
The main page uses roots, but I don't get the benefit of multiple crosses of X and Y axis, just 0,0. :(

Lagrange Interpolation Polynomials look like fun: http://www.wmueller.com/precalculus/.../lagrange.html

I could then use least squares to automate the simplication of the polynomial and wiggle it around to find the best fit.

bigben2k 03-22-2006 07:56 PM

Re: Units Converter & Equation Solver
 
Quote:

Originally Posted by Long Haired Git
...

Emailing you the code and classes BigBen2K, please don't distribute further, please don't post the source code, feel free to Applet-ise and host if you know java. Any other changes, please send them back so I can take advantage etc.

I'm guessing it overflowed my inbox.

PM'ing you another addy.

Long Haired Git 03-23-2006 11:13 PM

Re: Units Converter & Equation Solver
 
Wow, Lagrange is both awesome and scary.
Bugger me dead if it calculates a line straight through every point I supply, and does it in milliseconds. I'll host a lagrange version of my equation finder soon.

Its also unusable.

See, if we look at the PQ graph of the MCR220QP (its over at swiftech, but we all know the y = a.x.x.x + b.x.x + c.x shape where it passes through 0,0) then the formulae I get with my tool is:
y = 0.011115909951571587 . x^3 + 0.006326165221453601 . x^2
which I round to
y = 0.111 . x^3 + 0.0063 . x^2

This scores a "sum of the squares" difference of 0.0562 with the largest error at a known point being 0.03 mH20.

When I plug the same values into lagrange then it spits out:

-1.9158683767169433E-6 . x^7 + 9.144334308297495E-5 . x^6 + -0.0017305525312195573 . x^5 + 0.016418986110316565 . x^4 + -0.08073720151954691 . x ^ 3 + 0.19907864466310282 . x^ 2 + -0.14167268064530752 . x

It has a sum-of-squares score of zero because it hits every one of the points on my graph dead on.

BUT

Outside the points on my graph, and between the points on my graph near zero, it all goes horribly wrong. The above formulae gets a head of -0.03 mH20 at 0.5 LPM. Worse still, after reaching a peak around 13 LPM, the graph goes nutsoid and plummets to a head of -6 mH20 at 17 LPM.

Lastly, because the forumlaue is so complex, it cannot be "tweaked" at all. The combination of +ve and -ve coefficients and super-large powers means tweaking it makes very large uncontrollable differences. So I can't simplify it to make it quicker to calculate, I can only cut and paste.

I suppose I could force my approximator to only use values between the two extremese of known points, and I could supply a lot of points in order to prevent issues like the 0.5 LPM abberation above. However, more points result in higher powers and massively long formulae and very long execution times for my approximator.

So, suprisingly, equation finder stands up to lagrange and wins.....

bobo5195 03-23-2006 11:36 PM

Re: Units Converter & Equation Solver
 
For this exact reason that more accurate curve fitting is not better.

The x^7 correlation is wrong flow does not vary like that. Swiftechs results have errors and variances fitting in all the things they got wrong is not making things better. Flow correlations are not a many term polynomial! More likely to be a power law result but even then beware and be prepared to use voodoo magic.

Most stuff should correspond to a x^2 correlation only. So dp = a * flow^2.

Have a google for “hazen williams” and the “moody diagram” and its corelations to see slightly different equations to fit to.

bigben2k 03-24-2006 03:17 PM

Re: Units Converter & Equation Solver
 
Got it.

Pardon my ignorance (I have no experience with Java), but how do I set this up for hosting?

Long Haired Git 03-25-2006 03:51 PM

Re: Units Converter & Equation Solver
 
BigBen2k, I thought you wanted it for you.
I will need to write a front end to make it work as an Applet as I didn't bother.
Works as an app from the command line only right now.

bigben2k 03-27-2006 02:57 PM

Re: Units Converter & Equation Solver
 
Oh, then I can probably figure it out. I'm setting up my PC right now.


All times are GMT -5. The time now is 09:11 PM.

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
(C) 2005 ProCooling.com
If we in some way offend you, insult you or your people, screw your mom, beat up your dad, or poop on your porch... we're sorry... we were probably really drunk...
Oh and dont steal our content bitches! Don't give us a reason to pee in your open car window this summer...