Skip to content

Commit

Permalink
Cleaning up PETSc code.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Eslick committed Dec 22, 2021
1 parent 76de6c5 commit c2a15b6
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 660 deletions.
31 changes: 19 additions & 12 deletions petsc/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
# README

This is a first pass at creating an AMPL executable for the PETSc solver library, allowing PETSc to be used with Pyomo. This version supports the TS (time-stepping) and SNES (nonlinear) solvers; however in the future TAO (optimization) solvers and additional features may also be supported.
This is a first pass at creating an AMPL executable for the PETSc solver library,
allowing PETSc to be used with Pyomo via the AMPL Solver Library (ALS). This
version supports the TS (time-stepping) and SNES (nonlinear) solvers; however in
the future TAO (optimization) solvers and additional features may also be
supported.

## Usage

The petsc executable solver will run like any other AMPL executable and can take the standard PETSc options. The options can be set from within Pyomo. For use with Pyomo it is easiest if the petsc executable is in your executable path.

<TODO> Will fill out later, for now see examples and PETSc docs. PETSc command line options work with the PETSc solvers. The are some additional command line arguments (see ```petsc -help```). Command line arguments can be passed through Pyomo's solver interface.
## Building

## Testing
The solver wrapper build uses the PETSc build system. On Linux, compile PETSc
with the desired features (https://petsc.org/release/install/). The ASL can be
obtained from http://www.netlib.org/ampl/solvers/. Before building the wrapper
set the following environment variables:

The included tl.nl file can be used to test the petsc solver. The problem is an old version of the IDAES MEA model, but that's not important. The initial values of variables in the file are the solution. To test the solver the initial values can be perturbed before solving the problem the new solution can be compared to the old initial values to ensure the problem solved.
* ASL_INC - directory with ASL header files
* ASL_LIB - ASL library file
* PETSC_DIR - see PETSc docs
* PETSC_ARCH - see PETSc docs

To test the petsc executable run:

petsc -s t1 -snes_monitor -perturb_test 1.1
## Usage

This multiplies the initial values by 1.1 and resolves. The results shows any differences between the new and old solutions greater than 1e-6, and the values of those variables. Depending on the value of the variables, difference of more than 1e-6 are not necessarily bad.
The SNES solvers can be used with Pyomo to solve sets of nonlinear equations
as a standard AMPL solver. Tools to use the time stepping solver with Pyomo.DAE
are under development as part of the IDAES project, and example can be found
there (https://github.com/IDAES/idaes-pse/pull/552).
141 changes: 0 additions & 141 deletions petsc/examples/dae_pyomo/car_example.py

This file was deleted.

136 changes: 0 additions & 136 deletions petsc/examples/dae_pyomo/chemakzo.py

This file was deleted.

39 changes: 0 additions & 39 deletions petsc/examples/dae_pyomo/dae_vis_example.py

This file was deleted.

Loading

0 comments on commit c2a15b6

Please sign in to comment.