@@ -1470,16 +1470,13 @@ int DLLEXPORT EN_setflowunits(EN_Project p, int units)
14701470{
14711471 Network * net = & p -> network ;
14721472
1473- int i , j , oldUnitFlag ;
1473+ int i , j ;
14741474 double qfactor , vfactor , hfactor , efactor , pfactor , dfactor , xfactor , yfactor ;
14751475 double dcf , pcf , hcf , qcf ;
14761476 double * Ucf = p -> Ucf ;
14771477
14781478 if (!p -> Openflag ) return 102 ;
14791479
1480- // Make sure all curve types are correctly set
1481- assigncurvetypes (net );
1482-
14831480 // Determine unit system based on flow units
14841481 qfactor = Ucf [FLOW ];
14851482 vfactor = Ucf [VOLUME ];
@@ -1488,7 +1485,6 @@ int DLLEXPORT EN_setflowunits(EN_Project p, int units)
14881485 pfactor = Ucf [PRESSURE ];
14891486 dfactor = Ucf [DEMAND ];
14901487
1491- oldUnitFlag = p -> parser .Unitsflag ;
14921488 p -> parser .Flowflag = units ;
14931489 switch (units )
14941490 {
@@ -1504,23 +1500,17 @@ int DLLEXPORT EN_setflowunits(EN_Project p, int units)
15041500 p -> parser .Unitsflag = US ;
15051501 break ;
15061502 }
1507-
1508- // Revise pressure units depending on flow units
1509- if (oldUnitFlag != p -> parser .Unitsflag )
1510- {
1511- if (p -> parser .Unitsflag == US ) p -> parser .Pressflag = PSI ;
1512- else p -> parser .Pressflag = METERS ;
1513- }
15141503 initunits (p );
15151504
1516- // Update pressure units in rules
1505+ // Update units in rules
15171506 dcf = Ucf [DEMAND ] / dfactor ;
15181507 pcf = Ucf [PRESSURE ] / pfactor ;
15191508 hcf = Ucf [HEAD ] / hfactor ;
15201509 qcf = Ucf [FLOW ] / qfactor ;
15211510 updateruleunits (p , dcf , pcf , hcf , qcf );
15221511
1523- //update curves
1512+ //update curves after making sure that all curve types are correctly set
1513+ assigncurvetypes (net );
15241514 for (i = 1 ; i <= net -> Ncurves ; i ++ )
15251515 {
15261516 switch (net -> Curve [i ].Type )
0 commit comments