-
Notifications
You must be signed in to change notification settings - Fork 2
/
Config.hpp
97 lines (82 loc) · 3.28 KB
/
Config.hpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef CONFIG_HPP
#define CONFIG_HPP
#include "MirrorPlasma.hpp"
#include <toml.hpp>
#include <memory>
class MCTransConfig {
public:
/*
MCTransConfig( std::string const& configFile ) {
const toml::value config = toml::parse( configFile );
ReferencePlasmaState = std::make_unique<MirrorPlasma>( config );
bool MachSolve = ( ReferencePlasmaState->ElectronTemperature > 0.0 );
bool TempSolve = ( ReferencePlasmaState->ImposedVoltage > 0.0 );
if ( MachSolve && !TempSolve )
Type = SteadyStateMachSolve;
else if ( !MachSolve && TempSolve )
Type = SteadyStateTempSolve;
else if ( MachSolve && TempSolve )
throw std::invalid_argument( "[error] Cannot specify both temperature and voltage." );
else if ( !MachSolve && !TempSolve )
throw std::invalid_argument( "[error] Must specify at least one of ElectronTemperature or Voltage." );
if ( config.count( "timestepping" ) ) {
const auto & timestep_conf = toml::find<toml::table>( config, "timestepping" );
OutputDeltaT = timestep_conf.at( "OutputCadence" ).as_floating();
EndTime = timestep_conf.at( "EndTime" ).as_floating();
} else {
OutputDeltaT = 0.0005; // 500µs cadence
EndTime = 1.00; // 1s run time
}
};
*/
MCTransConfig(std::shared_ptr<MirrorPlasma> refPlasmaState, double deltaT = 0.0005, double tFinal = 0.5)
: ReferencePlasmaState(refPlasmaState), OutputDeltaT( deltaT ), EndTime( tFinal )
{
bool MachSolve = ( ReferencePlasmaState->ElectronTemperature > 0.0 );
bool TempSolve = ( ReferencePlasmaState->ImposedVoltage > 0.0 );
bool FWSolve = ( ReferencePlasmaState->ExternalResistance > 0.0 );
bool CBSolve = ( ReferencePlasmaState->CapBank );
#ifdef DEBUG
std::cerr << "MachSolve = " << MachSolve << " ; TempSolve = " << TempSolve << " ; FWSolve = " << FWSolve << " ; CBSolve = " << CBSolve << std::endl;
#endif
if ( CBSolve )
Type = CapBankSolve;
else {
if ( MachSolve && !TempSolve )
Type = SteadyStateMachSolve;
else if ( !MachSolve && TempSolve )
Type = SteadyStateTempSolve;
else if ( MachSolve && TempSolve )
throw std::invalid_argument( "[error] Cannot specify both temperature and voltage." );
else if ( !MachSolve && !TempSolve ) {
if ( FWSolve )
Type = FreewheelSolve;
else
throw std::invalid_argument( "[error] Must specify at least one of ElectronTemperature or Voltage." );
}
if ( FWSolve ) {
if ( MachSolve )
throw std::invalid_argument( "[error] If external resistance is specificed, a decaying simulation is assumed - neither the imposed voltage nor the temperature can be specified. The initial Voltage and initial temperature should be specified with appropriate options" );
else
Type = FreewheelSolve;
}
}
};
enum SolveType {
SteadyStateMachSolve,
SteadyStateTempSolve,
FreewheelSolve,
CapBankSolve
} Type;
std::shared_ptr<MirrorPlasma> Solve();
std::shared_ptr<MirrorPlasma> ReferencePlasmaState;
private:
void doMachSolve( MirrorPlasma& plasma ) const;
void doTempSolve( MirrorPlasma& plasma ) const;
void doFixedTeSolve( MirrorPlasma& plasma ) const;
void doFreeWheel( MirrorPlasma& plasma ) const;
void doCircuitModel( MirrorPlasma& plasma ) const;
void InitialisePlasma() const;
double OutputDeltaT,EndTime;
};
#endif // CONFIG_HPP