X = np.load('data/output_data_pow.npy') # plt.plot(X[:1000,2]) dt = X[1, 0] - X[0, 0] N = int(X.shape[0] / 2) freqs = np.arange(N) / (2 * N * dt) wf = freqs * 2 * np.pi idx = np.logspace(0, int(np.log10(N)), 100).astype(int) w = wf[idx] s = 1j * w ft_pot = lambda x, y, z: 1 / (rho * cp) * np.exp(-(v * (-x) + np.sqrt( (x**2 + y**2 + z**2) * (4 * a * s + v**2))) / (2 * a)) / ( 2 * np.pi * a * np.sqrt(x**2 + y**2 + z**2)) import fem3d_2ss fem2ss = fem3d_2ss.Fem3d_fenics('data/v2/16x8x2/') # fem2ss = fem3d_2ss.Fem3d_fenics('data/v2/16x8x2/') U = np.fft.fft(X[:, 1]) for i in range(3, X.shape[1]): H1 = U * np.fft.fft(X[:, i]) / U**2 plt.figure('Bode T/Pow ' + str(ops[i - 3])) control.bode_plot( (control.frd(H1[idx], w), control.frd(ft_pot(*ops[i - 3]), w), fem2ss.get_ss(ops[i - 3] + (.02, .02, 0))), w, dB=True) plt.legend(('fem', 'fdt', 'ss')) U = np.fft.fft(X[:, 1]) H1 = U * np.fft.fft(X[:, 7]) / U**2
import matplotlib.pyplot as plt import numpy as np import control import fem3d_2ss, weld1.filter1 # fem2ss = fem3d_2ss.Fem3d_fenics('data/v5/16x8x2/') # fem2ss = fem3d_2ss.Fem3d_fenics('data/v5/32x16x4/1500/') # fem2ss = fem3d_2ss.Fem3d_fenics('data/v5/40x20x5/') # fem2ss_2 = fem3d_2ss.Fem3d_fenics('data/v5/32x16x4/1500/k30/') # fem2ss = fem3d_2ss.Fem3d_fenics('data/v5/irregular/') fem2ss = fem3d_2ss.Fem3d_fenics('data/v5/irregular2/') fem2ss_2 = fem3d_2ss.Fem3d_fenics('data/v5/irregular2/k30/') # fem2ss.A.shape inp = np.array((.02,.02,0)) p1 = (.01,0,0) p2 = (0,0.005,0) plantp_d = control.sample_system(fem2ss.get_ss(inp + p1), .001) plantv_d = control.sample_system(fem2ss.get_ss_v(inp + p2), .001) # plant_d = plantp_d T = fem2ss.Teq control_on = True perturb_on = False # Controllers ctrl1_d = control.sample_system(control.tf(1, (1, 0)), .001) ctrl1 = weld1.filter1.Filter1((0,ctrl1_d.num[0][0][0]),ctrl1_d.den[0][0])
import matplotlib.pyplot as plt import numpy as np import control import fem3d_2ss fem2ss = fem3d_2ss.Fem3d_fenics() plant = fem2ss.get_ss((.02, .025, 0)) t1, y1 = control.step_response(1500 * plant) plt.figure('Weld model') plt.plot(t1, y1, label='Plant') plt.xlim((0, 12)) plt.figure('Weld model plants') # pts = ((.02,.02,0),(.021,.02,0),(.022,.02,0),(.023,.02,0),(.024,.02,0),(.025,.02,0),(.02,.021,0),(.02,.022,0), # (.02,.023,0),(.024,.02,0),(.025,.02,0),(.021,.021,0),(.022,.022,0),(.023,.023,0)): # pts = ((.02, .02, 0), (.02, .021, 0), (.02, .022, 0), (.02, .023, 0), (.02, .024, 0), (.02, .025, 0), (.02, .026, 0)): # pts = ((.02, .02, 0), (.021, .021, 0), (.022, .022, 0), (.023, .023, 0), (.024, .024, 0), (.025, .025, 0), (.026, .026, 0)): pts = ((.02, .02, 0), (.021, .02, 0), (.02, .021, 0), (.02, .02, 0.001), (.019, .02, 0), (.02, .019, 0.0), (.021, .021, 0.001)) pts = ((.025, .02, 0), (.02, .025, 0), (.03, .02, 0.0), (.02, .03, 0), (.04, .02, 0.0), (.025, .025, 0.0)) for p in pts: plant = fem2ss.get_ss(p) t1, y1 = control.step_response(1500 * plant) plt.plot(t1, y1, label='Plant ' + str(p)) plt.xlim((0, 12)) plt.legend() ctrl2 = control.tf2ss(1 * control.tf((1 / 1, 1), (1, 0)) * control.tf( (0 / 1, 1), (0 / 2, 1)))
import matplotlib.pyplot as plt import numpy as np import control import fem3d_2ss, weld1.filter1 # fem2ss = fem3d_2ss.Fem3d_fenics('data/16x8x2/') fem2ss = fem3d_2ss.Fem3d_fenics('data/32x16x4/') # fem2ss.A.shape plantp_d = control.sample_system(fem2ss.get_ss((.03, .02, 0)), .001) plantv_d = control.sample_system(fem2ss.get_ss_v((.02, .025, 0)), .001) plant_d = plantp_d # Temp profiles along x and y power = 1000 delta_speed = .001 nds1 = np.argwhere((fem2ss.X[:, 1] == 0.02) & (fem2ss.X[:, 2] == 0)) nds2 = np.argwhere((fem2ss.X[:, 0] == 0.02) & (fem2ss.X[:, 2] == 0)) T = np.zeros(fem2ss.B.shape) fig = plt.figure('Temp profiles 2') ax1 = fig.add_subplot(211) ax1.clear() ax1.set_xlim((0, .08)) ax1.set_ylim((0, 3000)) line1, = ax1.plot(fem2ss.X[nds1, 0], T[nds1, 0], label='T along x') line2, = ax1.plot(fem2ss.X[nds2, 1], T[nds2, 0], label='T along y') ax1.set_title('T (t=0 s)') ax1.legend() ax1.grid() ax1.set_xlabel('(m)') ax1.set_ylabel('(C)')
import fem3d_2ss fem2ss = fem3d_2ss.Fem3d_fenics('data_isotermas/box2/') ''' box T(0.036639,0.02,0): 1199.960824 T(0.02,0.022333,0): 1199.066792 T(0.039258,0.02,0): 999.964398 T(0.02,0.022484,0): 999.509632 T(0.042247,0.02,0): 799.997341 T(0.02,0.022635,0): 799.952473 T(0.050528,0.02,0): 599.981447 T(0.02,0.022848,0): 599.894708 box2 T(0.034018,0.02,0): 1199.997701 T(0.02,0.022354,0): 1198.289010 T(0.037608,0.02,0): 999.988668 T(0.02,0.022464,0): 999.134653 T(0.041366,0.02,0): 799.989001 T(0.02,0.022574,0): 799.980296 T(0.048639,0.02,0): 599.993479 T(0.02,0.022834,0): 599.972494 ''' vars = {} vars['A'] = fem2ss.A vars['B'] = fem2ss.B vars['Bv'] = fem2ss.Bv vars['C_1200x'] = fem2ss.get_C((0.034018, 0.02, 0)) vars['C_1200y'] = fem2ss.get_C((0.02, 0.022354, 0)) vars['C_1000x'] = fem2ss.get_C((0.037608, 0.02, 0)) vars['C_1000y'] = fem2ss.get_C((0.02, 0.022464, 0))
# fem2ss_32 = fem3d_2ss.Fem3d_fenics('data/v5/32x16x4/') inp = np.array((.02, .02, 0)) pts = ((0,0.003,0),(0,0.005,0),(0,0.010,0),(0.005,0,0),(0.010,0,0),(0.020,0,0)) w = np.logspace(-3,1,100) k=24.0 rho=7925 cp=460 v=0.005 a=k/(rho*cp) s = 1j*w ft_pot = lambda x,y,z: 1/(rho*cp)*np.exp(-(v*(-x)+np.sqrt((x**2+y**2+z**2)*(4*a*s+v**2)))/(2*a))/(2*np.pi*a*np.sqrt(x**2+y**2+z**2)) pts = ((0,0.003,0),(0,-0.003,0),(0,0.005,0),(0,-0.005,0),(0,0.010,0),(0,-0.010,0)) fem2ss = fem3d_2ss.Fem3d_fenics('data/v5/irregular/') fem2ss_32 = fem3d_2ss.Fem3d_fenics('data/v5/32x16x4/1500/') for p in pts: plt.figure('Bode Comp ' + str(p)) control.bode_plot((fem2ss.get_ss(inp + p), fem2ss_32.get_ss(inp + p), control.frd(ft_pot(*p), w)), w, dB=True) plt.legend(('irregular', '32', 'ft')) # fem2ss = fem3d_2ss.Fem3d_fenics('data/v5/32x16x4/1500/') fem2ss = fem3d_2ss.Fem3d_fenics('./') pts = ((0,0.003,0),(0,-0.003,0),(0,0.005,0),(0,-0.005,0),(0,0.010,0),(0,-0.010,0)) systemsQ = list() systemsV = list() legends = list()
import fem3d_2ss import numpy as np fem2ss = fem3d_2ss.Fem3d_fenics('test_open/') p1=np.load('test_open/p1.npy') p2=np.load('test_open/p2.npy') # p1r=np.load('test_open/p1r.npy') vars={} vars['A'] = fem2ss.A vars['B'] = fem2ss.B vars['Bv'] = fem2ss.Bv vars['C1'] = fem2ss.get_C(p1) vars['C2'] = fem2ss.get_C(p2, 2) # vars['C1r'] = fem2ss.get_C(p1r) # vars['Ar'] = np.load('test_open/AA3dr.npy') # vars['Br'] = np.load('test_open/BB3dr.npy') # vars['Bvr'] = np.load('test_open/BB3dvr.npy') vars['od'] = np.load('test_open/open_loop_data.npy') vars['T0'] = np.load('test_open/T03d.npy') vars['T0r'] = np.load('test_open/T03dr.npy') # X_xo = fem2ss.X - np.array(p2) # idx = np.argwhere(np.all((X_xo) == 0, axis=1)) # # dist = np.sqrt(X_xo[:,0]**2 + X_xo[:,1]**2 + X_xo[:,2]**2) # idx = np.argpartition(dist, 2)[:2] # fem2ss.X[idx] # fem2ss.Teq[idx[:]] # # distp = np.prod(dist[idx])