def plot_model(C, unknown_params, fvect=None, fmt='k-', \ clear=False, label=None, fi1=1): dB_theta, phase_theta, dB_accel, phase_accel = mymodel(C, \ unknown_params, \ fvect=fvect) fvect = _get_f(fvect=fvect) bode_utils.bode_plot(fvect, dB_theta, phase_theta, clear=clear, \ fmt=fmt, fignum=fi1, label=label) bode_utils.bode_plot(fvect, dB_accel, phase_accel, clear=clear, \ fmt=fmt, fignum=fi1+1, label=label)
def run_model_and_plot(label=None, freq=None, **kwargs): my_dict = build_params_dict(**kwargs) sys = FEA_ss_model(**my_dict) dB_theta, phase_theta, dB_accel, phase_accel = bode_from_FEA_sys(sys, freq=freq) if freq is None: freq = def_freq bode_utils.bode_plot(freq, dB_theta, phase_theta, fignum=1, clear=False, label=label) bode_utils.bode_plot(freq, dB_accel, phase_accel, fignum=2, clear=False, label=label)
from matplotlib.pyplot import * from scipy import * import control import bode_utils G = control.TransferFunction(100.0,[1,0,0])#100.0/s**2 f = logspace(-2,2,1000) w = 2*pi*f db, phase, f2 = control.bode(G, omega=w, dB=True, Hz=True, Plot=False) bode_utils.bode_plot(f, db, phase, clear=True, fignum=1, label='$G$') #Choose freq and design a lead comp. f_c = 10.0 w_c = 2*pi*f_c factor = 5.0 z = w_c/factor p = w_c*factor G_lead = control.TransferFunction([1,z],[1,p])*p/z gain = 6.0 db2, phase2, f2 = control.bode(G*G_lead*gain, omega=w, dB=True, Hz=True, Plot=False) bode_utils.bode_plot(f, db2, phase2, clear=False, fignum=1, label='$G_c \\cdot G$') subplot(211) legend(loc=3)
def plot_bode(f, db, phase, clear=True, freqlim=None, plot_str='-', \ **plot_args): bode_utils.bode_plot(f, db, phase, clear=clear, xlim=freqlim, \ fmt=plot_str, **plot_args)
# Bode Analysis # ------------------------- freq = logspace(-3, 2, 1000) def_freq = freq om = 2 * pi * freq run_simpler_model = 0 if run_simpler_model: mag_full_order, phase_full_order, omega_full_order = full_order_sys.freqresp(om) dB_full_order = squeeze(20.0 * log10(mag_full_order)) phase_full_order = squeeze(phase_full_order) * 180.0 / pi bode_utils.bode_plot(freq, dB_full_order, phase_full_order, fignum=1, clear=False) # Model with Base Mass and Motor Dynamics # ----------------------------------------------- run_old = 0 if run_old: nr1, nc1 = M11.shape N_bm = nr1 + 2 M_bm = zeros((N_bm, N_bm)) J_motor = 0.010
from matplotlib.pyplot import * from scipy import * import control import bode_utils G = control.TransferFunction(100.0, [1, 0, 0]) #100.0/s**2 f = logspace(-2, 2, 1000) w = 2 * pi * f db, phase, f2 = control.bode(G, omega=w, dB=True, Hz=True, Plot=False) bode_utils.bode_plot(f, db, phase, clear=True, fignum=1, label='$G$') #Choose freq and design a lead comp. f_c = 10.0 w_c = 2 * pi * f_c factor = 5.0 z = w_c / factor p = w_c * factor G_lead = control.TransferFunction([1, z], [1, p]) * p / z gain = 6.0 db2, phase2, f2 = control.bode(G * G_lead * gain, omega=w, dB=True, Hz=True, Plot=False)