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

Adding small CSTRs slow down simulation #213

Open
schmoelder opened this issue Jun 17, 2024 · 3 comments
Open

Adding small CSTRs slow down simulation #213

schmoelder opened this issue Jun 17, 2024 · 3 comments
Labels

Comments

@schmoelder
Copy link
Contributor

schmoelder commented Jun 17, 2024

To simplify the setup of large multi-column systems, the CarouselBuilder in CADET-Process adds small CSTR units for each zone inlet and outlet which serve to distribute the in- and outgoing streams. However, we noted that this massively slows down the simulation time compared to a setup without these distributor valves. For example, using a standard 4-Zone SMB without the CSTRs, the simulation time is ~10 s for 10 cycles. Adding the CSTRs increases this to ~40 s.

Trying to figure out what causes the slow-down, @ronald-jaepel suggested replacing the CSTRs with a LRM(P) with the same (small) volume and a single cell (using FV). This actually reduced simulation time down to ~20 s, which is still a bit more than I had hoped for but it is a large improvement. So something seems "off" with the CSTR.

Our first hypothesis was that even though in this case Q_in == Q_out for all CSTRs, the volume is still updated for each time step. Small variation due to floating point precision, combined with the fact that volumes in SI units are always awkwardly small, could make the system very stiff, increasing the simulation time.

@jbreue16 created an alternative CSTR unit operation with constant volume (see https://github.com/modsim/CADET/tree/feature/cstr_const_volume). However, first tests did not improve the simulation times at all (still ~40 s). So the hunt continues...

@lieres
Copy link
Member

lieres commented Jun 17, 2024

Puh, I was hoping for something else. Have you set the dispersion coefficient $D=0$ in the LRM(P) tests?

@AntoniaBerger
Copy link
Collaborator

AntoniaBerger commented Oct 9, 2024

When simulating a CSTR (system), the calculation time apparently depends on its volume and the ratio to the concentration fed into the sections.
The concrete observation so far is:
If the injected concentration is greater than the volume of the CSTR, the simulation of the CSTR (system) is up to ~4.5x slower than if the injected volume is less than or equal to the volume. For example, in a system with 5 CSTRs with a volume of 1E-3 each, a sudden increase in simulation time can be observed as soon as a concentration of more than 1E-3 is injected. (calculation script).
CSTR_Duration

Furthermore, we investigated which parts of Cadet contribute to the overall runtime. An overview of the findings is shown below. Each case involves 5 CSTRs, a cycle time of 500 minutes, 10 cycles, and adjusted relative and absolute tolerances.

@AntoniaBerger
Copy link
Collaborator

AntoniaBerger commented Oct 21, 2024

For a more structured analysis, the table below compares the exact calculation times for CADET-Core, CADET Python and CADET - Process for a CSTR and LRM system.

grafik

A more detailed profile analysis indicates that the overhead of the 4th case (CSTR with volume 1E-4 and injected volume 1E-3) is largely addessable to writing the results in the h5 file (see figure below). This also align with the observation that adjusting the tolerances for the integrater had no effect on the runtime behavior from the table abouve.

grafik

It would be interesting to see whether this problem also occurs with the new C-API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants