Skip to main content
4-Participant
December 2, 2022
Solved

Creating function to solve for Consolidation Settlement

  • December 2, 2022
  • 2 replies
  • 2066 views

Hi everyone,

I trying to program conditions to solve the calculate the settlement which is base of some conditions but i could not, every trial has a new wrong outputs or errors, I will be thankful for your help if possible,

 

-  if initial eff. stress equal to pre-consolidation stress then use eq1 than

otherwise check if

initial eff. stress bigger than pre-consolidation stress AND init. stress + changes in stress smaller than pre-con then use eq 2

other wise check if

initial eff. stress bigger than pre-consolidation stress AND init. stress + changes in stress Bigger than pre-con then use eq 3

 

then use eq2 than

Best answer by Werner_E

With the input values you provide all four sets of values would trigger case 3 (EQ3).
So I can not understand your "Correct answer".
You can't vectorize a boolean operator, so the best solution IMHO is to set up all calculations for single scalars as functions in the variables you'd like to vary and then call these functions vectorized if you want provide vectors of input rather than single scalar values.

Werner_E_0-1669992572613.png

Of course you could/should rename that function and instead of using the expression directly you may also turn EQ1 and EQ2 into functions and call them as I have shown with EQ3 only.

You may also note that you can, but you must not use the names of your later defined data vectors for your formal function arguments.

And because a "return" quits a program you may do the whole thing without any "else" and also add an error if none of the three cases applies:

Werner_E_1-1669993372268.png

 

 

 

2 replies

4-Participant
December 2, 2022

I used the values in vector form, I thought this is the best way, I am not sure if that has a relation to the wrong solutions..

Werner_E25-Diamond IAnswer
25-Diamond I
December 2, 2022

With the input values you provide all four sets of values would trigger case 3 (EQ3).
So I can not understand your "Correct answer".
You can't vectorize a boolean operator, so the best solution IMHO is to set up all calculations for single scalars as functions in the variables you'd like to vary and then call these functions vectorized if you want provide vectors of input rather than single scalar values.

Werner_E_0-1669992572613.png

Of course you could/should rename that function and instead of using the expression directly you may also turn EQ1 and EQ2 into functions and call them as I have shown with EQ3 only.

You may also note that you can, but you must not use the names of your later defined data vectors for your formal function arguments.

And because a "return" quits a program you may do the whole thing without any "else" and also add an error if none of the three cases applies:

Werner_E_1-1669993372268.png

 

 

 

4-Participant
December 5, 2022

Thank you for your great help and time, I really appreciate that.