1
0
Fork 0
mirror of https://github.com/gwm17/catima.git synced 2024-11-29 21:48:51 -05:00
catima/tests/test_reaction.cpp

76 lines
2.2 KiB
C++
Raw Normal View History

2019-10-08 14:49:52 -04:00
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#define DOCTEST_CONFIG_SUPER_FAST_ASSERTS
#include "doctest.h"
2018-05-01 20:18:50 -04:00
#include <math.h>
#include "catima/catima.h"
#include "catima/reactions.h"
#include "testutils.h"
using namespace std;
using catima::reaction_rate;
using catima::nonreaction_rate;
2019-10-08 14:49:52 -04:00
TEST_CASE("reaction"){
2018-07-30 19:41:44 -04:00
catima::Projectile proj{12,6,6,870};
2018-07-31 12:52:53 -04:00
catima::Projectile proj2{238,92,92,500};
2018-05-01 20:18:50 -04:00
auto c = catima::get_material(6);
2018-07-31 11:40:25 -04:00
auto h = catima::get_material(1);
catima::Material water({{0,8,2},{0,1,1}},1.0);
2018-07-31 09:34:41 -04:00
c.thickness(2.0);
2018-07-31 12:52:53 -04:00
double r,r2;
2018-05-01 20:18:50 -04:00
2018-07-31 09:34:41 -04:00
r= catima::nonreaction_rate(proj, c);
2019-10-08 14:49:52 -04:00
CHECK(r == approx(0.92,0.02));
2018-07-31 09:34:41 -04:00
catima::Layers l;
l.add(c);
l.add(c);
l.add(c);
2018-05-01 20:18:50 -04:00
2018-07-31 09:34:41 -04:00
auto res = catima::calculate(proj,l);
2019-10-08 14:49:52 -04:00
CHECK(res.total_result.sp == approx(r*r*r,0.02));
2018-07-31 09:34:41 -04:00
c.thickness(6.0);
r= catima::nonreaction_rate(proj, c);
2019-10-08 14:49:52 -04:00
CHECK(res.total_result.sp == approx(r,0.001));
2018-07-31 09:34:41 -04:00
c.thickness(0.0);
r= catima::nonreaction_rate(proj, c);
2019-10-08 14:49:52 -04:00
CHECK(r == 1.0);
2018-07-31 09:34:41 -04:00
proj.T = 0.0;
c.thickness(6);
r= catima::nonreaction_rate(proj, c);
2019-10-08 14:49:52 -04:00
CHECK(r == -1.0);
2018-05-02 19:23:47 -04:00
2018-07-31 12:52:53 -04:00
proj.T=870;
water.thickness(1);
r= catima::nonreaction_rate(proj2, water);
r2= catima::nonreaction_rate(proj, water);
2019-10-08 14:49:52 -04:00
CHECK( (r > 0 && r<1.0) );
CHECK( (r2 > 0 && r2<1.0) );
CHECK( r2>r );
}
TEST_CASE("production"){
2018-08-13 12:08:54 -04:00
catima::Projectile proj{12,6,6,870};
auto c = catima::get_material(6);
c.thickness(0.1);
double r,r2;
double cs = 70;
double rcsi = 870;
double rcso = 850;
r = 0.0001*cs*c.number_density_cm2();
r2 = catima::production_rate(cs,rcsi,rcso, c);
2019-10-08 14:49:52 -04:00
CHECK(r==approx(r2).R(0.01));
2018-08-13 12:08:54 -04:00
r2 = catima::production_rate(cs,2,1, c);
2019-10-08 14:49:52 -04:00
CHECK(r==approx(r2).R(0.001));
2018-08-13 12:08:54 -04:00
r = catima::production_rate(cs,870,870, c);
r2 = catima::production_rate(cs,870,860, c);
2019-10-08 14:49:52 -04:00
CHECK(r==approx(r2).R(0.001));
2018-08-13 12:08:54 -04:00
c.thickness(2.0);
r = catima::production_rate(cs,870,870, c);
r2 = catima::production_rate(cs,870,860, c);
2019-10-08 14:49:52 -04:00
CHECK(r==approx(r2).R(0.001));
2018-05-01 20:18:50 -04:00
}