fork download
  1. import numpy as np
  2. import pandas as pd
  3.  
  4. # Given parameters
  5. V = 100 # Voltage in volts
  6. R = 1 # Resistance in ohms
  7. L = 0.1 # Inductance in henries
  8.  
  9. # Time constant tau = L / R
  10. tau = L / R
  11.  
  12. # Times (in seconds) for which to calculate the current
  13. times = np.array([0, tau, 2*tau, 5*tau])
  14.  
  15. # Initial steady-state current
  16. I_steady = V / R
  17.  
  18. # Current at each time (exponential approach to steady state)
  19. I_t = I_steady * (1 - np.exp(-times / tau))
  20.  
  21. # Create a DataFrame to display the values
  22. data = {
  23. 'Time (s)': times,
  24. 'Current (A)': I_t
  25. }
  26.  
  27. df = pd.DataFrame(data)
  28. df
  29.  
Success #stdin #stdout 0.54s 62120KB
stdin
Standard input is empty
stdout
Standard output is empty