Menu

UO-01 Key not found exception : The given key was not present in the library

nihal
2022-06-06
2022-06-13
  • nihal

    nihal - 2022-06-06

    I am developing a code for python in DW-Sim using Python.NET but I am getting the error where it is saying that Key not found exception . My code is as follows -
    import numpy as np
    from scipy.integrate import solve_bvp
    import math
    import System
    from System import IO
    import matplotlib.pyplot as plt
    import pandas as pd

    defining overall mass and molar flow

    MF10 = ims1.Phases[0].Properties.molarflow #overall molar flow of heat transfer fluid
    MF20 = ims2.Phases[0].Properties.molarflow #overall molar flow of perhydrdibenzyltoluene mixture
    Tj = ims1.Phases[0].Properties.temperature #temperature of the heat transfer fluid
    Tf = ims2.Phases[0].Properties.temperature #temperature of the perhydrodibenzyltoluene
    WF10 =ims1.Phases[0].Properties.massflow #overall mass flow of heat transfer fluid
    WF20 =ims2.Phases[0].Properties.massflow #overall mass flow of perhydrdibenzyltoluene mixture
    Pf= ims2.Phases[0].Properties.pressure #Pressure on the reactor side
    feed1 = ims1
    feed2 = ims2
    pi= np.pi
    exp = np.exp
    cosh= np.cosh
    sinh = np.sinh
    log = np.log
    pd1=pd
    def dehyd(z,y):
    global feed1,feed2,pi,exp,cosh,sinh,log,dt,dh,MF10,MF20,Tj,Tf,pd1
    .
    .
    .
    .
    .
    . (Physical properties of compound and empirical equation
    .
    .
    .
    .
    .
    return np.vstack ((dC1dz,dC2dz,dC3dz,dTfdz,dTjdz,dPdz))
    def bc(ya,yb):
    global feed1,feed2,pi,exp,cosh,sinh,log,MF10,MF20,Tj,Tf
    WF1=(feed2.Phases[0].Compounds['perhydrodibenzyltoulene'].MassFlow) #mass flow rate of 18H-DBT (kg/s)
    MF1=(feed2.Phases[0].Compounds['perhydrodibenzyltoulene'].MolarFlow) #molar flow rate of 18H-DBT (mol/s)
    Tf = (feed2.Phases[0].Properties.temperature) #temperature of the perhydrodibenzyltoluene
    A1 = 1.1005251
    A2 = -0.0006384
    rho1 = (A1+(A2Tf))1000 #density of the 18H-DBT (Kg/m3)
    QDBT1 = (WF1/rho1) #Volumetric flow rate of perhydrodibenzyltoluene(m3/s)
    C0 = (MF1/QDBT1) #initial concentration of the PDBT
    Tf = feed2.Phases[0].Properties.temperature #feed temperature of perhydrodibenzyltoluene
    Tj = feed1.Phases[0].Properties.temperature # jacket temperature of diphenylether
    Pf= feed2.Phases[0].Properties.pressure #Pressure on the reactor side
    return np.array([ya[0]-C0, ya[1], ya[2] , ya[3]-Tj, yb[4]-Tf, ya[5]-Pf])
    # initial condions and boundary value
    n=150
    WF1= ims2.Phases[0].Compounds['perhydrodibenzyltoulene'].MassFlow #mass flow rate of 18H-DBT (kg/s)
    MF1= ims2.Phases[0].Compounds['perhydrodibenzyltoulene'].MolarFlow #molar flow rate of 18H-DBT (mol/s)
    A1 = 1.1005251
    A2 = -0.0006384
    rho1 = (A1+(A2Tf))1000 #density of the 18H-DBT (Kg/m3)
    QDBT1 = (WF1/rho1) #Volumetric flow rate of perhydrodibenzyltoluene(m3/s)
    C0 = (MF1/QDBT1) #initial concentration of the PDBT
    z = np.linspace(0,21,n)
    y = ([ np.full_like(z, C0), np.full_like(z, 0), np.full_like(z, 0), np.full_like(z, Tj), np.full_like(z, Tf), np.full_like(z,Pf)])
    sol=solve_bvp(dehyd,bc,z,y)
    Cend1=np.array(sol.y[0])
    Cendlength1=len(Cend1)
    Cendvalue1=Cend1[Cendlength1-1]
    Cend2=np.array(sol.y[1])
    Cendlength2=len(Cend2)
    Cendvalue2=Cend2[Cendlength2-1]
    Cend3=np.array(sol.y[2])
    Cendlength3=len(Cend3)
    Cendvalue3=Cend3[Cendlength3-1]
    Tf=np.array(sol.y[3])
    Tendlengthf=len(Tf)
    Tvaluef=Tf[Tendlengthf-1]
    Tj=np.array(sol.y[4])
    Tendlengthj=len(Tj)
    Tvaluej=Tj[Tendlengthj-1]
    Pf=np.array(sol.y[5])
    Pendlengthf=len(Pf)
    Pvaluef=Pf[Pendlengthf-1]

    output mole fraction

    Ctotal=Cendvalue1+Cendvalue2+Cendvalue3
    outy1=(Cendvalue1/Ctotal) #outlet mole fraction of 18H-DBT
    outy2=(Cendvalue2/Ctotal) #outlet mole fraction of DBT
    outy3=(Cendvalue3/Ctotal) #outlet mole fraction of Hydrogen

    output mass fraction of HTF

    outy4 = 0.99

    return output connected to port 1 and port 2

    oms1.Clear()
    oms2.Clear()
    oms2.Phases[0].Properties.temperature = System.Nullable[System.Double] (Tvaluef)
    oms1.Phases[0].Properties.temperature = System.Nullable[System.Double] (Tvaluej)
    oms1.Phases[0].Properties.pressure = ims1.Phases[0].Properties.pressure
    oms2.Phases[0].Properties.pressure = System.Nullable[System.Double] (Pvaluef)
    oms2.Phases[0].Compounds['perhydrodibenzyltoulene'].MoleFraction = System.Nullable[System.Double] (outy1)
    oms2.Phases[0].Compounds['Dibenzyltoulene'].MoleFraction = System.Nullable[System.Double] (outy2)
    oms2.Phases[0].Compounds['Hydrogen'].MoleFraction = System.Nullable[System.Double] (outy3)
    oms1.Phases[0].Compounds['diphenylether'].MoleFraction = System.Nullable[System.Double] (outy4)
    oms2.Phases[0].Properties.massflow = System.Nullable[System.Double] (WF20(outy1+outy2+outy3))
    oms1.Phases[0].Properties.massflow = System.Nullable[System.Double] (WF10
    (outy4))

    set massflow

    oms1.Phases[0].Properties.massflow = ims1.Phases[0].Properties.massflow
    oms2.Phases[0].Properties.massflow = ims2.Phases[0].Properties.massflow

    calculate remaining properties

    oms1.Calculate(True,True)
    oms2.Calculate(True,True)

    I am finding the error as UO-O1 key exception not found . The given key is not present in the library.

    @danwbr or anyone please provide in this regard

    Thank you

     

    Last edit: nihal 2022-06-10
  • nihal

    nihal - 2022-06-09

    Please check the error . It is like this

     
  • Daniel Medeiros

    Daniel Medeiros - 2022-06-09

    Compounds['perhydrodibenzyltoulene']

    is this matching the compound name exactly, including caps?

     
  • nihal

    nihal - 2022-06-10

    Yes Daniel , the compound name written in the code is matching with the material stream.

     

    Last edit: nihal 2022-06-10
  • nihal

    nihal - 2022-06-11

    @danwbr please look at the attached file

     
  • nihal

    nihal - 2022-06-13

    @danwbr Is the "solve_bvp" not functioning in the DWSim Python.NET