Skip to content

Commit

Permalink
Merge branch 'main' into read_additional_output_from_hdf5_file
Browse files Browse the repository at this point in the history
  • Loading branch information
jrutyna committed Sep 12, 2024
2 parents e9c8918 + 7ca1540 commit b57c2fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 37 deletions.
10 changes: 9 additions & 1 deletion src/clearwater_riverine/constituents.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Optional
)
from pathlib import Path
import warnings

import pandas as pd
import xarray as xr
Expand Down Expand Up @@ -63,7 +64,14 @@ def __init__(
input_array=self.input_array,
)
elif method == 'load':
self.units = mesh[name].Units
try:
self.units = mesh[name].Units
except AttributeError as err:
warnings.warn(
f'Constituent {self.name} does not have units defined',
UserWarning
)

self.set_value_range(mesh)


Expand Down
11 changes: 4 additions & 7 deletions src/clearwater_riverine/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
)
from pathlib import Path
import warnings
import inspect

from clearwater_riverine.mesh import (
instantiate_model_mesh,
load_model_mesh
)
from clearwater_riverine import variables
import clearwater_riverine.variables
from clearwater_riverine.variables import (
ADVECTION_COEFFICIENT,
COEFFICIENT_TO_DIFFUSION_TERM,
Expand All @@ -32,8 +33,6 @@
CHANGE_IN_TIME,
NUMBER_OF_REAL_CELLS,
VOLUME,
HYDRODYNAMIC_VARIABLES,
TOPOLOGY_VARIABLES,
)
from clearwater_riverine.utilities import UnitConverter
from clearwater_riverine.linalg import LHS, RHS
Expand Down Expand Up @@ -66,8 +65,6 @@
'Unknown': {'Liters': 0.001},
}



class ClearwaterRiverine:
""" Creates Clearwater Riverine water quality model.
Expand Down Expand Up @@ -785,9 +782,9 @@ def static_plot(
plt.show()

def _determine_constituents(self):
defined_variables = [f[1] for f in inspect.getmembers(clearwater_riverine.variables)]
self.constituents = [
f for f in self.mesh.data_vars
if FACES in self.mesh[f].dims
and f not in HYDRODYNAMIC_VARIABLES
and f not in TOPOLOGY_VARIABLES
and f not in defined_variables
]
32 changes: 3 additions & 29 deletions src/clearwater_riverine/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
FACE_NODES = 'face_nodes'
EDGE_FACE_CONNECTIVITY = 'edge_face_connectivity'
FACES = 'nface'
MESH_2D = 'mesh_2d'

# Available Variables
EDGES_FACE1 = 'edges_face1'
EDGES_FACE2 = 'edges_face2'
NUMBER_OF_REAL_CELLS = 'nreal'
VOLUME = 'volume'
FACE_SURFACE_AREA = 'faces_surface_area'
WETTED_SURFACE_AREA = 'wetted_surface_area'
EDGE_VELOCITY = 'edge_velocity'
EDGE_LENGTH = 'edge_length'
CHANGE_IN_TIME = 'dt'
Expand All @@ -33,32 +35,4 @@
SUM_OF_COEFFICIENTS_TO_DIFFUSION_TERM = 'sum_coeff_to_diffusion'
GHOST_CELL_VOLUMES_IN = 'ghost_volumes_in'
GHOST_CELL_VOLUMES_OUT = 'ghost_volumes_out'
FACE_VEL_MAG = 'face_velocity_magnitude'

# Water Quality
POLLUTANT_LOAD = 'pollutant_load'
CONCENTRATION = 'concentration'

TOPOLOGY_VARIABLES = [
'mesh2d',
FACE_NODES,
EDGE_NODES,
EDGE_FACE_CONNECTIVITY,
EDGES_FACE1,
EDGES_FACE2,
]

HYDRODYNAMIC_VARIABLES = [
FACE_SURFACE_AREA,
EDGE_VELOCITY,
EDGE_LENGTH,
WATER_SURFACE_ELEVATION,
VOLUME,
FLOW_ACROSS_FACE,
ADVECTION_COEFFICIENT,
EDGE_VERTICAL_AREA,
FACE_TO_FACE_DISTANCE,
DIFFUSION_COEFFICIENT,
CHANGE_IN_TIME,
'wetted_surface_area',
]
FACE_VEL_MAG = 'face_velocity_magnitude'

0 comments on commit b57c2fd

Please sign in to comment.