Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Dear PTC Mathcad Community,
I am working in Mathcad Prime on a nonlinear moment–curvature analysis of a reinforced concrete section according to Ukrainian concrete Code ДСТУ Б В.2.6-156:2010 (Appendix A, second equilibrium form).
I implemented a step-by-step algorithm with nested FOR loops, conditional checks, and accumulation of results into a matrix Moment_curvature.
Problem description
I expect to obtain a matrix with multiple rows (i.e., 10 rows), where each row corresponds to the final iteration of strains (εc1, εc2), which have to iterate until the condition of equation (4.3) N<0 is true, and contains:
However, Mathcad returns an empty table only, even though:
I understand that my script is one of the few possible ways to solve the issue; thus, with this regard, my questions arose:
I would greatly appreciate any guidance, examples, or references on best practices for iterative algorithms and matrix construction in Mathcad Prime that could help me resolve the issue.
Thank you very much for your time and support.
P.S.
For clarity, I attach my zipped file, which describes the algorithm I wish to realise in Prime 10.0.0 version.
Also, the explanation of what I expect to get from the code, the picture of the curvature, and the Table of data (performed in an online software) have been added to the attached Mathcad file.
Hi Ivan,
Your file was not attached.
It seems there is a problem with attaching files on the forum presently.
What appears to work is if you ZIP the Prime 10 .MCDX file and attach that .ZIP file.
To ZIP the file, in Windows Explorer select the file and then from the right-mouse-click menu choose
Send To => Compressed (zipped) folder
Success!
Luc
@LucMeekes Thank you for the comment. I'll try to fix the issue with the attachment.
That worked.
Now to your algorithm:
You have the assignments to Moment_curvature[i,1 through [i,9 outside of the for loop that iterates over i. So at that point i is a constant. Only the last row of the Moment_curvature matrix gets filled. See here:
I guess you must move the assignments upwards in the algorithm, probably at the end of the For loop.
Success!
Luc
@LucMeekes Thanks for the quick reply. I'll look through the routine, but the question is: whether the assignment should be moved into the FOR loop (where i decrements), and how to "explain" to the code that I need to go further through all the epsilon_c1 increments.
As you see, it is better than the previous look, but all the data is fixed without incrementing.
I only have limited time to look at your sheet, and absolutely no idea what it is about. Just trying to spot common errors.
You state further down the sheet that you expect a 10-line matrix.
Your index i runs over 20, but you have another for loop where m runs up to 10.
Maybe you need to store the data from within that for loop, using m instead of i...?
There should be no need to assign a variable to itself. So all the
,
,
and the like can be omitted.
Note that the result of the function is the (result of the ) last assignment. It is good habit to exit the function with a
return Moment_curvature
at a(ny) suitable spot. Your error detection(s) could be changed to
return "Something went wrong X"
in which case the program will stop and produce that string as result.
Success!
Luc
@LucMeekes Thank you a lot for your noticeable remarks regarding the:
@LucMeekes wrote:...
You state further down the sheet that you expect a 10-line matrix.
Your index i runs over 20, but you have another for loop where m runs up to 10.
Maybe you need to store the data from within that for loop, using m instead of i...?
There should be no need to assign a variable to itself. So all the
,
,
and the like can be omitted.
Note that the result of the function is the (result of the ) last assignment. It is good habit to exit the function with a
return Moment_curvature
at a(ny) suitable spot. Your error detection(s) could be changed to
return "Something went wrong X"
in which case the program will stop and produce that string as result.
...
I have even thought about my issue: to do a nested FOR loop, where the i-th iteration increments the epsilon c2 variable (slave) and the second FOR loop iterates over the m-th iteration of the epsilon c1 (master).
Nevertheless, I'll try to fix it, as I understand.🙂
@LucMeekes I have fixed the proposed remarks... and now I can see the error place
But it still doesn't work as it should.
If you change:
return "Something went wrong 2!"
with
return [ "error 2" Nnew Nnewest epsilonc2new epsilonc2old tolerance ]
you will get the values of the variables that are involved in the IF statement and can decide what made the test fail.
Note that [ ] is a 1-row matrix.
Success!
Luc
