Page 1 of 1

Re-initializing Model:

Posted: Sun Oct 06, 2019 3:54 pm
by mlaudu
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.

Re: Re-initializing Model:

Posted: Mon Oct 07, 2019 1:15 pm
by mitkof6
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;
}

Re: Re-initializing Model:

Posted: Mon Oct 07, 2019 2:13 pm
by aymanh
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