Thermal conductivity problem - Half practice, half practical problem... but definitely not working, help appreciated :P - Messages
Don't know if there is some area in the forum where newbies like me post newbie-like questions, and then some Yoda out there shows the path... that would be the case of this post :P
Starting from the beginning: just to practice a little bit with programming in SMath (I'm NOT an expert at all), I wanted to set up a small calculation file to determine temperature profiles into big pipelines equipped with internal refractory linings and external insulation layers.
It's both a programming exercise for me, and (in case I succeed) a handy tool for office work..
So, I started preparing the attached file.
PROVA CONDUZIONE TERMICA_bkp.sm (62 KiB) downloaded 60 time(s).
Basic elements of the file are:
* There are four layers of internal refractory (1 to 4)
* Layer 5 is steel
* Layers 6 and 7 are external insulation
* In case a layer is missing, its thickness is set to zero.
* A database o materials is defined, and conductivity is interpolated between known data (supplied by lining fabricators).
The logic behind is:
1) Input general data
2) Select materials and thicknesses
3) Program loops from a trial linear temperature profile, updating conductivities at each loop, since conductivity is a function of temperature itself... that's the reason for looping.
4) Equivalent thermal resistance is calculated
5) Total heat flux is calculated
6) Trial temperature profile is updated backwards...
... or at least, that was my initial goal

I found out that the "while" iterations will take A LOT of memory, even if in my mind this problem seems not so demanding in terms of resources.
This is the reason why the "while" loop is temporarily controlled by a maximum number of iterations.
I wanted to add a numerical residual check, in order to break the "while" when residuals where small enough, but I had to begin debugging, so at the moment i'm using the variable "counterlimit" to stop the loop.
It came out that, with counterlimit set to 3 (or below, but in that case results are not yet good enough..), Smath runs the calculation in 20 sec... If counter is set to 4 or above, it runs for minutes (and I always stop it manually).
This said..... why such increase in execution time? Does anybody understand where am I missing something and why is this calculation so demanding, only if counterlimit is increased?
What bothers me the most, is that calculation time does not increase proportionally with the "while" counter number, even if the dataset is not increase in dimension while iterations proceed...
If somebody is willing to dig a little bit into this file, I will be glad to learn something from some expert user!
Thank you
Ciao!
ps: I can see that the conductivity calculation, as I implemented it, is kind of messy (a matrix of materials made up of vectors, used to interpolate conductivity for each material at each loop).... but honestly speaking I couldn't find a better way to fit conductivity equations into (remarkable!) Davide Carpi Comboboxlist plugin.
I will try to store equations as a string, recall it from the database and cook it back again as a formula with "num2string"... Never tried this approach, but it's worth a test or two.
Your Rint 0 generates "division by zero" easy to imagine that Rint may not be
exactly 0 ... 10^-12 is very close to 0.
On the other hand, the while loop must be "Numeric" NOT Optimiz
Also, part of the while loop does not like Units.
My Smath version 6179
Would be wise to work unitless.
Will be back ... Jean
PROVA CONDUZIONE TERMICA_bkp.sm (229 KiB) downloaded 41 time(s).
Wrote... If somebody is willing to dig a little bit into this file...
Benvenuto.
I also try Jean Giraud's opinion that I was lost in a jungle, although the project does not seem to be a big one. I think you should first make a logic scheme and then structure the project accordingly. Otherwise, all the best.
WroteYour Rint 0 generates "division by zero" easy to imagine that Rint may not be exactly 0 ... 10^-12 is very close to 0.
I see that Rint=0 his coming from a modification in the calculation of the internal radius of the first layer of lining; it was Rint[1 in my file, resulting in a non-zero radius.
I see Rint[2 in yours, so first element of the vector is set to zero while second element stores the radius.
WroteOn the other hand, the while loop must be "Numeric" NOT Optimiz
Also, part of the while loop does not like Units.
....
Would be wise to work unitless.
Is there a way to understand during debugging if and why the units are creating the problem?
In any case, I understand that the file itself is still too much of a messy draft, I need to find some time to organize it better (and with some comments/explanation too), and in case post an updated draft.
PROVA CONDUZIONE TERMICA_bkp_alyles.sm (65 KiB) downloaded 32 time(s).
Wrote
Is there a way to understand during debugging if and why the units are creating the problem?
I know Jean has an aversion to using the built-in unit system within SMath, but I use it frequently without issue. I've not noticed a decrease in performance when using units vs. defining programs to be unitless. I personally think the use of units in calculation is extremely useful in quickly validating general arithmetic and results. Working with units can sometimes be a pain in the sense that when generating equations/programs you may often run into issues where units don't match (and calculations cannot complete) or end results don't make sense. Again, I find this useful in understanding all the different components of the equations/programs I generate.
WroteIs there a way to understand during debugging if and why the units are creating the problem?
Work 1rst modular like in the attached.
Most confusing are different but equivalent maths that output different unit system.
What other simple maths will output another/same unit system or "Units don't match".
PROVA CONDUZIONE TERMICA_bkp [0].sm (94 KiB) downloaded 36 time(s).
PROVA CONDUZIONE TERMICA_bkp_CBG.sm (224 KiB) downloaded 39 time(s).
Best Regards
Carlos
WroteA small modification
Thanks Carlos for doctoring this project.
1. Refreshed a bit
2. Few more things at the end.
3. "L" is confusing as not explained ... considered "unary"
4. Two pests [in green] wrt to units.
5. The last 4 "clear" removed from program [avoid red]
Wait and see for Originator to comment/complement
Jean
PROVA CONDUZIONE TERMICA_bkp_CBG [Jean].sm (344 KiB) downloaded 38 time(s).
I will review all the contributions one by one, I just had the chance right now to go through the posts now quickly..
The use of eval() is somehow new to me, I will look at it's implications, since I understand that it has improved a lot the execution time.
Yesterday morning I spent some minutes again testing my file and became suspicious at how I implemented lambda.
It looks like I was accessing to that database matrix a lot of time.
Now I see that a great improvement has come from this eval() function...
Will go through the details and keep you posted.
Thanks again for the support
WroteHello Jean
I think there is an error in the internal radios.
Thanks Carlos: my mistake from copy/paste, delete 'm'
Forgot the unit system bug that does not output 0m, 1m.
That bug was reported long time ago, may have corrected in 6671.
Added: Hermite sub-space fillet.
Jean
Project PROVA CONDUZIONE TERMICA_bkp_CBG [Jean].sm (390 KiB) downloaded 34 time(s).
I'm happy to see that the "while" was messy, not commented properly, etc etc... but it could work (with some help)!
And also the lambda function and the way I defined the database...
First of all, going to your contributions, now I see what Jean meant with one of the first replies:
WroteOn the other hand, the while loop must be "Numeric" NOT Optimiz
I needed to right click and set the while to Numerical optimization?
Setting my original file this way, makes the loop work quickly (shame on me, I wasn't even aware of such setting...)
Also Alyses hint has helped me to understand that the symbolic evaluation was the problem, and that some different setting should be implemented.
Wrote... I did optimize run time of the current implementation. I used the eval() function in the lamda_t function definition...
Iinfact, the following files by other users did not use the eval() function, so I was kind of lost, until I found that right click setting...
So, in the end, if my understanding is correct, eval() and right-click numeric optimization setting are equivalent, isn't it?
Now, going to Carlos contribution, thanks, I see that you found the way to make all the "if" and "while" loops scalable, meaning that I can add / subtract layers of lining.
The length of arrays, the number of loops will now automatically adapt... that was one of my goals, except that I got stuck in the execution time problem, so stayed simple with seven fixed layers of materials. Thank you.
And by the way, I see that your file uses a plugin with a lot of functions I did not know (that cases() function, for sure I will be using it a lot in the future....)WroteA small modification
Jean, what command are you using to generate this kind of matrix? What is the sintax, I mean,to define Q(w) or T.ext (°c) and obtain results without Units? Looks like it is a Custom Function again.
WroteWroteFew more things at the end.
Thanks guys, I definitely learnt something (to say the least) from this thread.
Federico
Ps: by the way, totally on the same page here, but I see Jean's point in running unitless with his example he provided too...
WroteI personally think the use of units in calculation is extremely useful in quickly validating general arithmetic and results. Working with units can sometimes be a pain in the sense that when generating equations/programs you may often run into issues where units don't match (and calculations cannot complete) or end results don't make sense
Wroteean, what command are you using to generate this kind of matrix? What is the sintax, I mean,to define Q(w) or T.ext (°c) and obtain results without Units? Looks like it is a Custom Function again.
That, mon ami, is too simple doing ... like this:
1. from the matrix palette, insert a 2 rows by 5 cols
2. in 2nd row, paste results from above results,
backspace on units Rint ... bacspace on all 'm'
3. in 1rst row, type trial(Alt+248C) => trial(°C)
4. λ(,) ... kg*m/s^3*K from result above
This type of matrix project collection is natural, fast
and fully accessible by more maths from other demands.
It has nothing to do with the plugin "Table region"
About your other question: optimiz mode, eval there is no clear 1/1 answer.
In some advanced maths, the RHS , i.e: the function must be set in eval(,) mode.
Observe: Genfit Rational Type J_6
1. Minimize(XY,f,φ,β) .... some eval(,) within overall numeric
2. φ(x,β,f,n) ... strictly symbolic
3. eval(Φ^-1)*d ... eval(,) within numeric
The λ(,) is 1/1 similar to the LMTD [Log Mean Temperature Difference]
otherwise related to diameters ratio. I found no maths from suppliers.
Cheers Frederico ... Jean
Genfit Rational Type J_6.sm (61 KiB) downloaded 43 time(s). ... stuff about eval(,)
Project PROVA CONDUZIONE TERMICA_bkp_CBG [Jean].sm (391 KiB) downloaded 40 time(s). ... refreshed
WroteSo, in the end, if my understanding is correct, eval() and right-click numeric optimization setting are equivalent, isn't it?
Not so simple !
In the just attached Hermite Polyline, open the first collapsed area.
Observe eval(,) in the subspace module, this is a case of local definition.
Jean
Couldn't reduce the height of the two first rows ... Ah !
Project PROVA CONDUZIONE TERMICA_bkp_CBG [Jean].sm (402 KiB) downloaded 54 time(s).
-
New Posts
-
No New Posts