Hi there, I'm not sure if this is the right section of the forum, hopefully yes.
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 (63kb) downloaded 38 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.