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

Python issues on high kinetics while simulating ECcat mechanism #6

Open
shuayliu opened this issue Feb 23, 2023 · 1 comment
Open

Comments

@shuayliu
Copy link

Hey, I found this excellent package simulating the cyclic voltammetry and try to use it in my projects. When I simulated the ECcat mechanism with high homogeneous kinetics, this programme returns std::badloc error. I tried to solve it myself, but I failed.

Here is the codes I use:

import pyecsim as ecs
import matplotlib.pyplot as plt

simECr = ecs.Simulation(True)

P = ecs.Species('P', 1.0, 1.0e-9) # name, concentration [mol/m3], diffusion coefficient [m2/s]
Q = ecs.Species('Q', 0.0, 1.0e-9)

A = ecs.Species('A', 1.0, 1.0e-9)
B = ecs.Species('B', 0.0, 1.0e-9)
# C = ecs.Species('C', 0.0, 1.0e-9)

rdx1 = ecs.Redox(P, Q, 1, 0.0, 1, 0.5).enable() # ox, red, n, E_0 [V], k_e [m/s], alpha
simECr.sys.addRedox( rdx1 )

rxn1 = ecs.Reaction(A, Q, B, P, 300000, 0).enable() # reactant1, reactant2, product1, product2, k_f, k_b
simECr.sys.addReaction( rxn1 )

simECr.el.disk(1.0e-3) # radius [m]
simECr.exper.setScanPotentials(0.5, [-0.5], 0.5) # potentials [V]: initial, [0 or more vertices], final
simECr.exper.setScanRate(0.05) # scan rate [V/s]

plt.plot(*simECr.run())

And the error message :

---------------------------------------------------------------------------
MemoryError                               Traceback (most recent call last)
<ipython-input-6-c5b7c4bcb650> in <module>
      1 # [potential, current] = simECr.run()
      2 # rxn1.setKf(2.3e3)
----> 3 plt.plot(*simECr.run())

MemoryError: std::bad_alloc

my working environment: CentOS 7.9, JupyterLab 3.2.9, Python 3.6.8, the pyecsim package was installed through PyPi.

I succeeded using these parameters on your website version, so I guess there might be something wrong with the python version.

Thanks a lot!

@Limhes
Copy link
Owner

Limhes commented Jun 29, 2023

Hi, sorry for the late answer. Hope it still reaches you :)

I've heard from another user who had similar issues, and we were unfortunately unable to find out where the error originates. What we did validate, is that both the Python code and the website version are compiled from the exact same source (same version), and therefore it must be either (1) the Python version running into some unknown error or (2) the webassembly version running into the same error but continues anyway. I am not sure.

As a workaround, you can run all simulations directly from C++. It is easy enough ;)

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

No branches or pull requests

2 participants