Community Tip - You can change your system assigned username to something more personal in your community settings. X
Dear PTC Mathcad Community,
I want to ask for clarification on the behaviour of units and symbolic substitution in Mathcad Prime (similar topics have already been raised, but I still haven't found an appropriate answer for my issue).
So I try to find a symbolic expression for epsilon_c2, which is a parameter of the equation N.
Solver succeeded with the issue, but with incompatible units (see picture)
So, I have tried to find out the solution in the community, but the advice of @Werner_E with calculation options didn't resolve the issue (see the picture)
So my issues are:
1. How to make the symbolic solving more "seamless" with appropriate units' manipulation in the solutions?
2. Why does Mathcad not see the assigned values of the epsilon_c2 obtained in the previous solution?
After some time, when the file has been refreshed, some magic happened, and now I can use the roots of epsilon c1 and c2 in a "normal" manner.
But the next issue is that it doesn't let me substitute the obtained symbolic solution into the following step calculation for the moment M calculation.
As it can be seen, the factual equation is real, with proper units,
Nevertheless, Mathcad is still not satisfied with...
I am still convinced of Mathcad's power, but each time I get stuck with such a misunderstanding of Mathcad logic, I feel broken, exhausted and unable to continue to the next step - automation of my manual solution.
Any clarification, examples, or references to documentation would be greatly appreciated.
I am trying to align my workflow with my Mathcad Prime 10.0.0.0 internal logic rather than fight against it.
Thank you very much for your time and support.
The file with the manual calculation of M is attached.
Solved! Go to Solution.
Hi Ivan
Version 4 of the file. Have found a couple of issues on checking my work. First to answer your questions.
"h" is not used in my worksheet. d is indeed h-as. the depth from top compression fiber to bottom steel layer.
The curvature is derived from e/kd not (ec1-ec2)/h. It is the same result.
Calculations for ecu1_cd/2 are an example only, I used as a check. they could be taken out and the sheet would still work.
The steel grade chosen like A400C is applied to both layers of steel. In practice it would not be a good idea to mix grades as errors on site of misplacing grades in wrong positions could occur.
I have found some errors in my sheet upon checking. That is why version 4.
Used the wrong column of DBN for fcd. This is corrected.
Used fyk and Es to set the max yield strain, then wound back the resulting stress by gamma s.
This means the steel stress strain diagram is altered.
Changes in yellow.
Results in very close answers to MQN.com. 383 to 385.
For some reason not getting the same stress values for the reinforcement?
Have corrected the stress calculations with s1 being the top reinforcement and s2 being the bottom reinforcement as per MQN.com.
Will continue to look for errors.
Do not be put of by the numeric integral calculus it gets the same result for compressive force in concrete as equation 4.3 is the mathematical equivalent:
Using the calculus it is easy to swap to Eurocode stress block.
I do not understand the second integration of compressive block in equation 4.4? If you take moments about the centroid of compressive force you eliminate that force from the moment calculation. What is X1 in equation 4.4?
I am checking for more errors as time permits so be prepared for version 5.
Not sure why your system does not find the text files. Try using the full path in Prime READFILE statements.
Cheers
Terry
@terryhendicott I am really impressed by your level of understanding and MathCAD mastery, Terry.
It'll help me a lot.
Trying to digest the material...
Regarding your question about X1
X1=ec1/א, where the א - curvature =1/h*(ec1-ec2)
I still can't get from the formula why do you put plus after the first member As*fs*(d-kd)...
The "+" sign depends on the distance d' from the most compressed part of the beam and comparison with kd. Whether the d ' is bigger than kd - the reinforcement is situated in the tensile zone, and the total moment will be equal to the lever arm (d-Centroid) produced by the sum of the reinforcement, which is in the tensile zone.
Hi Ivan,
Version 5 which can accommodate multiple layers of reinforcement defined in vectors "vAs" and "vd".
To do this have made some changes,
a) Reinforcement stress strain diagram accepts positive and negative strains.
The calculation of "kd" has been changed to read the reinforcement layers
The calculation of the moment has been changed to read the reinforcement layers.
You had questions about the signs of tension (-) and compression (+) and moment (+ anticlockwise around concrete stress block centroid).
How this sign convention works is in the enclosed graphic.
Cheers
Terry
@terryhendicott Hi Terry!
The effort you've put in is much appreciated and has been very helpful in solving my issue.
Thanks to your enclosed graphic, it is now much easier for me to investigate your assignments to characters in the code. Thank you so much for the time and goodwill you've spent on the problem solution.🙏
@Thank you for the clarification and the script modification, Werner.
I modified your script a little to include ORIGIN :0 in the hope that it'll give me zero values on the first iteration step, like here.
by providing a conditional statement and counting a coefficient from zero to four:
But somehow MathCAD do see the error still:
(((
Prime 10.0.0.0 is attached.
Can you explain why MathCAD sees it as an error?
As well as a few questions in the script, highlighted in colour.
i <- 0 is a local assignment!
In a conditional you have to use the comparison equal (Boolean equal)
See modifications in attached sheet.
If you just wanted all values to be zero in front it would have been easier to work from the previous sheet and simple add the zero values on top 😉
According your comments in the sheet - I don't see what you seemed to have seen. I only see errors because ec2 is not defined, etc.
You changed ORIGIN from 1 to it default value 0.
When you had a sum running from 1 to rows(...) it will not work that way, because vector indexing start with 0 now.
You are better of letting the sum run from ORIGIN to last(...). That way you are independent from the setting of ORIGIN.
@Werner_E Thank you for correcting the code, Werner.😁
Now, I really have the perspective to move forward to upgrade the code ))🙏
To make clear what I meant with my remark
"If you just wanted all values to be zero in front it would have been easier to work from the previous sheet and simple add the zero values on top"
You simply have to replace the bottom line of the program
with
to get
and
ORIGIN was not changed, its still 1..
I also noticed that the variables sigma_s1_2 and also x1 which you calculate are never used !?? So these calculations
and
could be deleted.
@Werner_E Yes, it will be more considerable!))
Thanks for your desire to help, Werner!!!
I played around a little bit and turned the calculations into individual functions rather than just working with vectors.
I had hoped that the maximum Moment value could be calculated with more precision using the derivative. Unfortunately Prime chokes on that - probably because of the if-statements and the resulting discontinuities in the derivative.
Nonetheless it may be useful. I also made all calculations ORIGIN-independent.
Prime 10 sheet attached
@Werner_E Thank you very much, Werner!
I have been pleasantly amazed with your analysis being performed.
@Werner_E wrote:I played around a little bit and turned the calculations into individual functions rather than just working with vectors.
I had hoped that the maximum Moment value could be calculated with more precision using the derivative. Unfortunately Prime chokes on that - probably because of the if-statements and the resulting discontinuities in the derivative.
Yeah, I still have some hopes, regarding the Mathcad Symbolic engine. But in my case, the three reinforcement layers provide no symbolic solution.
@Werner_E Thank you for your patience and desire to assist with my issue, Werner!
I still can't catch where the term "alef" is assigned from?? I have found no such assignment in the code, but I understand it is assigned elsewhere... Why is it important? Because I need to analyse the dependence (Moment Curvature = alef). And the point that alef is not the Curvature in terms of values.
Prime 10.0.0.0 file attached.
"alef" is on of the return values of your large iteration program. Its the last of the six returned results
And the values in "alef" correspond to the vector of values which you called "alef_dash" in your program.
As I have no experience whatsoever in your field of work I can't say if or why it may be important or what the meaning of those values would be. Its one of the vectors of values you calculated in your program, so I returned it so you can examine them in the sheet. If they have no importance, simply remove this return value.
Note that a program in Prime cannot alter variables defined in the worksheet nor can your worksheet look at the variables calculated in a program. If you need values which were calculated in the program you have to explicitly return them as the result of your program. To return more than one value you have to put them in a vector or matrix.
To return something from a program you may use the explicit "return" statement. Otherwise the result of the last line executed is the returned value. That's the reason why I did not need touse "return" in the last line.
But you sure can use
it may be good style anyway.
Hi
Version 6 of calculations now allows for choice of DBN or Eurocode stress block.
All the sample/checking calculations are removed leaving the bare bones.
Calculation of kd using the root() function is essentially the solution of a quadratic so a negative value is possible (especially at low curvature) the guess value could lead to the negative solution. Negative value of kd messes up the moment curvature graph at low curvature. The workaround is to use a better guess for kd at half the maximum steel depth instead of 30 mm. Graph glitches go away.
Cheers
Terry
@terryhendicott Hi Terry!
I tried a little bit to analyse your Moment equation. Thus, according to the analysis of equation (4.4)
We do need to consider the moment of equivalent concrete centroid (first member of the equation), or by your assignment:
Since it affects the total M value, it creates a moment that is taken with the lever arm cg (according to your assignment) against the clockwise direction. M=Centroid*cg
In my case it has a significant influence on the total moment M
I take the curvature as the maximum of design depth vd1, which'll be constant and not depend on the first assumption of kd=30 mm, as in your sample.
As I see from your moment calculation, you ignore the centroid input to the total moment M. You use only the moment produced by reinforcement multiplied by the respective lever arms. Why?
Also, I didn't catch why you don't put ec1u_cd as the maximum compressed strain of concrete instead of etop?
File attached.
Hi,
The trick is in where to take moments about for the moment equilibrium calculation.
Version 6 takes moments in the section about the centroid of the concrete section.
Equation 4.4 takes moments about the bottom of the concrete stress block.
Here is a diagram and calculations of the difference.
@terryhendicott Hi Terry!
Thank you for your explanation, but I'm still concerned about the correctness of my interpretation of your file and logic embedded in v.6/
I don't want to be annoying, but it seems to me that you misunderstand equation 4.4.
In my graph, you can see how the logic of equation 4.4 is built ( probably you've got it earlier, but still I want to express it by picture, maybe here is the point of your misunderstanding)
Hi,
It does not matter if you take moments about the moment centroid of the compressive stress block, or moments about the bottom of the concrete stress block you get the same answer for section moment.
When using the centroid of the concrete stress block as point to take moments about, lever arm of the tensile reinforcement is longer and gets the same overall moment.
When using the bottom of the concrete stress block as point to take moments about, lever arm of the tensile reinforcement is shorter and gets the same overall moment.
Here is sample calculation of both:
Cheers
Terry
@terryhendicott Hi Terry!
Thanks for the clarity.
You are definitely right regarding the leverarms - if we do take the moment of compressed concrete with its arm Fc*concrete arm, the respective arm of the reinforcement will be shorter, and the total moment M in such a case will consist of two components - concrete and reinforcement.
Otherwise, if we get an appropriate value of lever arm of compressed concrete block from the root() function, we can calculate the total moment M as the reinforcement equivalent force Fs multiplied by the bigger lever arm = (lever arm of concrete+lever arm of reinforcement) without considering the impact of compressed concrete Fc*concrete arm in the total moment M.
As far as I messed a little bit with your symbols, you do calculate the moment M under the second, bigger lever, arm without considering the impact of compressed concrete Fc*concrete arm. Am I right?
@Werner_E Thank you for your explicit explanation, Werner!
The lack of MathCAD nuances does not stop me from exploring its power!))
As far as I caught the idea, you can only use the data from the program if you saved it in the return [...] manner (matrices, if we have more than one variable, and without square brackets if we need to return only one value. Isn't it?
I'll try to exercise it a little.
As far as I caught the idea, you can only use the data from the program if you saved it in the return [...] manner (matrices, if we have more than one variable, and without square brackets if we need to return only one value. Isn't it?
Correct. For a worksheet being able to use the value(s) calculated in a program, the program must return these values to the calling instance, the worksheet.
And the data structure used to hold multiple values is a matrix/vector.
@Werner_E Hi Werner!
Maybe I don't understand the logic of MathCAD, but why in one case (Case of one-layer reinforcement), where I assigned the Curvature value by
Everything was seamless.
But unfortunately, after hard work with several mistakes corrected and thorough input, the same Curvature value for double reinforcement caused an error in MathCAD...
I'm on the edge of being broken.
With my "coarse" understanding of MathCAD logic, it seems to be the unexplainable issues, for me at least.
Sorry for annoying you, but I'm really trying to understand where there are possible **bleep**ups and to fix my issue.
File attached
Your program is impossible to read for me and i was hardly able to play around with it because Prime gets unacceptably slow in reaction.
I tried to throw in a try-on_error statement at the position of the error to see when the error occurs and would return "i" and the vector "ec2" in case of an error.
It showed me that the error occurs when i=3, but my attempt to show the returned vector ec2 failed because Prime would crash.
I saw the error "Unknown error: The method or operation is not implemented" without any clue as to which 'operation or method" the message would refer to.
I looked closer (not too close as of the prohibiting large expressions) at the definition of ec2 and noticed, that you don't return a value in case none of the conditions in your many if, elseif statements is met.
So I added an "else" at the end which guarantees that ec2_i would get a value in any case.
This at least makes the program work but chances are you get some wrong values because of the arbitrary value 12345 used. This means that you should recheck the logic of the calculation - there seems to be at least one case which you did not consider correctly.
And, as I already wrote in a prior reply, your if, if else,... calculations should always return a value. This usually may be achieved by using a simple "else" as the last statement. This is where you land if none of the other conditions are met.
EDIT:
I modified the program so that ec2 would be returned as well and so I can see that all values starting with i=3 do not meet any of your conditions and so now all are 12345. Sure not what you had intended:
P.S.: You really should try to shorten the expressions and the program. Maybe its possible to split the calculations or define functions for some of them which then could use in your program.
A simple example:
Instead of
you could define functions for the condition as well as for the resulting value
and use them in your program
If you then use meaningful function names that perhaps correspond to your application, this will not only make your program easier to read, but also easier and faster to edit.
@Werner_E Hi Werner
You are absolutely right, the more conditionals in the program the higher chance of error being happen. I also thought about it how to shorten the conditional part of the code.
Now, after checking my code I do found two additional conditiones which heven't been considered earlier in the code, but even though, the new error took place "The value must be real"
I do consider that I choose one of the possible roots of the symbolic solution in each conditional, maybe it caused that in the calculus will be imagine and real numbers...
So the next question is arose in my mind:
How can I define my conditons outside of the code ( as you sugeested it)
with choosing the only one root that meet my (if only I can guess them correct) requierements:
Choose the minimum real (non complex) value of two roots, for instance of this symbolic solution:
to be assigned afterwars in the conditionals of the programme...
Unfortunatelly, by putting the Real part of the value
The MathCAD launch the next error: " The value must be the vector or matrix".
It looks like there is an (implicit) multiplication between "Re" and the openeing parentheses "(". Delete it.
BTW, your error handling
does not work. If something went wrong you store a text string in ec2 and then you still use ec2 in subsequent calculations which will throw an error because ec2 is not a number.
You may try to use NaN instead and see if it works.
The program runs OK if you delete the implicit multiplication between Re and (, but you have to decide if using just the real part of a non-real solution gives you a correct result.
As the solutions for ec2 you choose from stem from an equation of second order with (as I suppose) real coefficients, either both solutions would be non real or none.
Choosing the smallest of both solutions only works if the solutions are real. This would require that you calculate both solutions and use the minimum (which then also may be negative).
One way to avoid the copy and paste of the symbolic solutions you calculated is to turn these calculations into functions.
It does not make much sense that you define
because what you actually define that way is the resulting 2x1 vector to the very right which contains a lot of variables but sure not ec2.
I understand that you tried to document that the expression you use for solving is q(...).
You could do it that way:
First define q as a function of all variables involved (as none of them is already defined at this stage.
Then solve this function for ec2 and assign the result (which is a vector with all values for ec2) to a function whose name should be something with ecs (and some name part which distinct this from all the other functions which also would calculate ec2).
Later you could use this function providing all variables and evaluate it numerically and then examine the vector you get and chose the solution according to rules you have to provide (e.g. take the smallest if both are positive, use the largest if one is negative, return NaN if both are non-real.
I don't know if if makes sense in your workflow but after you defines the variables in front of your program to calculate ec2, only ec1 and F_ seem to be left unknown as F_ is calculated in the program.
You could as example define a new function now
This function calculates the two values for ec2 and selects one following the logic outlined above. I have no idea if that's the logic you need, though.
You can now use this function in your program instead of the huge expression you copied there.
The function I mentioned can be found in the attached file.
I did not use it in the program because I had no idea where 😉
When you use it you sure have to use ec2 with index i of course.
I have an idea to check whether each condition is a real number using my function by defining the minRealRoot function (see the picture), but, to be frank, I'm only on my way to it (((, cause even on this simple sample I do not understand how the condition is to be formulated correctly...
I want to choose only the minimal real root, otherwise to assign, let it be ec2=0.
Why does MathCAD deliberately add an imaginary part to the real root? It seems more complicated than I can imagine.
I want to choose only the minimal real root, otherwise to assign, let it be ec2=0.
I understand that you want to use zero if all values are non-real.
Do you also want to use the minimum of all real values if it is positive? Or do you rather want to use 0 in this case?
Why does MathCAD deliberately add an imaginary part to the real root? It seems more complicated than I can imagine.
That's the way the "min" function works:
If the elements are complex, min returns the smallest real part of any value plus i times the smallest imaginary part of any value
See the help: Maxima and Minima of an Array
@Werner_E wrote:I want to choose only the minimal real root, otherwise to assign, let it be ec2=0.
I understand that you want to use zero if all values are non-real.
Do you also want to use the minimum of all real values if it is positive?
I want to assign ec2 the minimum root value if the root is a real number, otherwise ec2 will be zero.
@Ivan_Pat wrote:
@Werner_E wrote:
I want to choose only the minimal real root, otherwise to assign, let it be ec2=0.
I understand that you want to use zero if all values are non-real.
Do you also want to use the minimum of all real values if it is positive?
I want to assign ec2 the minimum root value if the root is a real number, otherwise ec2 will be zero.
OK, so the minimum could be positive as well.
Here is a special "Min" function which should do the job.
First all non-reals are replaced by NaN's.
Then we try to delete these NaN's using "filterNaN". This functions fails if either no NaN was found or if all values are NaN's. In this case the vector remains unchanged.
Fortunately "min" returns a zero if the vectors contains only NaN's which is exactly what you want to see if all values are non-real.
Prime 10 sheet attached
