Re-initializing Model:

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Musa Audu
Posts: 43
Joined: Mon Nov 24, 2008 11:30 am

Re-initializing Model:

Post by Musa Audu » Sun Oct 06, 2019 3:54 pm

Hi,
I am trying to change the parameters of some objects in my model during integration of the equations. Following is a snippet of the code I am using. After time t=1, I change the properties of HuntCrossley force and then re-initialize the model so the new values assume after that.
snippet.cpp
(841 Bytes) Downloaded 8 times
My problem is that the integration aborts at the line 'si = osimModel.initSystem();' with a generic error message that reads in part: "(process 14144) exited with code -1073741819." Am I doing this wrongly? Could someone give me guidance on the correct way to do this?
Thanks.

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Re-initializing Model:

Post by Dimitar Stanev » Mon Oct 07, 2019 1:15 pm

You can enclose your code into a try and catch statement, print the exception (if any) and pause the execution.

Code: Select all

#include <cstdio>

int main(int argc, char *argv[]) {
    try {
        // your code
    }
    catch (exception &e) {
        cout << e.what() << endl;
        getc();
        return -1;
    }
    return 0;
}

User avatar
Ayman Habib
Posts: 2235
Joined: Fri Apr 01, 2005 12:24 pm

Re: Re-initializing Model:

Post by Ayman Habib » Mon Oct 07, 2019 2:13 pm

Hello,

Can you give an example of what you mean by changing the parameters of the model "during integration"? Basically the integrator does not expect the layout of the State to be modified underneath it. Based on how entries in the State are created/allocated, you may need to recreate the State entirely.

-Ayman

POST REPLY