Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot handle uncertainties in quantities #8

Open
kyleniemeyer opened this issue Feb 8, 2018 · 3 comments
Open

Cannot handle uncertainties in quantities #8

kyleniemeyer opened this issue Feb 8, 2018 · 3 comments

Comments

@kyleniemeyer
Copy link
Member

As of v0.2.3, PyTeCK cannot handle ChemKED files with uncertainties (at least in ignition delay, and likely other quantities).

For example, in eval_model,

        ign_delay = [case.ignition_delay.to('second').magnitude
                     for case in properties.datapoints
                     ]

doesn't work when the ignition delays have uncertainties, because case.ignition_delay is now a Measurement type that does not have the method magnitude. Instead, it needs to be case.ignition_delay.to('second').value.magnitude (I think).

@kyleniemeyer
Copy link
Member Author

possibly fixed in 1442f91 / v0.2.4a1

@skrsna
Copy link

skrsna commented Aug 13, 2019

I'm running into similar issues while trying to run PyTeCK with ChemKED files with uncertainties in ignition delays. Specifically at this line, which makes PressureRiseProfile. The error I'm getting is as follows:

/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/site-packages/pyteck/eval_model.py:169: RuntimeWarning: Warning: multiple changing variables. Using temperature.
  RuntimeWarning
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/site-packages/pyteck/eval_model.py", line 79, in simulation_worker
    sim.setup_case(model_file, model_spec_key, path)
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/site-packages/pyteck/simulation.py", line 363, in setup_case
    self.time_end
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/site-packages/pyteck/simulation.py", line 255, in __init__
    reactants, pressure_rise, time_end
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/site-packages/pyteck/simulation.py", line 85, in create_volume_history
    [times, pressures] = sample_rising_pressure(time_end, pres, freq, pres_rise)
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/site-packages/pyteck/simulation.py", line 61, in sample_rising_pressure
    times = np.arange(0.0, time_end + (1.0 / freq), (1.0 / freq))
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/site-packages/uncertainties/core.py", line 2670, in raise_error
    % (self.__class__, coercion_type))
TypeError: can't convert an affine function (<class 'uncertainties.core.AffineScalarFunc'>) to float; use x.nominal_value
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "test_performance.py", line 18, in <module>
    skip_validation=True
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/site-packages/pyteck/eval_model.py", line 366, in evaluate_model
    results = pool.map(simulation_worker, jobs)
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/multiprocessing/pool.py", line 266, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/home/sirumalla.s/anaconda3/envs/pyteck/lib/python3.6/multiprocessing/pool.py", line 644, in get
    raise self._value
TypeError: can't convert an affine function (<class 'uncertainties.core.AffineScalarFunc'>) to float; use x.nominal_value

The ChemKED file that's causing this can be found here.
I googled the error and ended up at official Uncertainties repo issue page here. Hope this helps. If you want to reproduce the error I can point you to our private repo on CoMoChEng organization. Thanks

@kyleniemeyer
Copy link
Member Author

@skrsna can you share the other files you were using when you ran into this error, so I can replicate the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants