Giter VIP home page Giter VIP logo

assimulo's People

Contributors

agnesramle avatar aramle avatar chria avatar christian-winther avatar clausfse avatar efredriksson-modelon avatar jakesson avatar jschueller avatar modelonrobinandersson avatar petermeisrimelmodelon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

assimulo's Issues

KLU sparse solver and SPGMR preconditioning for IDA solver

I am trying to pass Jacobian as a sparse matrix through a jac function for the IDA solver. However, the code only take two types of linear solvers i.e. dense or SPGMR.

I understand it requires the interface for sparse KLU solver library in IDA which is not yet implemented in Assimulo. So, I proceeded with the SPGMR solver to pass a preconditioned matrix as per SUNDIALS documentation.

In the Assimulo documentation examples, I could find an example (ida_with_jac_spgmr.py) where jacv (Jacobian times vector) function is implemented. In this example, I figured there is no preconditioning used. Then looked at another example in CVODE (Explicit_Problem) where preconditioning is used (cvode_with_preconditioning.py).

However, trying out the same structure for IDA (Implicit_Problem) didn't work. The error was, the options for preconditioning were not available for IDA solver. I came to a conclusion about the behavior of this by looking into the source code of sundials.pyx.

---------------------------------Snippet of source code-------------------------------------------------------------------------

# From [sundials.pyx file](https://github.com/modelon-community/Assimulo/blob/master/src/solvers/sundials.pyx)---provides only two solvers-DENSE/SPGMR
if self.options["linear_solver"] == 'DENSE':
         
elif self.options["linear_solver"] == 'SPGMR':
    # PREC_NONE implies no preconditioner option is supplied to SUNDIALS
    IF SUNDIALS_VERSION >= (3,0,0):
        #Create the linear solver
        IF SUNDIALS_VERSION >= (4,0,0):
            IF SUNDIALS_VERSION >= (6,0,0):
                self.sun_linearsolver = SUNDIALS.SUNLinSol_SPGMR(self.yTemp, **PREC_NONE**, 0, ctx)
            ELSE:
                self.sun_linearsolver = SUNDIALS.SUNLinSol_SPGMR(self.yTemp, **PREC_NONE**, 0)
        ELSE:
            self.sun_linearsolver = SUNDIALS.SUNSPGMR(self.yTemp, PREC_NONE, 0)

        #Attach it to IDAS
        IF SUNDIALS_VERSION >= (4,0,0):
            flag = SUNDIALS.IDASetLinearSolver(self.ida_mem, self.sun_linearsolver, NULL)
        ELSE:
            flag = SUNDIALS.IDASpilsSetLinearSolver(self.ida_mem, self.sun_linearsolver)

From the comments I added in the code snippet from the source code, I understood that the preconditioning functionality for the SPGMR solver is not exposed in sundials.pyx file.

Let me know if I my understanding is correct. If yes, is there a chance for this functionality to be exposed?
It would be really helpful if you could provide some information on this.

Sinsitivities of derivative variables

Since the forum seems not working, I'm writing here. I am currently using Assimulo as the interface to the solver IDAS from the Sundials suite for the time integration of DAE-formulations of multibody system.
I found the sensitivities of the integration variables y stored inside the simulation result p_sol. I'm looking also for the sensitivities of the derivative variables yd but can't find them. As I understand from page 98 of the User Documentation for IDAS v3.1.0 (SUNDIALS v4.1.0) they should be available in Sundials. Where can I find them in Assimulo or how can I access to them?

MPI error with Assimulo 3.5.1

I have compiled and installed Assimulo 3.5.1 on an Arch linux system using the command:

python setup.py install --sundials-home=/usr --blas-home=/usr/lib --lapack-home=/usr

This is in a fresh Python 3.11 (compiled from scratch) virtual environment. The module compiles without error.

Some of the examples fail with the following error:

➜ python cvode_basic.py               
*** The MPI_Comm_dup() function was called before MPI_INIT was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.
[jr-xps13:342153] Local abort before MPI_INIT completed completed successfully, but am not able to aggregate error messages, and not able to guarantee that all other processes were killed!

Specifically, only the examples with cvode, ida and kinsol fail with this error. All other examples (dasp,3, dopri5, radau5, etc.) work as expected.

I did not specify any MPI options during the compile, but openmpi and python-mpi4py packages are installed on my system (although the latter is based on the system Python 3.12, and I compiled this in a virtual environment with Python 3.11).

Is this a bug or am I doing something wrong?

Versions

  • openblas 0.3.26
  • sundials 7.0.0

Implementation of the `CVode` solver while updating `atol`

I am having difficulty in understanding how do I implement the CVode solver in the way I want:

What I want?

I have a number of time points for which I want to simulate (basically ncp_list of the simulate() method). Between these time points, I want to modify the state of the solver in some way. Those ways are as follows:

  1. Modify the atol for each equation
  2. Modify a variable which is an arguement to the rhs_function, so when simulate() calls it next time, it's updated value is used.

Why do I want this?

I am trying to solve a very stiff system (chemical kinetics) with CVode in hopes of greater robustness and speed. I have two implementations available as a benchmark. One is an old Fortran one which uses DLSODES and one is that I have written which uses scipy.integrate.ode with the LSODA method. Note that LSODA is different that DLSODES as in the former automatically switches between a stiff and non-stiff solver but the latter always uses a stiff solver (BDF, I think). I have heard that CVode is arguably better than DLSODES so I wanted to try it.

What I have done so far?

I wrote the following code (only the relevant parts):

...
exp_mod = Explicit_Problem(dndt_wrapper, n0,)
exp_mod.jac = jacobian_wrapper
exp_mod.jac_nnz = dum_jac.size # A dummy call of `jacobian` which `jacobian_wrapper` wraps around
exp_mod.maxncf = 100
exp_sim = CVode(exp_mod)

exp_sim.iter = 'Newton'
exp_sim.discr = 'BDF'
exp_sim.atol = atol
exp_sim.rtol = rtol
exp_sim.linear_solver = 'sparse'
exp_sim.usesens = False

for i, time_step in enumerate(times):
    t, y = exp_sim.simulate(time_step)
    n = y[-1]
    n[n < min_val] = min_val
    exp_sim.atol = np.maximum(1e-25, 1e-5*n) # Modifying atol
    exp_sim.initialize_options()
    argument_to_rhs = some_func(argument_to_rhs) # Here modify an variable which is an argument to the RHS function

Here are the RHS and Jacobian functions (wrappers):

def dndt_wrapper(t, n, argument_to_rhs):
    dn = dndt(argument_to_rhs)
    return dn
	
def jacobian_wrapper(t, n, argument_to_rhs):
    J = jacobian(argument_to_rhs)
    J = csc_matrix(J)
    return J

This works only for first time step (which is a very small value) and then it fails with the following error:

assimulo.solvers.sundials.CVodeError: 'Convergence test failures occurred too many times during one internal time step or minimum step size was reached. At time 6656115.837052.'

One more thing you can perhaps note that I am supplying the size of my 2-D Jacobian matrix to nnz which is obviously not the number of non-zero values. When I did the following however:

exp_mod.jac_nnz = np.count_nonzero(dum_jac)

I got the following error:

assimulo.exception.AssimuloException: The Jacobian has more entries than supplied to the problem class via 'jac_nnz'

An equivalent working scipy implementation

sol = ode(dndt_wrapper, jacobian_wrapper)
sol.set_integrator('lsoda', rtol = rtol, atol = atol, nsteps = 2000)
sol.set_initial_value(n0, 0)
while s < len(times):
    sol.integrate(times[s])
    n = sol.y
    n[n < min_val] = min_val
    atol = np.maximum(1e-25, 1e-5*n)
    sol._integrator.call_args[1] = atol
    argument_to_rhs = some_func(argument_to_rhs) # Here modify an variable which is an argument to the RHS function
    s += 1

AttributeError: 'Assimulo_prepare' object has no attribute 'sundials_with_msvc'

I tried to install from source code:

python setup.py install --user

Then it pops up the following error

  tree = Parsing.p_module(s, pxd, full_module_name)
Traceback (most recent call last):
  File "setup.py", line 610, in <module>
    ext_list = prepare.cython_extensionlists()
  File "setup.py", line 518, in cython_extensionlists
    if self.sundials_with_msvc:
AttributeError: 'Assimulo_prepare' object has no attribute 'sundials_with_msvc'

SPGMR solvers are not using the user defined setup_jacobian function

Hi everyone,
I am trying to use Assimulo to use Kinsol and IDA functions in python.
I recently installed the package through anaconda (mamba install -c conda-forge assimulo) on a Debian 12 distribution.
Apparently the installation went through, but I somehow cannot get the package to work properly. In fact, in all the KINSOL examples I try to run, whenever the SPGMR solver is selected, I observe that the setup_jacobian function is never called, nor is the preconditioner solve. As a consequence, there is a high number of linear solver failures reported, and the final result accuracy is way higher than the specified tolerance. For instance, this is the output of the kinsol_ors example

No initialization defined for the problem.
No finalization defined for the problem.
Final Run Statistics: ORS Example 

 Number of function evaluations              : 68
 Number of Nonlinear Iterations              : 67
 Number of Backtrack Operations (Linesearch) : 0
 Number of Beta-condition Failures           : 0
 Number of Jacobian*Vector Evaluations       : 713
 Number of F-Eval During Jac*Vec-Eval        : 68
 Number of Linear Iterations                 : 646
 Number of Linear Convergence Failures       : 64

Solver options:

 Solver                  : Kinsol
 Linear Solver           : SPGMR
 Globalization Strategy  : NONE
 Function Tolerances     : 1.2947195696248386e-08
 Step Tolerances         : 3.666852862501036e-11
 Variable Scaling        : [1. 1. 1. ... 1. 1. 1.]
 Function Scaling        : [1. 1. 1. ... 1. 1. 1.]

Elapsed simulation time: 1.0814493019715883 seconds.
No initialization defined for the problem.
No finalization defined for the problem.
Final Run Statistics: ORS Example (Preconditioned) 

 Number of function evaluations              : 68
 Number of Nonlinear Iterations              : 67
 Number of Backtrack Operations (Linesearch) : 0
 Number of Beta-condition Failures           : 0
 Number of Jacobian*Vector Evaluations       : 713
 Number of F-Eval During Jac*Vec-Eval        : 68
 Number of Linear Iterations                 : 646
 Number of Linear Convergence Failures       : 64

Solver options:

 Solver                  : Kinsol
 Linear Solver           : SPGMR
 Globalization Strategy  : NONE
 Function Tolerances     : 1.2947195696248386e-08
 Step Tolerances         : 3.666852862501036e-11
 Variable Scaling        : [1. 1. 1. ... 1. 1. 1.]
 Function Scaling        : [1. 1. 1. ... 1. 1. 1.]

Elapsed simulation time: 1.2607804519939236 seconds.
Error                 , in y:  0.000541712298832705
Error (preconditioned), in y:  0.000541712298832705

As can be seen, it is way different from the one reported here https://jmodelica.org/assimulo/EXAMPLE_kinsol_ors.html

In addition, the same behavior is observed when I run the tests, in which I have

Ran 291 tests in 21.166s

FAILED (errors=22, failures=10)

Again, I think this is due to the fact that user prescribed jacobian and preconditioner functions are ignored during the computations. Has this behavior ever been observed?
I must say that I have an independent installation of sundials 6.5.0 (which I use for C++ simulations): could this interfere with the anaconda install?
Thank you very much for the help, and sorry for the lengthy message.

Andrea

Symbolic Jacobian for sundials solver

Hello

Is there a simple example of using symbolic jacobian function with Assimulo sundials solver? I am trying to create a simple example of how to use AD scheme to provide Jacobian for sundials solvers such as IDA or CVODE. I am using casadi python version to provide symbolic jacobian and try to use it in 'ida_with_jac.py' example but I keep getting errors such as f function return type error or Jacobian function is not callable.

Thanks,

Set up needs to be updated for NumPy >= 1.22

Unfortunately, it looks like NumPy introduced a change with 1.22 which breaks the set up of Assimulo. Below is an excerpt of the error. NumPy now looks for a new attribute, extra_c_compile_args of extensions.

...
#42 27.93     Traceback (most recent call last):
#42 27.93       File "<string>", line 1, in <module>
#42 27.93       File "/tmp/pip-req-build-6n21kyom/setup.py", line 691, in <module>
#42 27.93         ndc.setup(name=NAME,
#42 27.93       File "/usr/local/lib/python3.9/site-packages/numpy/distutils/core.py", line 169, in setup
#42 27.93         return old_setup(**new_attr)
#42 27.93       File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
#42 27.93         return distutils.core.setup(**attrs)
#42 27.93       File "/usr/local/lib/python3.9/distutils/core.py", line 148, in setup
#42 27.93         dist.run_commands()
#42 27.93       File "/usr/local/lib/python3.9/distutils/dist.py", line 966, in run_commands
#42 27.93         self.run_command(cmd)
#42 27.93       File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
#42 27.93         cmd_obj.run()
#42 27.93       File "/usr/local/lib/python3.9/site-packages/numpy/distutils/command/install.py", line 60, in run
#42 27.93         r = self.setuptools_run()
#42 27.93       File "/usr/local/lib/python3.9/site-packages/numpy/distutils/command/install.py", line 34, in setuptools_run
#42 27.93         return distutils_install.run(self)
#42 27.93       File "/usr/local/lib/python3.9/distutils/command/install.py", line 546, in run
#42 27.93         self.run_command('build')
#42 27.93       File "/usr/local/lib/python3.9/distutils/cmd.py", line 313, in run_command
#42 27.93         self.distribution.run_command(command)
#42 27.93       File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
#42 27.93         cmd_obj.run()
#42 27.93       File "/usr/local/lib/python3.9/site-packages/numpy/distutils/command/build.py", line 61, in run
#42 27.93         old_build.run(self)
#42 27.93       File "/usr/local/lib/python3.9/distutils/command/build.py", line 135, in run
#42 27.93         self.run_command(cmd_name)
#42 27.93       File "/usr/local/lib/python3.9/distutils/cmd.py", line 313, in run_command
#42 27.93         self.distribution.run_command(command)
#42 27.93       File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
#42 27.93         cmd_obj.run()
#42 27.93       File "/usr/local/lib/python3.9/site-packages/numpy/distutils/command/build_ext.py", line 316, in run
#42 27.93         self.build_extensions()
#42 27.93       File "/usr/local/lib/python3.9/distutils/command/build_ext.py", line 449, in build_extensions
#42 27.93         self._build_extensions_serial()
#42 27.93       File "/usr/local/lib/python3.9/distutils/command/build_ext.py", line 474, in _build_extensions_serial
#42 27.93         self.build_extension(ext)
#42 27.93       File "/usr/local/lib/python3.9/site-packages/numpy/distutils/command/build_ext.py", line 380, in build_extension
#42 27.93         extra_cflags = ext.extra_c_compile_args or []
#42 27.93     AttributeError: 'Extension' object has no attribute 'extra_c_compile_args'
#42 27.93     INFO:
#42 27.93     ########### EXT COMPILER OPTIMIZATION ###########
#42 27.93     INFO: Platform      :
#42 27.93       Architecture: x64
#42 27.93       Compiler    : gcc
#42 27.93     
#42 27.93     CPU baseline  :
#42 27.93       Requested   : 'min'
#42 27.93       Enabled     : SSE SSE2 SSE3
#42 27.93       Flags       : -msse -msse2 -msse3
#42 27.93       Extra checks: none
#42 27.93     
#42 27.93     CPU dispatch  :
#42 27.93       Requested   : 'max -xop -fma4'
#42 27.93       Enabled     : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL
#42 27.93       Generated   : none
#42 27.93     INFO: CCompilerOpt.cache_flush[817] : write cache to path -> /tmp/pip-req-build-6n21kyom/build/build/temp.linux-x86_64-3.9/ccompiler_opt_cache_ext.py
#42 27.93     ----------------------------------------
#42 27.93 ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-6n21kyom/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-6n21kyom/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-iap0qb7t/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/Assimulo Check the logs for full command output.
#42 28.13 WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
#42 28.13 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
#42 ERROR: process "/bin/sh -c pip install git+https://github.com/modelon-community/Assimulo.git@Assimulo-${ASSIMULO_VERSION}" did not complete successfully: exit code: 1

ncp_list timepoint evaluations do not match output

I have noticed that for some simulations for this code, the list of timepoints passed at ncp_list does not lead to the same number of evaluations in the output sol. Is this something that is to be expected?

mod = Explicit_Problem(self.func, self.y0, np.min(t))
sim=CVode(mod)

sim.rtol=self.rtol
sim.atol=self.atol
sim.verbosity=0
sim.maxsteps=10000
sim.time_limit=600
sim.linear_solver = 'SPGMR'
sol=sim.simulate(tfinal=np.max(t),ncp=0,ncp_list=list(t))

E.g. 20 timepoints as input, but only 17 have output. From what I saw, these values are typically some in-between values.

Kind regards,

Paul

Jacobian sparsity pattern

It would be great if the solvers could use a Jacobian sparsity pattern indicating which entries are zero for sure, similar to scipy's solve_ivp. This could increase speed for calculations on approximating the Jacobian is no analytical one is supplied.

2 tests are failing with sundials>=4.x

the same 2 tests fail (on current master) with all sundials versions>=4.x (out of tested versions 2.7.0, 3.2.0, 4.1.0, 5.8.0, 6.5.0):

  • IDAError: 'The solver took max internal steps but could not reach tout. At time 0.000087.'
  • assert_equal(imp_sim.statistics["nfcnjacs"], 0) (got value 28)

here is the test output:

======================================================================
ERROR: This tests the class Mechanical_system together with ind3 and ida
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/runner/work/Assimulo/Assimulo/tests/test_examples.py", line 195, in test_mech_system_pendulum3
    mech_system_pendulum.run_example('ind3',with_plots=False,with_test=True)
  File "/home/runner/.local/lib/python3.10/site-packages/Assimulo-trunk-py3.10-linux-x86_64.egg/assimulo/examples/mech_system_pendulum.py", line 60, in run_example
    t,y,yd=dae_pend.simulate(10.,100)
  File "assimulo/ode.pyx", line 185, in assimulo.ode.ODE.simulate
  File "assimulo/ode.pyx", line 308, in assimulo.ode.ODE.simulate
  File "assimulo/implicit_ode.pyx", line 129, in assimulo.implicit_ode.Implicit_ODE._simulate
  File "assimulo/implicit_ode.pyx", line 206, in assimulo.implicit_ode.Implicit_ODE._simulate
  File "assimulo/solvers/sundials.pyx", line 523, in assimulo.solvers.sundials.IDA.integrate
  File "assimulo/solvers/sundials.pyx", line 592, in assimulo.solvers.sundials.IDA.integrate
assimulo.solvers.sundials.IDAError: 'The solver took max internal steps but could not reach tout. At time 0.000087.'

======================================================================
FAIL: This tests the functionality of the property usejac.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/runner/work/Assimulo/Assimulo/tests/solvers/test_sundials.py", line 1055, in test_usejac
    nose.tools.assert_equal(imp_sim.statistics["nfcnjacs"], 0)
AssertionError: 28 != 0
-------------------- >> begin captured stdout << ---------------------
Final Run Statistics: --- 

 Number of steps                                 : 27
 Number of function evaluations                  : 28
 Number of Jacobian evaluations                  : 25
 Number of function eval. due to Jacobian eval.  : 28
 Number of error test failures                   : 0
 Number of nonlinear iterations                  : 28
 Number of nonlinear convergence failures        : 0

Solver options:

 Solver                       : IDA (BDF)
 Maximal order                : 5
 Suppressed algebr. variables : False
 Tolerances (absolute)        : 1e-06
 Tolerances (relative)        : 1e-06

Simulation interval    : 0.0 - 3.0 seconds.
Elapsed simulation time: 0.0005052060000139136 seconds.

--------------------- >> end captured stdout << ----------------------

Python 3.12: Fortran solvers not compiled

The latest release (3.5.2) compiles without error on Python 3.12, but the fortran based solvers are not compiled.

This is on Arch linux with SUNDIALS 6.7.0 and compilation per

python setup.py bdist_wheel --sundials-home=/usr --blas-home=/usr/lib --lapack-home=/usr/lib --extra-fortran-compile-flags="-fallow-argument-mismatch"

The wheel was installed manually afterwards in a Python 3.12 virtual environment.

Sundials-based solvers (e.g. CVODE) work without problem. Example of failing code:

python dopri5_basic.py 
/home/jr/src/Assimulo-Assimulo-3.5.2/examples/dopri5_basic.py:42: SyntaxWarning: invalid escape sequence '\d'
  name = 'DOPRI5 Example: $\dot y = - y$')
Could not find cannot import name 'dopri5' from 'assimulo.lib' (/home/jr/.virtualenvs/pydev/lib/python3.12/site-packages/assimulo/lib/__init__.py)
Could not find cannot import name 'rodas' from 'assimulo.lib' (/home/jr/.virtualenvs/pydev/lib/python3.12/site-packages/assimulo/lib/__init__.py)
Could not find cannot import name 'odassl' from 'assimulo.lib' (/home/jr/.virtualenvs/pydev/lib/python3.12/site-packages/assimulo/lib/__init__.py)
Could not find ODEPACK functions.
Could not find RADAR5
Could not find GLIMDA.
Traceback (most recent call last):
  File "/home/jr/src/Assimulo-Assimulo-3.5.2/examples/dopri5_basic.py", line 20, in <module>
    from assimulo.solvers import Dopri5
ImportError: cannot import name 'Dopri5' from 'assimulo.solvers' (/home/jr/.virtualenvs/pydev/lib/python3.12/site-packages/assimulo/solvers/__init__.py)
$ ls -l .virtualenvs/pydev/lib/python3.12/site-packages/assimulo/lib 
total 1048
drwxr-xr-x 1 jr jr     100 Jun 26 13:54 __pycache__
-rw-r--r-- 1 jr jr     687 Jun 26 13:54 __init__.py
-rwxr-xr-x 1 jr jr 1051464 Jun 26 13:54 radau5ode.cpython-312-x86_64-linux-gnu.so
-rw-r--r-- 1 jr jr   14112 Jun 26 13:54 radau_core.py

The Fortran-based .so files are missing.

Error at bulding from source (Error: Rank mismatch in argument ‘cont’ at (1) (scalar and rank-1))

Hi,

I got an error when I tried to build Assimulo from source by Docker in order to build PyFMI finally.
I guess fortran compiler was not fitted for this version.
Does anyone have idea to debug?
Let me know if you need any more info.
Thank you!

Error:

...
90.89 assimulo/thirdparty/hairer/radau_decsol.f:2192:72:
90.89 
90.89  2192 |   150      a(j,m) = a(j,m) + y * a(j,i)
90.89       |                                                                        1
90.89 Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 150 at (1)
90.94 assimulo/thirdparty/hairer/radau_decsol.f:4388:72:
90.94 
90.94  4388 |   623       SUM=SUM+FMAS(I,J)*YNEW(J)
90.94       |                                                                        1
90.94 Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 623 at (1)
90.94 assimulo/thirdparty/hairer/radau_decsol.f:4389:72:
90.94 
90.94  4389 |   624    AK(I)=AK(I)+SUM
90.94       |                                                                        1
90.94 Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 624 at (1)
90.95 assimulo/thirdparty/hairer/radau_decsol.f:961:25:
90.95 
90.95   961 |      &          F1,F2,F3,CONT,IP1,IP2,IPHES,IER,IJOB)
90.95       |                         1
90.95 Error: Rank mismatch in argument ‘cont’ at (1) (scalar and rank-1)
90.95 error: Command "/usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops -I/usr/local/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/assimulo/thirdparty/hairer -I/usr/local/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/numpy/distutils/include -I/usr/local/include/python3.9 -c -c assimulo/thirdparty/hairer/radau_decsol.f -o build/temp.linux-x86_64-3.9/assimulo/thirdparty/hairer/radau_decsol.o" failed with exit status 1
90.95 INFO: 
90.95 ########### EXT COMPILER OPTIMIZATION ###########
90.95 INFO: Platform      : 
90.95   Architecture: x64
90.95   Compiler    : gcc
90.95 
90.95 CPU baseline  : 
90.95   Requested   : 'min'
90.95   Enabled     : SSE SSE2 SSE3
90.95   Flags       : -msse -msse2 -msse3
90.95   Extra checks: none
90.95 
90.95 CPU dispatch  : 
90.95   Requested   : 'max -xop -fma4'
90.95   Enabled     : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL AVX512_SPR
90.95   Generated   : none
90.95 INFO: CCompilerOpt.cache_flush[864] : write cache to path -> /tmp/Assimulo/build/build/temp.linux-x86_64-3.9/ccompiler_opt_cache_ext.py
...

Fortran version:

# gfortran --version
GNU Fortran (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# apt show gfortran
Package: gfortran
Version: 4:12.2.0-3
Priority: optional
Section: devel
Source: gcc-defaults (1.203)
Maintainer: Debian GCC Maintainers <[email protected]>
Installed-Size: 16.4 kB
Provides: fortran-compiler, gfortran-mod-15
Depends: cpp (= 4:12.2.0-3), gcc (= 4:12.2.0-3), gfortran-12 (>= 12.2.0-1~)
Suggests: gfortran-multilib, gfortran-doc
Tag: devel::compiler, devel::lang:fortran, role::dummy, role::program,
 suite::gnu
Download-Size: 1428 B
APT-Manual-Installed: yes
APT-Sources: http://deb.debian.org/debian bookworm/main amd64 Packages
Description: GNU Fortran 95 compiler

Dockerfile:

FROM python:3.9

## Install Assimulo requirements
# Python libs
RUN pip install numpy
RUN pip install scipy
RUN pip install pylab-sdk
RUN pip install cython==0.29.14

# C-compiler, Fortran-compiler, BLAS, LAPACK
WORKDIR /tmp/sundials
RUN apt update && apt upgrade -y && apt install -y cmake gcc build-essential gfortran libblas-dev liblapack-dev
# Sundials 4.1
RUN wget https://github.com/LLNL/sundials/releases/download/v4.1.0/sundials-4.1.0.tar.gz
RUN tar -xvzf sundials-4.1.0.tar.gz
RUN cmake sundials-4.1.0
RUN make && make install

## Install Assimulo
WORKDIR /tmp
RUN git clone https://github.com/modelon-community/Assimulo.git

WORKDIR /tmp/Assimulo
RUN python setup.py install --sundials-home=/usr/local --blas-home=/usr/lib/x86_64-linux-gnu/blas --lapack-home=/usr/lib/x86_64-linux-gnu

http 404 not found for channel chria with conda install on google colab

Thank you for this package.

Iam using google colab.

I tried pip install and received the error :

Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting Assimulo
  Downloading Assimulo-3.0.tar.gz (1.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 43.4 MB/s eta 0:00:00
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  Preparing metadata (setup.py) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I tried conda install using condacolab ( https://stackoverflow.com/a/75239829/19955621 )

but (the ! at the beginning is for shell commands on google colab)

! conda install -c https://conda.binstar.org/chria assimulo

leads to the error

Collecting package metadata (current_repodata.json): failed

UnavailableInvalidChannel: HTTP 404 NOT FOUND for channel chria <https://conda.binstar.org/chria>

The channel is not accessible or is invalid.

You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state,
and use `conda config --show-sources` to view config file locations.

Sundials version - Assimulo 3.1

Looking at the Changelog file entry for Assimulo 3.1, it says this version supports Sundials 4.1. However, when I tried to install Assimulo with:

conda install -c conda-forge assimulo=3.1 sundials=4.1.0 it says that the versions are not compatible.

This makes sense, since the information of Assimulo 3.1 states that the highest sundials version supported is 3.3.0a0:

`assimulo 3.1 py37hf5aa970_0

file name : assimulo-3.1-py37hf5aa970_0.tar.bz2
name : assimulo
version : 3.1
build : py37hf5aa970_0
build number: 0
size : 953 KB
license : LGPL
subdir : win-64
url : https://conda.anaconda.org/conda-forge/win-64/assimulo-3.1-py37hf5aa970_0.tar.bz2
md5 : 7238aae19c40e36917ee9fcf4b023b9f
timestamp : 2019-12-05 10:07:21 UTC
dependencies:

  • matplotlib
  • numpy >=1.14.6,<2.0a0
  • python >=3.7,<3.8.0a0
  • scipy
  • sundials >=3.2.1,<3.3.0a0
  • vc >=14,<15.0a0`

My question is if Sundials 4.1 support is really implemented and there is a flaw in the package specifications in conda.

Assimulo Couldn't Work Correctly

when I trying to import assimulo using from assimulo.solvers import RodasODEfrom assimulo.problem import Explicit_Problem,it broke with a notion: Could not find GLIMDA. I checked the ....conda\pkgs\assimulo-3.2.9-py39h5a31ec5_0\Lib\site-packages\assimulo\solvers\glimda.py file and found this part:

try:
    from assimulo.lib.glimda import glimda
except ImportError:
    sys.stderr.write("Could not find GLIMDA.\n")

didn't work well. it's like there is no such a file named glimda in assimulo\lib and I got no idea about how to make it work well. If any of your guys have some useful options to deal with this, I will be appreciated so much.

"The 'IF' statement is deprecated and will be removed in a future Cython version"

(For visibility)

The build output is littered with the warning The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead., which is from the conditional compilation based on the Sundials version used.

There does not seem to be a straight-forward alternative right now and there is no timeline for actually removing it as of now. See further: cython/cython#4310.

Also see comment in particular, current plan is to ignore the warning and monitor the developments in Cython.

numpy.float

When I run simulate using Radau5ODE, I get a large number of errors

Traceback (most recent call last):
File "/home/peter/miniforge3/envs/stites/lib/python3.11/site-packages/numpy/init.py", line 324, in getattr
raise AttributeError(former_attrs[attr])
AttributeError: module 'numpy' has no attribute 'float'.
np.float was a deprecated alias for the builtin float. To avoid this error in existing code, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
Exception ignored in: 'radau5ode.py2c_d'

These do not occur with RodasODE, CVode, or LSODAR. The only place I could find N.float in the repo is explicit_ode.pyx, lines 40 and 41, but I am not sure how to test if that is the problem.

Installation issues

Hello,

I am trying to get an Assimulo installation set up, with no success. Any advice would be appreciated. Please let me know if there's a more appropriate place that I should put this. I have tried both using pip, and also installing the latest version (3.5.0) using setup.py with the path to my sundials library provided. My setup details and the error that I get are below:

Ubuntu 22.04 running on WSL
python 3.10
numpy 1.26.4
scipy 1.13.0
cython 3.0.10
matplotlib 3.9.0
sundials7.0.0, installed with LAPACK and CFLAGS=”-fPIC”
CMake 3.29
make 4.3
gfortran 11.4.0
libopenblas-dev 0.3.20
liblapack-dev 3.10.0

The final error message is:
Error: Rank mismatch in argument ‘cont’ at (1) (scalar and rank-1)
error: Command "/usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops -I/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/assimulo/thirdparty/hairer -I/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.10/numpy/distutils/include -I/home/isaac_basil/Documents/python_projects/test_assimulo/venv/include -I/usr/include/python3.10 -c -c assimulo/thirdparty/hairer/radau_decsol.f -o build/temp.linux-x86_64-cpython-310/assimulo/thirdparty/hairer/radau_decsol.o" failed with exit status 1

Before that, there are also other warnings:

WARN: CCompilerOpt.dist_test[637] : CCompilerOpt._dist_test_spawn[771] : Command (x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/isaac_basil/Documents/python_projects/test_assimulo/venv/include -I/usr/include/python3.10 -c /home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c -o /tmp/tmp8m9dxqha/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.o -MMD -MF /tmp/tmp8m9dxqha/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.o.d -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -mavx512f -mno-mmx -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512vnni -mavx512ifma -mavx512vbmi -mavx512vbmi2 -mavx512bitalg -mavx512vpopcntdq -Werror) failed with exit status 1 output ->
/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c: In function ‘main’:
/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c:22:5: error: unknown type name ‘__m512h’; did you mean ‘__m512bh’?
22 | __m512h a = _mm512_loadu_ph((void*)argv[argc-1]);
| ^~~~~~~
| __m512bh
/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c:22:17: error: implicit declaration of function ‘_mm512_loadu_ph’; did you mean ‘_mm512_loadu_ps’? [-Werror=implicit-function-declaration]
22 | __m512h a = _mm512_loadu_ph((void*)argv[argc-1]);
| ^~~~~~~~~~~~~~~
| _mm512_loadu_ps
/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c:23:5: error: unknown type name ‘__m512h’; did you mean ‘__m512bh’?
23 | __m512h temp = _mm512_fmadd_ph(a, a, a);
| ^~~~~~~
| __m512bh
/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c:23:20: error: implicit declaration of function ‘_mm512_fmadd_ph’; did you mean ‘_mm512_fmadd_ps’? [-Werror=implicit-function-declaration]
23 | __m512h temp = _mm512_fmadd_ph(a, a, a);
| ^~~~~~~~~~~~~~~
| _mm512_fmadd_ps
/home/isaac_basil/Documents/python_projects/test_assimulo/venv/lib/python3.10/site-packages/numpy/distutils/checks/cpu_avx512_spr.c:24:5: error: implicit declaration of function ‘_mm512_storeu_ph’; did you mean ‘_mm512_storeu_ps’? [-Werror=implicit-function-declaration]
24 | _mm512_storeu_ph((void*)(argv[argc-1]), temp);
| ^~~~~~~~~~~~~~~~
| _mm512_storeu_ps
cc1: all warnings being treated as errors

WARN: CCompilerOpt.feature_test[1576] : testing failed

CVODE Parallel

Hi, thanks for this nice package.

Just wondering if it is possible to run CVODE with multiple threads with DENSE linear solver.

Thanks.
Ivan

SPGMR vs DENSE linear solver issue

Hi all,

I installed using assimulo to integrate a large kinetic mechanism with cvode.

To get familirity with assimulo, I created a dummy example to couple assimulo and cantera using methane kinetic mechanism.
Everything seems to work fine if I use 'DENSE' as linear solver, but when i switch to 'SPGMR' (even if I set up everything as the example cvode_with_jac_spgmr.py) the solution fails because assimulo doesnt seem to integrate the ode system correctly. In the attachment the comparison of the dense vs spgmr solver and here below my code. Am I doing anything wrong?

Thanks a lot for any comments and help,

`import numpy as np
import cantera as ct
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem

gasconstant = 8314.46261815324

def f(t, y):
gas.set_unnormalized_mass_fractions(y[1:])
print(y[0])
gas.TD = y[0], rho1
wdot = gas.net_production_rates
dYdt = wdot * Wk / rho1
dTdt = - (np.dot(gas.partial_molar_enthalpies - np.ones(gas.n_species) * gasconstant * y[0], wdot) /
(rho1 * gas.cv))
yd_v = np.zeros(nsp)
yd_v[0] = dTdt
yd_v[1:] =dYdt
return yd_v

def jacv(t, y, fy, v):
eps1 = 1e-7
Jac = np.empty([nsp, nsp])
dy_perturbed_neg = f(t, y)
for i in range(nsp):
y_perturbed = np.copy(y)
y_perturbed[i] = y_perturbed[i] + eps1
dy_perturbed_pos = f(t, y_perturbed)
Jac[:, i] = (dy_perturbed_pos - dy_perturbed_neg) / (1 * eps1)
return np.dot(v,Jac)

gas = ct.Solution('gri30.yaml')
gas.TP = 900,50*1e5
gas.set_equivalence_ratio(1, 'CH4:1', 'O2:1,N2:3.76')

Wk = gas.molecular_weights
rho1 = gas.density
y0 = np.hstack((gas.T, gas.Y))
nsp =len(y0)

exp_mod = Explicit_Problem(f, y0, name='Example using the Jacobian Vector product')
exp_mod.jacv = jacv # Sets the Jacobian
exp_sim = CVode(exp_mod) # Create a CVode solver

exp_sim.iter = 'Newton' # Default 'FixedPoint'
exp_sim.discr = 'BDF' # Default 'Adams'
exp_sim.atol = 1e-10 # Default 1e-6
exp_sim.rtol = 1e-4 # Default 1e-6
exp_sim.linear_solver = 'spgmr' # Change linear solver
exp_sim.options["usejac"] = True

t, y = exp_sim.simulate(1, 1000) # Simulate 5 seconds with 1000 communication points

import matplotlib
matplotlib.use('Qt5Agg')

import matplotlib.pyplot as plt
plt.plot(t,y[:,0],linestyle="dashed",marker="o") #Plot the solution
plt.xlim(0, 0.5)

plt.ylim(800,3000)
plt.show()`

assimulo_jac_spgmr.txt
Capture

Compile failed

Hi!
Неre build error log:

compile options: '-I/usr/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/assimulo/thirdparty/hairer -I/usr/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/numpy/distutils/include -I/usr/include/python3.9 -c'
gfortran:f77: assimulo/thirdparty/hairer/radau_decsol.f
gfortran:f77: build/src.linux-x86_64-3.9/assimulo/thirdparty/hairer/radau5-f2pywrappers.f
assimulo/thirdparty/hairer/radau_decsol.f:1230:72:

 1230 |  30       A(I,K) = -A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 30 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1237:72:

 1237 |  40         A(I,J) = A(I,J) + A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 40 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1277:72:

 1277 |  10       B(I) = B(I) + A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 10 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1285:72:

 1285 |  30       B(I) = B(I) + A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 30 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1343:72:

 1343 |  30       A(I,K) = -A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 30 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1350:72:

 1350 |  40         A(I,J) = A(I,J) + A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 40 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1392:72:

 1392 |  10       B(I) = B(I) + A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 10 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1400:72:

 1400 |  30       B(I) = B(I) + A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 30 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1790:72:

 1790 |       DO 5 I = 1,ML
      |                                                                        1
Warning: Fortran 2018 deleted feature: Shared DO termination label 5 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1791:72:

 1791 |   5   A(I,J) = 0.D0
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 5 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1810:72:

 1810 |  30       A(I,K) = -A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 30 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1826:72:

 1826 |  40         A(IJK,J) = A(IJK,J) + A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 40 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1872:72:

 1872 |  10       B(IMD) = B(IMD) + A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 10 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1883:72:

 1883 |  30       B(IMD) = B(IMD) + A(I,K)*T
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 30 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:1931:72:

 1931 |       DO 5 I = 1,ML
      |                                                                        1
Warning: Fortran 2018 deleted feature: Shared DO termination label 5 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:2178:72:

 2178 |   140      a(i,j) = a(i,j) - y * a(m,j)
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 140 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:2181:72:

 2181 |   150      a(j,m) = a(j,m) + y * a(j,i)
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 150 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:4377:72:

 4377 |   623       SUM=SUM+FMAS(I,J)*YNEW(J)
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 623 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:4378:72:

 4378 |   624    AK(I)=AK(I)+SUM
      |                                                                        1
Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 624 at (1)
assimulo/thirdparty/hairer/radau_decsol.f:958:25:

  958 |      &          F1,F2,F3,CONT,IP1,IP2,IPHES,IER,IJOB)
      |                         1
Error: Rank mismatch in argument ‘cont’ at (1) (scalar and rank-1)
error: Command "/usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops -I/usr/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/assimulo/thirdparty/hairer -I/usr/lib/python3.9/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.9/numpy/distutils/include -I/usr/include/python3.9 -c -c assimulo/thirdparty/hairer/radau_decsol.f -o build/temp.linux-x86_64-3.9/assimulo/thirdparty/hairer/radau_decsol.o" failed with exit status 1

########### EXT COMPILER OPTIMIZATION ###########
Platform      : 
  Architecture: x64
  Compiler    : gcc

CPU baseline  : 
  Requested   : 'min'
  Enabled     : SSE SSE2 SSE3
  Flags       : -msse -msse2 -msse3
  Extra checks: none

CPU dispatch  : 
  Requested   : 'max -xop -fma4'
  Enabled     : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL
  Generated   : none
CCompilerOpt._cache_write[796] : write cache to path -> /home/inpos/tmp/Assimulo-Assimulo-3.2.5/build/build/temp.linux-x86_64-3.9/ccompiler_opt_cache_ext.py

OS: Gentoo Linux x86_64
Python: 3.9.5
GCC:

COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/10.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/notmpfs/portage/sys-devel/gcc-10.3.0/work/gcc-10.3.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/10.3.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.3.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.3.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.3.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/include/g++-v10 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/10.3.0/python --enable-languages=c,c++,go,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 10.3.0 p1' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --without-isl --enable-default-pie --enable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.0 (Gentoo 10.3.0 p1)

Cython 3.0 support

Assimulo does not build with Cython 3. We should add support for that.

Build error I got when trying with latest Cython available with Python 3.8:

[1/1] Cythonizing assimulo/explicit_ode.pyx
/opt/venv/lib/python3.8/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /opt/build/wheel_build/build/assimulo/explicit_ode.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:
------------------------------------------------------------
...
        cdef N.ndarray[double, mode="c", ndim=1] g_high_c = N.empty(n_g, dtype = N.double)
        cdef N.ndarray[double, mode="c", ndim=1] y_high_c = N.array(y_high)
        cdef int nstatefcns = 0
        cdef int ret = explicit_ode.f_event_locator(len(y_high), n_g, 1.e-13, t_low, &t_high,
                                                    &y_high_c[0], &g_low_c[0], &g_mid_c[0], &g_high_c[0],
                                                    callback_event, <void*>self.event_func,
                                                    ^
------------------------------------------------------------

assimulo/explicit_ode.pyx:345:52: Cannot assign type 'int (int, int, double, double *, double *, void *) except? -1' to 'FP_event_func'. Exception values are incompatible. Suggest adding 'noexcept' to type 'int (int, int, double, double *, double *, void *) except? -1'.

Error compiling Cython file:
------------------------------------------------------------
...
        cdef N.ndarray[double, mode="c", ndim=1] y_high_c = N.array(y_high)
        cdef int nstatefcns = 0
        cdef int ret = explicit_ode.f_event_locator(len(y_high), n_g, 1.e-13, t_low, &t_high,
                                                    &y_high_c[0], &g_low_c[0], &g_mid_c[0], &g_high_c[0],
                                                    callback_event, <void*>self.event_func,
                                                    callback_interp, <void*>self.interpolate,
                                                    ^
------------------------------------------------------------

assimulo/explicit_ode.pyx:346:52: Cannot assign type 'int (int, double, double *, void *) except? -1' to 'FP_interpolation'. Exception values are incompatible. Suggest adding 'noexcept' to type 'int (int, double, double *, void *) except? -1'.
Traceback (most recent call last):
  File "setup.py", line 652, in <module>
    ext_list = prepare.cython_extensionlists()
  File "setup.py", line 472, in cython_extensionlists
    ext_list = cythonize([os.path.join("assimulo", "explicit_ode.pyx")],
  File "/opt/venv/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
    cythonize_one(*args)
  File "/opt/venv/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: assimulo/explicit_ode.pyx

Installation from pip broken

While the installation through conda goes smoothly, the installation through pip is broken due to some missing files:

DEBUG:['thirdparty/hairer/LICENSE_HAIRER', 'lib/hairer/LICENSE_HAIRER', 'thirdparty/glimda/LICENSE_GLIMDA', 'lib/glimda/LICENSE_GLIMDA', 'thirdparty/odepack/LICENSE_ODEPACK', 'lib/odepack/LICENSE_ODEPACK', 'thirdparty/odassl/LICENSE_ODASSL', 'lib/odassl/LICENSE_ODASSL', 'thirdparty/dasp3/LICENSE_DASP3', 'lib/dasp3/LICENSE_DASP3']
non-existing path in '': 'assimulo/thirdparty/hairer/dopri5.pyf'
non-existing path in '': 'assimulo/thirdparty/hairer/rodas_decsol.pyf'
non-existing path in '': 'assimulo/thirdparty/hairer/radau_decsol.pyf'
non-existing path in '': 'assimulo/thirdparty/hairer/radar5.pyf'
non-existing path in '': 'assimulo/thirdparty/odepack/odepack.pyf'
non-existing path in '': 'assimulo/thirdparty/odassl/odassl.pyf'
running egg_info
running build_src
build_src
building extension "assimulo.algebraic" sources
building extension "assimulo.explicit_ode" sources
building extension "assimulo.implicit_ode" sources
building extension "assimulo.ode" sources
building extension "assimulo.problem" sources
building extension "assimulo.special_systems" sources
building extension "assimulo.support" sources
building extension "assimulo.solvers.euler" sources
building extension "assimulo.lib.dopri5" sources
target build/src.linux-x86_64-3.8/assimulo/thirdparty/hairer/dopri5module.c does not exist:
Assuming dopri5module.c was generated with "build_src --inplace" command.
error: 'assimulo/thirdparty/hairer/dopri5module.c' missing
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Installed packages are python 3.8, scipy 1.4.1, cython 0.29.14.

Difficulty in understanding the meaning of the `Explicit_problem` field `jac_nnz`

I was going through this example and I'm having difficulty in understanding what does exp_mod.jac_nnz exactly mean. In the sundials.pyx module, jac_nnz is kind of defined though this exception:

#Specify the use of CVSPGMR linear solver.
if self.problem_info["jac_fcn_nnz"] == -1:
    raise AssimuloException("Need to specify the number of non zero elements in the Jacobian via the option 'jac_nnz'")

which makes sense, as nnz has mean the number of non-zero elements in the parlance of ODE solvers. But then I don't understand why in the example it is set as exp_mod.jac_nnz = 9. Because if one calculates, the 2-D jacobian of that system, you will find that it only has at most 7 non-zero elements. So, I'm not sure how this 9 was calculated.

I'm sorry if this is really a trivial question and I have made a very doltish mistake.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.