https://github.com/aosync/libwaves
Library to manipulate and build linear combinations of harmonic oscillators
https://github.com/aosync/libwaves
Last synced: 9 months ago
JSON representation
Library to manipulate and build linear combinations of harmonic oscillators
- Host: GitHub
- URL: https://github.com/aosync/libwaves
- Owner: aosync
- Created: 2022-11-23T14:08:26.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T18:26:41.000Z (over 3 years ago)
- Last Synced: 2025-03-13T20:14:44.211Z (over 1 year ago)
- Language: Python
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# libwaves
Python library to manipulate linear combinations of harmonic oscillators
## Example
```py
from libwaves import *
import numpy as np
import matplotlib.pyplot as plt
n = 3
omega = 8/60*2*np.pi
nU1 = 200*1000
nU2 = 150*1000
nU3 = 20*1000
nU4 = 2*1000
# Define input signal
Fx = -nU1*(Cos(n*omega) + Sin(n*omega)) - nU2*(Cos(2*n*omega) + Sin(2*n*omega)) - nU3*(Cos(3*n*omega) + Sin(3*n*omega)) - nU4*(Cos(4*n*omega) + Sin(4*n*omega))
# Low pass filter with cutoff 1 Hz
H = lambda w: 1.0 if np.abs(w) < 1*2*np.pi else 0.0
# Calculate output signal by multiplicating each oscillator coefficient
# with corresponding return value of function
Xx = Fx.convofrf(H)
t = np.linspace(0, 10, 1000)
plt.plot(t, Xx(t))
plt.show()
```