equinor / equinor/neqsim-python

Java issues

Aperta
#339 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
113
Fork
28
Merge medio
1m
PR unite (30g)
1

Descrizione

Hello, Im trying to run a code using neqsim for plotting phase envelope of a CO2 mixture, but I keep getting the following error:

**AttributeError: Java package 'neqsim' is not valid**

I have in Environment Variables:

C:\Users\xxx\AppData\Local\Programs\Eclipse Adoptium\jdk-25.0.1.8-hotspot\bin

I have installed Eclipse Temurin as suggested in the description, and I have also installed jpype by using conda install -c conda-forge jpype1. I have also given the paths in the code as shown below, but I keep getting the same error: **AttributeError: Java package 'neqsim' is not valid**

Please help, I dont know what else to do.

import os
import jpype
import matplotlib.pyplot as plt

# -----------------------------
# 1) JVM path (from JPype)
# -----------------------------
jvm_path = jpype.getDefaultJVMPath()
print("Using JVM:", jvm_path)

# -----------------------------
# 2) NeqSim JAR paths (from your dir output)
# -----------------------------
jar_java11 = r"C:\Users\xxx\anaconda3\Lib\site-packages\neqsim\lib\java11\neqsim-3.1.3.jar"
jar_java8 = r"C:\Users\xxx\anaconda3\Lib\site-packages\neqsim\lib\java8\neqsim-3.1.3-Java8.jar"

# Join them into a single classpath string
classpath = os.pathsep.join([jar_java11, jar_java8])
print("Using classpath:", classpath)

# -----------------------------
# 3) Start JVM *with* NeqSim jars
# -----------------------------
if not jpype.isJVMStarted():
jpype.startJVM(
jvm_path,
"-ea",
f"-Djava.class.path={classpath}",
convertStrings=False,
)
print("JVM started with NeqSim jars")

# -----------------------------
# 4) Now import NeqSim thermo tools
# (do NOT import neqsim before startJVM)
# -----------------------------
from neqsim.thermo.thermoTools import *

# -----------------------------
# 5) Build CO2–N2 mixture and plot PT envelope
# -----------------------------
gas = fluid("srk") # SRK EOS
gas.addComponent("CO2", 0.7) # 70% CO2
gas.addComponent("nitrogen", 0.3) # 30% N2
gas.setMixingRule(2) # classic mixing rule

plt.figure(figsize=(8, 6))
phaseenvelope(gas, True) # True => P–T envelope plot

plt.title("P–T phase envelope – CO$_2$/N$_2$ (0.7 / 0.3)")
plt.xlabel("Temperature [K]")
plt.ylabel("Pressure [bar]")
plt.show()

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia leggendo il punto di ingresso documentato per l’importazione Python `neqsim.thermo.thermoTools` e la configurazione di avvio della JVM JPype mostrata nell’issue. Esegui l’esempio fornito con i percorsi dei JAR di NeqSim indicati e verifica se il pacchetto `neqsim` diventa disponibile. L’attività è completata quando l’esempio viene importato correttamente e raggiunge la chiamata per il tracciamento dell’inviluppo di fase.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java, python
Ambito
backend, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.