1 /*****************************************************************************
2  *   Copyright (C) 2004-2018 The pykep development team,                     *
3  *   Advanced Concepts Team (ACT), European Space Agency (ESA)               *
4  *                                                                           *
5  *   https://gitter.im/esa/pykep                                             *
6  *   https://github.com/esa/pykep                                            *
7  *                                                                           *
8  *   act@esa.int                                                             *
9  *                                                                           *
10  *   This program is free software; you can redistribute it and/or modify    *
11  *   it under the terms of the GNU General Public License as published by    *
12  *   the Free Software Foundation; either version 2 of the License, or       *
13  *   (at your option) any later version.                                     *
14  *                                                                           *
15  *   This program is distributed in the hope that it will be useful,         *
16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
18  *   GNU General Public License for more details.                            *
19  *                                                                           *
20  *   You should have received a copy of the GNU General Public License       *
21  *   along with this program; if not, write to the                           *
22  *   Free Software Foundation, Inc.,                                         *
23  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
24  *****************************************************************************/
25 
26 #ifndef KEP_TOOLBOX_THROTTLE_H
27 #define KEP_TOOLBOX_THROTTLE_H
28 
29 #include <iostream>
30 #include <numeric>
31 
32 #include <keplerian_toolbox/astro_constants.hpp>
33 #include <keplerian_toolbox/detail/visibility.hpp>
34 #include <keplerian_toolbox/epoch.hpp>
35 #include <keplerian_toolbox/serialization.hpp>
36 
37 namespace kep_toolbox
38 {
39 namespace sims_flanagan
40 {
41 
42 /// A single throttle
43 /**
44  * This class models a single throttle in the Sims-Flanagan model. It essentialy contains the cartesian
45  * components of one throttle (non dimensional impulse)
46  *impulse
47  * @author David di Lorenzo
48  * @author Dario Izzo (dario.izzo _AT_ googlemail.com)
49  */
50 
51 class KEP_TOOLBOX_DLL_PUBLIC throttle
52 {
53 public:
throttle()54     throttle() : m_start(), m_end()
55     {
56         m_value[0] = 0;
57         m_value[1] = 0;
58         m_value[2] = 0;
59     }
60 
throttle(const epoch & _start,const epoch & _end,const array3D & _value)61     throttle(const epoch &_start, const epoch &_end, const array3D &_value)
62         : m_start(_start), m_end(_end), m_value(_value)
63     {
64     }
65 
get_start() const66     const epoch &get_start() const
67     {
68         return m_start;
69     }
70 
get_end() const71     const epoch &get_end() const
72     {
73         return m_end;
74     }
75 
get_value() const76     const array3D &get_value() const
77     {
78         return m_value;
79     }
80 
set_start(const epoch & e)81     void set_start(const epoch &e)
82     {
83         m_start = e;
84     }
set_end(const epoch & e)85     void set_end(const epoch &e)
86     {
87         m_end = e;
88     }
set_value(const array3D & e)89     void set_value(const array3D &e)
90     {
91         m_value = e;
92     }
93 
get_norm() const94     double get_norm() const
95     {
96         return std::sqrt(std::inner_product(m_value.begin(), m_value.end(), m_value.begin(), 0.));
97     }
human_readable() const98     std::string human_readable() const
99     {
100         std::ostringstream s;
101         s << "start = " << m_start << std::endl;
102         s << "value = " << m_value << std::endl;
103         s << "end = " << m_end;
104         return s.str();
105     }
106 
107 private:
108     friend class boost::serialization::access;
109     template <class Archive>
serialize(Archive & ar,const unsigned int)110     void serialize(Archive &ar, const unsigned int)
111     {
112         ar &m_start;
113         ar &m_end;
114         ar &m_value;
115     }
116 
117     epoch m_start;
118     epoch m_end;
119     array3D m_value;
120 };
121 } // namespace sims_flanagan
122 } // namespace kep_toolbox
123 
124 #endif // KEP_TOOLBOX_THROTTLE_H
125