*** Error in syntax of function string: Invalid element: o2
Position: 7
(1-(1+o2/g)*exp(o1*e/f))*o2-(o1*m1)
?Hi,I am trying to solve a system of first order ODEs and nonlinear algebraic equations. These ODEs are with respect to position (x) as opposed to time. I am having some trouble getting them to solve using apmonitor. The model is shown below. Can anyone suggest where I might be going wrong?I am used to having to choose a 'guess' for the algebraic equations when solving alone in Matlab, is it necessary to instead provide an initial condition as a variable here?How might I vary the system with respect to position (x) instead of time (t)?Any help is greatly appreciated.Many thanks,BenModelConstantsa = 10b = .1c = .1d = .001e = .03f = .00001g = .0000001h = .0000000001i = 10j = 300k= 600End ConstantsVariablesl1 = 1l2 = 1m1 = 10m2 = 500n1 = 600000n2= 200000! o1 = 10^(-5) This would be my typical guesses for numerical solution of the algebraic equation! o2 = 10^(-6) This would be my typical guesses for numerical solution of the algebraic equationEnd VariablesEquationso1 = h*(i*j*(m1*exp(-o1/(.5*(l1*c*k/d)^(.5)*f/c))-m2*exp(o1*e/f))/(1+(g/o1)*(exp(o1*e/f)-exp(-o1/(.5*(l1*c*k/d)^(.5)*f/c))))-n1+n2) ! non-linear algebraic 1o2 = o1*m1/(1-(1+o2/g)*exp(o1*e/f)) ! non-linear algebraic 2$m1 = -(2*o2+2*o1*b^2*m1)/(b*l1) ! ODE 1$m2 = (2*o2+2*o1*b^2*m2)/(b*l2) ! ODE 2$n1 = -(30*d/(i1*c))*a*i1^2*c ! ODE 3$n2 = -(30*d/(i2*c))*a*i2^2*c ! ODE 4$l1 = 2*o1*b ! ODE 5$l2 = -2*o1*b ! ODE 6End EquationsEnd Model
Hi John,
Thanks very much for your detailed reply. Unfortunately the i1 and i2 were typos, as they should have been l1 and l2. I've changed i1 and i2 to l1 and l2, and eliminated i1 and i2 from the model parameters. I've now tried running the file through Matlab, and through the online APMonitor interface, and I get a successful result in Matlab (and through the online interface when I choose "Sequential, Simulate"). However, when I try to add values for changing x in the csv file, an error is returned, "Error: Did not converge to a solution, Attempt to reference field of non-structure array." The .csv is has the same name as the .apm file. I've attached the .csv file here in case you have any insight.
Thanks again,
Ben
Ben,
You need to leave the “time” header, even though you are integrating with respect to distance.

You may also need to include additional distance points because APM will solve only at the requested time/distance values that you specify. Once you have the sequential simulation working, you can also change to imode=5 for dynamic reconciliation with data for parameter estimation or imode=6 for dynamic optimization. For smaller problems, imode=4 (simultaneous simulation) can sometimes be faster than your current mode which is imode=7.
You can label the results as distance in your plots or other results…

-John Hedengren
--
--
APMonitor user's group e-mail list.
- To post a message, send email to apmo...@googlegroups.com
- To unsubscribe, send email to
apmonitor+...@googlegroups.com
- Visit this group at http://groups.google.com/group/apmonitor
---
You received this message because you are subscribed to the Google Groups "apmonitor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
apmonitor+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.