Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PETSc not working on Mac #1523

Open
fahim831 opened this issue Nov 13, 2024 · 16 comments
Open

PETSc not working on Mac #1523

fahim831 opened this issue Nov 13, 2024 · 16 comments
Assignees
Labels
bug Something isn't working Priority:High High Priority Issue or PR

Comments

@fahim831
Copy link
Contributor

Description

I'm having errors calling the PETSc solver on my Mac. It was working in the morning and broke when I checkouted out and in to my branch. So I think the branch updated, breaking it. The lines causing the error are the call to petsc, though different calls yield different errors:

results = petsc.petsc_dae_by_time_element(
        m,
        time=m.fs.time,
        skip_initial=True,
    )

The error stack trace (only lines starting with [0]PETSC ERROR are actually tied to this):

2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: WARNING: model contains export suffix 'scaling_factor' that contains 22
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: component keys that are not exported as part of the NL file.  Skipping.
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Called fg_read, err: 0 (0 is good)
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: ---------------------------------------------------
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: DAE: 1
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Reading nl file: /var/folders/76/5rvzy41s10bbm5rpz0gq9gjw0000gp/T/tmpg408nnfu.pyomo.nl
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of constraints: 205
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of nonlinear constraints: 112
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of linear constraints: 93
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of inequalities: 0
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of variables: 211
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of integers: 0
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of binary: 0
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of objectives: 0 (Ignoring)
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of non-zeros in Jacobian: 548 
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Explicit time variable: 0
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of derivatives: 6
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of differential vars: 6
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of algebraic vars: 199
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of state vars: 205
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: Number of degrees of freedom: 0
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: ---------------------------------------------------
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: Argument out of range
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: Input string 20>o has no integer value (do not include . in it)
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: WARNING! There are option(s) set that were not used! Could be the program crashed before they were used or a spelling mistake, etc!
2024-11-12 19:44:41 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-ts_adapt_type value: basic source: command line
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-ts_max_snes_failuresdERROR: Stream handle closed with un-decoded characters in the decoder buffer
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: that was not emitted to the output stream(s):
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: b'\x820XiLo\xfe\xc31n\xa1\x1c\xb2\xfa</eY\x01b1\x82\xaa=o\x01 value: 200
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: source: command line\n[0]PETSC ERROR:   Option left: name:-ts_monitor (no
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: value) source: command line\n[0]PETSC ERROR:   Option left:
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: name:-ts_save_trajectory value: 1 source: command line\n[0]PETSC ERROR:
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: Option left: name:-ts_trajectory_type value: visualization source: command
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: line\n[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: shooting.\n[0]PETSC ERROR: Petsc Release Version 3.19.2, Jun 01, 2023
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: \n[0]PETSC ERROR: /Users/fya/.idaes/bin/petsc on a  named mac141200 by fya Tue
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: Nov 12 19:44:41 2024\n[0]PETSC ERROR: Configure options --force --with-
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: debugging=0 --with-shared-libraries=0 --with-mpi=0 --with-fortran-bindings=0
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: --download-metis --download-mumps --with-mumps-serial=1
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: --prefix=/Users/johneslick/src/petsc-dist\n[0]PETSC ERROR: #1
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: PetscOptionsStringToInt() at
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: /Users/johneslick/src/petsc-3.19.2/src/sys/objects/options.c:2244\n[0]PETSC
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: ERROR: #2 PetscOptionsGetInt() at
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: /Users/johneslick/src/petsc-3.19.2/src/sys/objects/options.c:2580\n[0]PETSC
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: ERROR: #3 PetscOptionsInt_Private() at
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: /Users/johneslick/src/petsc-3.19.2/src/sys/objects/aoptions.c:901\n[0]PETSC
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: ERROR: #4 TSSetFromOptions() at
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: /Users/johneslick/src/petsc-3.19.2/src/ts/interface/ts.c:124\n[0]PETSC ERROR:
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: #5 main() at /Users/johneslick/src/idaes-ext-build/petsc/petsc.c:256\n[0]PETSC
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: ERROR: PETSc Option Table entries:\n[0]PETSC ERROR: -AMPL (source: command
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: line)\n[0]PETSC ERROR: -dae_solve (source: command line)\n[0]PETSC ERROR:
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: -ts_adapt_type basic (source: command line)\n[0]PETSC ERROR:
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: -ts_exact_final_time matchstep (source: command line)\n[0]PETSC ERROR:
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: -ts_init_time 0.0 (source: command line)\n[0]PETSC ERROR: -ts_max_reject
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: 20>o\x01 (source: command line)\n[0]PETSC ERROR: -ts_max_snes_failuresd\x820Xi
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: Lo\xfe\xc31n\xa1\x1c\xb2\xfa</eY\x01b1\x82\xaa=o\x01 200 (source: command
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: line)\n[0]PETSC ERROR: -ts_max_time 7.0 (source: command line)\n[0]PETSC
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: ERROR: -ts_monitor (source: command line)\n[0]PETSC ERROR: -ts_save_trajectory
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: 1 (source: command line)\n[0]PETSC ERROR: -ts_trajectory_type visualization
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: (source: command line)\n[0]PETSC ERROR: -ts_type beuler (source: command
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: line)\n[0]PETSC ERROR: ----------------End of Error Message -------send entire
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: error message to [email protected]\n'
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: ERROR: Solver (asl) returned non-zero return code (-6)
2024-11-12 19:44:42 [INFO] idaes.solve.petsc-dae: ERROR: See the solver log above for diagnostic information.
Traceback (most recent call last):
  File "/Users/fya/Documents/GitHub/watertap/watertap/flowsheets/ccro/CCRO_dynamic.py", line 412, in <module>
    m = main()
  File "/Users/fya/Documents/GitHub/watertap/watertap/flowsheets/ccro/CCRO_dynamic.py", line 62, in main
    solve_dynamic(m)
  File "/Users/fya/Documents/GitHub/watertap/watertap/flowsheets/ccro/CCRO_dynamic.py", line 329, in solve_dynamic
    results = petsc.petsc_dae_by_time_element(
  File "/opt/anaconda3/envs/watertap-dev/lib/python3.8/site-packages/idaes/core/solvers/petsc.py", line 640, in petsc_dae_by_time_element
    res = solver_dae.solve(
  File "/opt/anaconda3/envs/watertap-dev/lib/python3.8/site-packages/pyomo/opt/base/solvers.py", line 628, in solve
    raise ApplicationError("Solver (%s) did not exit normally" % self.name)
pyomo.common.errors.ApplicationError: Solver (asl) did not exit normally

If I change skip_initial=True to skip_initial=False, I get this instead:

2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: No support for this operation for this object type
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: Unsupported viewer p6k
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: Petsc Release Version 3.19.2, Jun 01, 2023 
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: /Users/fya/.idaes/bin/petsc on a  named mac141200 by fya Tue Nov 12 21:34:23 2024
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: Configure options --force --with-debugging=0 --with-shared-libraries=0 --with-mpi=0 --with-fortran-bindings=0 --download-metis --download-mumps --with-mumps-serial=1 --prefix=/Users/johneslick/src/petsc-dist
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: #1 PetscOptionsGetViewer() at /Users/johneslick/src/petsc-3.19.2/src/sys/classes/viewer/interface/viewreg.c:311
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: #2 SNESMonitorSetFromOptions() at /Users/johneslick/src/petsc-3.19.2/src/snes/interface/snes.c:841
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: #3 SNESSetFromOptions() at /Users/johneslick/src/petsc-3.19.2/src/snes/interface/snes.c:1026
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: #4 main() at /Users/johneslick/src/idaes-ext-build/petsc/petsc.c:310
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: PETSc Option Table entries:
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -AMPL (source: command line)
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -snes_monitor p6k (source: command line)
2024-11-12 21:34:23 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: ----------------End of Error Message -------send entire error message to [email protected]

Lastly, if I call it with all the options I sometimes call it with, i.e.,

results = petsc.petsc_dae_by_time_element(
        m,
        time=m.fs.time,
        keepfiles=True,
        symbolic_solver_labels=True,
        ts_options={
            "--ts_type": "beuler",
            "--ts_dt": 0.1,
            "--ts_rtol": 1e-3,
            "--ts_adapt_dt_min": 1e-3,
            "--ts_adapt_dt_max": 3600,
            "--snes_type": "newtontr",
            "--ts_monitor": "",
            "-ts_adapt_monitor": "",
            "-snes_converged_reason": "",
            "snes_grid_sequence": "",
            "-pc_type": "lu",
            "--ts_save_trajectory": 1,
            "--ts_trajectory_type": "visualization",
            "--ts_max_snes_failures": 25,
            "-snes_max_it": 50,
            "-snes_rtol": 0,
            "-snes_stol": 0,
            "-snes_atol": 1e-6,
        },
        skip_initial=True
    )

I get

2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: Invalid argument
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: Unknown logical value: 1e_arm64e
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: WARNING! There are option(s) set that were not used! Could be the program crashed before they were used or a spelling mistake, etc!
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-pc_type value: lu source: command line
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-snes_atol value: 1e-06 source: command line
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-snes_converged_reason (no value) source: command line
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-snes_max_it value: 50 source: command line
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-snes_rtol value: 0 source: command line
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-snes_stol value: 0 source: command line
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-snes_type value: newtontr source: command line
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-ts_max_snes_failureshared_cache_arm64e value: 25 source: command line
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR:   Option left: name:-ts_trajectory_type value: visualization source: command line
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: Petsc Release Version 3.19.2, Jun 01, 2023 
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: /Users/fya/.idaes/bin/petsc on a  named mac141200 by fya Tue Nov 12 21:36:25 2024
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: Configure options --force --with-debugging=0 --with-shared-libraries=0 --with-mpi=0 --with-fortran-bindings=0 --download-metis --download-mumps --with-mumps-serial=1 --prefix=/Users/johneslick/src/petsc-dist
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: #1 PetscOptionsStringToBool() at /Users/johneslick/src/petsc-3.19.2/src/sys/objects/options.c:2215
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: #2 PetscOptionsGetBool() at /Users/johneslick/src/petsc-3.19.2/src/sys/objects/options.c:2414
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: #3 PetscOptionsBool_Private() at /Users/johneslick/src/petsc-3.19.2/src/sys/objects/aoptions.c:1488
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: #4 TSSetFromOptions() at /Users/johneslick/src/petsc-3.19.2/src/ts/interface/ts.c:421
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: #5 main() at /Users/johneslick/src/idaes-ext-build/petsc/petsc.c:256
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: PETSc Option Table entries:
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -AMPL (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -dae_solve (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -pc_type lu (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -snes_atol 1e-06 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -snes_converged_reason (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -snes_max_it 50 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -snes_rtol 0 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -snes_stol 0 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -snes_type newtontr (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_adapt_dt_max 3600 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_adapt_dt_min 0.001 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_adapt_monitor (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_adapt_type basic (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_dt 0.1 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_exact_final_time matchstep (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_init_time 0.0 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_max_reject 20 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_max_snes_failureshared_cache_arm64e 25 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_max_time 7.0 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_monitor (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_rtol 0.001 (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_save_trajectory 1e_arm64e (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_trajectory_type visualization (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: -ts_type beuler (source: command line)
2024-11-12 21:36:25 [INFO] idaes.solve.petsc-dae: [0]PETSC ERROR: ----------------End of Error Message -------send entire error message to [email protected]

Expected Behavior

I do not have a working trace right now but it's supposed to print the time step it's trying, whether it's an accepted time-step, how the integration is proceeding, and so on.

Steps to Reproduce

Call petsc.petsc_dae_by_time_element in an arm64 machine, e.g., M1/2/3 chip macOS.

Environment

  • OS: macOS Sequoia 15.1 (24B83)
  • Python: 3.8.19
  • WaterTAP: 1.2.dev0

Anything Else?

The error started after I checked out and back in to the operation_cc branch today.

@fahim831 fahim831 added the bug Something isn't working label Nov 13, 2024
@BarrySmith
Copy link

It appears you are using "Petsc Release Version 3.19.2, Jun 01, 2023 ".

Did you install the PETSc yourself with ./configure ? Or obtain it some other way? If you installed it your self please attach configure.log and make.log here.

In the last couple of years Apple has changed some of its compile and link infrastructure that "broke" some older versions of PETSc so the configure.log and make.log might help us determine if that is the cause of your errors.

@fahim831
Copy link
Contributor Author

fahim831 commented Nov 13, 2024

I installed petsc as part of IDAES using the instructions here. Specifically, idaes get-extensions --extra petsc . Where can I find the configure.log and make.log?

I forgot to mention I just updated my OS yesterday to Sequoia too. Not sure if it could be related.

@BarrySmith
Copy link

I'll try an installation following the instructions above tonight; I cannot use Conda at work (it costs big bucks :-().

@fahim831
Copy link
Contributor Author

Thanks! Is there a reason you need Conda to install PETSc with IDAES? It says in my link that the miniconda part is optional.

@lbianchi-lbl
Copy link
Contributor

lbianchi-lbl commented Nov 13, 2024

I'll try an installation following the instructions above tonight; I cannot use Conda at work (it costs big bucks :-().

@BarrySmith Just FYI, there are many non-proprietary distributions of Conda that can be used without any licensing issues, such as MiniForge: https://github.com/conda-forge/miniforge?tab=readme-ov-file#miniforge3. The IDAES documentation is in the process to be updated so that Miniforge is the recommended method to install Conda (see IDAES/idaes-pse#1513).

@lbianchi-lbl
Copy link
Contributor

I installed petsc as part of IDAES using the instructions here. Specifically, idaes get-extensions --extra petsc . Where can I find the configure.log and make.log?

@fahim831 I believe configure.log and make.log would only be relevant and available if you built (compiled) PETSc. For reference, if you're using PETSc from IDAES, you're using a pre-built executable that's distributed as part of the IDAES extensions (see https://github.com/IDAES/idaes-ext) and installed by running idaes get-extensions.

I forgot to mention I just updated my OS yesterday to Sequoia too. Not sure if it could be related.

I don't have any evidence to back this up, but my gut feeling is that this is most likely related to the error (e.g. the update might have changed the location of some libraries or other components needed by the IDAES-distributed PETSc executable).

Conversely, there have been no changes on the Python, Pyomo, IDAES and/or WaterTAP side that could realistically interfere with PETSc, so I don't think that switching branches is related to the error. You should be able to test this assumption at least partially by switching back to the original branch and trying to see if the error persists (which, based on the OS update hypothesis above, I would expect it to do).

@fahim831
Copy link
Contributor Author

@lbianchi-lbl Thanks for the details. Yes, I had switched back to my other branch where things were previously working and also tried to go back to yesterday's pre-update commit but nothing worked. Unfortunately, you are forced to update the OS anyway eventually so there was no point in delaying it. But I understand the logs won't help in this case. Maybe I will wait for @BarrySmith to install it in a macOS v14 and v15 environment to verify where the issue is and if it's really a version problem. I'll see if I can set up a virtual windows environment and work until then.

@knepley
Copy link

knepley commented Nov 14, 2024

From the stack trace, it is clear that PETSc is being given invalid options. For example, from the last error, from the PETSc listing you use -ts_save_trajectory 1e_arm64e, but your input says "--ts_save_trajectory": 1,, so something is not right in the processing of the input file.

@lbianchi-lbl
Copy link
Contributor

lbianchi-lbl commented Nov 14, 2024

From the stack trace, it is clear that PETSc is being given invalid options. For example, from the last error, from the PETSc listing you use -ts_save_trajectory 1e_arm64e, but your input says "--ts_save_trajectory": 1,, so something is not right in the processing of the input file.

Not sure how relevant this can be, but I've just noticed the arm64 in the error message. Is there a chance that this could be due to a machine architecture mismatch of some kind between x86_64 (Intel) and arm64 (Apple Silicon)? This could be consistent with the error manifesting itself after a macOS update, since the update could have changed some of the virtualization/compatibility mode settings.

I'm not a macOS user and I'm obviously hand-waving a lot of the details away, but this sounds like something that should be looked at on the side of the IDAES extensions (https://github.com/IDAES/idaes-ext), i.e. the pseudo-package that distributes the PETSc executable from which this error originates.

@fahim831 can you post some information about the hardware of your macOS machine? e.g. by following the steps in the "View a system report" section of this page and copying the relevant portions of that data (i.e. without the serial number and other identifying information) here.

@fahim831
Copy link
Contributor Author

fahim831 commented Nov 14, 2024

@lbianchi-lbl Here are the things shown in the first page of the system report minus identifying details for both software and hardware:

Hardware Overview:

Model Name: MacBook Air
Model Identifier: Mac14,15
Model Number: Z18N000PVLL/A
Chip: Apple M2
Total Number of Cores: 8 (4 performance and 4 efficiency)
Memory: 16 GB
System Firmware Version: 11881.41.5
OS Loader Version: 11881.41.5
Serial Number (system): Hidden
Hardware UUID: Hidden
Provisioning UDID: Hidden
Activation Lock Status: Disabled

System Software Overview:

System Version: macOS 15.1 (24B83)
Kernel Version: Darwin 24.1.0

@BarrySmith
Copy link

I'll try an installation following the instructions above tonight; I cannot use Conda at work (it costs big bucks :-().

@BarrySmith Just FYI, there are many non-proprietary distributions of Conda that can be used without any licensing issues, such as MiniForge: https://github.com/conda-forge/miniforge?tab=readme-ov-file#miniforge3. The IDAES documentation is in the process to be updated so that Miniforge is the recommended method to install Conda (see IDAES/idaes-pse#1513).

My employer blocks all conda site access, which means even downloads of non-proprietary conda's are blocked. Anyways not important.

@BarrySmith
Copy link

Unfortunately, my installed testing failed. I followed the instructions and got to

tests/test_version.py ....                                                                                       [100%]

======================================================== ERRORS ========================================================
______________________________________ ERROR at setup of test_multi_period_model _______________________________________

    @pytest.fixture(scope="module")
    def build_multi_period_model():
>       m = MultiPeriodModel(
            n_time_points=5,
            process_model_func=build_flowsheet,
            linking_variable_func=get_linking_variable_pairs,
            use_stochastic_build=True,
            initialization_func=fix_dof_and_initialize,
            unfix_dof_func=unfix_dof,
        )

/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/apps/grid_integration/multiperiod/tests/test_multiperiod.py:65: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/apps/grid_integration/multiperiod/multiperiod.py:124: in __init__
    self.build_stochastic_multi_period(
/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/apps/grid_integration/multiperiod/multiperiod.py:472: in build_stochastic_multi_period
    blk = self._construct_flowsheet_instance(
/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/apps/grid_integration/multiperiod/multiperiod.py:324: in _construct_flowsheet_instance
    self.create_process_model(blk, **flowsheet_options)
/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/apps/grid_integration/multiperiod/tests/test_multiperiod.py:33: in build_flowsheet
    m.fs = FlowsheetBlock(dynamic=False)
/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/core/base/process_block.py:165: in __new__
    n = _ScalarProcessBlockMeta(bname, (cls._ComponentDataClass, cls), {})
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

mcs = <class 'idaes.core.base.process_block._ScalarProcessBlockMeta'>, name = '_ScalarFlowsheetBlock'
bases = (<class 'idaes.core.base.flowsheet_model.FlowsheetBlockData'>, <class 'idaes.core.base.flowsheet_model.FlowsheetBlock'>)
dct = {'__init__': <function _ScalarProcessBlockMeta.__new__.<locals>.__init__ at 0x13fee9480>, '__process_block__': 'scalar', 'base_class_module': <function _ScalarProcessBlockMeta.__new__.<locals>.<lambda> at 0x13fee93f0>}

    def __new__(mcs, name, bases, dct):
        def __init__(self, *args, **kwargs):
            _pyomo_kwargs = _process_kwargs(self, kwargs)
            bases[0].__init__(self, component=self)
            bases[1].__init__(self, *args, **_pyomo_kwargs)
    
        dct["__init__"] = __init__
        dct["__process_block__"] = "scalar"
        # provide function ``base_class_module()`` to get unit module, for visualizer
        dct["base_class_module"] = lambda mcs: bases[0].__module__
>       return type.__new__(mcs, name, bases, dct)
E       TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/core/base/process_block.py:133: TypeError
_________________________________ ERROR at setup of test_multi_period_stochastic_model _________________________________

This is with Sequoia 15.1 I f you can help me past this point I could possibly get to debugging the PETSc problem.

@fahim831
Copy link
Contributor Author

@BarrySmith I'm not sure why there is a multiperiod model in the error. Is there a reason your test uses that? As far as I know, the multiperiod does not even call PETSc as it's not dynamic. The issue is to do with PETSc so you could even just try to run the example files and you will run into the issue (I just tried and confirmed the issue persists for these example files too right now). The simplest one is this: https://idaes-examples.readthedocs.io/en/latest/docs/dae/petsc_chem_doc.html

@lbianchi-lbl
Copy link
Contributor

Unfortunately, my installed testing failed. I followed the instructions and got to

tests/test_version.py ....                                                                                       [100%]

======================================================== ERRORS ========================================================
______________________________________ ERROR at setup of test_multi_period_model _______________________________________

    @pytest.fixture(scope="module")
    def build_multi_period_model():
>       m = MultiPeriodModel(
            n_time_points=5,
            process_model_func=build_flowsheet,
            linking_variable_func=get_linking_variable_pairs,
            use_stochastic_build=True,
            initialization_func=fix_dof_and_initialize,
            unfix_dof_func=unfix_dof,
        )

/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/apps/grid_integration/multiperiod/tests/test_multiperiod.py:65: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/apps/grid_integration/multiperiod/multiperiod.py:124: in __init__
    self.build_stochastic_multi_period(
/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/apps/grid_integration/multiperiod/multiperiod.py:472: in build_stochastic_multi_period
    blk = self._construct_flowsheet_instance(
/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/apps/grid_integration/multiperiod/multiperiod.py:324: in _construct_flowsheet_instance
    self.create_process_model(blk, **flowsheet_options)
/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/apps/grid_integration/multiperiod/tests/test_multiperiod.py:33: in build_flowsheet
    m.fs = FlowsheetBlock(dynamic=False)
/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/core/base/process_block.py:165: in __new__
    n = _ScalarProcessBlockMeta(bname, (cls._ComponentDataClass, cls), {})
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

mcs = <class 'idaes.core.base.process_block._ScalarProcessBlockMeta'>, name = '_ScalarFlowsheetBlock'
bases = (<class 'idaes.core.base.flowsheet_model.FlowsheetBlockData'>, <class 'idaes.core.base.flowsheet_model.FlowsheetBlock'>)
dct = {'__init__': <function _ScalarProcessBlockMeta.__new__.<locals>.__init__ at 0x13fee9480>, '__process_block__': 'scalar', 'base_class_module': <function _ScalarProcessBlockMeta.__new__.<locals>.<lambda> at 0x13fee93f0>}

    def __new__(mcs, name, bases, dct):
        def __init__(self, *args, **kwargs):
            _pyomo_kwargs = _process_kwargs(self, kwargs)
            bases[0].__init__(self, component=self)
            bases[1].__init__(self, *args, **_pyomo_kwargs)
    
        dct["__init__"] = __init__
        dct["__process_block__"] = "scalar"
        # provide function ``base_class_module()`` to get unit module, for visualizer
        dct["base_class_module"] = lambda mcs: bases[0].__module__
>       return type.__new__(mcs, name, bases, dct)
E       TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

/opt/homebrew/Caskroom/miniconda/base/envs/my-idaes-env/lib/python3.10/site-packages/idaes/core/base/process_block.py:133: TypeError
_________________________________ ERROR at setup of test_multi_period_stochastic_model _________________________________

This is with Sequoia 15.1 I f you can help me past this point I could possibly get to debugging the PETSc problem.

This looks like an issue with the version(s) of IDAES and/or Pyomo (I'll link the GitHub issue in a minute).

@BarrySmith can you run conda env export -n my-idaes-env and paste the output here?

@lbianchi-lbl
Copy link
Contributor

lbianchi-lbl commented Nov 14, 2024

@fahim831 in the meantime, can you post a minimal example of a dynamic flowsheet that causes the error on your machine? It can be any IDAES flowsheet, but it should be as simple as possible, ideally in a single Python file so that @BarrySmith can run it after installing IDAES once we sort out the installation issues.

EDIT: Nevermind, I see your post above, thanks. I'll try to convert that example to a standalone .py file so that it can be run without installing the Jupyter notebook infrastructure.

@fahim831
Copy link
Contributor Author

fahim831 commented Nov 14, 2024

@lbianchi-lbl Yes, I actually already converted it to a standalone py file as the example calls upon another file. You just have to copy paste those reactions and details from that IPYNB into a .py and make a single file. I can post that in like an hour.

Edit: Below is the standalone code to get PETSc to run.

import numpy as np
import matplotlib.pyplot as plt

import pyomo.dae as pyodae
import pyomo.environ as pyo
import idaes.core.solvers.petsc as petsc  # petsc utilities module
# from idaes.core.solvers.features import dae  # DAE example/test problem

def dae(nfe=1):
    """This provides a DAE model for solver testing.

    The problem and expected result are from the problem given here:
    https://archimede.dm.uniba.it/~testset/report/chemakzo.pdf.

    Args:
        None

    Returns:
        (tuple): Pyomo ConcreteModel, correct solved value for y[1] to y[5] and y6
    """
    model = pyo.ConcreteModel(name="chemakzo")

    # Set problem parameter values
    model.k = pyo.Param([1, 2, 3, 4], initialize={1: 18.7, 2: 0.58, 3: 0.09, 4: 0.42})
    model.Ke = pyo.Param(initialize=34.4)
    model.klA = pyo.Param(initialize=3.3)
    model.Ks = pyo.Param(initialize=115.83)
    model.pCO2 = pyo.Param(initialize=0.9)
    model.H = pyo.Param(initialize=737)

    # Problem variables ydot = dy/dt,
    #    (dy6/dt is not explicitly in the equations, so only 5 ydots i.e.
    #    y6 is an algebraic variable and y1 to y5 are differential variables)
    model.t = pyodae.ContinuousSet(bounds=(0, 180))
    model.y = pyo.Var(model.t, [1, 2, 3, 4, 5], initialize=1.0)  #
    model.y6 = pyo.Var(model.t, initialize=1.0)  #
    model.ydot = pyodae.DerivativeVar(model.y, wrt=model.t)  # dy/dt
    model.r = pyo.Var(model.t, [1, 2, 3, 4, 5], initialize=1.0)
    model.Fin = pyo.Var(model.t, initialize=1.0)

    # Equations
    @model.Constraint(model.t)
    def eq_ydot1(b, t):
        return b.ydot[t, 1] == -2.0 * b.r[t, 1] + b.r[t, 2] - b.r[t, 3] - b.r[t, 4]

    @model.Constraint(model.t)
    def eq_ydot2(b, t):
        return b.ydot[t, 2] == -0.5 * b.r[t, 1] - b.r[t, 4] - 0.5 * b.r[t, 5] + b.Fin[t]

    @model.Constraint(model.t)
    def eq_ydot3(b, t):
        return b.ydot[t, 3] == b.r[t, 1] - b.r[t, 2] + b.r[t, 3]

    @model.Constraint(model.t)
    def eq_ydot4(b, t):
        return b.ydot[t, 4] == -b.r[t, 2] + b.r[t, 3] - 2.0 * b.r[t, 4]

    @model.Constraint(model.t)
    def eq_ydot5(b, t):
        return b.ydot[t, 5] == b.r[t, 2] - b.r[t, 3] + b.r[t, 5]

    @model.Constraint(model.t)
    def eq_y6(b, t):
        return 0 == b.Ks * b.y[t, 1] * b.y[t, 4] - b.y6[t]

    @model.Constraint(model.t)
    def eq_r1(b, t):
        return b.r[t, 1] == b.k[1] * b.y[t, 1] ** 4 * b.y[t, 2] ** 0.5

    @model.Constraint(model.t)
    def eq_r2(b, t):
        return b.r[t, 2] == b.k[2] * b.y[t, 3] * b.y[t, 4]

    @model.Constraint(model.t)
    def eq_r3(b, t):
        return b.r[t, 3] == b.k[2] / b.Ke * b.y[t, 1] * b.y[t, 5]

    @model.Constraint(model.t)
    def eq_r4(b, t):
        return b.r[t, 4] == b.k[3] * b.y[t, 1] * b.y[t, 4] ** 2

    @model.Constraint(model.t)
    def eq_r5(b, t):
        return b.r[t, 5] == b.k[4] * b.y6[t] ** 2 * b.y[t, 2] ** 0.5

    @model.Constraint(model.t)
    def eq_Fin(b, t):
        return b.Fin[t] == b.klA * (b.pCO2 / b.H - b.y[t, 2])

    # Set initial conditions and solve initial from the values of differential
    # variables.
    y0 = {1: 0.444, 2: 0.00123, 3: 0.0, 4: 0.007, 5: 0.0}  # initial differential vars
    for i, v in y0.items():
        model.y[0, i].fix(v)

    discretizer = pyo.TransformationFactory("dae.finite_difference")
    discretizer.apply_to(model, nfe=nfe, scheme="BACKWARD")

    return (
        model,
        0.1150794920661702,
        0.1203831471567715e-2,
        0.1611562887407974,
        0.3656156421249283e-3,
        0.1708010885264404e-1,
        0.4873531310307455e-2,
    )

# Get the model and known solution for y variables at t=180 minutes.
m, y1, y2, y3, y4, y5, y6 = dae(nfe=10)

# See the initial conditions:
print("at t = 0:")
print(f"    y1 = {pyo.value(m.y[0, 1])}")
print(f"    y2 = {pyo.value(m.y[0, 2])}")
print(f"    y3 = {pyo.value(m.y[0, 3])}")
print(f"    y4 = {pyo.value(m.y[0, 4])}")
print(f"    y5 = {pyo.value(m.y[0, 5])}")

# The command below will solve the problem.  In this case, we want to read the saved
# trajectory for each time element in the Pyomo.DAE problem (in this case there is
# only 1) so we will need to provide solver options to save the trajectory to the PETSc
# solver, a file name stub for variable information files, and a file stub for saving
# the trajectory information.  The options shown below will delete the trajectory
# information written by PETSc and resave it as json.  This allows us to cleanly read
# the trajectory data for multiple time elements.

result = petsc.petsc_dae_by_time_element(
    m,
    time=m.t,
    between=[m.t.first(), m.t.last()],
    ts_options={
        "--ts_type": "cn",  # Crank–Nicolson
        "--ts_adapt_type": "basic",
        "--ts_dt": 0.01,
        "--ts_save_trajectory": 1,
    },
)
tj = result.trajectory
res = result.results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority:High High Priority Issue or PR
Projects
None yet
Development

No branches or pull requests

5 participants