x040.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "xmodel.h"
4 #include "xphysics.h"
5 
6 namespace nmx::apps::x040 {
7 
11 enum class Idx {
12  MAXTHETA = 0, // maximaler Winkel damit der Stab nicht wegrutscht
13  NA = 1, //Normalkraft: Boden auf Stab
14  NB = 2, // Normalkraft: Wand auf Stab
15  STATIC_FRICTION = 3, //Haftreibung
16  WEIGHT = 4 //Gewicht des Stabs
17 };
18 
22 class X040 : public nmx::XModel, public CResult<5, Idx>
23 {
24 public:
25  // Eingabeparameter
26  const double length; //Länge des Stabs
27  const double mass; // Masse des Stabs
28  const double friction_coefficient; //Haftreibungskoeffizient
29 
30 public:
37  inline X040(double l, double m, double fc)
38  : XModel(__func__)
39  , length{ l }
40  , mass{ m }
41  , friction_coefficient{ fc } {
42  Check::all(nmx_msg, { length > 0, mass > 0, friction_coefficient > 0 });
43  }
44 
48  inline void exec() {
49  using namespace gravitation;
50  const auto tanMaxTheta = 2 * (friction_coefficient);
51  //rufe Methode der Basisklasse CResult auf, um die Werte
52  //zu speichern
53  set_result(Idx::MAXTHETA, atan(tanMaxTheta));
54  set_result(Idx::WEIGHT, -mass * Earth::g);
55  set_result(Idx::NA, -get(Idx::WEIGHT));
56  set_result(Idx::NB, 0.5 * (mass) *Earth::g * tanMaxTheta);
57  set_result(Idx::STATIC_FRICTION, -get(Idx::NB));
58  }
59 }; // namespace nmx::x5000
60 
65 inline void run() {
66  Data<5> data;
67  //Tabellendaten werden berechnet
68  for (double mu = 0.1; mu < 0.6; mu += 0.1) {
69  //Modellklasse wird initialisiert
70  X040 xobj{ 2.0, 10.0, mu };
71  xobj.exec(); //Ergebnisse werden berechnet
72  data += { xobj.friction_coefficient,
73  xobj(Idx::NA),
74  xobj(Idx::NB),
76  xobj(Idx::MAXTHETA) };
77  }
78  //Schreibe Daten in Datein (LaTeX-, CSV-Format)
80  X040::save(data, Output::plot);
81 }
82 
83 } // namespace nmx::apps::x040
The X5000 class Stab lehnt gegen eine senkrechte Wand.
Definition: x040.h:22
void run()
run Berechnung von Beispieldaten Stab lehnt gegen eine senkrechte Wand
Definition: x040.h:65
void exec()
exec interne Parameter werden berechnet
Definition: x040.h:48
The XModel class Basisklasse speichert eine ID in Form einer Zeichenkette enthält Hilfsfunktionen zur...
Definition: xmodel.h:22
#define nmx_msg
Definition: xerror.h:113
Idx
The Idx enum Zugriff auf berechnete Daten.
Definition: x040.h:11
const double length
Definition: x040.h:26
const double mass
Definition: x040.h:27
X040(double l, double m, double fc)
XModel Konstruktor.
Definition: x040.h:37
const double friction_coefficient
Definition: x040.h:28
static void save(const T &data, Format fmt)
save Speicherung von Daten in eine Datei
Definition: xmodel.h:70
The CResult class Speicherung von Rechenergebnissen.
Definition: xmodel.h:106
static const Format latex
Definition: xoutput.h:17
static void all(const std::string &s, std::initializer_list< bool > lst)
input teste mehrere Bedingungen auf einmal
Definition: xerror.h:76
static const Format plot
Definition: xoutput.h:18