cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Creating function to solve for Consolidation Settlement

Raied_Refaei
4-Participant

Creating function to solve for Consolidation Settlement

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

ACCEPTED SOLUTION

Accepted Solutions

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

 

 

 

View solution in original post

3 REPLIES 3

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

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

 

 

 

Raied_Refaei
4-Participant
(To:Werner_E)

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

Announcements

Top Tags