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

Parametric_tw_csv example #10

Merged
merged 6 commits into from
Sep 5, 2023
Merged

Parametric_tw_csv example #10

merged 6 commits into from
Sep 5, 2023

Conversation

dreamer2368
Copy link
Collaborator

@dreamer2368 dreamer2368 commented Aug 29, 2023

Miscellaneous addition to pylibROM

  • Bindings for utils::CSVDatabase and utils::HDFDatabase
  • python_utils/cpp_utils.hpp now provides a template function get1DArrayFromPtr for numpy array.
    • This resolves the issue Bindings with STL class input/output #11 , where the view numpy array is returned instead of the actual std::vector output variable.
    • The example is in line 110 of utils/pyCSVDatabase.cpp:
    csvdb.def("getIntegerVector", [](
        CSVDatabase &self, const std::string& key, bool append)
    {
        std::vector<int> *datavec = new std::vector<int>;
        self.getIntegerVector(key, *datavec, append);
        return get1DArrayFromPtr(datavec->data(), datavec->size(), true);
    },

examples/dmd/parametric_tw_csv.py example demonstration

parametric_tw_csv.py demonstrates the parametric DMD, along with the use of CSV/HDF databases.

  1. FOM sampling process
  • csv format
bash ./heat_conduction_csv.sh
  • hdf5 format
bash ./heat_conduction_hdf.sh
  1. Case1: serial DMD
    Add -hdf tag if you're following the workflow for hdf5.
python3 parametric_tw_csv.py -o hc_parametric_serial -rdim 16 -dtc 0.01 -offline
python3 parametric_tw_csv.py -o hc_parametric_serial -rdim 16 -dtc 0.01 -online
  1. Case2: time-windowing DMD
    Add -hdf tag if you're following the workflow for hdf5.
python3 parametric_tw_csv.py -o hc_parametric_tw -nwinsamp 25 -dtc 0.01 -offline
python3 parametric_tw_csv.py -o hc_parametric_tw -nwinsamp 25 -dtc 0.01 -offline

Demonstration results

  1. serial DMD, csv
Norm of true solution at t = 0.500

000 is 84.539879
Absolute error of DMD solution at t = 0.500000 is 0.106531
Relative error of DMD solution at t = 0.500000 is 0.001260

Elapsed time for training DMD: 0.000000e+00 second
Elapsed time for preprocessing DMD: 2.193182e-01 second
Total elapsed time for predicting DMD: 1.743942e+00 second
Average elapsed time for predicting DMD: 3.419494e-02 second

little difference from c++ libROM:

Norm of true solution at t = 0.5000000000000002 is 84.53987904150704
Absolute error of DMD solution at t = 0.5000000000000002 is 0.1065308142113612
Relative error of DMD solution at t = 0.5000000000000002 is 0.001260124989758469
Elapsed time for training DMD: 0.000000e+00 second
Elapsed time for preprocessing DMD: 2.209829e-01 second
Total elapsed time for predicting DMD: 1.791613e+00 second
Average elapsed time for predicting DMD: 3.512967e-02 second
  1. serial DMD, hdf
Norm of true solution at t = 0.500000 is 84.539879
Absolute error of DMD solution at t = 0.500000 is 0.106531
Relative error of DMD solution at t = 0.500000 is 0.001260

Elapsed time for training DMD: 0.000000e+00 second
Elapsed time for preprocessing DMD: 2.122204e-01 second
Total elapsed time for predicting DMD: 1.759935e+00 second
Average elapsed time for predicting DMD: 3.450852e-02 second

similar result from c++ libROM:

Norm of true solution at t = 0.5000000000000002 is 84.53987904150704
Absolute error of DMD solution at t = 0.5000000000000002 is 0.1065308142113612
Relative error of DMD solution at t = 0.5000000000000002 is 0.001260124989758469
Elapsed time for training DMD: 0.000000e+00 second
Elapsed time for preprocessing DMD: 1.646451e-01 second
Total elapsed time for predicting DMD: 1.757581e+00 second
Average elapsed time for predicting DMD: 3.446237e-02 second
  1. time-windowing, csv
Norm of true solution at t = 0.500000 is 84.539879
Absolute error of DMD solution at t = 0.500000 is 0.055013
Relative error of DMD solution at t = 0.500000 is 0.000651

Elapsed time for training DMD: 0.000000e+00 second
Elapsed time for preprocessing DMD: 1.072407e-01 second
Total elapsed time for predicting DMD: 2.882011e-01 second
Average elapsed time for predicting DMD: 5.651002e-03 second

c++ libROM:

Norm of true solution at t = 0.5000000000000002 is 84.53987904150704
Absolute error of DMD solution at t = 0.5000000000000002 is 0.0550131373888892
Relative error of DMD solution at t = 0.5000000000000002 is 0.0006507359368456049
Elapsed time for training DMD: 0.000000e+00 second
Elapsed time for preprocessing DMD: 8.679060e-02 second
Total elapsed time for predicting DMD: 2.865902e-01 second
Average elapsed time for predicting DMD: 5.619415e-03 second
  1. time-windowing, hdf
Norm of true solution at t = 0.500000 is 84.539879
Absolute error of DMD solution at t = 0.500000 is 0.055013
Relative error of DMD solution at t = 0.500000 is 0.000651

Elapsed time for training DMD: 0.000000e+00 second
Elapsed time for preprocessing DMD: 1.108568e-01 second
Total elapsed time for predicting DMD: 3.017945e-01 second
Average elapsed time for predicting DMD: 5.917540e-03 second

c++ libROM:

Norm of true solution at t = 0.5000000000000002 is 84.53987904150704
Absolute error of DMD solution at t = 0.5000000000000002 is 0.05501313738888904
Relative error of DMD solution at t = 0.5000000000000002 is 0.000650735936845603
Elapsed time for training DMD: 0.000000e+00 second
Elapsed time for preprocessing DMD: 7.375104e-02 second
Total elapsed time for predicting DMD: 2.931510e-01 second
Average elapsed time for predicting DMD: 5.748059e-03 second

@dreamer2368 dreamer2368 marked this pull request as ready for review August 31, 2023 00:55
@dreamer2368 dreamer2368 changed the title Twcsv Parametric_tw_csv example Aug 31, 2023
@dreamer2368 dreamer2368 added the RFR Ready for review label Aug 31, 2023
@dreamer2368 dreamer2368 mentioned this pull request Aug 31, 2023
@dreamer2368 dreamer2368 merged commit 3199284 into main Sep 5, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants