EPANET- how to convert the unit in EPANET using MATLAB

I need to convert the unit of Net2.inp (in EPANET) by using MATLAB.
For example, I would like to change the flow of all nodes from GMP unit to LPS unit.
So, how to execute the code in MATLAB. Kindly, help me. I am the beginner in MATLAB.
Thank you so much.

1 Like

Hello,
use the following code after loading your network:

  • d.setBinFlowUnitsLPS

Regards.

2 Likes

Hello,
In my experience this code only modifies units, not values

1 Like

You have to do this manually. I’ve converted the three EPANET example networks to SI units and you can download them from here: https://www.dropbox.com/sh/ua92rpf5e4awr2j/AAC1kjECinJVqY6TBI_jhlW_a?dl=0

1 Like

EPANET 2.2 includes an API to change the units EN_setflowunits(). I guess it was included in the Matlab class. If it doesn’t work please open an issue on GitHub or report the issue here.

2 Likes

Hi
You can use my tool which also allows you to convert flow units directly without programming a single line of code. It is in Spanish, but it is very easy to use.

Download link here

Corunica

1 Like

Hi @TRJ, you can try the following example:

d.setFlowUnitsLPS; 
% or save in new file
d.setFlowUnitsLPS('NET1_LPS.inp');

Regards,
Marios

1 Like

Thank you so much. It is really awesome tool!!

Thank you so much for your suggestion!!

Thank you so much for your suggestion

Thank you so much. They are really useful!!

Hi @kobusvanzyl
Unable to access files.
How can I get the files?
thanks.

Hi @eladsal
I reported the problem for myself in this section. I appreciate you if you read it and give your opinion.
many thanks.

Hi guys

I have difficulties dealing with EPANET 2.2 unit conversions. when I change the flow units from GPM to CMH, it seems that other relevant variables, such as node demands and link length or diameter, do not change properly. In other words, with the same values but different flow units, the model yields different analysis results. for example, the node pressures become negative, and flow directions change or reduce.

Does anybody have any similar experiences?

Hello, I have the same problem when I change the flow units from CFS to LPS. Did you find a solution please.

@Belsam-mzh,
Note that when you set flow units you also set the unit system for the entire project - all other units are taken as SI or US according to the flow units you selected.
See here the units of the different parameters associated with the flow units options

Thank you for your answer. Even when I set the flow unit LPS and the unit system SI, I have negative pressures.

1 Like

Hi @Belsam-mzh, @amin_msb

Can you send me an example with the input file where you have this problem?

Regards,
Marios

Hi @Mariosmsk
For example, i changed the Net1.inp of EPANET sample networks.

Hi @Mariosmsk, @amin_msb and @ Belsam-mzh

The negative pressure error comes from an error in the power units of the network pumps. I noticed that when converting the units from US customary to SI (or the other way round) using the function “setFlowUnitsLPS” for example, the parameters of power in the pumps’ section remain in horsepower. So what you should do is transform them to kW when using SI, with a factor of ~0.7457. Hope this helps.

Regards,
George