Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions INGRID/ingrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,14 @@ def PlotEastWestXpt1Ref(self, ax: object = None) -> None:
magx_tilt_2 = self.settings['grid_settings']['patch_generation']['xpt1_E_tilt']
except KeyError:
magx_tilt_2 = 0.0
try:
magx_tilt_3 = self.settings['grid_settings']['patch_generation']['xpt1_S_tilt']
except KeyError:
magx_tilt_3 = 0.0
try:
magx_tilt_4 = self.settings['grid_settings']['patch_generation']['xpt1_N_tilt']
except KeyError:
magx_tilt_4 = 0.0

if ax is None:
ax = plt.gca()
Expand Down Expand Up @@ -1028,6 +1036,38 @@ def PlotEastWestXpt1Ref(self, ax: object = None) -> None:
pass
xpt1_midline_ref_W.plot(color='lightpink', label='xpt1_ref_E')

if self.settings['grid_settings']['patch_generation']['use_xpt1_S'] is True:
R = self.settings['grid_settings']['rxpt']
Z = self.settings['grid_settings']['zxpt']
xpt1 = Point(np.array([R, Z]))

# Generate Horizontal Mid-Plane lines
LHS_Point = Point(xpt1.x, xpt1.y)
RHS_Point = Point(xpt1.x + 1e6 * np.cos(magx_tilt_3), xpt1.y + 1e6 * np.sin(magx_tilt_3))
xpt1_midline_ref_S = Line([LHS_Point, RHS_Point])

try:
[ax_line.remove() for ax_line in ax.lines if ax_line.get_label() == 'xpt1_ref_S']
except:
pass
xpt1_midline_ref_S.plot(color='teal', label='xpt1_ref_S')

if self.settings['grid_settings']['patch_generation']['use_xpt1_N'] is True:
R = self.settings['grid_settings']['rxpt']
Z = self.settings['grid_settings']['zxpt']
xpt1 = Point(np.array([R, Z]))

# Generate Horizontal Mid-Plane lines
LHS_Point = Point(xpt1.x, xpt1.y)
RHS_Point = Point(xpt1.x + 1e6 * np.cos(magx_tilt_4), xpt1.y + 1e6 * np.sin(magx_tilt_4))
xpt1_midline_ref_N = Line([LHS_Point, RHS_Point])

try:
[ax_line.remove() for ax_line in ax.lines if ax_line.get_label() == 'xpt1_ref_N']
except:
pass
xpt1_midline_ref_N.plot(color='darkturquoise', label='xpt1_ref_N')

def PlotEastWestXpt2Ref(self, ax: object = None) -> None:
"""
Plot midplane line through magnetic axis with any applied
Expand All @@ -1044,6 +1084,14 @@ def PlotEastWestXpt2Ref(self, ax: object = None) -> None:
magx_tilt_2 = self.settings['grid_settings']['patch_generation']['xpt2_E_tilt']
except KeyError:
magx_tilt_2 = 0.0
try:
magx_tilt_3 = self.settings['grid_settings']['patch_generation']['xpt2_N_tilt']
except KeyError:
magx_tilt_3 = 0.0
try:
magx_tilt_4 = self.settings['grid_settings']['patch_generation']['xpt2_S_tilt']
except KeyError:
magx_tilt_4 = 0.0

if ax is None:
ax = plt.gca()
Expand Down Expand Up @@ -1089,6 +1137,38 @@ def PlotEastWestXpt2Ref(self, ax: object = None) -> None:
pass
xpt2_midline_ref_W.plot(color='lightpink', label='xpt2_ref_E')

if self.settings['grid_settings']['patch_generation']['use_xpt2_N'] is True:
R = self.settings['grid_settings']['rxpt2']
Z = self.settings['grid_settings']['zxpt2']
xpt2 = Point(np.array([R, Z]))

# Generate Horizontal Mid-Plane lines
LHS_Point = Point(xpt2.x, xpt2.y)
RHS_Point = Point(xpt2.x + 1e6 * np.cos(magx_tilt_3), xpt2.y + 1e6 * np.sin(magx_tilt_3))
xpt2_midline_ref_N = Line([LHS_Point, RHS_Point])

try:
[ax_line.remove() for ax_line in ax.lines if ax_line.get_label() == 'xpt2_ref_N']
except:
pass
xpt2_midline_ref_N.plot(color='darkturquoise', label='xpt2_ref_N')

if self.settings['grid_settings']['patch_generation']['use_xpt2_S'] is True:
R = self.settings['grid_settings']['rxpt2']
Z = self.settings['grid_settings']['zxpt2']
xpt2 = Point(np.array([R, Z]))

# Generate Horizontal Mid-Plane lines
LHS_Point = Point(xpt2.x, xpt2.y)
RHS_Point = Point(xpt2.x + 1e6 * np.cos(magx_tilt_4), xpt2.y + 1e6 * np.sin(magx_tilt_4))
xpt2_midline_ref_S = Line([LHS_Point, RHS_Point])

try:
[ax_line.remove() for ax_line in ax.lines if ax_line.get_label() == 'xpt2_ref_S']
except:
pass
xpt2_midline_ref_S.plot(color='teal', label='xpt2_ref_S')

def PlotPatches(self) -> None:
"""
Plot the patch map that was generated with method 'CreatePatches'
Expand Down
43 changes: 36 additions & 7 deletions INGRID/topologies/sf105.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,15 @@ def construct_patches(self):
# topLine.plot()

# Tracing primary-separatrix: core-boundary

xpt1N__psiMinCore = self.LineTracer.draw_line(xpt1['N'], {'psi': psi_core}, option='rho', direction='cw',
if self.settings['grid_settings']['patch_generation']['use_xpt1_N']:
tilt = self.settings['grid_settings']['patch_generation']['xpt1_N_tilt']
# Draw a line along the psi_core flux surface; this will be intersected at the desired tilt angle from xpt1['N']
xpt1N__psiMinCore_tmp = self.LineTracer.draw_line(xpt1['N'], {'psi': psi_core}, option='rho', direction='cw', show_plot=False, text=verbose)
psiMinCore__midline_1_core = self.LineTracer.draw_line(xpt1N__psiMinCore_tmp.p[-1], {'line': midline_1}, option='theta', direction='cw', show_plot=False, text=verbose)
midline_1_core__modline_2_core = self.LineTracer.draw_line(psiMinCore__midline_1_core.p[-2], {'line': midline_2}, option='theta', direction='ccw', show_plot=False, text=verbose)
xpt1N__psiMinCore = self.LineTracer.draw_line(xpt1['N'], {'line': (midline_1_core__modline_2_core, tilt)}, option='z_const', direction='cw', show_plot=visual, text=verbose)
else:
xpt1N__psiMinCore = self.LineTracer.draw_line(xpt1['N'], {'psi': psi_core}, option='rho', direction='cw',
show_plot=visual, text=verbose)

if len(xpt1N__psiMinCore.p) < 100:
Expand Down Expand Up @@ -254,15 +261,28 @@ def construct_patches(self):
show_plot=visual, text=verbose)
G3_S = G2_N.reverse_copy()

B2_E__B1_E = self.LineTracer.draw_line(xpt1['S'], {'psi': psi_pf_1}, option='rho', direction='cw',
show_plot=visual, text=verbose)
if self.settings['grid_settings']['patch_generation']['use_xpt1_S']:
tilt = self.settings['grid_settings']['patch_generation']['xpt1_S_tilt']
# Draw a line along the psi_pf_1 surface; this will be intersected at the desired tilt angle from xpt1['S']
B2_E__B1_E = self.LineTracer.draw_line(xpt1['S'], {'psi': psi_pf_1}, option='rho', direction='cw', show_plot=False, text=verbose)
B1_E__EastPlate2 = self.LineTracer.draw_line(B2_E__B1_E.p[-1], {'line': EastPlate2}, option='theta', direction='ccw', show_plot=False, text=verbose)
EastPlate2__WestPlate2 = self.LineTracer.draw_line(B1_E__EastPlate2.p[-2], {'line': WestPlate2}, option='theta', direction='cw', show_plot=False, text=verbose)
B2_E__B1_E = self.LineTracer.draw_line(xpt1['S'], {'line': (EastPlate2__WestPlate2,tilt)}, option='z_const', direction='cw', show_plot=visual, text=verbose)
else:
B2_E__B1_E = self.LineTracer.draw_line(xpt1['S'], {'psi': psi_pf_1}, option='rho', direction='cw',
show_plot=visual, text=verbose)

A1_N = self.LineTracer.draw_line(xpt2['NW'], {'line': WestPlate1}, option='theta', direction='ccw',
show_plot=visual, text=verbose).reverse_copy()
A2_S = A1_N.reverse_copy()

B2_W = self.LineTracer.draw_line(xpt2['N'], {'line': A2_N__B2_N}, option='rho', direction='ccw',
show_plot=visual, text=verbose)
if self.settings['grid_settings']['patch_generation']['use_xpt2_N']:
tilt = self.settings['grid_settings']['patch_generation']['xpt2_N_tilt']
B2_W = self.LineTracer.draw_line(xpt2['N'], {'line': (A2_N__B2_N, tilt)}, option='z_const', direction='cw',
show_plot=visual, text=verbose)
else:
B2_W = self.LineTracer.draw_line(xpt2['N'], {'line': A2_N__B2_N}, option='rho', direction='ccw',
show_plot=visual, text=verbose)
A2_E = B2_W.reverse_copy()

B3_W = self.LineTracer.draw_line(B2_W.p[-1], {'line': A3_N__B3_N}, option='rho', direction='ccw',
Expand Down Expand Up @@ -302,7 +322,16 @@ def construct_patches(self):

B1_S, H1_S = B1_S__H1_S.split(H1_E.p[-1], add_split_point=True)

H3_E__H2_E = self.LineTracer.draw_line(xpt2['S'], {'psi': psi_pf_2}, option='rho', direction='ccw',
if self.settings['grid_settings']['patch_generation']['use_xpt2_S']:
tilt = self.settings['grid_settings']['patch_generation']['xpt2_S_tilt']
# Draw a line along the psi_pf_2 surface; this will be intersected at the desired tilt angle from xpt2['S']
H3_E__H2_E_tmp = self.LineTracer.draw_line(xpt2['S'], {'psi': psi_pf_2}, option='rho', direction='ccw', show_plot=False, text=verbose).reverse_copy()
H2_E__WestPlate2 = self.LineTracer.draw_line(H3_E__H2_E_tmp.p[0], {'line': WestPlate2}, option='theta', direction='cw', show_plot=False, text=verbose)
WestPlate2__EastPlate2 = self.LineTracer.draw_line(H2_E__WestPlate2.p[-2], {'line': EastPlate2}, option='theta', direction='ccw', show_plot=False, text=verbose)
H3_E__H2_E = self.LineTracer.draw_line(xpt2['S'], {'line': (WestPlate2__EastPlate2,tilt)}, option='z_const', direction='cw', show_plot=visual, text=verbose)
H3_E__H2_E = H3_E__H2_E.reverse_copy()
else:
H3_E__H2_E = self.LineTracer.draw_line(xpt2['S'], {'psi': psi_pf_2}, option='rho', direction='ccw',
show_plot=visual, text=verbose).reverse_copy()

if len(H3_E__H2_E.p) < 100:
Expand Down
38 changes: 33 additions & 5 deletions INGRID/topologies/sf135.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,16 @@ def construct_patches(self):
Upper_Point = Point(magx[0], magx[1] + 1e6)
topLine = Line([Lower_Point, Upper_Point])

F1_E = self.LineTracer.draw_line(xpt1['N'], {'psi': psi_core}, option='rho', direction='cw',
show_plot=visual, text=verbose)
if self.settings['grid_settings']['patch_generation']['use_xpt1_N']:
tilt = self.settings['grid_settings']['patch_generation']['xpt1_N_tilt']
# Draw a line along the psi_core flux surface; this will be intersected at the desired tilt angle from xpt1['N']
F1_E_tmp = self.LineTracer.draw_line(xpt1['N'], {'psi': psi_core}, option='rho', direction='cw', show_plot=False, text=verbose)
psiMinCore__midline_1_core = self.LineTracer.draw_line(F1_E_tmp.p[-1], {'line': midline_1}, option='theta', direction='cw', show_plot=False, text=verbose)
midline_1_core__midline_2_core = self.LineTracer.draw_line(psiMinCore__midline_1_core.p[-2], {'line': midline_2}, option='theta', direction='ccw', show_plot=False, text=verbose)
F1_E = self.LineTracer.draw_line(xpt1['N'], {'line': (midline_1_core__midline_2_core, tilt)}, option='z_const', direction='cw', show_plot=visual, text=verbose)
else:
F1_E = self.LineTracer.draw_line(xpt1['N'], {'psi': psi_core}, option='rho', direction='cw',
show_plot=visual, text=verbose)
C1_W = F1_E.reverse_copy()

C1_N = self.LineTracer.draw_line(xpt1['NW'], {'line': midline_1}, option='theta', direction='cw',
Expand Down Expand Up @@ -198,7 +206,15 @@ def construct_patches(self):

E1_S = d(F1_S.p[-1], {'line': topLine}, option='theta', direction='ccw', show_plot=visual, text=verbose)

B1_E = d(xpt1['S'], {'psi': psi_pf_1}, option='rho', direction='cw', show_plot=visual, text=verbose)
if self.settings['grid_settings']['patch_generation']['use_xpt1_S']:
tilt = self.settings['grid_settings']['patch_generation']['xpt1_S_tilt']
# Draw a line along the psi_pf_1 surface; this will be intersected at the desired tilt angle from xpt1['S']
B1_E_tmp = d(xpt1['S'], {'psi': psi_pf_1}, option='rho', direction='cw', show_plot=False, text=verbose)
B1_E__WestPlate1 = self.LineTracer.draw_line(B1_E_tmp.p[-1], {'line': WestPlate1}, option='theta', direction='ccw', show_plot=False, text=verbose)
WestPlate1__EastPlate1 = self.LineTracer.draw_line(B1_E__WestPlate1.p[-2], {'line': EastPlate1}, option='theta', direction='cw', show_plot=False, text=verbose)
B1_E = self.LineTracer.draw_line(xpt1['S'], {'line': (WestPlate1__EastPlate1,tilt)}, option='z_const', direction='cw', show_plot=visual, text=verbose)
else:
B1_E = d(xpt1['S'], {'psi': psi_pf_1}, option='rho', direction='cw', show_plot=visual, text=verbose)
G1_W = B1_E.reverse_copy()

G1_N = d(xpt1['SE'], {'line': EastPlate1}, option='theta', direction='cw', show_plot=visual, text=verbose)
Expand Down Expand Up @@ -252,7 +268,11 @@ def construct_patches(self):
B2_N, C2_N = B2_N__C2_N.split(C2_W.p[-1], add_split_point=True)
B3_S, C3_S = B2_N.reverse_copy(), C2_N.reverse_copy()

H2_E = d(xpt2['N'], {'line': H1_N__B1_N}, option='rho', direction='cw',
if self.settings['grid_settings']['patch_generation']['use_xpt2_N']:
tilt = self.settings['grid_settings']['patch_generation']['xpt2_N_tilt']
H2_E = d(xpt2['N'], {'line': (H1_N__B1_N, tilt)}, option='z_const', direction='cw', show_plot=visual, text=verbose)
else:
H2_E = d(xpt2['N'], {'line': H1_N__B1_N}, option='rho', direction='cw',
show_plot=visual, text=verbose)
B2_W = H2_E.reverse_copy()

Expand Down Expand Up @@ -287,7 +307,15 @@ def construct_patches(self):
show_plot=visual, text=verbose)
I3_S = I2_N.reverse_copy()

A2_E__A1_E = d(xpt2['S'], {'psi': psi_pf_2}, option='rho', direction='cw',
if self.settings['grid_settings']['patch_generation']['use_xpt2_S']:
tilt = self.settings['grid_settings']['patch_generation']['xpt2_S_tilt']
# Draw a line along the psi_pf_2 surface; this will be intersected at the desired tilt angle from xpt2['S']
A2_E__A1_E_tmp = d(xpt2['S'], {'psi': psi_pf_2}, option='rho', direction='cw', show_plot=False, text=verbose)
A1_E__WestPlate2 = self.LineTracer.draw_line(A2_E__A1_E_tmp.p[-1], {'line': WestPlate2}, option='theta', direction='cw', show_plot=False, text=verbose)
WestPlate2__EastPlate2 = self.LineTracer.draw_line(A1_E__WestPlate2.p[-2], {'line': EastPlate2}, option='theta', direction='ccw', show_plot=False, text=verbose)
A2_E__A1_E = self.LineTracer.draw_line(xpt2['S'], {'line': (WestPlate2__EastPlate2,tilt)}, option='z_const', direction='cw', show_plot=visual, text=verbose)
else:
A2_E__A1_E = d(xpt2['S'], {'psi': psi_pf_2}, option='rho', direction='cw',
show_plot=visual, text=verbose)

if len(A2_E__A1_E.p) < 100:
Expand Down
Loading
Loading