```python
import sympy as sy
import numpy as np
import control.matlab as cm
from mpmath import polyroots
sy.init_printing()
```


```python
kb, k, f, m, M = sy.symbols('k_b, k, f, m, M', real=True)
W = 1/m + 1/M
```


```python
s = sy.symbols('s', real=False)
```


```python
A = sy.Matrix([[0, 1, 0, 0], [-kb/M, 0, k/M, f/M], [0,0,0,1], [kb/M, 0, -k*W, -f*W]])
B = sy.Matrix([[0],[1/M], [0], [-W]])
Bv = sy.Matrix([[0],[1/M], [0], [-1/M]])
C = sy.Matrix([[1., 0, 0, 0]])

A

```


```python
G = C*(s*sy.eye(4)- A).inv()*B
Gv = C*(s*sy.eye(4)- A).inv()*Bv

```


```python
G
```


```python
# Constants
Mn = 100
mn = 6
kbn = 100
kn = 3
fn = 3

Gn = G.subs([(M,Mn), (m,mn), (kb, kbn), (k, kn), (f, fn)])
Gn = sy.simplify(Gn[0])
(num, den) = sy.fraction(Gn)
numP = sy.Poly(num, s)
numcoeffs = np.asarray(numP.all_coeffs(), dtype=float)
denP = sy.Poly(den, s)
dencoeffs = np.asarray(denP.all_coeffs(), dtype=float)

Gvn = Gv.subs([(M,Mn), (m,mn), (kb, kbn), (k, kn), (f, fn)])
Gvn = sy.simplify(Gvn[0])
(numv, denv) = sy.fraction(Gvn)
numPv = sy.Poly(numv, s)
numcoeffsv = np.asarray(numPv.all_coeffs(), dtype=float)
denPv = sy.Poly(denv, s)
dencoeffsv = np.asarray(denPv.all_coeffs(), dtype=float)

```


```python
#sy.factor(denP, extension=[sy.I])
poles = polyroots(dencoeffs)
poles
```




    [mpc(real='-0.23408260199788464', imag='-0.66645226904530763'),
     mpc(real='-0.23408260199788464', imag='0.66645226904530763'),
     mpc(real='-0.030917398002115359', imag='1.000570798665283'),
     mpc(real='-0.030917398002115359', imag='-1.000570798665283')]




```python
Gs = cm.tf(numcoeffs, dencoeffs)
Gsv = cm.tf(numcoeffsv, dencoeffsv)
cm.bode(Gs, Gsv)

```


```python
cm.pole(Gs)
```




    array([-0.0309174+1.0005708j , -0.0309174-1.0005708j ,
           -0.2340826+0.66645227j, -0.2340826-0.66645227j])




```python
Gsv
```




    
               s^2 + 0.5 s + 0.5
    --------------------------------------
    100 s^4 + 53 s^3 + 153 s^2 + 50 s + 50




```python
numcoeffs
```




    array([ 1.,  0.,  0.])




```python
Gs2 = cm.tf(1./100*np.array([0,0,1.]), [1, 0.5, 1.5, 0.5, 0.5])
Gs2
```




    
                     0.01
    -------------------------------------
    s^4 + 0.5 s^3 + 1.5 s^2 + 0.5 s + 0.5




```python
cm.pole(Gs2)
```




    array([  5.27355937e-16+1.j        ,   5.27355937e-16-1.j        ,
            -2.50000000e-01+0.66143783j,  -2.50000000e-01-0.66143783j])




```python
sy.simplify(sy.expand((s**2 + 2*0.1*1*s + 1)*(s**2 + 5*s + 7)))
```


```python
(num3, den3) = cm.zpk2tf(k=0.5, p=[-0.1+1j, -0.1-1j, -0.25 + 0.6*1j, -0.25-0.6*1j], z=[0, 0])
Gs3 = cm.tf(num3, den3)
Gs3
```




    
                       0.5 s^2
    ---------------------------------------------
    s^4 + 0.7 s^3 + 1.533 s^2 + 0.5895 s + 0.4267




```python
cm.rlocus(Gs3)
```


```python
1+ 1J
```




    (1+1j)




```python

```

13125c8feac25708cda0577dd22ac9f25635ded5
ipynb
Jupyter Notebook
notebooks/Active mass damper system.ipynb
alfkjartan/ingenieria-de-control
f9d9aa927376894dea1c9ae57de810342aa74e4d
MIT
notebooks/Active mass damper system.ipynb
alfkjartan/ingenieria-de-control
f9d9aa927376894dea1c9ae57de810342aa74e4d
MIT
notebooks/Active mass damper system.ipynb
alfkjartan/ingenieria-de-control
f9d9aa927376894dea1c9ae57de810342aa74e4d
MIT
Qwen/Qwen-72B
1. YES
2. YES