Willcox-Research-Group / rom-operator-inference-Python3

Operator Inference for data-driven, non-intrusive model reduction of dynamical systems.

Home Page:https://willcox-research-group.github.io/rom-operator-inference-Python3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Receive `Required step size is less than spacing between numbers` when using `cAH` mode.

minhtriet opened this issue · comments

commented

The objective
I tried to run the code with cA mode. After that I include model form H mode to cA to improve performance. However, I receive the error IntegrationWarning: Required step size is less than spacing between numbers from rom_operator_inference/core/nonparametric/_public.py

Already tried tests

def prepare_data_and_train(data_to_train, r, regularizer=1e-2):
  train_data_derivative = opinf.pre.ddt(data_to_train, DELTA_T, order=6)        # Calculate the time derivative matrix.
  Vr, _ = opinf.pre.pod_basis(data_to_train, r=r)    
  rom = opinf.ContinuousOpInfROM(modelform="cAH")  
  rom.fit(Vr, data_to_train, train_data_derivative, regularizer=regularizer)
  return rom

During my simulation, I took care to not let the Courant strays far from 1.0

How could I debug this error?

commented

This happened when I tried to increase r from pre.pod_basis from 3 to 4, 5, 6 etc. Also, if I change the mode from cAH to cAHG, then the integration error doesn't happen at pod_basis=4

commented

A grid search shows some insights, the first column is number of basis, 2nd is regularizer

4 10000.0
4 100000.0
4 1000000.0
4 10000000.0
5 10000.0
5 100000.0
5 1000000.0
5 10000000.0
6 10000.0
6 100000.0
6 1000000.0
6 10000000.0
7 10000.0
With r=7, regularizer=10000.0, integration error happens
7 100000.0
7 1000000.0
7 10000000.0
8 10000.0
8 100000.0
8 1000000.0
8 10000000.0
9 10000.0
9 100000.0
9 1000000.0
9 10000000.0
10 10000.0
10 100000.0
10 1000000.0
10 10000000.0
11 10000.0
11 100000.0
11 1000000.0
11 10000000.0
12 10000.0
12 100000.0
12 1000000.0
12 10000000.0
With r=13, regularizer=10000.0, unterdetermined system
With r=13, regularizer=100000.0, unterdetermined system
With r=13, regularizer=1000000.0, unterdetermined system
With r=13, regularizer=10000000.0, unterdetermined system
With r=14, regularizer=10000.0, unterdetermined system
With r=14, regularizer=100000.0, unterdetermined system
With r=14, regularizer=1000000.0, unterdetermined system
With r=14, regularizer=10000000.0, unterdetermined system
With r=15, regularizer=10000.0, unterdetermined system
With r=15, regularizer=100000.0, unterdetermined system
With r=15, regularizer=1000000.0, unterdetermined system
With r=15, regularizer=10000000.0, unterdetermined system
commented

By setting regularization to very large number (in comparison to machine learning normal range) like 3000 or 4000, I was able to solve the issue, but I do not know why

@minhtriet, the appropriate range for the regularizer is highly problem dependent. In relatively simple problems, we've had success with small regularization values. In others, such as in this paper, we've needed larger regularization values like the ones you are seeing. So this is normal. Hope that helps.

commented

@minhtriet yes, I recommend searching for the regularizer on a log scale, np.logspace() might be helpful. This repository might also be helpful to look at (specifically step3_train.py, though it uses an older version of the package).