Skip to content

Question about getDensity() #345

@bgrimstad

Description

@bgrimstad

Hi,

Thank you for sharing a useful software.

As a new user of neqsim-python, I am trying to figure out how to correctly access phase densities.

In the script below, I have made an example where I compare the phase densities accessed via getDensity("kg/m3"), getDensity(), and the density reported by tt.printFrame(fluid). In this case, getDensity(), without a specified unit, differs from the other two. Which unit should one expect from getDensity()?

Also, if I set a flow rate, e.g. as fluid.setTotalFlowRate(1.0, "kg/sec"), the three ways to access the densities give me three different answers. Why is this the case?

  • getDensity("kg/m3") gives a gas density of 1.10 and an oil density of 601.00
  • getDensity() gives a gas density of 48.49 and an oil density of 523.29
  • tt.printFrame(fluid) shows a gas density of 48.66 and an oil density of 601.00

I am using version 3.0.51.

from neqsim.thermo import thermoTools as tt

# Create fluid
composition = {
    "N2": 0.004,
    "CO2": 0.010,
    "methane": 0.700,
    "ethane": 0.120,
    "propane": 0.080,
    "i-butane": 0.020,
    "n-butane": 0.030,
    "nC10": 0.036,
    "water": 0.020,
}

fluid = tt.fluid("srk")
total = float(sum(composition.values()))
for name, frac in composition.items():
    fluid.addComponent(str(name), float(frac) / total)

# Set flow rate
# fluid.setTotalFlowRate(1.0, "kg/sec")

tt.TPflash(fluid, temperature=308, pressure=50, tUnit="K", pUnit="bara")

# Extract densities
densities = {}
densities_default_units = {}
for phase in range(fluid.getNumberOfPhases()):
    phase = fluid.getPhase(phase)
    densities[phase.getType().name()] = phase.getDensity("kg/m3")
    densities_default_units[phase.getType().name()] = phase.getDensity()  # Using default units

print(densities)
print(densities_default_units)

tt.printFrame(fluid)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions