def plot(self): for p in self.patch: geom.polyfill(p['x'],p['y'],color=next(color)) for h in self.hole: geom.polyfill(h['x'],h['y'],color=np.ones(3)) pl.axis('equal') pl.plot(0,0,'s') pl.plot(self.C['x'],self.C['y'],'o')
def plot(self, plot_loops=False, color=colors[0]): geom.polyfill(self.patch['r'], self.patch['z'], color=color) if plot_loops: pl.plot(self.segment['r'], self.segment['z'], color=0.75 * np.ones(3)) for loop in self.loops: r, z = self.get_segment(loop) pl.plot(r, z, '-')
def fill_loops(self): for part in self.parts: try: geom.polyfill(self.parts[part]['r'], self.parts[part]['z'], color=color(next(ic))) except: pass set_figure()
def fill_loops(self): color = cycle(sns.color_palette('Set2', 5)) for part in self.parts: try: geom.polyfill(self.parts[part]['r'], self.parts[part]['z'], color=next(color)) except: pass
def fill_part(self, part, alpha=1, **kwargs): if part == 'TF_Coil': cindex = len(self.parts.keys()) - 1 else: cindex = list(self.parts.keys()).index(part) - 1 c = kwargs.get('color', color[cindex]) geom.polyfill(self.parts[part]['r'], self.parts[part]['z'], color=c, alpha=alpha)
def plot(self): pl.figure() self.tf.fill() #self.pf.plot(coils=self.pf.coil,label=True,current=True) if hasattr(self, 'eq'): self.pf.plot(coils=self.pf.sub_coil, plasma=True) for name in self.PFsupport: nodes = np.array(self.PFsupport[name]) geom.polyfill(nodes[:, 0], nodes[:, 1], color=0.4 * np.ones(3)) nodes = np.array(self.Gsupport['base']) geom.polyfill(nodes[:, 0], nodes[:, 1], color=0.4 * np.ones(3)) pl.plot(self.Gsupport['radius'] * np.ones(2), [self.Gsupport['zbase'], self.Gsupport['zfloor']], 'o-', color=0.4 * np.ones(3), lw=4) for name in self.OISsupport: nodes = np.array(self.OISsupport[name]) geom.polyfill(nodes[:, 0], nodes[:, 1], color=0.4 * np.ones(3)) rnose = self.CSsupport['rnose'] rwp = self.CSsupport['rwp'] zo = self.CSsupport['zo'] ztop = self.CSsupport['ztop'] rCS = [rnose, rwp, rwp, rnose] zCS = [zo, zo, ztop, ztop] geom.polyfill(rCS, zCS, color=0.4 * np.ones(3))
def plot_ripple_contours(self, n=3e3, offset=-1): xlim, dx = np.zeros((3, 2)), np.zeros(3) xl = np.zeros((len(self.coil_loop), 3)) xl[:, 0], xl[:, 2] = geom.offset(self.coil_loop[:, 0], self.coil_loop[:, 2], offset) for i in range(3): xlim[i] = [np.min(xl[:, i]), np.max(xl[:, i])] dx[i] = xlim[i][1] - xlim[i][0] xlim[0][0] = self.plasma_loop[np.argmax(self.plasma_loop[:, 2]), 0] # plasma top ar = dx[0] / dx[2] nz = int(np.sqrt(n / ar)) nr = int(n / nz) r = np.linspace(xlim[0][0], xlim[0][1], nr) z = np.linspace(xlim[2][0], xlim[2][1], nz) R, Z = np.meshgrid(r, z, indexing='ij') rpl = np.zeros((nr, nz)) for i, r_ in enumerate(r): for j, z_ in enumerate(z): if geom.inloop(xl[:, 0], xl[:, 2], r_, z_): rpl[i, j] = self.point((r_, 0, z_), variable='ripple') else: rpl[i, j] = np.NaN levels = 10**(np.linspace(np.log10(0.01), np.log10(5), 7)) levels = np.round(levels, decimals=2) geom.polyfill(self.plasma_loop[:, 0], self.plasma_loop[:, 2], alpha=0.3, color=sns.color_palette('Set2', 5)[3]) self.get_ripple() # get max ripple on plasma contour rpl_max = self.res['fun'] iplasma = np.argmin(abs(np.log10(levels) - np.log10(rpl_max))) levels[iplasma] = rpl_max # select edge contour CS = pl.contour(R, Z, rpl, levels=levels, colors=[0.6 * np.ones(3)]) zc = CS.collections[iplasma] pl.setp(zc, color=[0.4 * np.ones(3)]) pl.clabel(CS, inline=1, fontsize='xx-small', fmt='%1.2f')
def cross_section(self, plot=True): depth = self.tf.section['winding_pack']['depth'] side = self.tf.section['case']['side'] width = self.tf.section['winding_pack']['width'] inboard = self.tf.section['case']['inboard'] outboard = self.tf.section['case']['outboard'] external = self.tf.section['case']['external'] nose = self.tf.section['case']['nose'] ro = self.profile.loop.p[0]['p0']['r'] theta = np.pi / self.nTF rsep = (depth / 2 + side) / np.tan(theta) rnose = ro - (width + inboard + nose) if rsep <= rnose: ynose = depth / 2 + side else: ynose = rnose * np.tan(theta) dy = depth / 2 + side - ynose dr = rsep - rnose rpoint = rsep - (depth / 2 + side) / dy * dr - ro rwp = ro - (width + inboard) if rsep <= rwp: ywp = depth / 2 + side else: ywp = rwp * np.tan(theta) self.CSsupport = { 'rnose': rnose, 'ynose': ynose, 'dt': side, 'rwp': rwp, 'ywp': ywp } self.cs = {} self.cs['wp'] = { 'r': [-width / 2, width / 2], 'y': depth / 2 * np.ones(2) } self.cs['ca'] = { 'in': { 'r': [ rpoint + width / 2 + inboard, -(nose + width / 2), rsep - (ro - width / 2 - inboard), width / 2 + inboard ], 'y': [0, ynose, depth / 2 + side, depth / 2 + side] }, 'out': { 'r': [-width / 2 - external, width / 2 + outboard], 'y': depth / 2 + side * np.ones(2) } } r, y = self.cs['wp']['r'], self.cs['wp']['y'] self.cs['wp']['pnt'] = { 'r': [r[0], r[1], r[1], r[0]], 'y': [y[0], y[1], -y[1], -y[0]] } r, y = self.cs['ca']['in']['r'], self.cs['ca']['in']['y'] self.cs['ca']['in']['pnt'] = { 'r': [r[1], r[2], r[3], r[3], r[2], r[1]], 'y': [y[1], y[2], y[3], -y[3], -y[2], -y[1]] } r, y = self.cs['ca']['out']['r'], self.cs['ca']['out']['y'] self.cs['ca']['out']['pnt'] = { 'r': [r[0], r[1], r[1], r[0]], 'y': [y[0], y[1], -y[1], -y[0]] } if plot: fig, ax = pl.subplots(1, 2, sharex=True, figsize=(6, 4)) pl.sca(ax[0]) pl.axis('equal') pl.axis('off') pl.xlim([-1, 0.5]) geom.polyfill(self.cs['ca']['in']['pnt']['r'], self.cs['ca']['in']['pnt']['y'], color=color[0]) geom.polyfill(self.cs['wp']['pnt']['r'], self.cs['wp']['pnt']['y'], color=color[1]) pl.sca(ax[1]) pl.axis('equal') pl.axis('off') geom.polyfill(self.cs['ca']['out']['pnt']['r'], self.cs['ca']['out']['pnt']['y'], color=color[0]) geom.polyfill(self.cs['wp']['pnt']['r'], self.cs['wp']['pnt']['y'], color=color[1])