Skip to content

Commit cff56e2

Browse files
source/solifluction.py is updated and the other functions are revised to consider type hint
modified: source/derivatives_discretization.py modified: source/io_data_process.py modified: source/layer.py modified: source/solifluction.py
1 parent 62ffa0b commit cff56e2

File tree

4 files changed

+193
-162
lines changed

4 files changed

+193
-162
lines changed

source/derivatives_discretization.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Discretize the derivatives
2+
from typing import Any
3+
24
import lue.framework as lfr
35
import numpy as np
46

@@ -144,12 +146,12 @@ def dz_upwind(phi, dz, uz):
144146

145147
# Second derivatives with non-uniform layer distance in y
146148
def second_derivatives_in_y(
147-
layer_variable_center,
148-
layer_variable_up,
149-
layer_variable_down,
150-
dy_layers_up,
151-
dy_layers_down,
152-
):
149+
layer_variable_center: Any,
150+
layer_variable_up: Any,
151+
layer_variable_down: Any,
152+
dy_layers_up: Any,
153+
dy_layers_down: Any,
154+
) -> Any:
153155
"""
154156
Calculate second derivatives for a discretization of non-uniform layer
155157
distances in y.

source/io_data_process.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -148,36 +148,36 @@ def default_boundary_type(
148148
return boundary_type_numpy_default, boundary_loc_numpy
149149

150150

151-
def read_run_setup(file_path: str) -> dict:
152-
variables: dict = {}
153-
154-
# Check if file exists
155-
if not os.path.exists(file_path):
156-
raise FileNotFoundError(f"Configuration file {file_path} not found.")
157-
158-
with open(file_path, "r") as file:
159-
for line in file:
160-
line = line.strip() # Remove leading/trailing whitespace
161-
162-
# Ignore empty lines or comments
163-
if not line or line.startswith("#"):
164-
continue
165-
166-
# Split the line at '=' and handle assignment
167-
if "=" in line:
168-
key, value = line.split("=", 1)
169-
key = key.strip() # Remove any extra whitespace around the key
170-
value = value.strip() # Remove extra whitespace around value
171-
172-
# Handle known types
173-
if key == "dt":
174-
variables[key] = float(value) # Convert dt to float
175-
elif key == "u_xfile":
176-
variables[key] = value # File path remains as string
177-
# Add more type checks here if needed
178-
179-
# Add any default handling for other variables as needed.
180-
else:
181-
variables[key] = value # Store as string by default
182-
183-
return variables
151+
# def read_run_setup(file_path: str) -> dict:
152+
# variables: dict = {}
153+
154+
# # Check if file exists
155+
# if not os.path.exists(file_path):
156+
# raise FileNotFoundError(f"Configuration file {file_path} not found.")
157+
158+
# with open(file_path, "r") as file:
159+
# for line in file:
160+
# line = line.strip() # Remove leading/trailing whitespace
161+
162+
# # Ignore empty lines or comments
163+
# if not line or line.startswith("#"):
164+
# continue
165+
166+
# # Split the line at '=' and handle assignment
167+
# if "=" in line:
168+
# key, value = line.split("=", 1)
169+
# key = key.strip() # Remove any extra whitespace around the key
170+
# value = value.strip() # Remove extra whitespace around value
171+
172+
# # Handle known types
173+
# if key == "dt":
174+
# variables[key] = float(value) # Convert dt to float
175+
# elif key == "u_xfile":
176+
# variables[key] = value # File path remains as string
177+
# # Add more type checks here if needed
178+
179+
# # Add any default handling for other variables as needed.
180+
# else:
181+
# variables[key] = value # Store as string by default
182+
183+
# return variables

source/layer.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1+
from typing import Any
2+
3+
14
class Layer:
25
def __init__(
36
self,
4-
u_x,
5-
u_z,
6-
T,
7-
h_mesh,
8-
mu_soil,
9-
density_soil,
10-
phase_state,
11-
k_conductivity_heat,
12-
rho_c_heat,
13-
vegetation_vol_fraction,
14-
):
7+
u_x: Any,
8+
u_z: Any,
9+
T: Any,
10+
h_mesh: Any,
11+
mu_soil: Any,
12+
density_soil: Any,
13+
phase_state: Any,
14+
k_conductivity_heat: Any,
15+
rho_c_heat: Any,
16+
vegetation_vol_fraction: Any,
17+
) -> None:
1518

1619
self.u_x = u_x # Velocity in x direction
17-
self.u_z = u_z # Velocity in z direction (y is almost in the gravity direction normal to the bed rock, x and z are layer coordinate parallel to bed rock)
20+
self.u_z = u_z # Velocity in z direction - y is almost in the gravity
21+
# direction normal to bed rock, x and z are layer coordinate parallel to bed rock
1822
self.T = T # Temperature
1923
self.h_mesh = h_mesh # soil layer thickness in mesh
2024
self.mu_soil = mu_soil # soil viscosity
21-
self.gama_soil = density_soil # soil density
25+
self.density_soil = density_soil # soil density
2226
self.phase_state = phase_state # Phase state (fluid, solid (ice), vegetation)
2327
self.k_conductivity_heat = k_conductivity_heat
2428
self.rho_c_heat = rho_c_heat

0 commit comments

Comments
 (0)