Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 features request #224

Open
idealkindom opened this issue Oct 26, 2023 · 10 comments
Open

2 features request #224

idealkindom opened this issue Oct 26, 2023 · 10 comments

Comments

@idealkindom
Copy link
Contributor

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.

@Proektsoftbg
Copy link
Owner

Hi, @idealkindom!

Thank you for your suggestions. It sound interesting, but am afraid that I do not fully understand how this should work.

  1. What #nounit is supposed to do? Can you please, provide some examples what happens after #withunit and #nounit.
  2. 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:

image

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.

@idealkindom
Copy link
Contributor Author

idealkindom commented Oct 26, 2023 via email

@Proektsoftbg
Copy link
Owner

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

@hildebrandopsj
Copy link
Sponsor Collaborator

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.

@Proektsoftbg
Copy link
Owner

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.

@idealkindom
Copy link
Contributor Author

idealkindom commented Oct 26, 2023 via email

@idealkindom
Copy link
Contributor Author

idealkindom commented Oct 26, 2023 via email

@idealkindom
Copy link
Contributor Author

idealkindom commented Oct 26, 2023 via email

@Itenium
Copy link

Itenium commented Nov 22, 2023

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|
#noUnit
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.

@Itenium
Copy link

Itenium commented Nov 22, 2023

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
#hide
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)))
#show
#noc
hy = sqrt(sin(x) + cos(atan(ln(x) + b)))
#equ
#novar
'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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants