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

These functions are used to manage a project More…

FunctionDescription
openOpens an EPANET input file & reads in network data.
closeCloses a project and frees all of its memory.
runProjectRuns a complete EPANET simulation.
initInitializes an EPANET project.
getCountRetrieves the number of objects of a given type in a project.
getTitleRetrieves the title lines of the project.
setTitleSets the title lines of the project.
saveInpFileSaves a project’s data to an EPANET-formatted text file.

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

FunctionDescription
solveHRuns a complete hydraulic simulation with results for all time periods written to a temporary hydraulics file.
useHydFileUses a previously saved binary hydraulics file to supply a project’s hydraulics.
openHOpens a project’s hydraulic solver.
initHInitializes a network prior to running a hydraulic analysis.
runHComputes a hydraulic solution for the current point in time.
nextHDetermines the length of time until the next hydraulic event occurs in an extended period simulation.
saveHTransfers a project’s hydraulics results from its temporary hydraulics file to its binary output file, where results are only reported at uniform reporting intervals.
saveHydFileSaves a project’s temporary hydraulics file to disk.
closeHCloses the hydraulic solver freeing all of its allocated memory.

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

FunctionDescription
solveQRuns a complete water quality simulation with results at uniform reporting intervals written to the project’s binary output file.
openQOpens a project’s water quality solver.
initQInitializes a network prior to running a water quality analysis.
runQMakes hydraulic and water quality results at the start of the current time period available to a project’s water quality solver.
nextQAdvances a water quality simulation over the time until the next hydraulic event.
stepQAdvances a water quality simulation by a single water quality time step.
closeQCloses the water quality solver, freeing all of its allocated memory.

These functions are used to report simulation results. More…

FunctionDescription
writeLineWrites a line of text to a project’s report file.
reportWrites simulation results in a tabular format to a project’s report file.
copyReportCopies the current contents of a project’s report file to another file.
clearReportClears the contents of a project’s report file.
resetReportResets a project’s report options to their default values.
setReportProcesses a reporting format command.
setStatusReportSets the level of hydraulic status reporting.
getStatisticRetrieves a particular simulation statistic.
getResultIndexRetrieves the order in which a node or link appears in an output file.

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

FunctionDescription
getFlowUnitsRetrieves a project’s flow units.
getOptionRetrieves the value of an analysis option.
getQualityInfoGets information about the type of water quality analysis requested.
getQualityTypeRetrieves the type of water quality analysis to be run.
getTimeParameterRetrieves the value of a time parameter.
setFlowUnitsSets a project’s flow units.
setOptionSets the value for an anlysis option.
setQualityTypeSets the type of water quality analysis to run.
setTimeParameterSets the value of a time parameter.

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

FunctionDescription
addNodeAdds a new node to a project.
deleteNodeDeletes a node from a project.
getNodeIndexGets the index of a node given its ID name.
getNodeIdGets the ID name of a node given its index.
setNodeIdChanges the ID name of a node.
getNodeTypeRetrieves a node’s type given its index.
getNodeValueRetrieves a property value for a node.
setNodeValueSets a property value for a node.
setJunctionDataSets a group of properties for a junction node.
setTankDataSets a group of properties for a tank node.
getCoordinatesGets the (x,y) coordinates of a node.
setCoordinatesSets the (x,y) coordinates of a node.

These functions are used for managing nodal demands. More…

FunctionDescription
addDemandappends a new demand to a junction node demands list.
deleteDemanddeletes a demand from a junction node.
getBaseDemandGets the base demand for one of a node’s demand categories.
getDemandIndexRetrieves the index of a node’s named demand category.
getDemandModelRetrieves the type of demand model in use and its parameters.
getDemandNameRetrieves the name of a node’s demand category.
getDemandPatternRetrieves the index of a time pattern assigned to one of a node’s demand categories.
getNumberOfDemandsRetrieves the number of demand categories for a junction node.
setBaseDemandSets the base demand for one of a node’s demand categories.
setDemandModelSets the type of demand model to use and its parameters.
setDemandNameAssigns a name to a node’s demand category.
setDemandPatternSets 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…

FunctionDescription
addLinkAdds a new link to a project.
deleteLinkDeletes a link from the project.
getLinkIndexGets the index of a link given its ID name.
getLinkIdGets the ID name of a link given its index.
setLinkIdChanges the ID name of a link.
getLinkTypeRetrieves a link’s type.
setLinkTypeChanges a link’s type.
getLinkNodesGets the indexes of a link’s start- and end-nodes.
setLinkNodesSets the indexes of a link’s start- and end-nodes.
getLinkValueRetrieves a property value for a link.
setLinkValueSets a property value for a link.
setPipeDataSets a group of properties for a pipe link.
getPumpTypeRetrieves the type of head curve used by a pump.
getHeadCurveIndexRetrieves the curve assigned to a pump’s head curve.
setHeadCurveIndexAssigns a curve to a pump’s head curve.
getVertexCountRetrieves the number of internal vertex points assigned to a link.
getVertexRetrieves the coordinate’s of a vertex point assigned to a link.
setVerticesAssigns a set of internal vertex points to a link.

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

FunctionDescription
addPatternAdds a new time pattern to a project.
deletePatternDeletes a time pattern from a project.
getPatternIndexRetrieves the index of a time pattern given its ID name.
getPatternIdRetrieves the ID name of a time pattern given its index.
setPatternIdChanges the ID name of a time pattern given its index.
getPatternLengthRetrieves the number of time periods in a time pattern.
getPatternValueRetrieves a time pattern’s factor for a given time period.
setPatternValueSets a time pattern’s factor for a given time period.
getAveragePatternValueRetrieves the average of all pattern factors in a time pattern.
setPatternSets the pattern factors for a given time pattern.

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

FunctionDescription
addCurveAdds a new data curve to a project.
deleteCurveDeletes a data curve from a project.
getCurveIndexRetrieves the index of a curve given its ID name.
getCurveIdRetrieves the ID name of a curve given its index.
setCurveIdChanges the ID name of a data curve given its index.
getCurveLenthRetrieves the number of points in a curve.
getCurveTypeRetrieves a curve’s type.
getCurveValueRetrieves the value of a single data point for a curve.
setCurveValueSets the value of a single data point for a curve.
setCurveassigns a set of data points to a curve.

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

FunctionDescription
addControlAdds a new simple control to a project.
deleteControlDeletes an existing simple control.
getControlRetrieves the properties of a simple control.
setControlSets the properties of an existing simple control.

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

FunctionDescription
addRuleAdds a new rule-based control to a project.
deleteRuleDeletes an existing rule-based control.
getRuleRetrieves summary information about a rule-based control.
getRuleIdGets the ID name of a rule-based control given its index.
getPremiseGets the properties of a premise in a rule-based control.
setPremiseSets the properties of a premise in a rule-based control.
setPremiseIndexSets the index of an object in a premise of a rule-based control.
setPremiseStatusSets the status being compared to in a premise of a rule-based control.
setPremiseValueSets the value in a premise of a rule-based control.
getThenActionGets the properties of a THEN action in a rule-based control.
setThenActionSets the properties of a THEN action in a rule-based control.
getElseActionGets the properties of an ELSE action in a rule-based control.
setElseActionSets the properties of an ELSE action in a rule-based control.
setRulePrioritySets the priority of a rule-based control.