diff --git a/INGRID/line_tracing.py b/INGRID/line_tracing.py index b3ce6c5..75066cc 100644 --- a/INGRID/line_tracing.py +++ b/INGRID/line_tracing.py @@ -301,7 +301,21 @@ def map_xpt(self, xpt, magx, xpt_ID='xpt1', visual=False, verbose=False): if (np.linalg.norm(N_minimizer - magx) >= self.eps): self.flip_NSEW_lookup(xpt_ID) - self.config = 'LSN' if self.NSEW_lookup['xpt1']['coor']['N'][1] > xpt[1] else 'USN' + # + # By default assume we are not needing to swap midlines + # + # NOTE: This can occur when the primary x-point is in the + # upper midplane. + # Since we perform an xpt1 analysis even in the case of + # two x-points, we will always know whether or not to + # swap midlines + # + if self.NSEW_lookup['xpt1']['coor']['N'][1] > xpt[1]: + self.config = 'LSN' + self.swap_midlines = False + else: + self.config = 'USN' + self.swap_midlines = True elif xpt_ID == 'xpt2': diff --git a/INGRID/topologies/snl.py b/INGRID/topologies/snl.py index 0bb6bf6..e0d3bbf 100644 --- a/INGRID/topologies/snl.py +++ b/INGRID/topologies/snl.py @@ -168,8 +168,11 @@ def construct_patches(self): Upper_Point = Point(magx[0], magx[1] + 1e6) topLine = Line([Lower_Point, Upper_Point]) - # If USN, we swap east and west lines - if self.config == 'USN': + # + # If primary x-point is in the "upper" orientation, we swap + # the midlines + # + if self.LineTracer.swap_midlines: temp = midline_1.copy() midline_1 = midline_2 midline_2 = temp diff --git a/INGRID/topologies/udn.py b/INGRID/topologies/udn.py index 81acbf3..a5223cf 100644 --- a/INGRID/topologies/udn.py +++ b/INGRID/topologies/udn.py @@ -154,6 +154,15 @@ def construct_patches(self): Upper_Point = Point(magx[0], magx[1] + 1e6) topLine = Line([Lower_Point, Upper_Point]) + # + # If primary x-point is in the "upper" orientation, we swap + # the midlines + # + if self.LineTracer.swap_midlines: + temp = midline_1.copy() + midline_1 = midline_2 + midline_2 = temp + # Tracing primary-separatrix: core-boundary xpt1N__psiMinCore = self.LineTracer.draw_line(xpt1['N'], {'psi': psi_core}, @@ -304,14 +313,14 @@ def construct_patches(self): if self.settings['grid_settings']['patch_generation']['use_xpt2_W']: tilt = self.settings['grid_settings']['patch_generation']['xpt2_W_tilt'] - E3_E = self.LineTracer.draw_line(xpt2['W'], {'psi_horizontal': (psi_2, tilt)}, option='z_const', direction='cw', show_plot=visual, text=verbose).reverse_copy() + E3_E = self.LineTracer.draw_line(xpt2['W'], {'psi_horizontal': (psi_2, tilt)}, option='z_const', direction='ccw', show_plot=visual, text=verbose).reverse_copy() else: E3_E = self.LineTracer.draw_line(xpt2['W'], {'psi': psi_2}, option='rho', direction='ccw', show_plot=visual, text=verbose).reverse_copy() F3_W = E3_E.reverse_copy() if self.settings['grid_settings']['patch_generation']['use_xpt2_E']: tilt = self.settings['grid_settings']['patch_generation']['xpt2_E_tilt'] - D3_W = self.LineTracer.draw_line(xpt2['E'], {'psi_horizontal': (psi_1, tilt)}, option='z_const', direction='ccw', show_plot=visual, text=verbose) + D3_W = self.LineTracer.draw_line(xpt2['E'], {'psi_horizontal': (psi_1, tilt)}, option='z_const', direction='cw', show_plot=visual, text=verbose) else: D3_W = self.LineTracer.draw_line(xpt2['E'], {'psi': psi_1}, option='rho', direction='ccw', show_plot=visual, text=verbose) C3_E = D3_W.reverse_copy() @@ -341,7 +350,7 @@ def construct_patches(self): G2_E = H2_W.reverse_copy() if self.settings['grid_settings']['patch_generation']['use_xpt1_W']: - tilt = -self.settings['grid_settings']['patch_generation']['xpt1_W_tilt'] + tilt = self.settings['grid_settings']['patch_generation']['xpt1_W_tilt'] B3_W = self.LineTracer.draw_line(B2_W.p[-1], {'line': (midline_1__WestPlate1, tilt)}, option='z_const', direction='ccw', show_plot=visual, text=verbose) else: B3_W = self.LineTracer.draw_line(B2_W.p[-1], {'line': midline_1__WestPlate1}, diff --git a/example_files/UDN/DIIID_UDN.yml b/example_files/UDN/DIIID_UDN.yml index a7e170c..faf894f 100644 --- a/example_files/UDN/DIIID_UDN.yml +++ b/example_files/UDN/DIIID_UDN.yml @@ -11,7 +11,7 @@ DEBUG: eqdsk: ../data/UDN/DIII-D/neqdsk grid_settings: grid_generation: - skewness_correction: + distortion_correction: all: active: false resolution: 1000 @@ -25,19 +25,18 @@ grid_settings: nlevs: 30 num_xpt: 2 patch_generation: - pf_split_point_ratio: 0.5 + xpt2_E_tilt: -2.0 + xpt2_W_tilt: -3.2 xpt1_E_tilt: 0.0 - xpt1_W_tilt: 0.65 + xpt1_W_tilt: -0.9 rmagx_shift: 0.0 - xpt2_E_tilt: 0.0 - xpt2_W_tilt: 0.0 strike_pt_loc: limiter magx_tilt_1: 0.0 magx_tilt_2: 0.0 - use_xpt1_E: false - use_xpt1_W: false - use_xpt2_E: false - use_xpt2_W: false + use_xpt1_E: False + use_xpt1_W: False + use_xpt2_E: False + use_xpt2_W: False zmagx_shift: 0.0 psi_1: 1.127 psi_2: 1.131758078227