'---------------------------------------------- '---------Creation Information----------------- '---------------------------------------------- ' 'Name: osblinp 'Author: Cindy How 'Date: 6/97 ' '---------------------------------------------- '------------Purpose/Description--------------- '---------------------------------------------- ' 'This script will take the .dbf files created 'in previous steps and create the naUTilus input 'file. The input file will be called "osbl.in" ' '----------------------------------------------- '-------------------Input----------------------- '----------------------------------------------- ' '1. Node theme '2. Attribute table of the Node theme '3. Branch theme '4. Attribute table of the Branch theme '5. oinflow.dbf table '6. osblcon.dbf table '7. obr.dbf table '8. odrops.dbf table ' '----------------------------------------------- '------------------Output----------------------- '----------------------------------------------- ' '1. Text input file, "osbl.in" ' ' '----------------------------------------------- '-------------------Notes----------------------- '----------------------------------------------- ' 'The variables InList, InDefault, and OutList are 'temporary and used at several points in the script. 'They take on new values several times. ' '----------------------------------------------- '---------Get Initial Information--------------- '----------------------------------------------- TheProject = av.GetProject TheView = av.GetActiveDoc NdTheme = theview.Findtheme("onode.shp") BrTheme = TheView.Findtheme("obranch.shp") NodeTab = NdTheme.GetFtab BranchTab = BrTheme.GetFtab FTabName = av.GetProject.FindDoc("oinflow.dbf") FlowTab = FTabName.GetVtab CTabName = av.GetProject.FindDoc("osblcon.dbf") ConnTab = CTabName.GetVtab BTabName = av.GetProject.Finddoc("obrtab.dbf") BrTab = BTabName.GetVtab DropName = av.GetProject.FindDoc("odrops.dbf") DropTab = DropName.GetVtab '----------------------------------------------- '------------------Find Fields------------------ '----------------------------------------------- 'In BrTab BFld = BrTab.FindField("Branch") LFld = BrTab.Findfield("Length") DFld = BrTab.Findfield("Diameter") SFld = BrTab.FindField("Slope") 'In flowtab ConFld = flowtab.FindField("Branch") FlFld = flowtab.FindField("Flow") TempFld = flowtab.Findfield("Temperat") CFld = flowtab.FindField("Concentra") OilFld = flowtab.FindField("Oil_frac") 'InConnTab Fld1 = ConnTab.FindField("Cola") Fld2 = ConnTab.FindField("Colb") 'InNodeTab NNumFld = NodeTab.Findfield("Node") ArcFld = NodeTab.Findfield("Arc_") TypeFld = NodeTab.Findfield("Node_Type") JFld = NodeTab.FindField("Junction") 'InBranchTab BrFld = BranchTab.FindField("Osbl_") FFld = BranchTab.Findfield("Fnode_") 'InDropTab DNdFld = DropTab.FindField("Node") DBrFld = DropTab.Findfield("Branch") DHtFld = DropTab.FindField("Height") DTWDFld = DropTab.FindField("Tailwater") '----------------------------------------------- '----------------Make Text File----------------- '----------------------------------------------- NewFile = "osbl.in".AsFileName LFile = LineFile.Make(NewFile,#File_Perm_write) Lfile.WriteElt("Number of branches") numbr = 0 For each record in Brtab numbr = numbr + 1 end LFile.WriteElt(numbr.AsString) LFile.WriteElt("Number of Nodes") numnode = 0 juncnt = 0 For each record in Nodetab Nd = NodeTab.ReturnValue(NNumFld,record) if (nd < 1) then else numnode = numnode + 1 end Junc = NodeTab.ReturnValue(JFld,record) if (Junc = 1) then juncnt = juncnt + 1 else end end LFile.WriteElt(numnode.AsString) Lfile.WriteElt("Last branch, Last node") 'finds the last node in the system by the naUTilus numbering system arclist = list.make TypeList = list.make For each record in NodeTab arcnum = NodeTab.ReturnValue(ArcFld,record) ntype = NodeTab.ReturnValue(TypeFld,record) ArcList.Add(arcnum) TypeList.Add(ntype) end IdxNum = TypeList.FindByValue(2) arcid = ArcList.Get(IdxNum) arcidx = arcid - 1 LNodeAv = BranchTab.ReturnValue(FFld,arcidx) LNodeAvIdx = LNodeAv - 1 LastNode = NodeTab.ReturnValue(NNumFld,LNodeAvIdx) 'finds last branch in the system. LastBranch = NodeTab.ReturnValue(ArcFld,IdxNum) LFile.WriteElt(LastBranch.AsString+","+LastNode.AsString) 'TAG! Need to count number of manholes numman = numnode - juncnt LFile.WriteElt("Number of manhole covers, number of openings per manhole, opening area (m2)") 'User prompt for manhole characteristics InList = {"No. of openings per cover","opening area (m2)"} InDefault = {"4","5.1e-4"} OutList = MsgBox.MultiInput("Enter manhole characteristics","User Input",InList,InDefault) 'write manhole characteristics LFile.WriteElt(numman.AsString+","+Outlist.Get(0).AsString+","+Outlist.Get(1).AsString) 'TAG-Need to count number of junctions with no manholes, enter node numbers LFile.WriteElt("Number of junctions with no manholes") LFile.WriteElt(juncnt.AsString) LFile.WriteElt("Enter node number for junctions with no manholes") For each record in NodeTab junc = NodeTab.ReturnValue(JFld,record) If (junc = 1) then JuncNode = NodeTab.ReturnValue(NNumFld,record) LFile.WriteElt(JuncNode.AsString) else end end 'User Prompt for wind speed LFile.WriteElt("Ambient wind velocity (m/s)") wspeed = MsgBox.Input("Enter the ambient wind speed (m/s)","User Input","1") 'write wind speed LFile.WriteElt(wspeed.AsString) 'User prompt for ambient conditions InList = {"Ambient Temperature (C)","Relative humidity"} InDefault = {"25","0.5"} OutList = MsgBox.MultiInput("Enter the Ambient Conditions","User Input",InList,InDefault) 'write ambient conditions LFile.WriteElt("Ambient Temperature (C) and relative humidity") LFile.WriteElt(OutList.Get(0).AsString+","+OutList.Get(1).AsString) 'prompt user to input Henry's Law method MethodList = {"Hc=exp(A-B/T)","Hc at known T, adjusted using Antoine's constants","VP/Sol using Antoine's constants","Hc=constant"} 'MethodList = {"1","2","3","4"} meth = Msgbox.ChoiceAsString(MethodList,"Select the method used to determine Henry's constant:","Henry's Law Constant") MethodIdx = MethodList.FindByValue(meth) Method = MethodIdx + 1 LFile.WriteElt("Henry's Law Constant - Method 1,2,3,4") LFile.WriteElt(Method.AsString) 'TAG! Find better default values for defaults below! 'Prompt for correct variables (dependent on Method) If (Method = 1) then InLabels = {"A","B"} InDefaults = {"1","1"} OutList = Msgbox.MultiInput("Enter the values of A and B (Hc = exp(A-B/T))","Method 1",InLabels,InDefaults) check = OutList.Count If (check > 0) then LFile.WriteElt(Outlist.Get(0).AsString+","+Outlist.Get(1).AsString) else MsgBox.Info("Error: Input file will not be complete. Re-run the script.","Error") exit end elseif (Method = 2) then InLabels = {"Hc","T in C","Antoine's A","Antoine's B","Antoine's C"} InDefaults = {"0.5","25","1","1","1"} Outlist = Msgbox.MultiInput("Enter the Values of Hc at a known temperature, the known temperature, and Antoine constants A,B, and C. (Antoine constants for T in K, giving vapor Presure in mmHg","Method 2",InLabels,InDefaults) check = OutList.Count If (check > 0) then LFile.WriteElt(Outlist.Get(0).AsString+","+Outlist.Get(1).AsString+","+Outlist.Get(2).AsString+","+Outlist.Get(3).AsString+","+Outlist.Get(4).AsString) else MsgBox.Info("Error: Input file will not be complete. Re-run the script.","Error") exit end elseif (Method = 3) then InLabels = {"A","B","C","Solubility (g/L)","Molecular Weight (g/mol)"} InDefaults = {"1","1","1","1","100"} OutList = MsgBox.MultiInput("Enter the values of Antoine's A, B, and C, solubility, and MW","Method 3",InLabels,InDefaults) check = OutList.Count If (check > 0) then LFile.WriteElt(Outlist.Get(0).AsString+","+Outlist.Get(1).AsString+","+Outlist.Get(2).AsString+","+Outlist.Get(3).AsString+","+Outlist.Get(4).AsString) else MsgBox.Info("Error: Input file will not be complete. Re-run the script.","Error") exit end elseif (Method = 4) then InLabels = {"Hc"} InDefaults = {"0.5"} OutList = MsgBox.MultiInput("Enter the Henry's Constant","Method 4",Inlabels,InDefaults) check = OutList.Count If (check > 0) then LFile.WriteElt(Outlist.Get(0).AsString) else MsgBox.Info("Error: Input file will not be complete. Re-run the script.","Error") exit end else MsgBox.Info("Error: Input file will not be complete. Re-run the script.","Error") exit end 'User Prompt for diffusivities InList = {"Liquid Phase Diffusivity (cm2/s)","Gas Phase Diffusivity (cm2/s)"} InDefault = {"1.0e-6","0.1"} outList = MsgBox.MultiInput("Enter the Diffusivities","User Input",InList,InDefault) 'write diffusivities Lfile.WriteElt("Liquid Diffusivity, Gas Diffusivity") LFile.WriteElt(OutList.Get(0).AsString+","+OutList.Get(1).AsString) 'User prompt for presence of oil oilList = {"No oil present","Oil present only at surface","Oil present and dispersed (not at surface)"} oilcheck = MsgBox.ChoiceAsString(OilList,"Indicate presence and condition of oil","User Input").AsString oilIdx = OilList.FindbyValue(oilcheck) oilcond = oilidx + 1 LFile.WriteElt("1 = no oil, 2 = oil only at surface") LFile.WriteElt("3 = oil only dispersed, not at surface") LFile.WriteElt(oilcond.AsString) LFile.WriteElt("If oil is present, read Kow, density, oil MW (else, empty)") if (oilcond > 1) then InLabels = {"Kow","Oil density (g/m3)","Oil molecular weight (g/mol)"} InDefaults = {".5","20","100"} OutList = MsgBox.MultiInput("Enter oil characteristics","User Input",InLabels,InDefaults) LFile.WriteElt(Outlist.Get(0).AsString+","+Outlist.Get(1).AsString+","+Outlist.Get(2).AsString) else end 'fill dummy variable lines (5 of them) LFile.WriteElt("Indicate method of determining vapor pressure if oil is present") LFile.WriteElt("Method 1-Antoine's constants") LFile.WriteElt("Enter A,B,C for T in K giving VP in mmHg") LFile.WriteElt("Method 2-Vapor Pressure = constant") LFile.WriteElt("Enter Vapor Pressure") if (oilcond > 1) then MethList = {"Antoine's constants","Constant vapor pressure"} oilmeth = msgbox.ChoiceAsString(MethList,"Indicate method of calculating vapor pressure","User Input").AsString methind = MethList.findByValue(oilMeth) indnum = methind + 1 if (indnum = 1) then InLabels = {"A","B","C"} InDefaults = {"1","1","1"} Outlist = MsgBox.MultiInput("Enter the Antoine's constants (for T in K, giving vapor pressure in mmHg)","User Input",InLabels,InDefaults) LFile.WriteElt(Outlist.Get(0).AsString+","+Outlist.Get(1).AsString+","+Outlist.Get(2).AsString) else VapPres = MsgBox.Input("Enter the vapor pressure (atm)","User Input","1") Lfile.WriteElt(VapPres.AsString) end else end 'do not use default reach length, enter length, diameter, and slope for each reach 'may need to change this later (6/11/97) LFile.WriteElt("Enter 1 to change default reach characteristics") LFile.WriteElt("1") LFile.WriteElt("Number of branches to be modified") Lfile.Writeelt("Number, Length, Diameter, slope for each branch") LFile.WriteElt(numbr.AsString) for each record in BrTab Br = BrTab.ReturnValue(BFld,record) Len = BrTab.ReturnValue(LFld,record) Diam = BrTab.ReturnValue(DFld,record) Slope = BrTab.ReturnValue(SFld,record) LFile.WriteELT(br.AsString+","+diam.AsString+","+len.AsString+","+Slope.AsString) end 'user input - indicate P&P or OEG LFile.WriteElt("1 = Parkhurst&Pomeroy, 2 = Owens-Edwards-Gibbs") ChList = {"Parkhurst & Pomeroy","Owens-Edwards-Gibbs"} ch = Msgbox.ChoiceAsString(ChList,"Calculate using:","User Input").AsString ChInd = ChList.FindByValue(ch) Chnum = chInd + 1 LFile.WriteElt(Chnum.AsString) 'Fill dummy variables (4 lines) LFile.WriteElt("Enter no. of branches connected to node i") LFile.WriteElt("Branch number, kind of connection") LFile.WriteElt("Enter no. of branches connected to node i + 1, etc...") LFile.WriteElt("Branch number, kind of connection") LFile.WriteElt("...1 for inflow, -1 for outflow") for each record in ConnTab columna = ConnTab.ReturnValue(Fld1,record) columnb = ConnTab.ReturnValue(Fld2,record) If (columnb = 0) then Lfile.WriteElt(columna.AsString) else LFile.WriteElt(columna.AsString+","+columnb.AsString) end end numdrops = 0 For each record in Droptab numdrops = numdrops + 1 end chList = {"Nakasone","WATER8"} dmethod = MsgBox.ChoiceAsString(chList,"Choose the method for calculating emissions at drop structures.","User Input") ChIndex = ChList.FindByValue(dmethod) ChNum = ChIndex + 1 LFile.WriteElt("Number of drops, Nakasone(1)/WATER8(2)") LFile.writeElt("enter node, branch, drop height (m), tailwater depth (m) for each drop") LFile.WriteElt(numdrops.AsString+","+ChNum.AsString) If (numdrops = 0) then else For each record in DropTab DrNode = DropTab.ReturnValue(DNdFld,record) DrBranch = DropTab.ReturnValue(DBrFld,record) DrHeight = DropTab.ReturnValue(DHtFld,record) DrTWD = DropTab.ReturnValue(DTWDFld,record) LFile.WriteElt(DrNode.AsString+","+DrBranch.AsString+","+DrHeight.AsString+","+DrTWD.AsString) end end LFile.WriteElt("Number of nodes at which flow enters the system") FlowCount = 0 For each record in FlowTab FlowCount = FlowCount + 1 end LFile.WriteElt(FlowCount.AsString) LFile.WriteElt("Enter Branch Number,") LFile.WriteElt("Flow rate (L/s), Temperature (C), Concentration (mg/L), and oil fraction by volume") for each record in flowtab conn = flowtab.ReturnValue(ConFld,record).AsString rate = flowtab.ReturnValue(FlFld,record).AsString temp = flowtab.ReturnValue(TempFld,record).AsString Conc = flowtab.ReturnValue(CFld,record).AsString Oil = flowtab.ReturnValue(OilFld,record).AsString LFile.WriteElt(conn+","+rate+","+temp+","+conc+","+oil) end '----------------------------------------------- '----------------------END---------------------- '-----------------------------------------------