Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Harvey Hensley  
#1 Posted : 04 July 2020 00:18:32(UTC)
Harvey Hensley


Rank: Member

Groups: Registered
Joined: 28/05/2020(UTC)
Posts: 18
United States
Location: Bartlesville, OK

Was thanked: 4 time(s) in 2 post(s)
I have a function called "rfun(x,y) that calculates a dimensionless reaction rate. The function works fine when calculating a single
value, but when it appears in a program function used to create a matrix of rates for x and y vector inputs, it doesn't work properly.
All elements of the resulting matrix contain the same value which corresponds to the last value calculated. See below.

result using rfun directly

I found a workaround as shown in the next image. All of the elements produced by these two functions are correct.

the workaround

Can anyone explain why the first method doesn't work? If I try this method with simpler functions, it works fine. The rfun function involves some use of the Prode Physical properties which may be a cause. However, since the rfun function works fine for a single result, I don't understand why it doesn't work here. Also, the rfun function doesn't work in Maxima Draw3d either.

Also, is there a more elegant workaround that could be done in just one program function?

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Jean Giraud  
#2 Posted : 04 July 2020 02:25:23(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
No document = No monkey see no monkey do
Offline Harvey Hensley  
#3 Posted : 04 July 2020 03:25:43(UTC)
Harvey Hensley


Rank: Member

Groups: Registered
Joined: 28/05/2020(UTC)
Posts: 18
United States
Location: Bartlesville, OK

Was thanked: 4 time(s) in 2 post(s)
I found a solution. When I create the rfun function, I do it with a program. The first line of the program is a Clear() statement that clears the output of the rate function. The second line is the result = math expression, and the last line is the result variable for the output.

I had previously tried using clear statements in the matrix creation function with no success.
Offline Jean Giraud  
#4 Posted : 04 July 2020 14:22:25(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Harvey Hensley Go to Quoted Post
I had previously tried using clear statements in the matrix creation function with no success.

When re-using matrix/vector in program, set [M, V]:=0

ClearMatrix.PNG

thanks 1 user thanked Jean Giraud for this useful post.
on 05/07/2020(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.