From 54814a43cbba70d5cd1c752b876ac84c4032fe74 Mon Sep 17 00:00:00 2001
From: Ian Bell <ian.bell@nist.gov>
Date: Fri, 15 Oct 2021 21:03:06 -0400
Subject: [PATCH] Remove some example files that are no longer relevant and
 superceded by other things

---
 src/main.cpp          | 75 -------------------------------------------
 src/test_autodiff.cpp | 67 --------------------------------------
 src/test_variant.cpp  | 68 ---------------------------------------
 3 files changed, 210 deletions(-)
 delete mode 100644 src/main.cpp
 delete mode 100644 src/test_autodiff.cpp
 delete mode 100644 src/test_variant.cpp

diff --git a/src/main.cpp b/src/main.cpp
deleted file mode 100644
index 9180327..0000000
--- a/src/main.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-#include <iostream>
-#include <algorithm>
-#include <numeric>
-#include <valarray>
-#include <chrono>
-#include <iomanip>
-
-#include "teqp/derivs.hpp"
-#include "teqp/models/eos.hpp"
-#include "teqp/models/pcsaft.hpp"
-
-void test_vdwMix() {
-    // Argon + Xenon
-    std::valarray<double> Tc_K = { 150.687, 289.733 };
-    std::valarray<double> pc_Pa = { 4863000.0, 5842000.0 };
-    vdWEOS<double> vdW(Tc_K, pc_Pa);
-
-    double T = 298.15;
-    auto rho = 3.0;
-    auto R = get_R_gas<double>();
-    auto rhotot = rho;
-
-    const auto rhovec = (Eigen::ArrayXd(2) << rho/2, rho/2).finished();
-
-    auto fPsir = [&vdW](const auto& T, const auto& rhovec) {
-        using container = decltype(rhovec);
-        auto rhotot_ = std::accumulate(std::begin(rhovec), std::end(rhovec), (decltype(rhovec[0]))0.0);
-        auto molefrac = rhovec/rhotot_;
-        auto R = forceeval(vdW.R(molefrac));
-        return vdW.alphar(T, rhotot_, molefrac)*R*T*rhotot_;
-    };
-    auto Psir = fPsir(T, rhovec);
-    auto dPsirdrho0 = rhovec[0]*derivrhoi(fPsir, T, rhovec, 0);
-    auto dPsirdrho1 = rhovec[1]*derivrhoi(fPsir, T, rhovec, 1);
-    auto pfromderiv = rho*R*T - Psir + dPsirdrho0 + dPsirdrho1;
-    using id = IsochoricDerivatives<decltype(vdW)>;
-    auto sr = id::get_splus(vdW, T, rhovec);
-
-    auto t2 = std::chrono::steady_clock::now();
-    auto pfromderiv3 = rhotot*R*T + id::get_pr(vdW, T, rhovec);
-    auto t3 = std::chrono::steady_clock::now();
-    std::cout << std::chrono::duration<double>(t3 - t2).count() << " from isochoric (mix) " << std::endl;
-}
-
-int main(){
-    test_vdwMix();
-    
-    std::vector<std::string> names = { "Methane", "Ethane" };
-    PCSAFTMixture mix(names);
-    mix.print_info();
-    using id = IsochoricDerivatives<decltype(mix)>;
-    using vd = VirialDerivatives<decltype(mix)>;
-    using tdx = TDXDerivatives<decltype(mix)>;
-    double T = 300;
-    const auto rhovec = (Eigen::ArrayXd(2) << 1.0, 2.0).finished();
-    const Eigen::ArrayXd molefrac = (rhovec/rhovec.sum()).eval();
-    const double rho = rhovec.sum();
-    
-    double a00csd = tdx::get_Ar01<ADBackends::complex_step>(mix, T, rho, molefrac);
-    double a00cx = tdx::get_Ar01<ADBackends::multicomplex>(mix, T, rho, molefrac);
-    double a00ad = tdx::get_Ar01<ADBackends::autodiff>(mix, T, rho, molefrac);
-    double a11ad = tdx::get_Ar11<ADBackends::autodiff>(mix, T, rho, molefrac);
-
-    for (auto T = 20; T < 1e5; T *= 1.3) {
-        double neff = tdx::get_neff<ADBackends::autodiff>(mix, T, 1e-10, molefrac);
-        std::cout << T << "," << neff << std::endl;
-    }
-    double neff = tdx::get_neff<ADBackends::autodiff>(mix, T, rho, molefrac);
-    double a00iso = id::get_Ar01(mix, T, rhovec);
-    double apriso = id::get_pr(mix, T, rhovec);
-    double B2 = vd::get_B2vir(mix, T, molefrac);
-    double B12 = vd::get_B12vir(mix, T, molefrac);
-
-    return EXIT_SUCCESS;
-}
\ No newline at end of file
diff --git a/src/test_autodiff.cpp b/src/test_autodiff.cpp
deleted file mode 100644
index 525624d..0000000
--- a/src/test_autodiff.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-#include <iostream>
-#include <algorithm>
-#include <numeric>
-#include <valarray>
-#include <complex>
-#include "teqp/models/eos.hpp"
-
-#include "MultiComplex/MultiComplex.hpp"
-
-// autodiff include
-#include <autodiff/forward/dual.hpp>
-#include <autodiff/forward/dual/eigen.hpp>
-using namespace autodiff;
-
-template<typename Model>
-void test_autodiff(Model model) {
-    
-    double T = 298.15;
-    double rho = 3.0;
-    auto rhotot = rho;
-    const std::valarray<double> rhovec = { rhotot / 2, rhotot / 2 };
-    const std::valarray<double> molefrac = { 0.5, 0.5 };
-    double v1, v2, v3;
-
-    int Nrep = 10000;
-
-    auto ticn1 = std::chrono::steady_clock::now();
-    for (int i = 0; i < Nrep; ++i) {
-        volatile double rr = model.alphar(T+i*1e-16, rho, molefrac);
-    }
-    auto tic0 = std::chrono::steady_clock::now();
-
-    // autodiff derivatives
-    for (int i = 0; i < Nrep; ++i) {
-        autodiff::dual4th varT = static_cast<double>(T);
-        auto f = [&model, &rho, &molefrac](auto& T) {return eval(model.alphar(T, rho, molefrac)); };
-        auto [alphar, dalphardT,d2,d3,d4] = derivatives(f, wrt(varT), at(varT));
-        v1 = dalphardT;
-    }
-    auto tic1 = std::chrono::steady_clock::now();
-
-    // complex step (first) derivative
-    constexpr double h = 1e-100;
-    for (int i = 0; i < Nrep; ++i){
-        volatile auto dalphardT_comstep = model.alphar(std::complex<double>(T,h), rho, molefrac).imag()/h;
-        v2 = dalphardT_comstep;
-    }
-    auto tic2 = std::chrono::steady_clock::now();
-
-    // Multicomplex derivatives
-    for (int i = 0; i < Nrep; ++i) {
-        volatile auto diffs = mcx::diff_mcx1<double>([&model, &rho, &molefrac](auto& T) {return model.alphar(T, rho, molefrac); }, T, 1, true)[1];
-        v3 = diffs;
-    }
-    auto tic3 = std::chrono::steady_clock::now();
-
-    std::cout << std::chrono::duration<double>(tic0 - ticn1).count()/Nrep*1e6 << " us (function evaluation in double)" << std::endl; 
-    std::cout << std::chrono::duration<double>(tic1 - tic0).count()/Nrep*1e6 << " us (autodiff)" << std::endl;
-    std::cout << std::chrono::duration<double>(tic2 - tic1).count()/Nrep*1e6 << " us (CSD)" << std::endl;
-    std::cout << std::chrono::duration<double>(tic3 - tic2).count()/Nrep*1e6 << " us (MCX)" << std::endl;
-}
-
-int main() {
-    test_autodiff(build_simple());
-    test_autodiff(build_vdW());
-    return EXIT_SUCCESS;
-}
\ No newline at end of file
diff --git a/src/test_variant.cpp b/src/test_variant.cpp
deleted file mode 100644
index 3a5e8d3..0000000
--- a/src/test_variant.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <vector>
-#include <iostream>
-#include <complex>
-#include <variant>
-#include <chrono>
-#include <map>
-#include <valarray>
-
-#include "teqp/types.hpp"
-#include "nlohmann/json.hpp"
-#include "teqp/models/eos.hpp"
-//#include "teqp/models/CPA.hpp"
-#include "teqp/models/multifluid.hpp"
-#include "teqp/models/pcsaft.hpp"
-#include "teqp/containers.hpp"
-#include <Eigen/Dense>
-
-template <typename ModelContainer, typename T1, typename T2, typename T3> 
-auto get_f(const ModelContainer &modcon, const T1& x1, const T2& x2, const T3& x3){
-    // The output type is the type promotion of T, rho, and molefrac
-    std::common_type_t<T1, T2, decltype(x3[0])> result = -1;
-    // Call the function with T, rho, molefrac arguments
-    std::visit([&](auto&& model) { result = model.alphar(x1, x2, x3); }, modcon);
-    return result;
-}
-
-int main(){
-    // Here, all models that can be stored in this container are defined. Types may
-    // be obtained from factory functions without explicit definition
-    using MFType = decltype(build_multifluid_model(std::vector<std::string>{"", ""}, "", ""));
-    ModelContainer<MFType, vdWEOS<double>, vdWEOS1> mc;
-    nlohmann::json vdWargs = { { "a",3 }, { "b", 4 } };
-    std::string vdWs = vdWargs.dump();
-    for (auto i = 0; i < 10; ++i) {
-        mc.add_model(vdWEOS1(1, 2));
-    }
-    const auto& v = mc.get_ref<vdWEOS1>(1);
-
-    auto c = (Eigen::ArrayXd(2) << 3.0, 3.0).finished();
-    int N = 1000;
-    volatile double x1 = 3.0;
-    std::complex<double> x2(3.0, 1.0);
-    vdWEOS1 b1(3, 4);
-    for (auto i = 0; i < mc.size(); ++i) {
-        Timer t(N);
-        for (auto j = 0; j < N; ++j) {
-            volatile auto v = b1.alphar(x1, x2, c);
-            //std::cout << v << std::endl;
-        }
-    }
-    std::cout << "----" << std::endl;
-    for (auto i = 0; i < mc.size(); ++i) {
-        const auto& m = mc.get_model(1);
-        Timer t(N); 
-        for (auto j = 0; j < N; ++j) {
-            auto v = get_f(m, x1, x2, c);
-            //std::cout << v << std::endl;
-        }
-    }
-    std::cout << "----" << std::endl;
-    for (auto i = 1; i <= mc.size(); ++i) {
-        Timer t(N);
-        for (auto j = 0; j < N; ++j) {
-            auto v = mc.get_alphar(i, x1, x2, c);
-            //std::cout << v << std::endl;
-        }
-    }
-}
\ No newline at end of file
-- 
GitLab