I want to use python to solve a set of equations describing a thermistor, a electronic component where the electrical resistance changes with temperature. The upper equation G(T) describes the conductance through the thermistor, dependent on the temperature T and the bottom equation how T varies with time, where $T_{ON}$ is an initial condition and v is the applied voltage, which I want to be a sinusoidal voltage. \begin{equation} G(T) = \bigg( R_{ON} \cdot e^{\beta_N \big(\frac{1}{T}-\frac{1}{T_{ON}} \big)} \bigg)^{-1} \end{equation} \begin{equation} \frac{dT}{dt} = \frac{\delta_N}{H_{CN}}(T_{ON}-T) + \frac{G(T)}{H_{CN}}v^2 \end{equation}
Using for example "scipy.odeint" I pass in dT/dt, an initial value, $T_{ON}$, and a time array. But I struggle to understand how to do it in this case..
- If I wanted to plot G(T) as a function of applied voltage, do I pass in the arguments mentioned above and update G(T) for each iteration and store these G(t) values?
- I try to pass in a vector of sinusoidal values v, for the time array, but get an error saying the time array must be monotonically increasing. Am I mixing up things here? The differential equation is not dependent on the time step, just the voltage v?
Any pointers or tips on where to look would be of great help!
This should be pretty straightforward. You define the helper functions as described,
Add the necessary import statements for sin and exp, from math or numpy, both should work. (The ODE solver only uses single-point evaluations in default mode, numpy has overhead to detect and handle arrays.)
Then define the ODE function as given
and pass it to the ODE solver as usual. To plot $G(T(t))$ against $v(t)$, solve for a time array and then compute these functions for the solution (now one needs the numpy variants)