modsim / CADET

A modular, fast, and accurate simulation framework for (column) liquid chromatography
GNU General Public License v3.0
49 stars 24 forks source link

Choose best defaults for modified Newton method #221

Open jbreue16 opened 1 week ago

jbreue16 commented 1 week ago

We have made the choice of full and modified Newton method optional. Full Newton method is still the default since FV is also still the default, for which the modified Newton showed mixed results with full Newton being more performant for more time consuming models (i.e. non-linear binding for LRMP and GRM), see the FV benchmarks.

For DG and the LRMP and GRM however, modifed Newton was generally faster, see the DG benchmarks. We added modified Newton as the recommended default for these settings to the documentation.

Once DG becomes the spatial methods default, we need to make modified Newton the default.

jbreue16 commented 5 days ago

Ive tested full vs modified Newton for specific SMB systems (thanks to @schmoelder) and these settings show similar results to what we saw for the single column benchmakrs, i.e. an advantage of the full newton method for FV $N_e=100$ and of the modified Newton method for DG ($N_d=4, N_e=16$). Notably, DG was substantially faster, even though the number of axial discrete points is only slightly smaller (80 for DG and100 for FV ). A more rigorous convergence benchmark could be conducted to get more detailed insights into the perfromance differences.

The results are:

    "single_column_DG": {
        "DG_Modified_Newton_sim_time": 1.2131713000000002,
        "DG_Full_Newton_sim_time": 3.3930438,
        "FV_Modified_Newton_sim_time": 6.588945300000001,
        "FV_Full_Newton_sim_time": 5.599763
    },
    "single_column_DG_cstr": {
        "DG_Modified_Newton_sim_time": 1.2799902,
        "DG_Full_Newton_sim_time": 4.2717521000000005,
        "FV_Modified_Newton_sim_time": 6.9316716000000005,
        "FV_Full_Newton_sim_time": 6.087354
    },
    "single_column_DG_lrm": {
        "DG_Modified_Newton_sim_time": 1.3860162,
        "DG_Full_Newton_sim_time": 4.4453478,
        "FV_Modified_Newton_sim_time": 22.029851,
        "FV_Full_Newton_sim_time": 23.743489200000003
    },
    "smb_DG_cstr": {
        "DG_Modified_Newton_sim_time": 32.962329100000005,
        "DG_Full_Newton_sim_time": 48.967928900000004,
        "FV_Modified_Newton_sim_time": 252.32834300000002,
        "FV_Full_Newton_sim_time": 158.61109960000002
    },
    "smb_DG_lrm": {
        "DG_Modified_Newton_sim_time": 14.4318898,
        "DG_Full_Newton_sim_time": 28.966108900000002,
        "FV_Modified_Newton_sim_time": 416.86199000000005,
        "FV_Full_Newton_sim_time": 254.41401140000002
    }

The benchmark code and its results can be found on gitlab.