-
Notifications
You must be signed in to change notification settings - Fork 0
/
Leak_Model_Results.dat
1 lines (1 loc) · 8.95 KB
/
Leak_Model_Results.dat
1
{"nodes":["{\"script\":\"global& opt_file_sum = \\\"${getDataFolder()}//Summer_Opt.inp\\\"; \\nglobal& control_file_sum = \\\"${getDataFolder()}//Summer_Control.inp\\\"; \\n\\nglobal& opt_file_win = \\\"${getDataFolder()}//Winter_Opt.inp\\\"; \\nglobal& control_file_win = \\\"${getDataFolder()}//Winter_Control.inp\\\"; \",\"label\":\"New Script Node\",\"uniqueName\":\"WW_4_75_95\",\"mode\":\"Editing\",\"HorizontalOffset\":\"0.0082781638658113*\",\"VerticalOffset\":\"0.0247129190790753*\",\"Width\":\"605.581115722656\",\"Height\":\"248.774810791016\",\"inbounds\":{}}","{\"script\":\"Stopwatch sw; sw.Start;\\nvar& createMapLeakModelResults = fun[](cweeStr filePath, cweeStr controlPath){\\n // Get EPAnet Projects and simulate them\\n var& p = EPAnet.loadProject(filePath);{ p.DoHydraulicSimulation; }\\n var& p2 = EPAnet.loadProject(controlPath);{ p2.DoHydraulicSimulation; }\\n \\n var& findControlNode = fun[p2](nodeName){ for (n : p2.network.Node){ if (n && n.Name_p == nodeName){ return n; } } };\\n \\n // Get Zones from Optimized Model\\n Map zones; {\\n for (z : p.network.Zone){ if (z){\\n zones[z.to_string()] := Szone(z); // copies a ptr to the zone \\\"z\\\"\\n } }\\n try{ // 'try' to ensure we don't crash if these zones don't exist\\n // called out by-hand as zone(s) we don't want to publish on\\n zones.erase(\\\"DMA Draw Zone (Reservoir SystemConnection)\\\"); \\n zones.erase(\\\"DMA Reduced Zone (Pipe TimeOfUse_6pm_To_7pm)\\\");\\n }\\n }\\n \\n // Get Content\\n Map out;\\n for (z : zones){\\n var& zone := z.second;\\n var& control_zone = findControlNode(zone.Node[0].Name_p).Zone;\\n var& prevPressure = control_zone.AverageNodePressure; // previous pressure from control project\\n year surveyF = zone.SurveyFrequency(p, prevPressure); // survey frequency, in years\\n out[z.first] := zone.LeakModelResults(p, surveyF, prevPressure);\\n out[z.first][\\\"Survey Frequency\\\"] := surveyF;\\n }\\n return out;\\n} \\nvar& result = createMapLeakModelResults(opt_file_sum, control_file);\\n \\ncweeStr out = \\\"ZONE,ITEM,TIME,VALUE\\\";\\nfor (x : result){\\n\\tfor (y : x.second){\\n\\t\\ttry{\\n\\t\\t\\tvar& knots = y.second.GetTimeSeries(y.second.GetMinTime, y.second.GetMaxTime, 1_hr);\\n\\t\\t\\tint num = knots.size.int;\\n\\t\\t\\tfor (int j = 0; j < num; ++j){\\n\\t\\t\\t\\tout.AddToDelimiter(\\\"${x.first},${y.first},${knots[j].first.cweeTime},${ knots[j].second }\\\", \\\"\\\\n\\\");\\n\\t\\t\\t} \\n\\t\\t}catch(err){ // we will ignore the error … this is likely not a pattern type.\\n\\t\\t\\tout.AddToDelimiter(\\\"${x.first},${y.first},N/A,${y.second}\\\", \\\"\\\\n\\\");\\t\\n\\t\\t} \\n\\t}\\n}\\n\\\"${getDataFolder()}//LeakModelResults.csv\\\".writeFileFromCweeStr(out);\\nsw.Stop; submitToast(\\\"Script 1\\\", \\\"${sw.Seconds_Passed}\\\"); \\nreturn sw.Seconds_Passed;\",\"label\":\"New Script Node\",\"uniqueName\":\"WW_31_43_89\",\"mode\":\"Editing\",\"HorizontalOffset\":\"0.182214312738137*\",\"VerticalOffset\":\"0.0683168981190526*\",\"Width\":\"1200.81262207031\",\"Height\":\"0\",\"inbounds\":{\"\":\"WW_4_75_95\"}}","{\"script\":\"Stopwatch sw; sw.Start; \\n// Make the helper function(s)\\nvar& GetNodePressures = fun[](cweeStr filePath, bool onlyCustomers){\\n\\t// Get EPAnet Projects and simulate them\\n\\tvar& p = EPAnet.loadProject(filePath);{ p.DoHydraulicSimulation; }\\n\\tMap out;\\n\\tfor (zone : p.network.Zone){\\n\\t\\tout[zone.Name_p] ?= Map();\\n\\t\\tfor (n : zone.Node){\\n\\t\\t\\tif (onlyCustomers){ if (!n.HasWaterDemand){ continue; } }\\n \\t\\t\\tout[zone.Name_p][n.Name_p] := (n.Head - n.El).Cast(1_ft_water).Cast(1_psi);\\n\\t\\t}\\n\\t}\\n\\treturn [p, out]; \\n} \\nvar& convertToCSV = fun[](content, cweeStr savePath){\\n\\tcweevector_cweeStr out;\\n\\tout.push_back(cweeStr(\\\"ZONE,NODE,TIME,UNIXTIME,VALUE\\\"));\\n\\tvar& p = content[0];\\n\\tvar& minT = p.project.times.GetCalibrationDateTime.cweeTime.double.second;\\n\\tvar& maxT = (p.project.times.GetCalibrationDateTime + p.project.times.Dur).cweeTime.double.second;\\n\\tcweeStr delim = \\\"\\\\n\\\";\\n\\tcweeStr row_p2;\\n\\tint num;\\n\\tfor (zone_pair : content[1]){\\n\\t\\tfor (node_pair : zone_pair.second){\\n\\t\\t\\tcweeStr row = \\\"${zone_pair.first},${node_pair.first},\\\";\\t\\t\\t\\n\\t\\t\\tvar& knots = node_pair.second.GetTimeSeries(minT, maxT, 1_hr);\\n\\t\\t\\tnum = knots.size.int; \\n\\t\\t\\tvar& knot;\\n\\t\\t\\tfor (var& index = 0; index < num; ++index){\\t\\t\\t\\t\\n\\t\\t\\t\\tknot := knots[index];\\n\\t\\t\\t\\trow_p2 = knot.first.cweeTime.to_string + \\\",\\\" + knot.first.to_string + \\\",\\\" + knot.second.to_string;\\n\\t\\t\\t\\tout.push_back(row + row_p2);\\n\\t\\t\\t}\\n\\t\\t} \\n\\t}\\t\\n\\tsavePath.writeFileFromStrList(out);\\n\\treturn out;\\n};\\n// Call the helper function on our EPAnet file\\nvar& node_pressures_opt_sum = GetNodePressures(opt_file_sum, false);\\nvar& customer_pressures_opt_sum = GetNodePressures(opt_file_sum, true);\\n\\nvar& node_pressures_con_sum = GetNodePressures(control_file_sum, false);\\nvar& customer_pressures_con_sum = GetNodePressures(control_file_sum, true);\\n\\nvar& node_pressures_opt_win = GetNodePressures(opt_file_win, false);\\nvar& customer_pressures_opt_win = GetNodePressures(opt_file_win, true);\\n\\nvar& node_pressures_con_win = GetNodePressures(control_file_win, false);\\nvar& customer_pressures_con_win = GetNodePressures(control_file_win, true);\\n\\n\\n// Convert to CSV\\nconvertToCSV(node_pressures_opt_sum, \\\"${getDataFolder()}//NodePressure_Summer_Opt.csv\\\");\\nconvertToCSV(customer_pressures_opt_sum, \\\"${getDataFolder()}//CustomerPressure_Summer_Opt.csv\\\");\\n\\nconvertToCSV(node_pressures_con_sum, \\\"${getDataFolder()}//NodePressure_Summer_Con.csv\\\");\\nconvertToCSV(customer_pressures_con_sum, \\\"${getDataFolder()}//CustomerPressure_Summer_Con.csv\\\");\\n\\nconvertToCSV(node_pressures_opt_win, \\\"${getDataFolder()}//NodePressure_Winter_Opt.csv\\\");\\nconvertToCSV(customer_pressures_opt_win, \\\"${getDataFolder()}//CustomerPressure_Winter_Opt.csv\\\");\\n\\nconvertToCSV(node_pressures_con_win, \\\"${getDataFolder()}//NodePressure_Winter_Con.csv\\\");\\nconvertToCSV(customer_pressures_con_win, \\\"${getDataFolder()}//CustomerPressure_Winter_Con.csv\\\");\\n\\nsw.Stop; submitToast(\\\"Script2\\\", \\\"${sw.Seconds_Passed}\\\"); \\nreturn sw.Seconds_Passed; \",\"label\":\"New Script Node\",\"uniqueName\":\"WW_70_96_19\",\"mode\":\"Editing\",\"HorizontalOffset\":\"0.488131095739972*\",\"VerticalOffset\":\"0.0760655106821881*\",\"Width\":\"988.793701171875\",\"Height\":\"1508.81884765625\",\"inbounds\":{}}","{\"script\":\"Stopwatch sw; sw.Start; \\n// Make the helper function(s)\\nvar& LoadEPAnetProject = fun[](cweeStr filePath){ \\n\\tvar& p = EPAnet.loadProject(filePath); \\n\\tp.DoHydraulicSimulation; \\n\\treturn p; \\n};\\nvar& FindMatchingZone = fun[](p, node_name){\\n\\tfor (n : p.network.Node){\\n \\tif (n && n.Name_p == node_name){\\n \\treturn n.Zone;\\n\\t\\t}\\n\\t}\\n};\\n// Load the EPAnet Projects\\nvar& opt = LoadEPAnetProject(opt_file_sum);\\nvar& control = LoadEPAnetProject(control_file_sum);\\n// Make the CSV\\ncweeStr out = \\\"Node,ControlZone,OptZone\\\";\\nfor (zone : opt.network.Zone){ \\n\\tfor (n : zone.Node){\\n \\tif (n){\\n \\tvar& control_zone = FindMatchingZone(control, n.Name_p);\\n out.AddToDelimiter(\\\"${n.Name_p},${control_zone.Name_p},${zone.Name_p}\\\", \\\"\\\\n\\\");\\n\\t\\t}\\n\\t}\\n}\\n// Save the CSV\\n\\\"${getDataFolder()}//NodeToZones_sum.csv\\\".writeFileFromCweeStr(out);\\nsw.Stop; submitToast(\\\"Script3\\\", \\\"${sw.Seconds_Passed}\\\"); \\nreturn sw.Seconds_Passed; \",\"label\":\"New Script Node\",\"uniqueName\":\"WW_14_43_52\",\"mode\":\"Editing\",\"HorizontalOffset\":\"0.791436208893349*\",\"VerticalOffset\":\"0.040471224246552*\",\"Width\":\"1158.56079101563\",\"Height\":\"1055.37463378906\",\"inbounds\":{\"\":\"WW_70_96_19\"}}"],"canvasWidth":4918.20556640625,"canvasHeight":2097.595947265625,"ScriptName":"New Script"}