Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vout,t = var("Vout,t")
- #The known variables
- L = 1e-3
- C = 1e-9
- Vin = 5
- R = 1e3
- Vout = function("Vout",t)
- equation = L*C*diff(Vout,t,2) + R*C*diff(Vout,t) + Vout == Vin
- generalSolution = desolve(equation,Vout,ivar=t)
- print "General Solution :", generalSolution
- show(generalSolution)
- specificSolution = desolve(equation,Vout,ivar=t,ics=[0,0,0])
- print "Specific Solution :", specificSolution
- show(specificSolution)
- #Plotting
- plotMax = 2e-5
- plot1 = plot(specificSolution,[t,0,plotMax],rgbcolor=[0,0,0]) #Differential equation
- plot1 += plot(Vin*0.1,[t,0,plotMax],rgbcolor=[0,0,1]) #10% line
- plot1 += plot(Vin*0.9,[t,0,plotMax],rgbcolor=[0,0,1]) #90% line
- show(plot1)
- #Find the local maximum
- findMax = find_local_maximum(specificSolution,1e-6,5e-6)
- print "Local max =", findMax
- print "### First Issue ###"
- ### FIRST ISSUE ###
- ### Normally i would take the differential and set it to zero
- findMax2 = solve(diff(specificSolution,t) == 0,t)
- print "Local max2", findMax2 ## Result is obviously wrong. It should match findMax
- print "### Second Issue ###"
- ### SECOND ISSUE ###
- #First as i usually would do
- print "\t 10% = ",solve(specificSolution==Vin*0.1,t)
- print "\t 90% = ",solve(specificSolution==Vin*0.9,t)
- ## i found this somewhere, but it didn't help
- func(t) = specificSolution
- print "\t 10% = ",solve(func(x)==Vin*0.1,x)
- print "\t 90% = ",solve(func(x)==Vin*0.9,x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement