SCM-NV / pyZacros

Python Library for Automating Zacros Simulations
Other
7 stars 2 forks source link

Crash from formatting issue with high precision in gas energy #58

Closed stefsmeets closed 3 years ago

stefsmeets commented 3 years ago

Hi all, when I specify a gas_energy with very high precision, the Zacros crashes because of formatting issues

More information: Invalid expression "gas_energies 0.0 0.0-4.157842190497977" in line 7.

nfaguirrec commented 3 years ago

Dear Stef,

Thanks a lot for reporting this bug. I just fixed it within my last commit to the 'develop' branch. Please, let me know if your example now works!

stefsmeets commented 3 years ago

OK, I think it's this one: https://github.com/SCM-NV/pyZacros/commit/73becbed6b005aa101afe1860818b6b22f285212

I will have a try.

stefsmeets commented 3 years ago

Yeah, that seems to work, although I'm not necessarily a fan of the unnecessary scientific formatting:

n_gas_species    3
gas_specs_names              O2           CO          CO2
gas_energies        0.00000e+00  0.00000e+00 -4.15780e+00
gas_molec_weights   3.19898e+01  2.79949e+01  4.39898e+01
gas_molar_fracs     5.00000e-01  5.00000e-01  0.00000e+00

Instead of " %12.5e", you could try " %12.5g" which will switch from fixed point to scientific formatting if the value gets too large to fit within the specified precision.

nfaguirrec commented 3 years ago

Yeah. Me neither. But we found it necessary for several systems, where e.g. molar fractions in the order of 1e-7 are needed. Anyway, these input files are not intended for the user; they don't need to know that they exist. So, it is better to let it in that way to ensure we do not lose precision during the writing of the input files.