Skip to content

Navier-Stokes Scenarios in physical Mode¤

apebench.scenarios.physical.DecayingTurbulence ¤

Bases: BaseScenario

Source code in apebench/scenarios/physical/_navier_stokes.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class DecayingTurbulence(BaseScenario):
    domain_extent: float = 1.0
    dt: float = 0.1

    diffusivity: float = 1e-4

    num_substeps: int = 1

    coarse_proportion: float = 0.5

    order: int = 2
    dealiasing_fraction: float = 2 / 3
    num_circle_points: int = 16
    circle_radius: float = 1.0

    def __post_init__(self):
        if self.num_spatial_dims != 2:
            raise ValueError(
                "Decaying turbulence is only defined for 2 spatial dimensions"
            )

    def _build_stepper(self, dt):
        substepped_stepper = ex.stepper.NavierStokesVorticity(
            self.num_spatial_dims,
            self.domain_extent,
            self.num_points,
            dt / self.num_substeps,
            diffusivity=self.diffusivity,
            order=self.order,
            dealiasing_fraction=self.dealiasing_fraction,
            num_circle_points=self.num_circle_points,
            circle_radius=self.circle_radius,
        )

        if self.num_substeps == 1:
            stepper = substepped_stepper
        else:
            stepper = ex.RepeatedStepper(substepped_stepper, self.num_substeps)

        return stepper

    def get_ref_stepper(self) -> ex.BaseStepper:
        return self._build_stepper(self.dt)

    def get_coarse_stepper(self) -> ex.BaseStepper:
        return self._build_stepper(self.dt * self.coarse_proportion)

    def get_scenario_name(self) -> str:
        return f"{self.num_spatial_dims}d_phy_decay_turb"
domain_extent class-attribute instance-attribute ¤
domain_extent: float = 1.0
dt class-attribute instance-attribute ¤
dt: float = 0.1
diffusivity class-attribute instance-attribute ¤
diffusivity: float = 0.0001
num_substeps class-attribute instance-attribute ¤
num_substeps: int = 1
coarse_proportion class-attribute instance-attribute ¤
coarse_proportion: float = 0.5
order class-attribute instance-attribute ¤
order: int = 2
dealiasing_fraction class-attribute instance-attribute ¤
dealiasing_fraction: float = 2 / 3
num_circle_points class-attribute instance-attribute ¤
num_circle_points: int = 16
circle_radius class-attribute instance-attribute ¤
circle_radius: float = 1.0
get_scenario_name ¤
get_scenario_name() -> str
Source code in apebench/scenarios/physical/_navier_stokes.py
55
56
def get_scenario_name(self) -> str:
    return f"{self.num_spatial_dims}d_phy_decay_turb"
__post_init__ ¤
__post_init__()
Source code in apebench/scenarios/physical/_navier_stokes.py
23
24
25
26
27
def __post_init__(self):
    if self.num_spatial_dims != 2:
        raise ValueError(
            "Decaying turbulence is only defined for 2 spatial dimensions"
        )

apebench.scenarios.physical.KolmogorovFlow ¤

Bases: BaseScenario

Source code in apebench/scenarios/physical/_navier_stokes.py
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
class KolmogorovFlow(BaseScenario):
    domain_extent: float = 2 * pi
    dt: float = 0.1

    diffusivity: float = 1e-2  # Just Re=100 to have it almost scale-resolved

    injection_mode: int = 4
    injection_scale: float = 1.0
    drag: float = -0.1

    num_substeps: int = 20

    coarse_proportion: float = 0.5

    num_warmup_steps: int = 500  # Overwrite

    vlim: tuple[float, float] = (-10.0, 10.0)  # Overwrite

    order: int = 2
    dealiasing_fraction: float = 2 / 3
    num_circle_points: int = 16
    circle_radius: float = 1.0

    def __post_init__(self):
        if self.num_spatial_dims != 2:
            raise ValueError("Kolmogorov Flow is only defined for 2 spatial dimensions")

    def _build_stepper(self, dt):
        substepped_stepper = ex.stepper.KolmogorovFlowVorticity(
            self.num_spatial_dims,
            self.domain_extent,
            self.num_points,
            dt / self.num_substeps,
            diffusivity=self.diffusivity,
            injection_mode=self.injection_mode,
            injection_scale=self.injection_scale,
            drag=self.drag,
            order=self.order,
            dealiasing_fraction=self.dealiasing_fraction,
            num_circle_points=self.num_circle_points,
            circle_radius=self.circle_radius,
        )

        if self.num_substeps == 1:
            stepper = substepped_stepper
        else:
            stepper = ex.RepeatedStepper(substepped_stepper, self.num_substeps)

        return stepper

    def get_ref_stepper(self) -> ex.BaseStepper:
        return self._build_stepper(self.dt)

    def get_coarse_stepper(self) -> ex.BaseStepper:
        return self._build_stepper(self.dt * self.coarse_proportion)

    def get_scenario_name(self) -> str:
        return f"{self.num_spatial_dims}d_phy_kolm_flow"
domain_extent class-attribute instance-attribute ¤
domain_extent: float = 2 * pi
dt class-attribute instance-attribute ¤
dt: float = 0.1
diffusivity class-attribute instance-attribute ¤
diffusivity: float = 0.01
injection_mode class-attribute instance-attribute ¤
injection_mode: int = 4
injection_scale class-attribute instance-attribute ¤
injection_scale: float = 1.0
drag class-attribute instance-attribute ¤
drag: float = -0.1
num_substeps class-attribute instance-attribute ¤
num_substeps: int = 20
coarse_proportion class-attribute instance-attribute ¤
coarse_proportion: float = 0.5
num_warmup_steps class-attribute instance-attribute ¤
num_warmup_steps: int = 500
vlim class-attribute instance-attribute ¤
vlim: tuple[float, float] = (-10.0, 10.0)
order class-attribute instance-attribute ¤
order: int = 2
dealiasing_fraction class-attribute instance-attribute ¤
dealiasing_fraction: float = 2 / 3
num_circle_points class-attribute instance-attribute ¤
num_circle_points: int = 16
circle_radius class-attribute instance-attribute ¤
circle_radius: float = 1.0
get_scenario_name ¤
get_scenario_name() -> str
Source code in apebench/scenarios/physical/_navier_stokes.py
115
116
def get_scenario_name(self) -> str:
    return f"{self.num_spatial_dims}d_phy_kolm_flow"
__post_init__ ¤
__post_init__()
Source code in apebench/scenarios/physical/_navier_stokes.py
82
83
84
def __post_init__(self):
    if self.num_spatial_dims != 2:
        raise ValueError("Kolmogorov Flow is only defined for 2 spatial dimensions")