Tuesday, May 24, 2016

Charging Up!

I'm done with MathCAD. I can't afford it and the free version is laughable. The plotting capabilities are so limited that it is almost useless to me.

So I found something that I can use instead.
Jupyter Notebook as installed with the Anaconda Package and plotting capabilities with Bokeh.

All of this is 'free as in beer'. Thanks goes to the developers of Jupyter Notebook and Continuum Analytics.

Here is a simple RC circuit showing a capacitor charge over time. It uses numpy for the array calculations.

There seems to be a bunch of overhead code just to get things done. This is really not an issue because this overhead can be copied and pasted as needed. What is not shown here is how interactive the plot is and how useful the interface is when iterating designs.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import numpy as np
from bokeh.io import output_notebook
from bokeh.plotting import figure, output_file, show, ColumnDataSource
from bokeh.models import HoverTool

R = 1.0e3 #1Kohm
C = 1.0e-6 #1uF
tau = R*C
t = np.arange(0,6.0*tau,0.1*tau)
Vc= 5.0*(1-np.e**(-t/tau))

output_notebook()
CVplot= figure(plot_width=400, plot_height=400,
   tools="pan,box_zoom,reset,save,hover",
   title="RC Charge Curve",
   x_axis_label='mSec', y_axis_label='Cap Voltage'
)

CVplot.circle(t/1e-3, Vc, line_color="black")
CVplot.line(t/1e-3, Vc, line_color="red")

#adjust what information you get when you hover over it
hover = CVplot.select(dict(type=HoverTool))
hover.tooltips = [
    ("time", "@x"),
    ("Vc", "@y"),
]


show(CVplot)


Enough for now.

No comments:

Post a Comment