odeint: How do I log intermediate results while integrating?

user22097

I want to know how I can log the values other than states during integration by odeint. I have a simulation of the satellite dynamics, which is described as differential equations of total angular momentum, L, and momentum of an internal wheel, h. My simulation is running correctly. But I need to log not only the state variables but also some other values such as external torque, N, and angular velocity, omega, that is Jinv*L, where Jinv is a 3x3 constant, satellite-inertia matrix. In a sense, the purpose of my simulator is not to calculate L and h, but to generate time-histories of "other" varialbes.

To show what I'm doing, below is a slightly simplified version of my current code.

class satellite
{
public:
Eigen::Matrix3d Jinv;

void operator()( state_type &x , state_type &dxdt , double t )
{
    L << x[0], x[1], x[2];
    h << x[3], x[4], x[5], x[6];

    N = external_torque(t);

    omega = Jinv * (L-h);
    dLdt = N - omega.cross(L);

    OMEGA = func1(omega(0), omega(1), omega(2));

    dqdt = OMEGA * q * 0.5;

    dxdt[0] = dLdt(0);    dxdt[1] = dLdt(1);    dxdt[2] = dLdt(2);
    dxdt[3] = dqdt(0);    dxdt[4] = dqdt(1);    dxdt[5] = dqdt(2);    dxdt[6] = dqdt(3);
}
};

class streaming_observer
{
public:
std::ostream& os;
satellite& sat;

streaming_observer( std::ostream& _os, satellite& _sat ) : os(_os), sat(_sat) { }

template<class State>
void operator() (const State& x, double t) const
{
     L << x[0], x[1], x[2];

    os << t << ' ' << (sat.Jinv*(L)).transpose() << std::endl;
}
};
머리 어깨

중간체의 계산과 옵저버의 로깅을 수행해야합니다. 중복을 피하기 위해 클래스 메서드의 별도 함수에서 계산을 수행하고 시스템 함수 (예에서는 operator ())와 관찰자에서이 메서드를 호출하는 것이 좋습니다. 거기에 값을 기록하고이 값으로 나중에 분석을 수행 할 수도 있습니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How do I exclude search results in ActiveRecord?

분류에서Dev

How do I get out of this do-while loop?

분류에서Dev

How do I disable the touchpad while I'm typing?

분류에서Dev

How do I add ncmpcpp search results to the current playlist?

분류에서Dev

How do I create a log entry for the systemd journal?

분류에서Dev

/dev/log is missing. how do I fix?

분류에서Dev

How do i stop a while loop after a certain time in C

분류에서Dev

How do I show a loading image while script is working?

분류에서Dev

How scrapy write in log while running spider?

분류에서Dev

How do I add /home to arch with uuid if I messed up while installing?

분류에서Dev

How can I use Selenium (Python) to do a Google Search and then open the results of the first page in new tabs?

분류에서Dev

How do I find out containing OU in results of “Find Users, Contacts, and Groups"?

분류에서Dev

Can I see the summed up results of the ping command while it is running?

분류에서Dev

How do I log postgres driver messages with slf4j?

분류에서Dev

How do I download log4j on ec2 instance?

분류에서Dev

How do I copy regex matches from a file? Need to get all MAC addresses from log file

분류에서Dev

How do I redirect Google Chrome Logs out of my kern.log

분류에서Dev

How do I can change contents of some div sections while clicking text from another div

분류에서Dev

How do I preserve newline character in Spring while sending data through a JSP form

분류에서Dev

How do I determine the number of rows and columns in a gnome-terminal window while resizing?

분류에서Dev

How do I run multiple while loops that switch off after each loop round?

분류에서Dev

How do I keep a UILongPressGestureRecognizer active while switching from a UIViewController to another

분류에서Dev

How do I respond to "there is no root file system" message while installing Ubuntu?

분류에서Dev

What do i look for while buying a mouse?

분류에서Dev

How to tackle inconsistent results while using pandas rolling correlation?

분류에서Dev

How can I limit the results in a PagingAndSortingRepository @Query?

분류에서Dev

How to do a `tail -f` of log rotated files?

분류에서Dev

using tee to output intermediate results to stdout instead of files

분류에서Dev

How do I then() on a promise?

Related 관련 기사

  1. 1

    How do I exclude search results in ActiveRecord?

  2. 2

    How do I get out of this do-while loop?

  3. 3

    How do I disable the touchpad while I'm typing?

  4. 4

    How do I add ncmpcpp search results to the current playlist?

  5. 5

    How do I create a log entry for the systemd journal?

  6. 6

    /dev/log is missing. how do I fix?

  7. 7

    How do i stop a while loop after a certain time in C

  8. 8

    How do I show a loading image while script is working?

  9. 9

    How scrapy write in log while running spider?

  10. 10

    How do I add /home to arch with uuid if I messed up while installing?

  11. 11

    How can I use Selenium (Python) to do a Google Search and then open the results of the first page in new tabs?

  12. 12

    How do I find out containing OU in results of “Find Users, Contacts, and Groups"?

  13. 13

    Can I see the summed up results of the ping command while it is running?

  14. 14

    How do I log postgres driver messages with slf4j?

  15. 15

    How do I download log4j on ec2 instance?

  16. 16

    How do I copy regex matches from a file? Need to get all MAC addresses from log file

  17. 17

    How do I redirect Google Chrome Logs out of my kern.log

  18. 18

    How do I can change contents of some div sections while clicking text from another div

  19. 19

    How do I preserve newline character in Spring while sending data through a JSP form

  20. 20

    How do I determine the number of rows and columns in a gnome-terminal window while resizing?

  21. 21

    How do I run multiple while loops that switch off after each loop round?

  22. 22

    How do I keep a UILongPressGestureRecognizer active while switching from a UIViewController to another

  23. 23

    How do I respond to "there is no root file system" message while installing Ubuntu?

  24. 24

    What do i look for while buying a mouse?

  25. 25

    How to tackle inconsistent results while using pandas rolling correlation?

  26. 26

    How can I limit the results in a PagingAndSortingRepository @Query?

  27. 27

    How to do a `tail -f` of log rotated files?

  28. 28

    using tee to output intermediate results to stdout instead of files

  29. 29

    How do I then() on a promise?

뜨겁다태그

보관