Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time step detemined at model instantiation #14

Merged
merged 1 commit into from
Sep 27, 2024
Merged
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
8 changes: 3 additions & 5 deletions twowave.py
Original file line number Diff line number Diff line change
@@ -235,7 +235,6 @@ def __init__(
a_short: float | np.ndarray = 0.01,
k_short: float | np.ndarray = 10,
grid_size: int = 100,
time_step: float = 1e-2,
num_periods: int = 10,
curvilinear: bool = True,
) -> None:
@@ -246,16 +245,15 @@ def __init__(
self.a_short = a_short
self.k_short = k_short
self.grid_size = grid_size
self.dt = time_step
self.num_periods = num_periods
self.omega_long = angular_frequency(self.grav0, self.k_long, 0)
self.T_long = 2 * np.pi / self.omega_long
self.phase = np.linspace(0, 2 * np.pi, self.grid_size, endpoint=False)
self.x = self.phase / self.k_long
self.dx = self.x[1] - self.x[0]
self.ds = self.dx * np.ones(
self.grid_size
) # surface-following horizontal coordinate
self.ds = self.dx * np.ones(self.grid_size)
Cg_short = 0.5 * angular_frequency(grav0, k_short) / k_short
self.dt = self.dx / (Cg_short + self.a_long * self.omega_long) # CFL
self.time = np.arange(0, self.num_periods * self.T_long + self.dt, self.dt)
self.num_time_steps = len(self.time)
self.curvilinear = curvilinear