Computing function for one or more time steps.
[error]=MASCARET_compute(id,InitTime,FinalTime,TimeStep,print)
(Output argument) Error code value : zero indicates that no errors occurred
MASCARET instance number returned by the function MASCARET_create
Initial time of the simulation (s)
Final time of the simulation (s)
Computational time step in second(s)
Flag for writing on listing files (1-> write 0-> no write)
Function for the simulation of one or more time steps. Compute a new hydraulic state with the help of the previous state and of the current model.
Another API function can also do the same job but with more arguments, it is MASCARET_compute_BC
Before using this function, it is necessary to initialise the MASCARET state, calling one of the following functions MASCARET_initStateName, MASCARET_initState ou MASCARET_importXml with the last parameter set to 0 (zero).
toolbox_dir=getenv("toolbox_dir"); c = filesep(); // creation of the MASCARET model [err, id] = MASCARET_create(); assert_checktrue(id>0); // read data from files path_xml = "file://"+toolbox_dir+c+"demos"+c+"Help"+c+"demo1"+c+"demo1.xcas"; TabNomFichier = [strsubst(path_xml,'\','/'), .. toolbox_dir+c+"demos"+c+"Help"+c+"demo1"+c+"demo1.geo", .. toolbox_dir+c+"demos"+c+"Help"+c+"demo1"+c+"demo1_0.loi", .. toolbox_dir+c+"demos"+c+"Help"+c+"demo1"+c+"demo1_1.loi", .. toolbox_dir+c+"demos"+c+"Help"+c+"demo1"+c+"demo1.lis", .. toolbox_dir+c+"demos"+c+"Help"+c+"demo1"+c+"demo1.opt"]; TypeNomFichier = ["xcas","geo","loi","loi","listing","res"]; impression = 0; err = MASCARET_importModel(id,TabNomFichier,TypeNomFichier,impression); assert_checkequal(err,0); // initialisation err = MASCARET_initStateName(id,toolbox_dir+c+"demos"+c+"Help"+c+"demo1"+c+"demo1.lig",impression); assert_checkequal(err,0); // get the initial state on the cross-section #5 (water level) [err,Zsection5] = MASCARET_getDouble(id,"State.Z",5,0,0); assert_checkequal(err,0); printf("\tWater level on the cross-section #5 before the simulation :%f\n", Zsection5); // computation err = MASCARET_compute(id,0., 36000., 1., impression); assert_checkequal(err,0); // get the result on the cross-section #5 (water level) [err,Zsection5] = MASCARET_getDouble(id,"State.Z",5,0,0); assert_checkequal(err,0); printf("\tWater level on the cross-section #5 after the simulation :%f\n", Zsection5); // model deletion err = MASCARET_delete(id); assert_checkequal(err,0); | ![]() | ![]() |