Re: Pass variables into Newton or BROYDEN for solving non-linear equations [message #77919] |
Tue, 18 October 2011 08:47 |
Zhang Bo
Messages: 22 Registered: October 2011
|
Junior Member |
|
|
On Oct 17, 9:20 pm, Beaker <mattjamesfran...@gmail.com> wrote:
> Yep that looks right, assuming you actually use the values A,B,C,D in
> the LCL function (are they to replace the constants you have in there,
> such as 223.1986 etc??).
yes, they replace T_s, Mmr_s etc. Thanks a lot!
|
|
|
|
Re: Pass variables into Newton or BROYDEN for solving non-linear equations [message #77928 is a reply to message #77926] |
Mon, 17 October 2011 18:10  |
Zhang Bo
Messages: 22 Registered: October 2011
|
Junior Member |
|
|
On Oct 17, 7:13 pm, Beaker <mattjamesfran...@gmail.com> wrote:
> On Oct 18, 6:24 am, Zhang Bo <bzhang20071...@gmail.com> wrote:
>
>> I have a non-linear equations system to solve in every loop step. I
>> have 4 equations with 8 variables. 4 of the variables are known and
>> calculated in each loop. I cannot find a way to pass the known
>> variables(which are different in each loop) into a BROYDEN or NEWTON
>> function to solve the system. If I put all 8 variables as input guess,
>> it won't calculate for me because there are 8 variables and 4
>> equations. I kind of stuck here.
>
> When I encountered a similiar issue using AMOEBA, the only solution I
> could see was to cover myself with garlic and use a COMMON block. I
> set the extra variables I want to send to each call before making that
> call and have the COMMON block visible from within the user defined
> function you send to NEWTON or whatever.
>
> Does that make sense?
Like this?
common lclinput, A, B, C, D
A = ****
B = ****
C = ****
D = ****
X = [250, 20, 6.2, 750]
Result = broyden(X,'lcl')
FUNCTION LCL, X
COMMON lclinput, A, B, C, D
return, [X[0]-T_s*(X[1]/P_s)^(287/cp_s),$
X[2] - X[3]*Mmr_s/(0.622+Mmr_s),$
X[1]-26.66082+alog(X[1]),$
X[0] - (X[1]-sqrt(X[1]^2-223.1986))/0.0182758048]
END
|
|
|
Re: Pass variables into Newton or BROYDEN for solving non-linear equations [message #77929 is a reply to message #77928] |
Mon, 17 October 2011 16:13  |
Matt Francis
Messages: 94 Registered: May 2010
|
Member |
|
|
On Oct 18, 6:24 am, Zhang Bo <bzhang20071...@gmail.com> wrote:
> I have a non-linear equations system to solve in every loop step. I
> have 4 equations with 8 variables. 4 of the variables are known and
> calculated in each loop. I cannot find a way to pass the known
> variables(which are different in each loop) into a BROYDEN or NEWTON
> function to solve the system. If I put all 8 variables as input guess,
> it won't calculate for me because there are 8 variables and 4
> equations. I kind of stuck here.
When I encountered a similiar issue using AMOEBA, the only solution I
could see was to cover myself with garlic and use a COMMON block. I
set the extra variables I want to send to each call before making that
call and have the COMMON block visible from within the user defined
function you send to NEWTON or whatever.
Does that make sense?
|
|
|