Hopsan / hopsan

Hopsan is a free multi-domain system simulation tool developed at the division of Fluid and mechatronic systems at Linköping university.
Apache License 2.0
157 stars 43 forks source link

HopsanCLI saves fullCSV on error #2007

Open mrejster opened 3 years ago

mrejster commented 3 years ago

Describe the bug A clear and concise description of what the bug is. When using hopsanCLI, and a component generates an error the simulation stops as it should. But then hopsan tries to save the full CSV file anyway, WITHOUT caring about the --logonly variables. For my size model, this results in a csv file of over 300Gb. This effectively locks up the computer, and is impossible to handle since the return status seen by the calling software is received after the saving occurs.

To Reproduce If the bug can be reproduce, please give the steps taken to reproduce the behavior: Not sure if this applies to all components (in my example its custom components), but try making a model that throws an error during simulation and see if hopsanCLI generates a csv file not obaying the saveonly flag.

Expected behavior A clear and concise description of what you expected to happen. HopsanCLI should just halt on error.

Screenshots, Model or Data files If applicable, add screenshots, models or data files, that display or cause the bug.

Hopsan version (please complete the following information): Version information is shown in the message widget when HopsanGUI is started

Additional information Add any other context/information about the problem here.

Here's the output from hopsan: Error: In hydMech_P_A_3; hydMech_P_A> ports crossing more than 10 mm! Info: In hydMech_P_A_3; X1=0.034766076085979106 Info: In hydMech_P_A_3; X2=0.038604388594068742 Info: In hydMech_P_A_3; Simulation was stopped at t=-0.076045999992137098 Info: In md20_lr_5_5; Simulation was stopped at t=-0.076045999992137098 Error: In hydMech_P_A_3; hydMech_P_A> volume < 0! Info: In hydMech_P_A_3; X1=0.034766076085979106 Info: In hydMech_P_A_3; X2=0.038604388594068742 Info: In hydMech_P_A_3; Simulation was stopped at t=-0.076045999992137098 Info: In md20_lr_5_5; Simulation was stopped at t=-0.076045999992137098 Saving Full results to file: cli\output.csv Transposing CSV file

peterNordin commented 3 years ago

I can not recreate this issue using the latest version of Hopsan (master branch) Can you give me an example of the commandline you use to call hopsancli ?

As an example I tested with this one: ./hopsancli_d -m ../UnitTests/HopsanCoreTests/SimulationTest/unittestmodel.hmf -s hmf --resultsFullCSV test.csv --resultsCSVSort cols --logonly TestGain\#out

I also added simulation abort at t=0.5 in that model to run the test again. (Just connect a SimulationTime block into StopSimulation) The output file still contains the same information up until the stop time, where the aborted output contains one incomplete additional line with zeroes, which is a different problem.

Also is the version information given correct ? If so try to upgrade. Not that anything in this code has changed for a while.

peterNordin commented 3 years ago

I found that if you do not use the resultsSortCSV cols option, then when the simulation aborts, the export would still contain the entire time vector. But I think that I have fixed that problem in my ongoing work #2002 Also now if the CSV data is transposed, it does not have that extra line with missing data at the end. At least in my tests.

mrejster commented 3 years ago

Hi, here is an example of call used with hopsanCLI, -m C:\git\rdcm\hopsan\models\md20_lr_best_fit.hmf --externalLibsFile hopsan_libs.txt --simulate 0,1.000000e-06,2.000000e-01 --numLogSamples 100000 --parameterImport cli\params_mod.csv --resultsFullCSV cli\output.csv --resultsCSVSort cols --logonly logVariables_md20_lr.txt

I tested using stopsimulation like you said, but I'm also unable to replicate the issue. I'll get back if I'm able to track it down further.

(I forgot to update version info, it's the custom version Robert sent: 2.14.0.20200826.0831, but doubt it makes a difference since I couldn't replicate on this version either.)

//Erik

Den tis 20 okt. 2020 kl 21:57 skrev Peter Nordin notifications@github.com:

I found that if you do not use the resultsSortCSV cols option, then when the simulation aborts, the export would still contain the entire time vector. But I think that I have fixed that problem in my ongoing work

2002 https://github.com/Hopsan/hopsan/pull/2002

Also now if the CSV data is transposed, it does not have that extra line with missing data at the end. At least in my tests.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Hopsan/hopsan/issues/2007#issuecomment-713103155, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRS3W5EQE5S35BYECLXW33SLXTR3ANCNFSM4SXRPQAQ .