Skip to content

Conversation

@dgaida
Copy link
Owner

@dgaida dgaida commented Jan 27, 2026

No description provided.

google-labs-jules bot and others added 3 commits January 27, 2026 08:15
…base

Ensured that all state vectors and flow rate lists passed to DLL methods
are converted to 2D numpy arrays. This resolves the recurring
'ArgumentException: Object of type System.Double[] cannot be converted to type System.Double[,]'
caused by pythonnet 3.x strictness.

Changes:
- In feedstock.py: used np.array to preserve 2D structure of mixed ADM streams
- In adm1.py: used np.atleast_2d for state vectors in process indicators and ODE
- In parallel.py: used np.atleast_2d for metrics calculation
- In digester.py: used np.atleast_2d for process indicators in step()
- In adm_equations.py: used np.atleast_2d for pH calculation in acid-base rates

This thorough fix ensures stability across all simulation paths.

Co-authored-by: dgaida <23057824+dgaida@users.noreply.github.com>
Systematically ensured that all state vectors and flow rate lists passed
to .NET DLL methods (biogas.ADMstate and substrates.mySubstrates) are
converted to 2D numpy arrays. This resolves ArgumentException errors
in pythonnet 3.x due to strict double[] vs double[,] type checking.

Files updated:
- pyadm1/core/adm1.py
- pyadm1/substrates/feedstock.py
- pyadm1/simulation/parallel.py
- pyadm1/components/biological/digester.py
- pyadm1/core/adm_equations.py

Co-authored-by: dgaida <23057824+dgaida@users.noreply.github.com>
Ensured that all state vectors and flow rate lists passed to .NET DLL methods
are converted to standard Python lists of floats. This resolves both
dimensionality mismatches (Double[] vs Double[,]) and type conversion
failures (np.float64 to System.Double) in pythonnet 3.x.

Changes:
- In feedstock.py: Reverted mixADMstreams to use a 1D list of standard floats.
- In adm1.py: Updated process value calculations and DLL calls to use list comprehension
  [float(x) for x in data] to ensure standard types.
- Systematically applied similar changes to parallel.py, digester.py, and adm_equations.py.
- Maintained targeted use of 2D NumPy arrays only where specifically required
  by method signatures.

This fix addresses the 'No method matches given arguments' and 'ArgumentException'
errors reported in parallel simulation tests.

Co-authored-by: dgaida <23057824+dgaida@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants