Example of an RLC circuit

RLC

Import

Python itself does not provide usefool ttools for numerical computations. So we have to import them. Ther is several ways to import modules:

  • You can import all the methods and functions with
    from module import *
    
  • You can import selected functions f1 and f2 from a given module with
    from module import f1, f2
    
  • You can import the module with a specified label with
    import module as label
    
In [1]:
# Load Plot module
import matplotlib.pyplot as plt
# This line configures matplotlib to show figures embedded in the notebook, 
# instead of poping up a new window.
%pylab inline
# Load numerical module
import numpy as np
eps = np.spacing(1) # numerical precision

import seaborn
Populating the interactive namespace from numpy and matplotlib

Array definition

On souhaite afficher la courbe $A\sin(2\pi f_0t)$ pour $t\in [0,1]$. Tout d'abord on définit un signal $s(f_0)=A\sin(2\pi f_0t)$, puis on l'utilise récursivement.

In [2]:
# Time Vector
t = np.linspace(0,1,300)
# Signal function
A = 10 # Amplitude (V)
s = lambda f0: A*np.sin(2*np.pi*f0*t)

# Plot for a list of f0
for f0 in np.linspace(1,2,3):
    label = '$f_0=$'+str(f0)
    plt.plot(t, s(f0), label=label)

# Plot axis
plt.xlabel('Temps (s)')
plt.ylabel('Amplitude (V)')

# Plot label and legend
plt.title('$\sin(2\pi f_0 t)$')
plt.legend(loc=0) # option loc=0 set location with minimal overlap

# Show the plot
plt.show()

Somme

Ici on somme les trois signaux pour visualiser une forme d'onde complexe i.e. nonpure.

In [3]:
plt.plot(t, [np.sum(e) for e in zip(*[s(f0) for f0 in [1,2,3]])], label='$\sum_{i=1}^3 S_i(t)$')

# Plot axis
plt.xlabel('Temps (s)')
plt.ylabel('Amplitude (V)')

# Plot label and legend
plt.title('$\sin(2\pi f_0 t)$')
plt.legend(loc=1) # option loc=0 set location with minimal overlap

# Show the plot
plt.show()

A description of Port-Hamiltonian Systems

Here we details the pH approach to the passive modeling and simulation of complex, multiphysics systems.

  • We recall some notions from system theory (state space, passivity, lyapunov function, etc.)
  • We give the port-Hamiltonian structure as introuced by A.J. Van der Schaft and B. Maschke
  • We show how to build this structure automatically from a netlits description.

Read more…