kill(all)$

intro resistor(R)-inductance(L) 'serial','transient' ,version 1.0
peter.vlasschaert@gmail.com,02/01/2020

load packages
---------------------

load(lrats)$

serial circuit ( R & L)

sinusoidal source: E0*cos(ω*t)

serial : R-L circuit 
=============
Initial Condition = IC
=>  t =.0;   suppose  i=0
Why because takes time to take energy up 

Differential equations : 'R-L circuit'
===========================
use : KVL Law ,see ELECTRICAL : website
vsource = vL + vR

Model : R-L circuit

p1:L*'diff(i,t) +R*i = E;
p1a:E = E0*cos(ω*t);

E0 : amplitude sinusiodal signal

How to solve : ode2
===============

a) ode 
---------

p2:subst([p1a], p1);

b) solve ode2
-------------------

p2a:ode2(p2,i,t);

c)  how to find  %c
-------------------------

solution : i=0 ,@t=0, use p2a

p2b: subst([i=0,t=0],p2a);

p2b1:solve(p2b,%c);

d) final result i = i(t)
---------------------------

p2c:subst(p2b1,p2a);

p2c1:expand(p2c);

p2c1a:ratsimp(p2c1);

check : IC condition , limit
-------------------------------------
'see above'

p2d:limit(i,t,0) = limit(rhs(p2c1),t,0);

find : vL,vR,vsource
===============

a) vL = L*diff(i,t)
----------------------

p3:vL = L*'diff(i,t);

p3a:lhs(p3) = subst([p2c1],rhs(p3));

p3b:ratsimp(ev(p3a,nouns));

p3b1:expand(p3b);

b)  vR  = i*R
------------------

p4:vR = i*R;
p4a:expand(subst([p2c1],p4));

c)  find : vsource
------------------------
use : 'p3b','p4a'

p5:vsource  = vL+vR;

p5a:subst([p3b1,p4a],p5);

p5b:ratsimp(p5a);

check : use 'p2' ? 'p5b'
--------------------------------
is 'command' , Maxima

p6:is(rhs(p2) = rhs(p5b));

How to solve : i=u*v
===============
i=i(t) , 'see above' , u = u(t),v=v(t)

a)  ode : 'p2'
------------------

p7:p2;
p7a:i=u(t)*v(t);

b) substitution i
---------------------

p8:expand(p7/L);

p8a:subst([p7a],p8);

p8b:ev(p8a,diff);

c)  set = R/L = α
----------------------
into 'p8b'

p8c:[ R/L=α];
p8c1:lratsubst(p8c,p8b);

rem : lhs(), v(t)

p8c2:ratcoef(lhs(p8c1),v(t));

d) set :u(t)*α+'diff(u(t),t,1) = 0
----------------------------------------

p8d: p8c2  = 0;

e)   set 'p8d' in lhs
--------------------------

p8e :lratsubst([p8d],p8c1);

f)  two ode's : 'd' & 'e'
------------------------------

1e)  simple differential equation 'p8d'
---------------------------------------------------

assume(R>0,L>0);

assume(t>0);

a)  set  u(t) =A*exp(p*t)
----------------------------------
find : by direct integration on paper.

p8f:[u(t)=A*exp(p*t)];

b) use 'p8f' in 'p8d'
--------------------------

assume(α>0);

p8f1:subst(p8f,p8d);

p8f2:ev(p8f1,diff);

p8f3:factor(p8f2);

c) find p
-----------
because : A ≠ 0, exp(p*t) ≠0

p8f4:part(lhs(p8f3),3) =rhs(pf3);

p8f5:solve(p8f4,p);

d) subst into 'a)'
----------------------

p8f6:subst(p8f5,p8f[1]);

2e) differential equations, ode combination 1e).
----------------------------------------------------------------
use : 'p8e'

p8f7:subst([p8f6],p8e);

a)  find v(t)
---------------

p8f8:expand(p8f7/(rhs(p8f6)));

b) integrate
-----------------

p8f9:integrate(p8f8,t);

3e)  i = u(t)*v(t)
---------------------
use : 'p7a'

p8g1:p7a;

p8g2:subst([p8f[1],p8f9,p8f5[1]],p8g1);

p8g3:expand(p8g2);

4e)  set A = 1, find only one IC ( i=0 @t=0,find %c1)
-----------------------------------------------------------------------

a)  A=1
----------

p8e1:subst([A=1],p8g3);

b)  find  %c1
-----------------

p8e2:subst([i=0,t=0],p8e1);

p8e3:solve(p8e2,%c1);

5e) find i(t)
----------------
use : 'p8e1' & 'p8e3'

p8e4:subst(p8e3,p8e1);

p8e5:ratsimp(p8e4);

6e) resubst :α = R/L,needed for check ,between the methods
-----------------------------------------------------------------------------------

p8e6:p8c[1];

p8e7:rhs(p8e6) = lhs(p8e6);

p8e8:subst([p8e7],p8e4);

   ?  first method ' p2c1a'
==================
i=(E0*L*%e^((R*t)/L)*ω*sin(t*ω)+E0*R*%e^((R*t)/L)*cos(t*ω)\-E0*R)/(L^2*%e^((R*t)/L)*ω^2+R^2*%e^((R*t)/L))

second method
============

p8e9:ratsimp(p8e8);

p8e9a:expand(p8e9);

check : i(t),see above.

p8e10:is(rhs(p2c1a)= rhs(p8e9));

result : both methods gives same result.

two limits : t=0,t =inf
===============

a)  t=0
----------

p8e11a:limit(p8e9,t,0);

b) t=∞
---------

p8e11b:limit(p8e9,t,inf);

find approximation exp(-α*t) small is when t is very large.
-----------------------------------------------------------------------------
see :α=R/L

set : R^2/L^2 = α^2
===============
denominator : p8e9

denominator : p8e9,rhs
---------------------------------
find y :

p9a:(p8e6)^2;

p9aa1:lratsubst([p8e6,p9a],denom(rhs(p8e9)));

p9aa2:p9aa1= y*L;

p9aa3:solve(p9aa2,y)[1];

p9aa4:lhs(p9aa3)=factor(rhs(p9aa3));

numerator : p8e9,rhs
------------------------------
find x:

a) isolate L
---------------

p9a2:num(rhs(p8e9)) = L*x;

b) solve for x
--------------------

p9b1:solve(p9a2,x)[1];

p9b2:expand(p9b1);

p9b3:lratsubst([p8e6],p9b2);

i= x/y
=====

p9c1:i= expand(rhs(p9b3))/rhs(p9aa4);

p9c2:lhs(p9c1)=expand(num(rhs(p9c1)))/denom(rhs(p9c1));

p9c3:expand(p9c2);

assume(ω>0);

limit :find i , t= 0,t =∞
================

aa)  t=0
------------

p9c4a:limit(p9c3,t,0);

bb) t= very large
----------------------

p9c4b:lhs(p9c3) = part(rhs(p9c3),1)+part(rhs(p9c3),2);

p9c4b1:lhs(p9c4b) = factor(rhs(p9c4b));

how construct : i = B*sin(ω*t+φ)
=========================
amplitude = B
phase       = φ

a) find : B,φ
----------------

1e) model i 
---------------

p10a:i=B*sin(ω*t+φ);

p10b:lhs(p10a) =expand(trigexpand(rhs(p10a)));

set : A1 = B*cos(φ)
set : A2 = B*sin(φ)

p10b1: B*cos(φ) = A1;
p10b2: B*sin(φ)  = A2;
p10b3:p10b2/p10b1;
p10b4:tan(φ) =rhs(p10b3);

p10b5:trigsimp((p10b1)^2+(p10b2)^2);

p10b6:sqrt(p10b5);

p10c:lratsubst([p10b1,p10b2],p10b);

2e) find  A1,A2.
---------------------
see :p9c4b1

p11:expand(p9c4b1);

p11a:A1=ratcoeff(rhs(p11),sin(ω*t));
p11b:A2=ratcoeff(rhs(p11),cos(ω*t)) ;

3e) find B
--------------
amplitude

p11c:lhs(p10b5) = subst([p11a,p11b],rhs(p10b5));

p11c1:lhs(p11c) =ratsimp(rhs(p11c));

p11c2:sqrt(p11c1);

p11c3:distrib(p11c2);

because L >0

p11c4:B= E0/(L*sqrt(ω^2+α^2));

4e)  find φ
--------------
phase

p11d:lhs(p10b4) = subst([p11a,p11b],rhs(p10b4));

p11d1:atan(p11d);

rem : set :atan(tan(φ)) = φ

p11d2:atan(tan(φ)) = φ;
p11d3:lratsubst([p11d2],p11d1);

rem :

? atan;

find general equation  i = B*sin(ω*t+φ)
=============================
use p11c4,p11d3

p11d4:lhs(p10a) = subst([p11c4],rhs(p10a));

How to find voltage after large time ( time  = t) through the inductance( = L)
-----------------------------------------------------------------------------------------------------
use :vL = L*diff(i,t)

p11d5:vL= L*'diff(i,t);
p11d6:lhs(p11d5) = subst([p11d4],rhs(p11d5));

p11d7:ev(p11d6,diff);

rem: relation between sin & cos

sin(t*ω+φ+π/2);

phase : between ( i,vL)

reason : phase between : i & vl :  π/2 forward
=> ω*t +φ + π/2- ω*t -φ = π/2

meaning : i ref  then vl ( π/2 positiv direction against ref : i)

c1 =amplitude : vector : i
c2 = amplitude : vector : vL

p12a:subst([B=1],rhs(p10a));

p12b:subst([B=1,φ=φ+π/2],rhs(p10a));

p12aa:c1= rhs(p11d4)/p12a;
p12bb:c2 = rhs(p11d7)/p12b;

How to find voltage after large time ( time  = t) through the resistor=R
-----------------------------------------------------------------------------------------------
use : vR =i*R

i through the resistor 
----------------------------

p13a:p11d4;

vR over the resistor
--------------------------

p13b:vR = i*R;
p13b1:subst([p11d4],p13b);

phase = 0 ,phase = between (i,vR) = 0

c1a =amplitude : vector : i
c2a= amplitude : vector : vR

p13aa:c1a= rhs(p13a)/p12a;
p13bb:c2a= rhs(p13b1)/p12a;

How to find : τ = time constant
-----------------------------------------
use :p8f6

p14a:p8f6;
p14a1:rhs(p8f6) = A*exp(-t/τ);
p14a2:p14a1/A;
p14a3:log(p14a2);
p14a4:solve(p14a3,τ)[1];
p14a5:lratsubst([p8e7],p14a4);

meaning : L/R dimension time , analog : R.C also dimension time.