Published
Edited
Apr 21, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
outPNxy = {RLC_js ; //wait for new values
pyPN`
h = 0.01 #sampling period
p = PolyNum('const:(~2~,-4~4~-4~4~...~)') / h # = 2/h * (~1~-1~)/(~1~1~)
E_0 = 10
[R, L, C] = window.RLC # print(R, L, C)

E = PolyNum('const:(~1~,2~2~2~2~...~)') * (E_0 / 2) # E_0 for t > 0
Z_C = 1 / ( p*C )
Z = p*L + R + Z_C
U_R = E * R / Z
U_C = E * Z_C / Z

# data for d3chartPN()
window._h = h
window._E_asPointsList = E.asPointsList(h)
window._U_R_asPointsList = U_R.asPointsList(h)
window._U_C_asList = U_C.asList()
`
return ([ //data for d3chartPN()
{'xy':window._E_asPointsList, 'nmHtml':'<b>‒‒‒</b> <i>e(t)</i>', 'color':`${colors_[0]}`}
, {'xy':window._U_R_asPointsList, 'nmHtml':'‒○‒ <i>u<sub>R</sub>(t)</i>', 'color':`${colors_[2]}`
,'pathAttrs':{"stroke-width": 1}
,'symbAttrs':{'symb': "circle", 'r':3}}
, {'yh':window._U_C_asList, 'h':window._h, 'nmHtml':'<b>‒○‒</b> <i>u<sub>C</sub>(t)</i>', 'color':`${colors_[1]}`
//can be ovr. in ..Attrs as "stroke": "..."
,'pathAttrs':{"stroke-width": 2.5, "stroke": "DarkBlue"}
,'symbAttrs':{'symb': "circle", 'r':3}}
]);
// var obj=window._ans; return obj.__class__.__repr__(obj)
}
Insert cell
chart_RLC = d3chartPN_(this, outPNxy, {xMinMax_:[0, 0.65], yMinMax_:[-2, 18]})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {pyPN} from "@andrzejq/pnlib-brython-python-source"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more