Skip to content

The NeqSim parameter database

Even Solbraa edited this page Mar 31, 2023 · 51 revisions

NeqSim reads the model parameters (such as Tc, Pc, acentric factor, kij, etc.) from a SQL database via a JDBC connection.

By default H2 is used as the data base engine (from version 2.4.4 of neqsim) by creating an in memory database when neqsim is initiated.

A Java H2 database is embedded in the source code distribution, and is the default parameter database used by NeqSim. The access to the parameter database is controlled via the NeqSimDatabase class.

The parameter tables used by H2 are stored as CSV files. New components can be seen/added by modifying the COMP.csv file (pure component parameters). Interaction parameters can be seen/added by modifying the INTER.csv file. Please make an issue/pull request if new components should be added or parameters updated. See this pull request for an example of how to add a new component to the database.

Alternative parameter databases can be used by inserting required tables, and setting the JDBC connection in the NeqSimDatabase.class. A simple way to create a new parameter database used by NeqSim is:

  1. Create a new parameter database using the SQL script (creates a copy of the embedded Derby database and populates it with the default parameters)

  2. Modify the connection string in the [NeqSimDatabase class], eg.(https://github.com/equinor/neqsimsource/blob/master/src/main/java/neqsim/util/database/NeqSimDataBase.java):

neqsim.util.database.NeqSimDataBase.setDataBaseType("mySQL"); neqsim.util.database.NeqSimDataBase.setConnectionString("jdbc:mysql://tr-w33:3306/neqsimthermodatabase");

The database contains all parameters needed for doing simulations with NeqSim database. Examples of tables in the database are the COMP table with the pure component parameters (TC, PC, acentric factor) and the INTER table with binary interaction coefficients (kij).

The NeqSim database parameter can be viewed or edited in a jdbc database viewer. The databases editor in the Eclipse IDE is typically set to view or edit the NeqSim database (the database must be extracted from the NeqSim jar library to the local disk before editing). To access the embedded database: user/pass remote/remote.

Viewing and editing parameters in Eclipse

Pure component names in embedded neqsim database: https://github.com/equinor/neqsim/blob/master/src/main/resources/neqsim_component_names.txt

Using a MySql database

Include MySql library on classpath by adding the dependency in the pom.xml.

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>8.0.27</version>
		</dependency>

Using a MS Access database

The NeqSim parameter database in MS Access format is downloadable from this link: https://github.com/equinor/neqsim/blob/master/docs/wiki/NeqSimDatabase.mdb

Add the following dependencies in the pom.xml.

                <dependency>
			<groupId>org.ojalgo</groupId>
			<artifactId>ojalgo</artifactId>
			<version>48.4.2</version>
		</dependency>
		<dependency>
			<groupId>org.xerial</groupId>
			<artifactId>sqlite-jdbc</artifactId>
			<version>3.34.0</version>
		</dependency>
		<dependency>
			<groupId>net.sf.ucanaccess</groupId>
			<artifactId>ucanaccess</artifactId>
			<version>5.0.1</version>
		</dependency>

Add the following to the NeqSimDataBase.java for the correct path to the database.

static String dataBaseType = "MSAccessUCanAccess";
  public static String connectionString =
      "jdbc:ucanaccess:///workspaces/neqsim/NewDataBase/NeqSimDatabase.mdb;memory=true";

or alternatively in your program

`neqsim.util.database.NeqSimDataBase.setDataBaseType("MSAccessUCanAccess");
neqsim.util.database.NeqSimDataBase.setConnectionString("jdbc:ucanaccess:///workspaces/neqsim/NewDataBase/NeqSimDatabase.mdb;memory=true");`

where workspaces/neqsim/NewDataBase/NeqSimDatabase.mdb is the local path to the MS Access database file.

Clone this wiki locally