Skip to content

Project Class

Create a Project object by instancing the epanetJs.Project class with a Workspace object.

import { Workspace, Project } from `epanet-js`
const ws = new Workspace()
const model = new Project(ws)

Class Methods

Functions Description
Project Functions These functions are used to manage a project
Hydraulic Analysis Functions These functions are used to perform a hydraulic analysis
Water Quality Analysis Functions These functions are used to perform a water quality analysis
Reporting Functions These functions are used to report simulation results
Analysis Options Functions These functions are used to get and set analysis options
Network Node Functions These functions are used for working with network nodes
Nodal Demand Functions These functions are used for managing nodal demands
Network Link Functions These functions are used for working with network links
Time Pattern Functions These functions are used for working with time patterns
Data Curve Functions These functions are used for working with data curves
Simple Control Functions These functions are used for working with simple conditional controls
Rule-Based Control Functions These functions are used for working with rule-based controls

Project Functions

These functions are used to manage a project More...

Function Description
open Opens an EPANET input file & reads in network data.
close Closes a project and frees all of its memory.
runProject Runs a complete EPANET simulation.
init Initializes an EPANET project.
getCount Retrieves the number of objects of a given type in a project.
getTitle Retrieves the title lines of the project.
setTitle Sets the title lines of the project.
saveInpFile Saves a project's data to an EPANET-formatted text file.

Hydraulic Analysis Functions

These functions are used to perform a hydraulic analysis. More...

Function Description
solveH Runs a complete hydraulic simulation with results for all time periods written to a temporary hydraulics file.
useHydFile Uses a previously saved binary hydraulics file to supply a project's hydraulics.
openH Opens a project's hydraulic solver.
initH Initializes a network prior to running a hydraulic analysis.
runH Computes a hydraulic solution for the current point in time.
nextH Determines the length of time until the next hydraulic event occurs in an extended period simulation.
saveH Transfers a project's hydraulics results from its temporary hydraulics file to its binary output file, where results are only reported at uniform reporting intervals.
saveHydFile Saves a project's temporary hydraulics file to disk.
closeH Closes the hydraulic solver freeing all of its allocated memory.

Water Quality Analysis Functions

These functions are used to perform a water quality analysis. More...

Function Description
solveQ Runs a complete water quality simulation with results at uniform reporting intervals written to the project's binary output file.
openQ Opens a project's water quality solver.
initQ Initializes a network prior to running a water quality analysis.
runQ Makes hydraulic and water quality results at the start of the current time period available to a project's water quality solver.
nextQ Advances a water quality simulation over the time until the next hydraulic event.
stepQ Advances a water quality simulation by a single water quality time step.
closeQ Closes the water quality solver, freeing all of its allocated memory.

Reporting Functions

These functions are used to report simulation results. More...

Function Description
writeLine Writes a line of text to a project's report file.
report Writes simulation results in a tabular format to a project's report file.
copyReport Copies the current contents of a project's report file to another file.
clearReport Clears the contents of a project's report file.
resetReport Resets a project's report options to their default values.
setReport Processes a reporting format command.
setStatusReport Sets the level of hydraulic status reporting.
getStatistic Retrieves a particular simulation statistic.
getResultIndex Retrieves the order in which a node or link appears in anĀ output file.

Analysis Options Functions

These functions are used to get and set analysis options. More...

Function Description
getFlowUnits Retrieves a project's flow units.
getOption Retrieves the value of an analysis option.
getQualityInfo Gets information about the type of water quality analysis requested.
getQualityType Retrieves the type of water quality analysis to be run.
getTimeParameter Retrieves the value of a time parameter.
setFlowUnits Sets a project's flow units.
setOption Sets the value for an anlysis option.
setQualityType Sets the type of water quality analysis to run.
setTimeParameter Sets the value of a time parameter.

Network Node Functions

These functions are used for working with network nodes. More...

Function Description
addNode Adds a new node to a project.
deleteNode Deletes a node from a project.
getNodeIndex Gets the index of a node given its ID name.
getNodeId Gets the ID name of a node given its index.
setNodeId Changes the ID name of a node.
getNodeType Retrieves a node's type given its index.
getNodeValue Retrieves a property value for a node.
setNodeValue Sets a property value for a node.
setJunctionData Sets a group of properties for a junction node.
setTankData Sets a group of properties for a tank node.
getCoordinates Gets the (x,y) coordinates of a node.
setCoordinates Sets the (x,y) coordinates of a node.

Nodal Demand Functions

These functions are used for managing nodal demands. More...

Function Description
addDemand appends a new demand to a junction node demands list.
deleteDemand deletes a demand from a junction node.
getBaseDemand Gets the base demand for one of a node's demand categories.
getDemandIndex Retrieves the index of a node's named demand category.
getDemandModel Retrieves the type of demand model in use and its parameters.
getDemandName Retrieves the name of a node's demand category.
getDemandPattern Retrieves the index of a time pattern assigned to one of a node's demand categories.
getNumberOfDemands Retrieves the number of demand categories for a junction node.
setBaseDemand Sets the base demand for one of a node's demand categories.
setDemandModel Sets the type of demand model to use and its parameters.
setDemandName Assigns a name to a node's demand category.
setDemandPattern Sets the index of a time pattern used for one of a node's demand categories.

These functions are used for working with network links. More...

Function Description
addLink Adds a new link to a project.
deleteLink Deletes a link from the project.
getLinkIndex Gets the index of a link given its ID name.
getLinkId Gets the ID name of a link given its index.
setLinkId Changes the ID name of a link.
getLinkType Retrieves a link's type.
setLinkType Changes a link's type.
getLinkNodes Gets the indexes of a link's start- and end-nodes.
setLinkNodes Sets the indexes of a link's start- and end-nodes.
getLinkValue Retrieves a property value for a link.
setLinkValue Sets a property value for a link.
setPipeData Sets a group of properties for a pipe link.
getPumpType Retrieves the type of head curve used by a pump.
getHeadCurveIndex Retrieves the curve assigned to a pump's head curve.
setHeadCurveIndex Assigns a curve to a pump's head curve.
getVertexCount Retrieves the number of internal vertex points assigned to a link.
getVertex Retrieves the coordinate's of a vertex point assigned to a link.
setVertices Assigns a set of internal vertex points to a link.

Time Pattern Functions

These functions are used for working with time patterns. More...

Function Description
addPattern Adds a new time pattern to a project.
deletePattern Deletes a time pattern from a project.
getPatternIndex Retrieves the index of a time pattern given its ID name.
getPatternId Retrieves the ID name of a time pattern given its index.
setPatternId Changes the ID name of a time pattern given its index.
getPatternLength Retrieves the number of time periods in a time pattern.
getPatternValue Retrieves a time pattern's factor for a given time period.
setPatternValue Sets a time pattern's factor for a given time period.
getAveragePatternValue Retrieves the average of all pattern factors in a time pattern.
setPattern Sets the pattern factors for a given time pattern.

Data Curve Functions

These functions are used for working with data curves. More...

Function Description
addCurve Adds a new data curve to a project.
deleteCurve Deletes a data curve from a project.
getCurveIndex Retrieves the index of a curve given its ID name.
getCurveId Retrieves the ID name of a curve given its index.
setCurveId Changes the ID name of a data curve given its index.
getCurveLenth Retrieves the number of points in a curve.
getCurveType Retrieves a curve's type.
getCurveValue Retrieves the value of a single data point for a curve.
setCurveValue Sets the value of a single data point for a curve.
setCurve assigns a set of data points to a curve.

Simple Control Functions

These functions are used for working with simple conditional controls. More...

Function Description
addControl Adds a new simple control to a project.
deleteControl Deletes an existing simple control.
getControl Retrieves the properties of a simple control.
setControl Sets the properties of an existing simple control.

Rule-Based Control Functions

These functions are used for working with rule-based controls.More...

Function Description
addRule Adds a new rule-based control to a project.
deleteRule Deletes an existing rule-based control.
getRule Retrieves summary information about a rule-based control.
getRuleId Gets the ID name of a rule-based control given its index.
getPremise Gets the properties of a premise in a rule-based control.
setPremise Sets the properties of a premise in a rule-based control.
setPremiseIndex Sets the index of an object in a premise of a rule-based control.
setPremiseStatus Sets the status being compared to in a premise of a rule-based control.
setPremiseValue Sets the value in a premise of a rule-based control.
getThenAction Gets the properties of a THEN action in a rule-based control.
setThenAction Sets the properties of a THEN action in a rule-based control.
getElseAction Gets the properties of an ELSE action in a rule-based control.
setElseAction Sets the properties of an ELSE action in a rule-based control.
setRulePriority Sets the priority of a rule-based control.