Open iroychoudhury opened 5 years ago
Hello @iroychoudhury, thanks for your question.
I must admit I'm a bit confused about what you are trying to do here, do you have an easy reference for me perhaps? From reading your code, there are a couple of things I'm curious about:
Vs
value for every t
value?Vs
is an input, which variable represents the output, and do you have measurements for this output?w
or i_a
is your output variable, and therefore one of them should have data for a fit to make sense right? The fact that you set both to None
surprises me, and I'm sure it surprises Fit
as well ;).Let me know the answers to these question, and perhaps then I can help you further :).
Hello @tBuLi, thank you for kindly taking the time to respond to this. Sorry for the confusing wall of text above. What you understand is correct. I do have a Vs
value for every t
value.
I am trying to identify the parameters for a DC motor. In the state-space formulation, state variables = {i_a, w}, parameters = {L, R, k, J, B}, input = {Vs}, and output = {f}, where:
The state transition model is:
D(i_a, t): (1/L) * (Vs - R * i_a - k * w),
D(w, t): (1/J) * (k * i_a - B * w)
The observation model is: RPM = 55.3 * w
.
So for every value of t, I also have a value for RPM and a value for Vs, and I want to match and fit the parameters for L, R, J, and B.
How should I do it using sympy? Thank you again for your help! :) Much appreciated!
Thank you for your explanation. So in principle, Fit
should be called as
wdata = RPM / 55.3
fit = Fit(ode_model, t=data_c_compact['seconds_total'], i_a=None, w=wdata, Vs=Vsdata)
However, regarding your ODE I'm afraid ODEModel
will not work because currently that only supports one independent variable, t
, but in your case you have two independent variables, t
and Vs
.
You could try to solve your ODE analytically using sympy: https://docs.sympy.org/latest/modules/solvers/ode.html Not sure if your system has a closed solution but it is worth a shot.
Otherwise, you will have to play with scipy's ode solvers to see if you can get this to work, and then build a CallableNumericalModel to feed that solution to symfit. Let me know if you do find a solution in anyway, I'm invested in this problem now :P.
I apologize if this is not the best place for this, but I am trying to fit an ODEModel that includes a variable 'input' parameter.
Basically, if I have the following differential equations for a DC motor:
So
Vs
is basically an input that keeps changing. However, when I run it, I get the errorAttributeError: 'Variable' object has no attribute 'symbol'
I have also tried making 'Vs' a variable, but get another error saying
TypeError: got an unexpected keyword argument 'Vs'
. The code for that is below:Please help!