<commit_before>#!/usr/bin/env python

from veros import VerosSetup, veros_method, runtime_settings as rs
import veros.tools


class ACCSector(VerosSetup):
    """A model using spherical coordinates with a partially closed domain representing the narrow sector of Atlantic and ACC.

    The bathymetry of the model is idealized to a flat-bottom (with depth of 4000 m) over the majority of the domain,
    except a half depth appended within the confines of the circumpolar channel at the inflow and outflow regions.
    The horizontal grid has resolution of :math:`2 \\times 2` degrees, and the vertical one has 40 levels.

    Wind forcing over the sector part and buoyancy relaxation drive a large-scale meridional overturning circulation.

    This setup demonstrates:
     - setting up an idealized geometry after `(Munday et al., 2013) <https://doi.org/10.1175/JPO-D-12-095.1>`_.
     - modifing surface forcings over selected regions of the domain
     - sensitivity of circumpolar transport and meridional overturning 
       to changes in Southern Ocean wind stress and buoyancy anomalies
     - basic usage of diagnostics

    :doc:`Adapted from ACC channel model </reference/setups/acc>`.

    """
    max_depth = 4000.

    @veros_method
    def set_parameter(self, vs):
        vs.identifier = "acc_sector"

        vs.nx, vs.ny, vs.nz = 15, 62, 40
        vs.dt_mom = 3600.
        vs.dt_tracer = 3600.
        vs.runlen = 86400 * 365

        vs.coord_degree = True
        vs.enable_cyclic_x = True

        vs.congr_epsilon = 1e-12
        vs.congr_max_iterations = 5000

        vs.enable_neutral_diffusion = True
        vs.K_iso_0 = 1000.0
        vs.K_iso_steep = 500.0
        vs.iso_dslope = 0.005
        vs.iso_slopec = 0.01
        vs.enable_skew_diffusion = True

        vs.enable_hor_friction = True
        vs.A_h = 5e4 * 2 
        vs.enable_hor_friction_cos_scaling = True
        vs.hor_friction_cosPower = 1

        vs.enable_bottom_friction = True
        vs.r_bot = 1e-5

        vs.enable_implicit_vert_friction = True

        vs.enable_tke = True
        vs.c_k = 0.1
        vs.c_eps = 0.7
        vs.alpha_tke = 30.0
        vs.mxl_min = 1e-8
        vs.tke_mxl_choice = 2
        vs.kappaM_min = 2e-4
        vs.kappaH_min = 2e-5
        # vs.enable_tke_superbee_advection = True
        vs.enable_Prandtl_tke = False

        vs.K_gm_0 = 1300.0
        vs.enable_eke = False
        vs.eke_k_max = 1e4
        vs.eke_c_k = 0.4
        vs.eke_c_eps = 0.5
        vs.eke_cross = 2.
        vs.eke_crhin = 1.0
        vs.eke_lmin = 100.0
        vs.enable_eke_superbee_advection = False
        vs.enable_eke_isopycnal_diffusion = False

        vs.enable_idemix = False
        vs.enable_idemix_hor_diffusion = False
        vs.enable_eke_diss_surfbot = False
        vs.eke_diss_surfbot_frac = 0.2
        vs.enable_idemix_superbee_advection = False

        vs.eq_of_state_type = 3

    @veros_method
    def set_grid(self, vs):
        vs.dxt[...] = 2.0
        vs.dyt[...] = 2.0
        vs.x_origin = 0.0
        vs.y_origin = -60.0
        vs.dzt[...] = veros.tools.get_vinokur_grid_steps(vs.nz, self.max_depth, 10., refine_towards="lower")

    @veros_method
    def set_coriolis(self, vs):
        vs.coriolis_t[:, :] = 2 * vs.omega * np.sin(vs.yt[None, :] / 180. * vs.pi)

    @veros_method
    def set_topography(self, vs):
        x, y = np.meshgrid(vs.xt, vs.yt, indexing="ij")
        vs.kbot = np.logical_or((x > 1.0) & (x < 27), y < -40).astype(np.int)

        # A half depth (ridge) is appended to the domain within the confines
        # of the circumpolar channel at the inflow and outflow regions<commit_msg>tweak acc sector<commit_after>#!/usr/bin/env python

from veros import VerosSetup, veros_method, runtime_settings as rs
import veros.tools


class ACCSector(VerosSetup):
    """A model using spherical coordinates with a partially closed domain representing the narrow sector of Atlantic and ACC.

    The bathymetry of the model is idealized to a flat-bottom (with depth of 4000 m) over the majority of the domain,
    except a half depth appended within the confines of the circumpolar channel at the inflow and outflow regions.
    The horizontal grid has resolution of :math:`2 \\times 2` degrees, and the vertical one has 40 levels.

    Wind forcing over the sector part and buoyancy relaxation drive a large-scale meridional overturning circulation.

    This setup demonstrates:
     - setting up an idealized geometry after `(Munday et al., 2013) <https://doi.org/10.1175/JPO-D-12-095.1>`_.
     - modifing surface forcings over selected regions of the domain
     - sensitivity of circumpolar transport and meridional overturning 
       to changes in Southern Ocean wind stress and buoyancy anomalies
     - basic usage of diagnostics

    :doc:`Adapted from ACC channel model </reference/setups/acc>`.

    """
    max_depth = 4000.

    @veros_method
    def set_parameter(self, vs):
        vs.identifier = "acc_sector"

        vs.nx, vs.ny, vs.nz = 15, 62, 40
        vs.dt_mom = 3600.
        vs.dt_tracer = 3600.
        vs.runlen = 86400 * 365

        vs.coord_degree = True
        vs.enable_cyclic_x = True

        vs.congr_epsilon = 1e-12
        vs.congr_max_iterations = 5000

        vs.enable_neutral_diffusion = True
        vs.K_iso_0 = 1000.0
        vs.K_iso_steep = 500.0
        vs.iso_dslope = 0.005
        vs.iso_slopec = 0.01
        vs.enable_skew_diffusion = True

        vs.enable_hor_friction = True
        vs.A_h = 5e4 * 2
        vs.enable_hor_friction_cos_scaling = True
        vs.hor_friction_cosPower = 1

        vs.enable_bottom_friction = True
        vs.r_bot = 1e-5

        vs.enable_implicit_vert_friction = True

        vs.enable_tke = True
        vs.c_k = 0.1
        vs.c_eps = 0.7
        vs.alpha_tke = 30.0
        vs.mxl_min = 1e-8
        vs.tke_mxl_choice = 2
        vs.kappaM_min = 2e-4
        vs.kappaH_min = 2e-5
        # vs.enable_tke_superbee_advection = True
        vs.enable_Prandtl_tke = False

        vs.K_gm_0 = 1300.0
        vs.enable_eke = False
        vs.eke_k_max = 1e4
        vs.eke_c_k = 0.4
        vs.eke_c_eps = 0.5
        vs.eke_cross = 2.
        vs.eke_crhin = 1.0
        vs.eke_lmin = 100.0
        vs.enable_eke_superbee_advection = False
        vs.enable_eke_isopycnal_diffusion = False

        vs.enable_idemix = False
        vs.enable_idemix_hor_diffusion = False
        vs.enable_eke_diss_surfbot = False
        vs.eke_diss_surfbot_frac = 0.2
        vs.enable_idemix_superbee_advection = False

        vs.eq_of_state_type = 3

    @veros_method
    def set_grid(self, vs):
        # keep total domain size constant when nx or ny changes
        vs.dxt[...] = 2.0 * 15 / vs.nx
        vs.dyt[...] = 2.0 * 62 / vs.ny

        vs.x_origin = 0.0
        vs.y_origin = -60.0

        vs.dzt[...] = veros.tools.get_vinokur_grid_steps(vs.nz, self.max_depth, 10., refine_towards="lower")

    @veros_method
    def set_coriolis(self, vs):
        vs.coriolis_t[:, :] = 2 * vs.omega * np.sin(vs.yt[None, :] / 180. * vs.pi)

    @veros_method
    def set_topography(self, vs):
        x, y = np.meshgrid(vs.xt, vs.yt, indexing="ij")
        vs.kbot = np.logical_or((x > 1.0) & (x < 27), y < -40).astype(np.int)

        # A half depth (ridge) is appended to the domain within the confines
        # of the circumpolar channel at the inflow and outflow regions
{'fraction_non_alphanumeric': 0.08764135702746365, 'fraction_numerical': 0.03742595584275713, 'mean_word_length': 2.2342185459294734, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '805186', 'n_tokens_mistral': 2853, 'n_tokens_neox': 2523, 'n_words': 667}