-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot.cpp
More file actions
44 lines (37 loc) · 1.07 KB
/
Copy pathplot.cpp
File metadata and controls
44 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <vector>
#include <sciplot/sciplot.hpp>
#include <Eigen/Dense>
#include "input.h"
#include "matrix.h"
#include <cmath>
using namespace sciplot;
void plotter(const MatrixData& mat, ProblemType::ProblemType pt)
{
Eigen::Index n{ mat.D.size() };
std::vector<double> x(n);
for (size_t i = 1; i < n; i++)
x[i] = mat.D(i) + x[i - 1];
Plot2D plot;
plot.legend();
plot.xlabel("z [cm]");
if (pt == ProblemType::fixedsource)
{
plot.ylabel("Flux [n/cm**2/s]");
plot.drawCurve(x, mat.Flux.array());
}
else if (pt == ProblemType::eigenvalue)
{
plot.ylabel("Normalized Flux");
plot.drawCurve(x, mat.Flux.array()/mat.Flux.maxCoeff()).label("CPM");
}
//std::vector <double> y(n);
//for (size_t i=0;i<n;i++)
// y[i] = std::sin(0.197484176581 * (x[i]+0.4));
//plot.drawCurve(x, y).label("Diffusion Equation");
// Create figure to hold plot
Figure fig = { {plot} };
// Create canvas to hold figure
Canvas canvas = { {fig} };
canvas.show();
canvas.save("flux.png");
}