Open idealkindom opened 1 year ago
Hi, @idealkindom!
Thank you for your suggestions. It sound interesting, but am afraid that I do not fully understand how this should work.
#nounit
is supposed to do? Can you please, provide some examples what happens after #withunit
and #nounit
.For example, we may have the following code:
x = 10
b = 5
y = sqrt(sin(x) + cos(atan(ln(x) + b))
Obviously, we cannot substitute all functions at once, because the nested functions will disappear. So, we will need to show all steps. What Calcpad does is only the first level - to substitute the variables:
y = √( sin(x) + cos(atan(ln(x) + b))) = √(sin(10) + cos(atan(ln(10) + 5))) = 0.556
But to substitute the functions, we will need to unroll the calculations on 4-5 more lines:
ln(x) = ln(10) = 2.3 atan(ln(x) + b) = atan(2.3 + 5) = 82.2 cos(atan(ln(x) + b)) = cos(82.2) = 0.136 sin(x) = sin(10) = 0.174 sqrt(sin(x) + cos(atan(ln(x) + b)) = √(0.174 + 0.136) = 0.556
Graphically, it looks as follows:
Is that what you mean? Showing steps is a good option mostly for educational and debugging purposes, but it is also more complicated to develop.
Hi,Ned.
For the substitution, you got what I supposed.Yes ,when there are many level it's quite complicated to output substition procedure.
For the switch on and off of units of parameter in calculation, after the off command it's implying that a ommit of unit was operated before sent to calculation,only the number before the switch command is sent to calculation.
在 2023-10-26 18:22:46,"Ned Ganchovski" @.***> 写道:
Hi, @idealkindom!
Thank you for your suggestions. It sound interesting, but am afraid that I do not fully understand how this should work.
What #nounit is supposed to do? Can you please, provide some examples what happens after #withunit and #nounit. About substituting functions, I have thought about before some time, but it is not very simple. Unlike variables, function calls can be nested within each other at multiple levels.
For example, we may have the following code:
x = 10 b = 5 y = sqrt(sin(x) + cos(atan(ln(x) + b))
Obviously, we cannot substitute all functions at once, because the nested functions will disappear. So, we will need to show all steps. What Calcpad does is only the first level - to substitute the variables:
y = √( sin(x) + cos(atan(ln(x) + b))) = √(sin(10) + cos(atan(ln(10) + 5))) = 0.556
But to substitute the functions, we will need to unroll the calculations on 4-5 more lines:
ln(x) = ln(10) = 2.3 atan(ln(x) + b) = atan(2.3 + 5) = 82.2 cos(atan(ln(x) + b)) = cos(82.2) = 0.136 sin(x) = sin(10) = 0.174 sqrt(sin(x) + cos(atan(ln(x) + b)) = √(0.174 + 0.136) = 0.556
Graphically, it looks as follows:
Is that what you mean? Showing steps is a good option mostly for educational and debugging purposes, but it is also more complicated to develop.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Hi!
But if we just omit the units, the calculations will look wrong. Image that we have:
a = 10 cm
b = 10 mm
c = a + b ' = 10 cm + 10 mm = 1.1 cm
After we omit the units, we will have:
a = 10 cm
b = 10 mm
#nounit
c = a + b ' = 10 + 10 = 1.1
Hi!
I think @idealkindom is trying to do is something similar to this:
fck = 25MPa
alpha_v2 = 1 -fck/250
In brazilian code the alpha_v2 is a factor to reduce the concrete efficiency, but when we divide fck by 250 we got an error because of units. Normally i do this:
'<p>Choose fck:
'<select data-target="f_ck">
'<option value=20>C20</option>
'<option value=25>C25</option>
'<option value=30>C30</option>
'<option value=35>C35</option>
'<option value=40>C40</option>
'<option value=45>C45</option>
'<option value=50>C50</option>
'</select></p>
#hide
α_v2 = 1 - f_ck/250
α_e
α_i = 0.8 + 0.2*(f_ck/80)
f_cd = f_ck/γ_c
'<!--Define Units-->
f_ck = f_ck*MPa
f_cd = f_cd*MPa
#noc
α_v2 = 1 - f_ck/250
#equ
α_v2
Look that the f_ck is choose without units, so i perform all the formulas that are unit incosistent and before apply the units.
Hi! We have the same issue in Eurocode.
Actually, there are hidden units in these equations. If you see the text "where (something) is in (some units)". What I do is much simpler. I make these hidden units apparent. In your case, you can simply write:
f_ck = 25MPa
α_v2 = 1 - f_ck/250MPa
α_i = 0.8 + 0.2*(f_ck/80MPa)
or
α_v2 = 1 - (f_ck/250)*MPa^-1
α_i = 0.8 + 0.2*(f_ck/80)*MPa^-1
It is not a trouble that the formula does not look exactly by the book. It is important that it is correct and the additional units are required for that purpose. Everyone with engineering degree would understand. In the same way, we will have conversion factors (say, 10^3 or 10^-6), if we do not use units. They are also additional. You can also look at this blog post:
https://calcpad.blog/2023/02/28/units-in-empirical-formulas/
Omitting the units in the output will not solve the problem. It will still throw an error if it tries to subtract 0.1MPa from 1.
I will never use this in this case. Since you do nuclear facilities U know there are many empirical functions to calculate accidental explosion effects, like those many we could find in literatures, such as Henrych's formula.
在 2023-10-26 20:48:36,"Ned Ganchovski" @.***> 写道:
Hi!
But if we just omit the units, the calculations will look wrong. Image that we have:
a = 10 cm b = 10 mm c = a + b ' = 10 cm + 10 mm = 1.1 cm
After we omit the units, we will have:
a = 10 cm b = 10 mm
c = a + b ' = 10 + 10 = 1.1
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
this is a very good example.
在 2023-10-26 21:25:16,"Hildebrando Pereira" @.***> 写道:
Hi!
I think @idealkindom is trying to do is something similar to this:
fck = 25MPa alpha_v2 = 1 -fck/250
In brazilian code the alpha_v2 is a factor to reduce the concrete efficiency, but when we divide fck by 250 we got an error because of units. Normally i do this:
'
Choose fck: '
α_v2 = 1 - f_ck/250 α_e α_i = 0.8 + 0.2(f_ck/80) f_cd = f_ck/γ_c ' f_ck = f_ckMPa f_cd = f_cd*MPa
α_v2 = 1 - f_ck/250
α_v2
Look that the f_ck is choose without units, so i perform all the formulas that are unit incosistent and before apply the units.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
This could be a very good example! some parameter has implying unit, but in the formula it's wierd to display the unit.
在 2023-10-26 22:08:50,"Ned Ganchovski" @.***> 写道:
Hi! We have the same issue in Eurocode.
Actually, there are hidden units in these equations. If you see the text "where (something) is in (some units)". What I do is much simpler. I make these hidden units apparent. In your case, you can simply write:
f_ck = 25MPa α_v2 = 1 - f_ck/250MPa α_i = 0.8 + 0.2*(f_ck/80MPa)
or
α_v2 = 1 - (f_ck/250)MPa^-1 α_i = 0.8 + 0.2(f_ck/80)*MPa^-1
It is not a trouble that the formula does not look exactly by the book. It is important that it is correct and the additional units are required for that purpose. Everyone with engineering degree would understand. In the same way, we will have conversion factors (say, 10^3 or 10^-6), if we do not use units. They are also additional. You can also look at this blog post:
https://calcpad.blog/2023/02/28/units-in-empirical-formulas/
Omitting the units in the output will not solve the problem. It will still throw an error if it tries to subtract 0.1MPa from 1.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Good day.
In engineering, we have learned to never mix units. Thus for example we would not write: a = 10 cm b = 10 mm c = a + b ' = 10 + 10 = 1.1 but rather have it in the same unit. Thus, my program will look something like this: a_cm = 10 cm b_mm = 10 mm b_cm = b_mm|cm|
c_cm = a_cm + b_cm ' = 10 + 0.1 = 1.1 cm
I still agree, it would be nice if one can omit the Units for the substitution of values in the calculation.
The Unit checking must however still work, as it helps with code debugging.
Finally, the Unit must be in the then in the answer.
This will also help with the second point.
Currently, I want to show steps, I create values with the names. For example x = 10 b = 5
sin_x = sin(x) ln_x = ln(x) ln_x,b = (ln(x) + b) atan_ln_x,b = atan((ln(x) + b)) cos_atan_ln = cos(atan(ln(x) + b)) sinx_cos_atan_ln = sin(x) + cos_atan_ln sqrt_in_brackets = sqrt(sin(x) + cos(atan(ln(x) + b)))
hy = sqrt(sin(x) + cos(atan(ln(x) + b)))
'y = 'y = sqrt(sin(x) + cos(atan(ln(x) + b))) 'y = 'y = sqrt(sin_x + cos(atan(ln_x + b))) 'y = 'y = sqrt(sin_x + cos(atan_ln_x,b)) 'y = 'y = sqrt(sin_x + cos_atan_ln) 'y = 'y = sqrt(sinx_cos_atan_ln) 'y = 'y = sqrt_in_brackets
The moments I add units, this becomes very difficult to understand. Thus adding a #nounit in the calculations steps would help.
Then, also #noanswer would help, as it then does not show the answer each time.
The answer helped me, to make sure there were no typos, which I then could correct.
I hope such an option would be possible, as it makes the step-wise calculation then much more readable.
If there is then a function not to show the answer, one can omit the answer.
1.introduce a new pair of command to control patameter's unit in calculation,maybe we could call it #nounit and #withunit 2.support substitution for function value evaluation.