Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_Test::HarmonicOscillatorModel< Scalar > Class Template Reference

Consider the ODE:

\[ m\ddot{x} + c\dot{x} + kx=f \]

where $k \geq 0$ is a constant, $c$ is a constant damping parameter, $f$ is a constant forcing parameter, and $m>0$ is a constant mass parameter, with initial conditions are:

\begin{eqnarray*} x(0) & = & 0\\ \dot{x}(0) & = & 1 \end{eqnarray*}

It is straight-forward to show that the exact solution to this ODE is:

\begin{eqnarray*} x(t) & = & t(1+0.5\tilde{f}t), \hspace{3.6cm} if \hspace{0.2cm} k = c = 0 \\ & = & \frac{(\tilde{c}-\tilde{f})}{\tilde{c}^2}(1-e^{-\tilde{c}t}) + \frac{f}{c}t, \hspace{1.9cm} if \hspace{0.2cm} k = 0, c\neq 0 \\ & = & \frac{1}{\sqrt{\tilde{k}}}\sin(\sqrt{\tilde{k}}t) + \frac{f}{k}\left(1-\cos(\sqrt{\tilde{k}}t) \right), \hspace{0.2cm} if \hspace{0.2cm} k > 0, c = 0 \end{eqnarray*}

where $\tilde{c}\equiv c/m$, $\tilde{k}\equiv k/m$ and $\tilde{f}\equiv f/m$. While it is possible to derive the solution to this ODE for the case when $k > 0$ and $c \neq 0$, we do not consider that case here. When $c = k = 0$, $m=1$, and $f=-1$, our ODE simplies to a canonical differential equation model of a ball thrown up in the air, with a parabolic trajectory solution, namely

\[ x(t) = t(1-0.5t) \]

where $t\in [0,2]$. An EpetraExt version of this simplified version of the test is implemented in Piro::MockModelEval_B (see Trilinos/packages/piro/test), where it is used to test the Piro (EpetraExt) Newmark-Beta scheme (see input_Solver_NB.xml input file). When $c = f = 0$ and $m=k = 1$, this test is equivalent to the SinCos model.. More...

#include <HarmonicOscillatorModel_decl.hpp>

Inheritance diagram for Tempus_Test::HarmonicOscillatorModel< Scalar >:

Public Member Functions

 HarmonicOscillatorModel (Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
 
Thyra::ModelEvaluatorBase::InArgs
< Scalar > 
getExactSolution (double t) const
 
Public functions overridden from ModelEvaluator.
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
get_x_space () const
 
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
get_f_space () const
 
Thyra::ModelEvaluatorBase::InArgs
< Scalar > 
getNominalValues () const
 
Teuchos::RCP
< Thyra::LinearOpWithSolveBase
< Scalar > > 
create_W () const
 
Teuchos::RCP
< Thyra::LinearOpBase< Scalar > > 
create_W_op () const
 
Teuchos::RCP< const
Thyra::LinearOpWithSolveFactoryBase
< Scalar > > 
get_W_factory () const
 
Thyra::ModelEvaluatorBase::InArgs
< Scalar > 
createInArgs () const
 
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
get_p_space (int l) const
 
Teuchos::RCP< const
Teuchos::Array< std::string > > 
get_p_names (int l) const
 
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
get_g_space (int j) const
 
Public functions overridden from ParameterListAcceptor.
void setParameterList (Teuchos::RCP< Teuchos::ParameterList > const &paramList)
 
Teuchos::RCP< const
Teuchos::ParameterList > 
getValidParameters () const
 

Private Member Functions

void setupInOutArgs_ () const
 
Private functions overridden from ModelEvaluatorDefaultBase.
Thyra::ModelEvaluatorBase::OutArgs
< Scalar > 
createOutArgsImpl () const
 
void evalModelImpl (const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs_bar, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs_bar) const
 

Private Attributes

Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
x_space_
 
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
p_space_
 
Teuchos::RCP< const
Thyra::VectorSpaceBase< Scalar > > 
g_space_
 
Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
x_vec_
 
Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
x_dot_vec_
 
Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
x_dot_dot_vec_
 
Teuchos::RCP
< Thyra::VectorBase< Scalar > > 
p_init_
 
int vecLength_
 
int numResponses_
 
Thyra::ModelEvaluatorBase::InArgs
< Scalar > 
inArgs_
 
Thyra::ModelEvaluatorBase::OutArgs
< Scalar > 
outArgs_
 
Thyra::ModelEvaluatorBase::InArgs
< Scalar > 
nominalValues_
 
bool isInitialized_
 
double c_
 
double f_
 
double k_
 
double m_
 
Teuchos::RCP
< Teuchos::FancyOStream > 
out_
 

Detailed Description

template<class Scalar>
class Tempus_Test::HarmonicOscillatorModel< Scalar >

Consider the ODE:

\[ m\ddot{x} + c\dot{x} + kx=f \]

where $k \geq 0$ is a constant, $c$ is a constant damping parameter, $f$ is a constant forcing parameter, and $m>0$ is a constant mass parameter, with initial conditions are:

\begin{eqnarray*} x(0) & = & 0\\ \dot{x}(0) & = & 1 \end{eqnarray*}

It is straight-forward to show that the exact solution to this ODE is:

\begin{eqnarray*} x(t) & = & t(1+0.5\tilde{f}t), \hspace{3.6cm} if \hspace{0.2cm} k = c = 0 \\ & = & \frac{(\tilde{c}-\tilde{f})}{\tilde{c}^2}(1-e^{-\tilde{c}t}) + \frac{f}{c}t, \hspace{1.9cm} if \hspace{0.2cm} k = 0, c\neq 0 \\ & = & \frac{1}{\sqrt{\tilde{k}}}\sin(\sqrt{\tilde{k}}t) + \frac{f}{k}\left(1-\cos(\sqrt{\tilde{k}}t) \right), \hspace{0.2cm} if \hspace{0.2cm} k > 0, c = 0 \end{eqnarray*}

where $\tilde{c}\equiv c/m$, $\tilde{k}\equiv k/m$ and $\tilde{f}\equiv f/m$. While it is possible to derive the solution to this ODE for the case when $k > 0$ and $c \neq 0$, we do not consider that case here. When $c = k = 0$, $m=1$, and $f=-1$, our ODE simplies to a canonical differential equation model of a ball thrown up in the air, with a parabolic trajectory solution, namely

\[ x(t) = t(1-0.5t) \]

where $t\in [0,2]$. An EpetraExt version of this simplified version of the test is implemented in Piro::MockModelEval_B (see Trilinos/packages/piro/test), where it is used to test the Piro (EpetraExt) Newmark-Beta scheme (see input_Solver_NB.xml input file). When $c = f = 0$ and $m=k = 1$, this test is equivalent to the SinCos model..

Definition at line 52 of file HarmonicOscillatorModel_decl.hpp.

Constructor & Destructor Documentation

template<class Scalar >
Tempus_Test::HarmonicOscillatorModel< Scalar >::HarmonicOscillatorModel ( Teuchos::RCP< Teuchos::ParameterList >  pList = Teuchos::null)

Definition at line 28 of file HarmonicOscillatorModel_impl.hpp.

Member Function Documentation

template<class Scalar >
Teuchos::RCP< Thyra::LinearOpWithSolveBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::create_W ( ) const

Definition at line 155 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::create_W_op ( ) const

Definition at line 172 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::InArgs< Scalar > Tempus_Test::HarmonicOscillatorModel< Scalar >::createInArgs ( ) const

Definition at line 193 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::OutArgs< Scalar > Tempus_Test::HarmonicOscillatorModel< Scalar >::createOutArgsImpl ( ) const
private

Definition at line 206 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
void Tempus_Test::HarmonicOscillatorModel< Scalar >::evalModelImpl ( const Thyra::ModelEvaluatorBase::InArgs< Scalar > &  inArgs_bar,
const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &  outArgs_bar 
) const
private

Definition at line 216 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_f_space ( ) const

Definition at line 135 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_g_space ( int  j) const

Definition at line 324 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Teuchos::Array< std::string > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_p_names ( int  l) const

Definition at line 314 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_p_space ( int  l) const

Definition at line 304 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_W_factory ( ) const

Definition at line 182 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > Tempus_Test::HarmonicOscillatorModel< Scalar >::get_x_space ( ) const

Definition at line 126 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::InArgs< Scalar > Tempus_Test::HarmonicOscillatorModel< Scalar >::getExactSolution ( double  t) const

Definition at line 69 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::InArgs< Scalar > Tempus_Test::HarmonicOscillatorModel< Scalar >::getNominalValues ( ) const

Definition at line 144 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Teuchos::ParameterList > Tempus_Test::HarmonicOscillatorModel< Scalar >::getValidParameters ( ) const

Definition at line 414 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
void Tempus_Test::HarmonicOscillatorModel< Scalar >::setParameterList ( Teuchos::RCP< Teuchos::ParameterList > const &  paramList)

Definition at line 382 of file HarmonicOscillatorModel_impl.hpp.

template<class Scalar >
void Tempus_Test::HarmonicOscillatorModel< Scalar >::setupInOutArgs_ ( ) const
private

Definition at line 338 of file HarmonicOscillatorModel_impl.hpp.

Member Data Documentation

template<class Scalar >
double Tempus_Test::HarmonicOscillatorModel< Scalar >::c_
private

Definition at line 114 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
double Tempus_Test::HarmonicOscillatorModel< Scalar >::f_
private

Definition at line 115 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::g_space_
private

Definition at line 103 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::InArgs<Scalar> Tempus_Test::HarmonicOscillatorModel< Scalar >::inArgs_
mutableprivate

Definition at line 110 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
bool Tempus_Test::HarmonicOscillatorModel< Scalar >::isInitialized_
mutableprivate

Definition at line 113 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
double Tempus_Test::HarmonicOscillatorModel< Scalar >::k_
private

Definition at line 116 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
double Tempus_Test::HarmonicOscillatorModel< Scalar >::m_
private

Definition at line 117 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::InArgs<Scalar> Tempus_Test::HarmonicOscillatorModel< Scalar >::nominalValues_
mutableprivate

Definition at line 112 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
int Tempus_Test::HarmonicOscillatorModel< Scalar >::numResponses_
private

Definition at line 109 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<Teuchos::FancyOStream> Tempus_Test::HarmonicOscillatorModel< Scalar >::out_
private

Definition at line 118 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Thyra::ModelEvaluatorBase::OutArgs<Scalar> Tempus_Test::HarmonicOscillatorModel< Scalar >::outArgs_
mutableprivate

Definition at line 111 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<Thyra::VectorBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::p_init_
private

Definition at line 107 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::p_space_
private

Definition at line 102 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
int Tempus_Test::HarmonicOscillatorModel< Scalar >::vecLength_
private

Definition at line 108 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<Thyra::VectorBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::x_dot_dot_vec_
private

Definition at line 106 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<Thyra::VectorBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::x_dot_vec_
private

Definition at line 105 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::x_space_
private

Definition at line 101 of file HarmonicOscillatorModel_decl.hpp.

template<class Scalar >
Teuchos::RCP<Thyra::VectorBase<Scalar> > Tempus_Test::HarmonicOscillatorModel< Scalar >::x_vec_
private

Definition at line 104 of file HarmonicOscillatorModel_decl.hpp.


The documentation for this class was generated from the following files: