= #JxnPortable\docs\programmer_examples\commons_math_examples\CommonsMath_ODE_RLC_circuit~Demo.jxn

#import org.apache.commons.math3.ode
#import org.apache.commons.math3.ode.nonstiff
!
slider = @JxnSliderPanel($this)
tend = slider.add( "tend   ", 200., 0., 2000. )
R = slider.add( "R   ", 0.02, 0., 1. )
L = slider.add( "L   ", 1.0, 0., 5. )
C = slider.add( "C   ", 1.0, 0., 5. )
lgf = slider.add( "lg 2 pi f   ", 0.05, -4., 2. )
!
dp853 = @DormandPrince853Integrator( 1.E-8, 100., 0.0001, 0.0001 )
com = @ContinuousOutputModel()
dp853.addStepHandler( com )
!
ode = @ODE_RLC_circuit( R, L, C, lgf )
t0 = 0.
y0 = { 0., 0. }
y  = { 0., 0. }
dp853.integrate( ode, t0, y0, tend, y )
!
tt = tend { 0 : 1000 } / 1000
uC = JxnCOMAnalyzer.analyze( com, tt, 0 )
iL = JxnCOMAnalyzer.analyze( com, tt, 1 )
plot( tt, iL, uC ).setPlotFrameTitle( "RLC circuit, red: iL, blue: uC")