'---------------------------------------------- '---------Creation Information----------------- '---------------------------------------------- ' 'Name: writeinp '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 (temporarily) will be 'called "infile.in" ' '----------------------------------------------- '-------------------Input----------------------- '----------------------------------------------- ' '1. Node theme '2. Attribute table of the Node theme '3. Branch theme '4. Attribute table of the Branch theme '5. drains.dbf table '6. nodecon.dbf table '7. brtable.dbf table '8. drops.dbf table '9. hardpipe.dbf table ' '----------------------------------------------- '------------------Output----------------------- '----------------------------------------------- ' '1. Text input file, "input.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("inodes.shp") BrTheme = TheView.Findtheme("ibranch.shp") NodeTab = NdTheme.GetFtab BranchTab = BrTheme.GetFtab DTabName = av.GetProject.FindDoc("drains.dbf") DrainTab = DTabName.GetVtab CTabName = av.GetProject.FindDoc("nodecon.dbf") ConnTab = CTabName.GetVtab BTabName = av.GetProject.Finddoc("brtable.dbf") BrTab = BTabName.GetVtab DropName = av.GetProject.FindDoc("drops.dbf") DropTab = DropName.GetVtab HPName = av.GetProject.FindDoc("hardpipe.dbf") HPTab = HPName.GetVtab '----------------------------------------------- '------------------Find Fields------------------ '----------------------------------------------- 'In BrTab LFld = BrTab.Findfield("Length") DFld = BrTab.Findfield("Diameter") SFld = BrTab.FindField("Slope") 'In DrainTab DtypeFld = DrainTab.FindField("Drain_type") ConFld = DrainTab.FindField("Connectivi") FlFld = DrainTab.FindField("Flow_rate") TempFld = DrainTab.Findfield("Temperatur") CFld = DrainTab.FindField("Concentrat") DDFld = DrainTab.FindField("Diameter") SealFld = DrainTab.Findfield("Sealed") OilFld = DrainTab.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") 'InBranchTab FFld = BranchTab.Findfield("Fnode_") 'InDropTab DNdFld = DropTab.FindField("Node") DBrFld = DropTab.Findfield("Branch") DHtFld = DropTab.FindField("Height") DTWDFld = DropTab.FindField("Tailwater") 'InHPTab HPCFld = HPTab.FindField("Connect") HPFFld = HPTab.FindField("Flow_rate") HPTFld = HPTab.FindField("Temp") HPConFld = HPTab.FindField("Conc") HPOilFld = HPTab.FindField("Oil_fraction") '----------------------------------------------- '----------------Make Text File----------------- '----------------------------------------------- NewFile = "infile.in".AsFileName LFile = LineFile.Make(NewFile,#File_Perm_write) Lfile.WriteElt("no.branches, no.nodes, no. drains, open/closed") LFile.WriteElt("1 = open/mixed, 2 = closed") numbr = 0 For each record in Branchtab numbr = numbr + 1 end numnode = 0 For each record in Nodetab Nd = NodeTab.ReturnValue(NNumFld,record) if (nd < 1) then else numnode = numnode + 1 end end numdr = 0 sealcheck = 2 for each record in drainTab numdr = numdr + 1 sealflag = DrainTab.ReturnValue(SealFld,record) if (sealflag < 2) then sealcheck = 1 else end end Lfile.WriteElt(numbr.AsString+","+numnode.AsString+","+numdr.AsString+","+sealcheck.AsString) Lfile.WriteElt("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) LFile.WriteElt(LastNode.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") 'TAG! in ISBL code, remove dummy variables (9 lines) before running! 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 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) 'User prompt for manhole characteristics InList = {"No. of pick-holes per cover","Pick-hole diameter (m)"} InDefault = {"4","0.0254"} OutList = MsgBox.MultiInput("Enter manhole characteristics","User Input",InList,InDefault) 'write manhole characteristics LFile.WriteElt("no. pickholes per cover, pickhole diameter (m)") LFile.WriteElt(Outlist.Get(0).AsString+","+Outlist.Get(1).AsString) 'User Prompt for wind speed wspeed = MsgBox.Input("Enter the ambient wind speed (m/s)","User Input","1") 'write wind speed LFile.WriteElt(wspeed.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 '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) '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 accept default reach length") LFile.WriteElt("2") LFile.WriteElt("User specified branch characteristics") Lfile.Writeelt("Length, Diameter, slope for each branch") for each record in BrTab Len = BrTab.ReturnValue(LFld,record) Diam = BrTab.ReturnValue(DFld,record) Slope = BrTab.ReturnValue(SFld,record) LFile.WriteELT(len.AsString+","+Diam.AsString+","+Slope.AsString) end LFile.WriteElt("Enter drain characteristics: type - elbow(1)/on line(2), branch/node connectivity, flowrate (L/s),") LFile.WriteElt("temperature(C), concentration (mg/L), drain diameter (m2),") LFile.WriteElt("unseald(1)/sealed(2> drain, oil vol./total vol.") for each record in Draintab type = Draintab.ReturnValue(DtypeFld,record).AsString conn = DrainTab.ReturnValue(ConFld,record).AsString rate = DrainTab.ReturnValue(FlFld,record).AsString temp = DrainTab.ReturnValue(TempFld,record).AsString Conc = DrainTab.ReturnValue(CFld,record).AsString Diam = Draintab.ReturnValue(DDFld,record).AsString Seal = DrainTab.ReturnValue(SealFld,record).AsString Oil = Draintab.ReturnValue(OilFld,record).AsString LFile.WriteElt(type+","+conn+","+rate+","+temp+","+conc+","+diam+","+seal+","+oil) end 'Fill dummy variables (4 lines) LFile.WriteElt("Enter no. of branches connected to node i, kind of node (junction/manhole)") LFile.WriteElt("...1 for junction, 2 for manhole...") LFile.WriteElt("Enter branch no., kind of connection") LFile.WriteElt("...1 for inflow, -1 for outflow") for each record in ConnTab columna = ConnTab.ReturnValue(Fld1,record).AsString columnb = ConnTab.ReturnValue(Fld2,record).AsString LFile.WriteElt(columna+","+columnb) end numdrops = 0 For each record in Droptab numdrops = numdrops + 1 end LFile.WriteElt("Number of drops") LFile.WriteElt(numdrops.AsString) LFile.writeElt("enter node, branch, drop height (m), tailwater depth (m) for each drop") 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("Enter no. of hard-piped connections") HPcount = 0 For each record in HPTab HPCount = HPCount + 1 end LFile.WriteElt(HPCount.AsString) LFile.WriteElt("Enter node connectivity, flow rate (L/s), temperature (C),") LFile.WriteElt("concentration (mg/L), oil volume/total volume") If (HPCount > 0) then For each record in HPTab HPNode = HPTab.ReturnValue(HPCFld,record).AsString HPFlow = HPTab.ReturnValue(HPFFld,record).AsString HPTemp = HPTab.ReturnValue(HPTFld,record).AsString HPConc = HPTab.ReturnValue(HPConFld,record).AsString HPFrac = HPTab.ReturnValue(HPOilFld,record).AsString LFile.WriteElt(HPNode+","+HPFlow+","+HPTemp+","+HPConc+","+HPFrac) end else end