Bases: BaseScenario
Uses the single channel convection mode to not have channels grow with
spatial dimensions.
By default single-channel Burgers
Source code in apebench/scenarios/difficulty/_nonlinear.py
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
57
58
59
60
61
62
63
64
65 | class Nonlinear(BaseScenario):
"""
Uses the single channel convection mode to not have channels grow with
spatial dimensions.
By default single-channel Burgers
"""
gammas: tuple[float, ...] = (0.0, 0.0, 1.5, 0.0, 0.0)
deltas: tuple[float, float, float] = (0.0, -1.5, 0.0)
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):
pass
def _build_stepper(self, gammas, deltas):
substepped_gammas = tuple(g / self.num_substeps for g in gammas)
substepped_deltas = tuple(d / self.num_substeps for d in deltas)
substepped_stepper = ex.stepper.generic.DifficultyNonlinearStepper(
num_spatial_dims=self.num_spatial_dims,
num_points=self.num_points,
linear_difficulties=substepped_gammas,
nonlinear_difficulties=substepped_deltas,
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):
return self._build_stepper(self.gammas, self.deltas)
def get_coarse_stepper(self):
return self._build_stepper(
tuple(f * self.coarse_proportion for f in self.gammas),
tuple(f * self.coarse_proportion for f in self.deltas),
)
def get_scenario_name(self) -> str:
return f"{self.num_spatial_dims}d_diff_nonlin"
|
gammas
class-attribute
instance-attribute
gammas: tuple[float, ...] = (0.0, 0.0, 1.5, 0.0, 0.0)
deltas
class-attribute
instance-attribute
deltas: tuple[float, float, float] = (0.0, -1.5, 0.0)
num_substeps
class-attribute
instance-attribute
coarse_proportion
class-attribute
instance-attribute
coarse_proportion: float = 0.5
order
class-attribute
instance-attribute
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
_build_stepper
_build_stepper(gammas, deltas)
Source code in apebench/scenarios/difficulty/_nonlinear.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 | def _build_stepper(self, gammas, deltas):
substepped_gammas = tuple(g / self.num_substeps for g in gammas)
substepped_deltas = tuple(d / self.num_substeps for d in deltas)
substepped_stepper = ex.stepper.generic.DifficultyNonlinearStepper(
num_spatial_dims=self.num_spatial_dims,
num_points=self.num_points,
linear_difficulties=substepped_gammas,
nonlinear_difficulties=substepped_deltas,
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
|
get_ref_stepper
Source code in apebench/scenarios/difficulty/_nonlinear.py
| def get_ref_stepper(self):
return self._build_stepper(self.gammas, self.deltas)
|
get_coarse_stepper
Source code in apebench/scenarios/difficulty/_nonlinear.py
| def get_coarse_stepper(self):
return self._build_stepper(
tuple(f * self.coarse_proportion for f in self.gammas),
tuple(f * self.coarse_proportion for f in self.deltas),
)
|
get_scenario_name
get_scenario_name() -> str
Source code in apebench/scenarios/difficulty/_nonlinear.py
| def get_scenario_name(self) -> str:
return f"{self.num_spatial_dims}d_diff_nonlin"
|