HLM

new HLM(configfile) → {Object}

Class definition of the HLM model that is BMI-compliant. Creates an HLM instance. If no configuration file given, then it only initializes an empty shell. Otherwise, passes config string to initialize method.

Parameters:
NameTypeDescription
configfileString

string path to json configuration file.

Returns:

creates a new instance of an HLM model

Type: 
Object

Extends

Methods

(static) current_time(name) → {Number}

Current time of the model

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

Returns:
  • The current model time.
Type: 
Number

(static) end_time() → {Number}

End time of the model

Returns:

-The maximum model time.

Type: 
Number

(static) finalize()

Perform all tasks that take place after exiting model time loop (ie. memory cleanup, closing files, reporting)

To Do
  • Potential Tasks: - garbage collection stuff - provide outputs in even intervals

(static) get_component_name() → {String}

Gets name of the component.

Returns:
  • The name of the component
Type: 
String

(static) get_grid_edge_count(grid) → {Number}

Get the number of edges in the grid

Parameters:
NameTypeDescription
gridNumber

A grid identifier

Returns:

The total number of grid edges

Type: 
Number

(static) get_grid_edge_nodes(grid, edge_nodes) → {Array.<Object>}

Get the edge-node connectivity.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

edge_nodesArray.<Object>

An array of Number, shape *(2 x nnodes,) to place the edge-node connectivity. For each edge, connectivity is given as node at edge tail, followed by node at edge head.

Returns:

The input array that holds the edge-node connectivity.

Type: 
Array.<Object>

(static) get_grid_face_count(grid) → {Number}

Get the number of faces in the grid.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

Returns:

The total number of grid faces.

Type: 
Number

(static) get_grid_face_edges(grid, face_edges) → {Array.<Object>}

Get the face-edge connectivity.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

face_edgesArray.<Object>

An array to place the face-edge connectivity.

Returns:

The input array that holds the face-edge connectivity.

Type: 
Array.<Object>

(static) get_grid_face_nodes(grid, face_nodes) → {Array.<Object>}

Get the face-edge connectivity.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

face_nodesArray.<Object>

An array to place the face-node connectivity. For each face, the nodes (listed in a counter-clockwise direction) that form the boundary of the face.

Returns:

The input array that holds the face-node connectivity.

Type: 
Array.<Object>

(static) get_grid_node_count(grid) → {Number}

Get the number of nodes in the grid.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

Returns:

The total number of grid nodes

Type: 
Number

(static) get_grid_nodes_per_face(grid, nodes_per_face) → {Array.<Object>}

Get the face-edge connectivity.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

nodes_per_faceArray.<Object>

An array of Number, shape *(nfaces,) to place the number of nodes per face.

Returns:

The input array that holds the number of nodes per face.

Type: 
Array.<Object>

(static) get_grid_origin(grid, origin) → {Array.<Object>}

Get coordinates for the lower-left corner of the computational grid.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

originArray.<Object>

An array of Number, shape *(ndim,) to hold the coordinates of the lower-left corner of the grid.

Returns:

The input array that holds the coordinates of the grid's lower-left corner.

Type: 
Array.<Object>

(static) get_grid_rank(grid) → {Number}

Get number of dimensions of the computational grid.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

Returns:

Rank of the grid.

Type: 
Number

(static) get_grid_shape(grid, shape) → {Array.<Object>}

Get dimensions of the computational grid

Parameters:
NameTypeDescription
gridNumber

A grid identifier

shapeArray.<Object>

A array of Number, shape *(ndim,) into which to place the shape of the grid.

Returns:

The input array that holds the grid's shape.

Type: 
Array.<Object>

(static) get_grid_size(grid) → {Number}

Get the total number of elements in the computational grid.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

Returns:

Size of the grid.

Type: 
Number

(static) get_grid_spacing(grid, spacing) → {Array.<Object>}

Get dimensions of the computational grid

Parameters:
NameTypeDescription
gridNumber

A grid identifier

spacingArray.<Object>

A array of Number, shape *(ndim,) to hold the spacing between grid rows and columns.

Returns:

The input array that holds the grid's spacing.

Type: 
Array.<Object>

(static) get_grid_type(grid) → {String}

Get the grid type as a string. HLM grid is an unstructured grid per BMI grid specifications

HLM models are formulated as directed trees

Parameters:
NameTypeDescription
gridNumber

A grid identifier

Returns:

Type of grid as a string.

Type: 
String

(static) get_grid_x(grid, x) → {Array.<Object>}

Get coordinates of grid nodes in the x direction.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

xArray.<Object>

An array of Number, shape *(nrows,) to hold the x-coordinates of the grid node columns

Returns:

The input array that holds the grid's column x-coordinates.

Type: 
Array.<Object>

(static) get_grid_y(grid, y) → {Array.<Object>}

Get coordinates of grid nodes in the y direction.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

yArray.<Object>

An array of Number, shape *(ncols,) to hold the y-coordinates of the grid node rows

Returns:

The input array that holds the grid's row y-coordinates

Type: 
Array.<Object>

(static) get_grid_z(grid, z) → {Array.<Object>}

Get coordinates of grid nodes in the z direction.

Parameters:
NameTypeDescription
gridNumber

A grid identifier

zArray.<Object>

An array of Number, shape *(nlayers,) to hold the z-coordinates of the grid nodes layers.

Returns:

The input array that holds the grid's layer z-coordinates.

Type: 
Array.<Object>

(static) get_input_item_count() → {Number}

Count of a model's input variables.

Returns:
  • The number of input variables. Number of variables model can use from other models implementing a BMI.
Type: 
Number

(static) get_input_var_names() → {Array.<Object>}

Gets an array of names for the variables the model can use from other models implementing a BMI. The length of the array is given by get_input_item_count. The names are preferably in the form of CSDMS Standard Names.

Returns:

array with string names

Type: 
Array.<Object>

(static) get_output_item_count() → {Number}

Count of a model's output variables.

Returns:
  • The number of output variables.
Type: 
Number

(static) get_output_var_names() → {Array.<Object>}

Gets an array of names for the variables the model can provide to other models implementing a BMI. The length of the array is given by get_output_item_count. The names are preferably in the form of CSDMS Standard Names.

Returns:

array with string names

Type: 
Array.<Object>

(static) get_value(name, dest) → {Array.<Object>}

Get a copy of values of the given variable. This is a method for the model, used to access the model's current state. It returns a copy of a model variable, with the return type, size and rank dependent on the variable.

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

destArray.<Object>

A array into which to place the values

Returns:

-The same array that was passed as an input buffer.

Type: 
Array.<Object>

(static) get_value_at_indices(name, dest, inds) → {Array.<Object>}

Get values at particular indices.

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

destArray.<Object>

An array into which to place the values

indsArray.<Object>

The indices into the variable array

Returns:

-Value of the model variable at the given location.

Type: 
Array.<Object>

(static) get_value_ptr(name) → {Array.<Object>}

NOT IMPLEMENTED IN JS Get a reference to values of the given variable. This is a method for the model, used to access the model's current state. It returns a reference to a model variable, with the return type, size and rank dependent on the variable.

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

Returns:

-A reference to a model variable.

Type: 
Array.<Object>

(static) get_var_grid(name) → {Number}

Returns an identifier of the grid upon which the 'var_name' is defined. HLM only uses one grid. Grids indexed from 0

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

Returns:
  • The grid identifier.
Type: 
Number

(static) get_var_ind(var_name) → {number}

Helper method to provide the index of a variable can parse all variables, regardles of input names or output names.

Parameters:
NameTypeDescription
var_namestring
Returns:
  • the variable index
Type: 
number

(static) get_var_itemsize(name) → {Number}

Get memory use for each array element in bytes

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

Returns:
  • Item size in bytes.
Type: 
Number

(static) get_var_location(name) → {String}

Get the grid element type that the a given variable is defined on. The grid topology can be composed of nodes, edges, and faces. node A point that has a coordinate pair or triplet: the most basic element of the topology. edge A line or curve bounded by two nodes. face A plane or surface enclosed by a set of edges. In a 2D horizontal application one may consider the word “polygon”, but in the hierarchy of elements the word “face” is most common.

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

Returns:
  • The grid location on which the variable is defined. Must be one of "node", "edge", or "face".
Type: 
String

(static) get_var_nbytes(name) → {Number}

Get size, in bytes, of the given variable

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

Returns:
  • The size of the variable, counted in bytes.
Type: 
Number

(static) get_var_type(name) → {String}

Get data type of the given variable.

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

Returns:
  • The variable type; e.g., "str", "int", "float".
Type: 
String

(static) get_var_units(name) → {String}

Get units of the given variable. Standard unit names, in lower case, should be used, such as "meters" or "seconds". Standard abbreviations, like "m" for meters, are also supported. For variables with compound units, each unit name is separated by a single space, with exponents other than 1 placed immediately after the name, as in "m s-1" for velocity, "W m-2" for an energy flux, or "km2" for an area.

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

Returns:
  • The variable units.
Type: 
String

(static) getLinkForces(data, target) → {Object}

Get and organize forcing data for an individual link

Parameters:
NameTypeDescription
dataObject

forcing data

targetString

link id to get forcing for

Throws:

Throws error if data object provided is not properly formatted.

Returns:

object of forcing data

Type: 
Object

(static) getLinkOrder() → {Array.<Object>}

Return link order to step the solution of the links. Could house a variety of different logics. Would be helpful to find a post-order DFS alg in JS to plug into here.

Returns:

array of numbers.

Type: 
Array.<Object>

(static) handleModelConfig(models)

Attaches proper mathematical models and supporting functions for the hydrological model designated in the configuration file. Sets BMI-compliant standard names for specifica variables in _inNames and _outNames.

Parameters:
NameTypeDescription
modelsObject

object holding mathematical models. Fetched from models.js.

(static) handleModelConfig(solvers)

Attaches to the HLM instance functions associated to the numerical engine.

Parameters:
NameTypeDescription
solversObject
Throws:

Currently throws if DOPRI solver is chosen.

(static) initialize(configfile)

Intialize the HLM instance with data.

Parameters:
NameTypeDescription
configfilestring

string path to json configuration file.

Throws:

Will throw an error if no path is provided to configuration file.

Fetches model input data and builds link objects

Parameters:
NameTypeDescription
simFileURLsObject

object of file paths.

Throws:

Throws error if one of the key input types are missing.

simFileURLs should have the following key-value pairs: 'prm' : <parameter data input filepath>.json 'rvr' : <network topology data input filepath>.json 'str' : <forcing data filepath>.json 'ics' : <initial conditions data filepath>.json

(static) set_value(name, src)

Specify a new value for a model variable. This is the setter for the model, used to change the model's current state. It accepts, through src, a new value for a model variable, with the type, size and rank of src dependent on the variable.

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

srcArray.<Object>

The new value for the specified variable

(static) set_value_at_indices(name, inds, src)

Specify a new value for a model variable at particular indices.

Parameters:
NameTypeDescription
nameString

An input or output variable name, a CSDMS Standard Name

indsArray.<Object>

The indices into the variable array

srcArray.<Object>

The new value for the specified variable

(static) start_time() → {Number}

Start time of the model. Model times should be of type float

Returns:

-The model start time.

Type: 
Number

(static) time_step() → {Number}

Current time step of the model. HLM implementation is the DEFAULT time step.

Returns:

-The time step used in model.

Type: 
Number

(static) time_units() → {String}

Time units of the model

Returns:

-The model time unit; e.g., 'days' or 's'.

Type: 
String

(static) update()

Advance model by one DEFAULT timestep Default timestep is set in the config file.

default timestep is meant to standardize the timesteps of each hillslope link over all of the dynamically stepping links

(static) update_until(tGoal)

Steps model until a specified time, tGoal. tGoal unit is seconds since beginning of simulation

Parameters:
NameTypeDescription
tGoalnumber