Skip to content

Chore/replace ejml with ojalgo - #2263

Open
asmfstatoil wants to merge 19 commits into
masterfrom
chore/replace-ejml-with-ojalgo
Open

Chore/replace ejml with ojalgo#2263
asmfstatoil wants to merge 19 commits into
masterfrom
chore/replace-ejml-with-ojalgo

Conversation

@asmfstatoil

Copy link
Copy Markdown
Collaborator

Pull Request

Thank you for contributing to NeqSim! Please complete the following checklist before requesting review:

  • Confirm ./mvnw test runs successfully
  • Verify code formatting using Checkstyle
  • Update any relevant docs/README
  • Link to an associated issue or discussion

See CONTRIBUTING.md for the full contribution process.

@asmfstatoil
asmfstatoil requested a review from EvenSol as a code owner June 7, 2026 20:33
@asmfstatoil
asmfstatoil requested review from Copilot and removed request for EvenSol June 7, 2026 20:33
@asmfstatoil
asmfstatoil force-pushed the chore/replace-ejml-with-ojalgo branch from 7123f59 to 47306d5 Compare June 7, 2026 20:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces EJML with ojAlgo as the primary linear algebra backend across flash operations, process equipment solvers, and related tests, updating Maven dependencies accordingly.

Changes:

  • Swap Maven dependency from org.ejml:ejml-all to org.ojalgo:ojalgo (incl. Java 8 pom).
  • Migrate several linear algebra implementations in thermo/process codepaths (LU, SVD, eigen) from EJML to ojAlgo / Commons Math.
  • Add JUnit tagging (@Tag("LinearAlgebra")) to group solver/benchmark tests affected by the dependency change.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/test/java/neqsim/thermodynamicoperations/util/example/CriticalPointFlashTest.java Adds LinearAlgebra tag; introduces trailing blank lines at EOF.
src/test/java/neqsim/thermodynamicoperations/flashops/TPmultiflashTest.java Tags test class for linear algebra grouping.
src/test/java/neqsim/thermodynamicoperations/flashops/NewtonSolverAnalysisTest.java Replaces EJML benchmarking code with ojAlgo equivalents; adds LinearAlgebra tag.
src/test/java/neqsim/thermo/phase/GaussianEliminationTest.java Replaces EJML inversion/solve comparisons with ojAlgo LU-based reference.
src/test/java/neqsim/process/equipment/reactor/GibbsReactorAlgorithmTest.java Tags tests; minor formatting cleanup.
src/test/java/neqsim/process/equipment/network/PipelineNetworkDocExamplesTest.java Tags doc-compilation test for linear algebra grouping.
src/test/java/neqsim/process/equipment/network/NetworkLinearSolverTest.java Tags network solver test for linear algebra grouping.
src/main/java/neqsim/thermodynamicoperations/flashops/TPmultiflash.java Replaces EJML-based solves/determinant/pinv with ojAlgo LU/SVD and primitive-array helpers.
src/main/java/neqsim/thermodynamicoperations/flashops/SysNewtonRhapsonTPflash.java Migrates the preallocated Newton solve loop from EJML to ojAlgo LU.
src/main/java/neqsim/thermodynamicoperations/flashops/CriticalPointFlash.java Replaces EJML eigen decomposition with ojAlgo eigen solver and array-based quadratic form.
src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java Removes EJML imports and introduces an in-file EJML-compat shim backed by ojAlgo.
src/main/java/neqsim/thermo/phase/PhaseSrkCPAs.java Removes leftover EJML-related commented imports.
src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java Removes EJML imports and introduces an in-file EJML-compat shim backed by ojAlgo (incl. invert).
src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java Removes EJML imports and introduces an in-file EJML-compat shim backed by ojAlgo.
src/main/java/neqsim/process/util/reconciliation/DataReconciliationEngine.java Replaces EJML SimpleMatrix usage with ojAlgo stores and LU-based solve helper.
src/main/java/neqsim/process/equipment/reactor/GibbsReactor.java Replaces EJML matrix operations with ojAlgo (LU/SVD/invert/pinv) and helper conversion methods.
src/main/java/neqsim/process/equipment/network/NetworkLinearSolver.java Migrates dense solver path from EJML to ojAlgo; “sparse” path now dispatches to dense backend.
src/main/java/neqsim/physicalproperties/interfaceproperties/surfacetension/GTSurfaceTensionODE.java Replaces EJML SVD/nullspace + LU solves with Apache Commons Math linear algebra.
pomJava8.xml Swaps EJML dependency for ojAlgo in Java 8 build pom.
pom.xml Swaps EJML dependency for ojAlgo in main build pom.
.github/workflows/publish_to_maven_central.yml Removes workflow step that cleared EJML from Maven cache.
.github/copilot-instructions.md Updates dependency description text from EJML to ojAlgo (spelling/casing adjusted).

Comment thread src/main/java/neqsim/process/equipment/reactor/GibbsReactor.java Outdated
Comment on lines +395 to +402
private void solveLinear(double[][] matrix, double[] rhs, double[] result) {
RealMatrix a = new Array2DRowRealMatrix(matrix, false);
DecompositionSolver solver = new LUDecomposition(a).getSolver();
RealVector x = solver.solve(new ArrayRealVector(rhs, false));
for (int i = 0; i < result.length; i++) {
result[i] = x.getEntry(i);
}
}
Comment thread src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java Outdated
Comment thread src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java Outdated
Comment thread .github/copilot-instructions.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 8 comments.

Comment on lines +1820 to +1831
private double conditionP2(double[][] matrix) {
Primitive64Store matrixStore = toStore(matrix);
SingularValue<Double> svd = SingularValue.PRIMITIVE.make(matrixStore);
if (!svd.decompose(matrixStore)) {
return Double.POSITIVE_INFINITY;
}
double maxSingular = svd.getOperatorNorm();
double minSingular = svd.getFrobeniusNorm() / Math.max(1.0, svd.getRank());
if (Math.abs(minSingular) < 1.0e-30) {
return Double.POSITIVE_INFINITY;
}
return maxSingular / minSingular;
Comment thread src/main/java/neqsim/thermo/phase/PhaseSrkCPA.java Outdated
Comment thread src/main/java/neqsim/thermo/phase/PhaseUMRCPA.java Outdated
Comment thread src/main/java/neqsim/thermo/phase/PhaseElectrolyteCPA.java Outdated
@asmfstatoil
asmfstatoil force-pushed the chore/replace-ejml-with-ojalgo branch from 5bc33f4 to 54e86f1 Compare June 8, 2026 18:51
@asmfstatoil
asmfstatoil force-pushed the chore/replace-ejml-with-ojalgo branch 2 times, most recently from 35a556c to dfdda8d Compare June 22, 2026 07:35
system.addComponent(components[h3oIndex].getComponentNumber(), molesToAdd, phasenumb);

// Set OH- to maintain Kw ≈ 10^-14 (x_H3O * x_OH ≈ 3.2e-18)
if (ohIndex >= 0) {
@asmfstatoil
asmfstatoil force-pushed the chore/replace-ejml-with-ojalgo branch from dfdda8d to 6620661 Compare June 22, 2026 07:43
asmfstatoil and others added 15 commits June 23, 2026 00:29
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants