Following the example Daniel provided on (https://gist.github.com/DanWBR/c355fd5420d20d960f5d084a7142cde8), I attempted to create an input file for the Pump by substituting the Heater with the Pump. However, the calculated pressure after the Pump always turns out to be zero. I would greatly appreciate your assistance in helping me understand my mistake.
Kind regards
Morteza
importpythoncompythoncom.CoInitialize()importclrfromSystem.IOimportDirectory,Path,FilefromSystemimportString,Environment# dwsimpath = "C:\\Users\\Daniel\\AppData\\Local\\DWSIM8\\"dwsimpath="C:\\Users\\Morteza\\AppData\\Local\\DWSIM\\"clr.AddReference(dwsimpath+"CapeOpen.dll")clr.AddReference(dwsimpath+"DWSIM.Automation.dll")clr.AddReference(dwsimpath+"DWSIM.Interfaces.dll")clr.AddReference(dwsimpath+"DWSIM.GlobalSettings.dll")clr.AddReference(dwsimpath+"DWSIM.SharedClasses.dll")clr.AddReference(dwsimpath+"DWSIM.Thermodynamics.dll")clr.AddReference(dwsimpath+"DWSIM.UnitOperations.dll")clr.AddReference(dwsimpath+"DWSIM.Inspector.dll")clr.AddReference(dwsimpath+"System.Buffers.dll")fromDWSIM.Interfaces.Enums.GraphicObjectsimportObjectTypefromDWSIM.ThermodynamicsimportStreams,PropertyPackagesfromDWSIM.UnitOperationsimportUnitOperationsfromDWSIM.AutomationimportAutomation3fromDWSIM.GlobalSettingsimportSettingsDirectory.SetCurrentDirectory(dwsimpath)# create automation managerinterf=Automation3()sim=interf.CreateFlowsheet()# add waterwater=sim.AvailableCompounds["Water"]sim.SelectedCompounds.Add(water.Name,water)# create and connect objectsm1=sim.AddObject(ObjectType.MaterialStream,50,50,"inlet")m2=sim.AddObject(ObjectType.MaterialStream,150,50,"outlet")e1=sim.AddObject(ObjectType.EnergyStream,100,50,"power")# h1 = sim.AddObject(ObjectType.Heater, 100, 50, "heater")h1=sim.AddObject(ObjectType.Pump,100,50,"pump")m1=m1.GetAsObject()m2=m2.GetAsObject()e1=e1.GetAsObject()h1=h1.GetAsObject()sim.ConnectObjects(m1.GraphicObject,h1.GraphicObject,-1,-1)sim.ConnectObjects(h1.GraphicObject,m2.GraphicObject,-1,-1)sim.ConnectObjects(e1.GraphicObject,h1.GraphicObject,-1,-1)sim.AutoLayout()# steam tables property packagestables=PropertyPackages.SteamTablesPropertyPackage()sim.AddPropertyPackage(stables)# set inlet stream Pressure# default properties: T = 298.15 K, P = 101325 Pa, Mass Flow = 1 kg/s# m1.SetTemperature(300.0) # Km1.SetPressure(1000000.0)# Pam1.SetMassFlow(100.0)# kg/s# set heater outlet pressure# h1.CalcMode = UnitOperations.Heater.CalculationMode.OutletTemperatureh1.CalcMode=UnitOperations.Pump.CalculationMode.OutletPressure# h1.OutletTemperature = 400 # Kh1.OutletPressure=2000000# K# request a calculationSettings.SolverMode=0errors=interf.CalculateFlowsheet2(sim)print(String.Format("Pump Heat Load: {0} kW",h1.DeltaQ))# save filefileNameToSave=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),"pumpsample.dwxmz")interf.SaveFlowsheet(sim,fileNameToSave,True)# save the pfd to an image and display itclr.AddReference(dwsimpath+"SkiaSharp.dll")clr.AddReference("System.Drawing")fromSkiaSharpimportSKBitmap,SKImage,SKCanvas,SKEncodedImageFormatfromSystem.IOimportMemoryStreamfromSystem.DrawingimportImagefromSystem.Drawing.ImagingimportImageFormatPFDSurface=sim.GetSurface()bmp=SKBitmap(1024,768)canvas=SKCanvas(bmp)canvas.Scale(1.0)PFDSurface.UpdateCanvas(canvas)d=SKImage.FromBitmap(bmp).Encode(SKEncodedImageFormat.Png,100)str=MemoryStream()d.SaveTo(str)image=Image.FromStream(str)imgPath=Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),"pfd.png")image.Save(imgPath,ImageFormat.Png)str.Dispose()canvas.Dispose()bmp.Dispose()fromPILimportImageim=Image.open(imgPath)im.show()
Dear all
Following the example Daniel provided on (https://gist.github.com/DanWBR/c355fd5420d20d960f5d084a7142cde8), I attempted to create an input file for the Pump by substituting the Heater with the Pump. However, the calculated pressure after the Pump always turns out to be zero. I would greatly appreciate your assistance in helping me understand my mistake.
Kind regards
Morteza
Hi Morteza. Change
h1.OutletPressure
to
h1.Pout