Document ID: EPA-HQ-OW-2022-0801-0572
Agency: epa
Document Type: Supporting & Related Material
Title: 
Posted Date: 2023-12-06T05:00Z

--------------------------------------------------------------------------------
SafeWater LCR User Guide and Description of Source Code
This memo describes how to install and use SafeWater LCR to 1) create a sample population of public water systems and 2) run the different cost models for the previous rule and final rule. The memo describes the pdf versions of the source code used for SafeWater LCR.
    Installing and Using SafeWater LCR
The SafeWater LCR executable program and most of the associated data has been provided as a zip file titled SafeWaterLCR_Executables&DataFiles. The zip file contains the SafeWater LCR executable (SafeWaterRun.exe), the configuration settings (config.ini), and a folder containing the following required data files:
 "Data" 
 High bound estimate access databases for LCR, LCRR, and proposed LCRI in a "High_Database" folder
 LCR_DataRequest_high.accdb
 LCR_DataRequest_high.xlsm
 LCRR_DataRequest_high.accdb
 LCRR_DataRequest_high.xlsm
 LCRI_DataRequest_high.accdb
 LCRI_DataRequest_high.xlsm
 Low bound estimate access databases for LCR, LCRR, and proposed LCRI in a "Low_Database" folder
 LCR_DataRequest_low.accdb
 LCR_DataRequest_low.xlsm
 LCRR_DataRequest_low.accdb
 LCRR_DataRequest_low.xlsm
 LCRI_DataRequest_low.accdb
 LCRI_DataRequest_low.xlsm
 the cost equations spreadsheets for the LCR, LCRR, and proposed LCRI 
 LCR_Baseline.xlsx (LCR_Baseline_v8.xlsx)
 LCRR_Baseline.xlsx (LCRR_Baseline_v17.xlsx)
 LCRI_Option.xlsx (Working_Option_v22.xlsx)
 SDWIS Inventory 
 sdwis_2023.xlsx
 Unique data variables for the school sampling program
 state_school_samp_data.xlsx
 Unique data for systems service greater than 1M customers
 VLSEntryPointValues.xlsx
 VLSSystemData.xlsx
The steps to install SafeWater LCR are as follows:
 Extract the files from the zip file titled SafeWaterLCR_Executables&DataFiles and save in a folder named "SafeWaterLCR."
The steps to use SafeWater LCR are as follows:
 Create the sample: This creates the CSV files of the public water system variables that SafeWater LCR reads based on SDWIS variables and the database variables. A sample must be created for each previous rule and final rule option the user wishes to generate.
 Open the executable LCRSample in the "SafeWaterLCR" folder; this will pull up a prompt that allows the user to create the sample files.
 In the "Excel Input" field, load the SDWIS_CWS_2016_Q3 (sdwis_2023.xlsx) file saved in the "Data" folder.
 Select LCRR in the "Baseline" dropdown. This selection is currently ignored since the sample creation run will create all the necessary sample input files.
 Select LCRI in "Option Name" dropdown.
 Enter a value in "Sample Name" (5-6 characters).
 In the "LCR Baseline Costing Logic Workbook" field load LCR_Baseline_v8.xlsx.
 In the "LCR Baseline Variable Database" field, load the LCR_DataRequest_High.accdb file to create the High LSLs sample files.
 In the "LCRR Baseline Costing Logic Workbook" field, load LCRR_Baseline_v17.xlsx.
 In the "LCRR Baseline Variable Database" field, load LCRR_DataRequest_High.accdb.
 In the "Option Costing Logic Workbook" field, load Working_Option_v22.xlsx.
 In the "Option Variable Database" field, load LCRI_DataRequest_High.accdb.
 In the "Minimum # of PWS per Size/SW category" to run a replicated sample, which is necessary to capture the variability contained in the database variables, enter the minimum number of replicated systems desired and uncheck the "Do not replicate" field (the results presented in the final rule economic analysis relied on 5,000 as the minimum number of systems per size and source water category).
 In the "Create Proxy PWS Records" field, check the box to create the proxy records necessary to examine the cost of the small system and non-transient noncommunity water system (NTNCWS) flexibility final rule requirement.
 In the "Small Proxy Cutoff Population" field, enter the appropriate desired population threshold below which the small system flexibilities will be applied. The appropriate value should be 10000.
 Ensure that the "Make LCR Baseline", "Make LCRR Baseline" and "Make Option" fields are selected in order to generate a sample for the previous rule and the final rule.
 Select the "LSL Level" dropdown to High
 Ensure that the "PWS90Pct Bp1" and the "PWS90Pct Bp2" fields contain 10 and 15, respectively. These fields are currently not used.
 Ensure that the "Create Profile Sample" field is unchecked unless the user requires a sample of the sample output to be generated.
 Click "Make Sample" to create PWS samples for the previous and final rule.
 The generated PWS samples for the previous rule and the final rule option will be saved in the "Data" folder.
Note to create the Low LSLs sample files, choose the *_DataRequest_Low.accdb files  		for the "LCR Baseline Variable Database", "LCRR Baseline Variable Database" and 		"Option Variable Database" inputs.
 Generate the cost and benefit results for the preferred option run:
 Open the executable SafeWaterLCR in the "SafeWaterLCR" folder; this will pull up a prompt that allows the user to tailor the SafeWater LCR run.
 If a pop-up appears requesting confirmation that the user wants to load a saved configuration, select "No."
 In the "Run Name" field, give the run a name.
 For the "Baseline Name" dropdown, select LCRR. For the "Option Name" dropdown, select LCRI.
 Ensure that the "CodeSite logging" and "DELAWARE" fields are unchecked. These fields and the "Test Parser" button above are used for debugging. Ensure the "Use Compiled Cost" is checked.
 In the "Run Description" field, provide an optional description, which will be saved in the log file generated by that run of the SafeWaterLCR program.
 In the "CVDDR," "IQVal," "IQDR," and "Child BL" fields enter the appropriate values for the desired benefit options, with 0 for normal.
 Ensure that the "No BL Averaging" field is unchecked, unless the user requires a run with averaged blood levels.
 For the "LCR Baseline Database" field, load LCR_DataRequest_High.accdb.
 Ensure "Use LCR Baseline" is checked.
 For the "Baseline SDWIS Sample File" field, load LCRRBaseline_Rep5K_high.csv.
 For the "Option SDWIS Sample File" field, load LCRIRep5K_high.csv.
 For the "Baseline Costing Logic Workbook" field, load LCRR_Baseline_v17.xlsx.
 For the "Baseline Variable Database" field, load LCRR_DataRequest_High.accdb.
 For the "Option Costing Logic Workbook" field, load Working_Option_v22.xlsx.
 For the "Option Variable Database" field, load LCRI_DataRequest_High.accdb.
 For the "Population" field, select the desired public water system option (Both).
 In the "Discount" field, select the desired discount rate (i.e., 3% or 7%).
 In the "Small Proxy Cutoff Population" field, enter the appropriate desired population threshold below which the small system flexibilities will be applied (3300).
 For the "LCRI Option ALE" dropdown, select the appropriate value. (10)
 For the "WQP Monitoring Size Cutoff" dropdown, select nothing. I don't think this is used.
 For the "LCRI LSL Option" dropdown, select the appropriate value. (1)
 For the "Temp POU Option" dropdown, select the appropriate value. (3)
 For the "LSLR Rate" dropdown, select the appropriate value. (0.10)
 Select Filters for LSL/Uknown appropriately.
 Select Low / High radio buttons to match LSLs option.
 For the "LSLR Deferral Cap" dropdown, select the appropriate value. (10000)
 In the "School option" field, select the desired school option. (school_3a)
 Ensure that the "No Random," "Output Lead Bins," "DebugOut," and "CCT Partial to Full" fields are unchecked. These are used for debugging.
 Ensure that the "Small System Flexibility" field is checked.
 In the "CCT Cost Equations" field, select the desired CCT cost equations. (High)
 Select either "Full Run" to generate the results for the incremental run, "Baseline Only" to generate the results for the previous rule, or "Option Only" to generate the results for the final rule.
 Ensure that the "Micro Output" and "Undiscounted Ben by Year" fields are unchecked. These are used for debugging.
 Ensure Run Adult Benefits is checked.
 Click "Run Model" to begin the SafeWater LCR run.
 The results will be saved in the "User" folder within the "SafeWaterLCR" parent folder.
 Multiple runs can occur at once. To do so, minimize the existing SafeWater LCR window and repeat the above steps.
SafeWater LCR Source Code
In addition to the SafeWater LCR executables and user guide, the EPA is providing pdfs of the Delphi code used for SafeWater LCR in the zip file titled SafeWaterLCR_sourcecode, which is available in the LCRR docket (EPA-HQ-OW-2017_0300) and on the EPA website at https://www.epa.gov/ground-water-and-drinking-water/final-revisions-lead-and-copper-rule. 
In addition to Delphi 11.2 source code, the following third party components are required to compile the code:
:: HtmlViewer-HtmlViewer-11.7
:: CodeSite_5_Express_RX101
Links to the third party vendors are provided at the end of this memo.
The file structure for the zip drive SafeWaterLCR_sourcecode is as follows:
 The code used for the SafeWater LCR program is contained in the folders "Code," "codeLCRR," and "uiLCRR."
 The code used for the SafeWater LCR sample creation is contained in the folders "LCRISample," "Code," and "codeLCRR."
Third Party Links
HtmlViewer-HtmlViewer-11.7: https://github.com/BerndGabriel/HtmlViewer
CodeSite_5_Express_RX101: https://www.embarcadero.com/products/delphi