Analysis of assemblies dynamic thermal performance behaviour under ISO 13786-2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Analysis of assemblies dynamic thermal performance behaviour under ISO 13786-2023
Thanks to the community members for being patient with my questions.
Although a lot of guys in the PTC community gave me valuable tips,
I still want to improve my code slightly (perfectionism).
So, I'll try to list of what do I want to get from my code:
- Define all the calculus dependencies in the first step.
- Define the variables' range (each layer generally has its range). The idea is to account for all possible permutations.
- The k1 and f functions should be figured out for each set of thicknesses (variable) iteration of my multilayered assembly (I have no idea how to assign a specific range of thickness to a particular layer; this is my weak point; I’m not confident in this area).
- To sort out what of the total k1 and f values fit the restriction condition and arrange the result in a matrix with headers (for convenience, with aggregated values’ Names) (the particular matrix components should be plottable afterwards).
- The number of layers varies, so I need to script the sequence of each iteration by indexing (I'm a bit frustrated in this regard right now).
- The desired code has to be as compact and optimised ( in terms of machine time consumerance) as possible (the maxima goal).
Firstly, I tried to make it more generalised (with indexing), but the understanding of the leakage of base coding skills became evident very quickly.
I also understand that poor code is better than its absence.
For clarification, I attached my code in MathCAD Prime 10.0.0 and asked for assistance (advice, somehow) on how to deal with it.
I would appreciate any help.
I've attached my modified code and working sample for two layers.
PS. I also cannot understand why Chat GPT always creates JS-based code for my appropriate MathCAD prompt.
Best regards and thanks in advance.
Solved! Go to Solution.
- Labels:
-
Programming
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
But thats nearly exactly what I provided with my generic "doIt" program if you make the two changes indicated in my reply above so that the numbering starts by 1 and not by 0. ????
Whats new and was never mentioned by you so far are the different step widths k (this variable needs to be of unit length!).
Furthermore the values in the vector you call "a" in your last sheet seem to have a different meaning now as they now are one less the number of times the value of d is taken or better its the number of times the new increment/step k is added to the base thicknesses in d, starting with 0!
So to get the 1000 entries for your three element vector d you have to chose "a" to be all 9's and not 10's!
Attached the modified program to accommodate the new changes and I also changed it so that d1 is modified first and the other values stay constant rather than doing it the other way round as in the original "doIt" program.
I also added a simple version using nested for-loops. You may change the values in the three vectors but the program will only work for two elements.
If you want to work it for three-element vectors, you would have to add another for-loop around the already existing ones.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
In kJ definition set label as Unit
Main loop is i = 1..n In the three times through the loop you set delta ’s three elements
in the first time through the loop you use delta 2 and delta 3 but they are not yet initialized as you have not gone second and third time through the loop yet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Main loop is i = 1..n In the three times through the loop you set delta ’s three elements
in the first time through the loop you use delta 2 and delta 3 but they are not yet initialised as you have not gone second and third time through the loop yet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@terryhendicott Now I see what you mentioned, Terry, but still, I have no idea how to assign symbolic ranges of a1, a2, and a3 for my variables (ksi_j the first), (ksi_k the second), and (ksi_p for the third or i-th layers? in general), respectively.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@terryhendicott, I decided to split the global goal into smaller parts.
Unsurprisingly, I have figured out. that even in the beginning, I cannot get the desired results:
For instance, I expected to receive the list of parameter delta here:
I got only one of the delta suppose of the last layer...
The iteration from 1 to n isn't works as it should ( in terms of my Matchcad experience).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The result of a Mathcad programme always is the result of the last calculation done in the program. In your case thats the last assignment in your loop when i=n.
To return the the full vector delta, simply write delta (or return delta) as the last line of your program beneath the for-loop (nit inside the loop).
I am not sure what you intend with the variable dtot. If you want a header for your vector of values on top, you may write stack("delta", delta) as your last line.
The assignment of dtot inside of the loop does not make much sense as you would overwrite each time the last assignment done.
You may use
or
And if your dtot assignment should have just been a programmers comment, you may use the string alone without assigning it a variable
BTW, to be independent from the setting of the system variable ORIGIN (you have set it to 1) and also not needing the variable "n", you may define the loop shown in the pic below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Werner_E Thank you, Werner. You clarified my MAthCAD black box a little bit.
May I want to create the list of permutations without repeating of two values d1 and d2 being iterated with i-th and j-th increments:
As I get from the output - its smth huge which is the values production result...
Nested loop assign to each j-th value i-th value. For instance
d1=0.01m
d2=0.01m
range1: a1=10
range2: a2 =10
for i E 1... a1
for j E 1... a2
d1<-i*a1
d2<-j*a2
What I'm expecting for in output
permut_d = [ "d1" "d2"]
[ 0.01 0.01]
[ 0.01 0.02]
[0.01 0.03]
[ ... ... ]
[0.1 0.1]
If we have 2 positions with 10 possible numbers in each one the total permutation will be 10^2 =100.
As well other modification doesn't reflects my expectations:
I convinced that there are simple and elegant solution does exist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Werner_E I guess that the proposed code in this thread could be modified a little:
https://community.ptc.com/t5/Mathcad/Combinations-without-repetition/m-p/350033#M136821
but as you probably got from my queries, I'm unfamiliar with MathCAD coding. Unfortunatelly...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
A similar table could be created a bit simpler with a code like the following
When I used "r" and "c" I was thinking on "row" and "column", when using "R" I had Result or Return in the back of my head.
Because I collected the d-values in a vector I could use a second loop for the columns.
If you have distinct variables and don't want to collect them in a vector, you could use just one for-loop for the rows and use the row-operator when assigning the three values. As usual there are many ways to skin a cat ...
If you need further assistance, please ask a specific question and attach the Mathcad sheet if necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Werner_E Thank you a lot for the desire to assist.
This is a pretty cool and compact code, but I'd like to obtain all the possible arrangements (permutations) of my layers with repetitions. Each layer is described as iterable for a varied range from 1 to AI value.
The math equation sample is represented here:
In the attached Prime 10.0.0.0 sample you can see my considerations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
To get the 1000 x 1 vector which you seem to expect, you could program 3 nested loops (for the 3 thicknesses d), each running from 1 to 10 (or better from 1 to a_i). Maybe the loops should run from 0 to a_i if you want to also deal with the case that one of the layers is not present at all.
This approach with nested loops of course is quite inefficient, especially if you think of modifying the number of available layers (d). You mayl find more efficient, general and elaborate algorithms for programming permutations in the literature and may try to duplicate them in a Mathcad program.
Here is the brute force approach with nested loops for the example with the three letter words. As you can see it would be quite easy to change the number of available letters, but it would require to change the program code if you intended to change the number of letters in the final word.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks a lot for your assistance, Werner. It is more acceptable than nothing for my goal function. Yes, I have heard of the significance of increasing time consumption when nested loops are calculated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
My concerns were not about time consuming calculations - after all you have to calculate 1000 results anyway.
My concerns were about the need to change the program in case you add more layer thicknesses (d).
Here's a quick hack (sure could be done shorter and more elegant) but I am not sure if you are looking for something like that.
In case you don't like that the quantities also include zero, you have to make two modifications
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I'm trying to "digest" the proposed code, but there is probably a big gap between the code level and my understanding...
What I'm expecting is the possibility to assign each d-th layer sequences of ai range and make the matrix of all the permutations (arrangements) with repeats.
Thanks a lot for your patience. I tried to modify your sample a bit, but I haven't had any positive outcomes yet.
I know that my code looks ugly. I need to master my coding skills and understand basic concepts.
Can you recommend such guidelines or relevant literature ( particularly in MathCAD coding)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
As far as I understand the code I posted does what you demand (maybe you are just looking for the last column of my table2 ?).
Otherwise you would have to explain much more precisely what you need and not just ‘assign each d-th layer sequences of ai range and make the matrix of all the permutations’ which at least to me is totally unclear.
Preferably with a very specific complete example of the desired output result. Perhaps only with two thicknesses (but please make them different) and with a-values of just 3 instead of 10.
Then you should specify the desired nine-row matrix that you expect as output (type in manually).
Unfortunately I am not aware of any literature on Prime or Mathcad that I would /could recommend. Just doing it by trial and error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Werner_E Sorry for the unclear explanation of my issue.
I suppose in the attachment now, you'll get it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
But thats nearly exactly what I provided with my generic "doIt" program if you make the two changes indicated in my reply above so that the numbering starts by 1 and not by 0. ????
Whats new and was never mentioned by you so far are the different step widths k (this variable needs to be of unit length!).
Furthermore the values in the vector you call "a" in your last sheet seem to have a different meaning now as they now are one less the number of times the value of d is taken or better its the number of times the new increment/step k is added to the base thicknesses in d, starting with 0!
So to get the 1000 entries for your three element vector d you have to chose "a" to be all 9's and not 10's!
Attached the modified program to accommodate the new changes and I also changed it so that d1 is modified first and the other values stay constant rather than doing it the other way round as in the original "doIt" program.
I also added a simple version using nested for-loops. You may change the values in the three vectors but the program will only work for two elements.
If you want to work it for three-element vectors, you would have to add another for-loop around the already existing ones.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you for your patience and desire to help, Werner!
It looks pretty cool and could be used and intended for several coding realisations.
This code (sample2) looks more understandable (as for me).
