-
Notifications
You must be signed in to change notification settings - Fork 6
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
Additional parameters for set_equivalence_ratio #108
Comments
Hi @corykinney. I believe you can already more or less do this manually, e.g. gas.set_equivalence_ratio(1, fuel='CH4:1.', oxidizer='O2:0.2, Ar:0.7') where you specify the composition of the |
@ischoegl you could try to specify the >>> gas.set_equivalence_ratio(1, fuel='CH4:1.', oxidizer='O2:0.2, Ar:0.7')
>>> gas.mole_fraction_dict()
{'AR': 0.6999999999999998, 'CH4': 0.1, 'O2': 0.2} it only happens to work because for an O2 concentration of 0.2, the corresponding CH4 concentration is 0.1, which cancels out the normalization of the oxidizer. If I were to use a different equivalence ratio (or diluent concentration) it would give an unintended result: >>> gas.set_equivalence_ratio(0.5, fuel='CH4:1.', oxidizer='O2:0.2, Ar:0.7')
>>> gas.mole_fraction_dict()
{'AR': 0.736842105263158, 'CH4': 0.052631578947368425, 'O2': 0.2105263157894737} |
@corrykinney ... got it. Personally, I'd have two suggestions to tweak your original proposal to >>> gas.set_equivalence_ratio(0.5, fuel='CH4', oxidizer='O2', diluent='Ar', mole_fraction_diluent=0.7) as |
@ischoegl that makes sense. I would suppose my revised proposal for the Python function signature would be: set_equivalence_ratio(phi, fuel, oxidizer, diluent=None, *, fuel_mole_fraction=None, diluent_mole_fraction=None) Maybe with the |
One first step (I think) could be to just do the conversion in the Python function to calculate the oxidizer mole fraction that includes the diluent. Since this is mainly a convenience feature to offload the calculation from the user. Then the python function could call the underlying C++, using the same signature as before? If this is the approach, we'd want to make a parallel change in the Matlab toolbox. |
I agree that things could be limited to Python. As an alternative, I could also see a new function set_dilution(diluent, diluent_mole_fraction=None) This has the advantage that it would keep Regarding MATLAB, I don't think that an implementation is necessary. The MATLAB interface is incomplete as it stands, and (as far as I am aware of) there are some ongoing attempts to replace it by a new approach, making any new feature implementation potentially short-lived. |
I have a couple ideas here... I think the way that CHEMKIN and possibly also CEA do this is by allowing you to specify a set of "extra" species whose mole fractions are known. That would solve the diluent issue, and should be pretty easy to implement. A Python interface like: set_equivalence_ratio(1.0, 'CH4:1,C3H8:1', 'O2:1,N2:3.76', extra='AR:0.7') would work nicely, IMO. That would set the mole fraction (by default) of argon to 0.7 and scale everything else accordingly. This should be relatively simple to do in C++ so it can probably be added to every interface. As far as setting the fuel concentration, that API seems a little trickier to fit in with set_equivalence_ratio(1.0, 'CH4:1', 'O2:1,N2:3.76', extra='CH4:0.04', diluent='AR') or perhaps a specific name like set_equivalence_ratio(1.0, 'CH4:1,C3H8:1', 'O2:1,N2:3.76', extra='fuel:0.7', diluent='AR') |
@bryanwweber Yeah I'm not 100% sure how to get the features to fit with the existing If we went the route of using the set_equivalence_ratio(1.0, 'CH4: 1', 'O2: 1, N2: 3.76', extra='fuel:0.04, CO2: 0.50, Ar') with the mole fraction for set_equivalence_ratio(1.0, 'CH4: 1', 'O2: 1, N2: 3.76', extra='CO2, 0.30, Ar: 0.40') to make a stoichiometric mixture out of the remaining 30%. |
Hi @corykinney! I don't understand your first case... The CO2 should have a mole fraction of 0.4, the fuel (in this case methane) at 0.04, o2 and n2 in the air proportion, and with their mole fraction set to the stoichiometric ratio with the fuel, and the balance argon? Honestly, that seems too complicated for this function, and since it's meant to support a particular class of experiments, I'd suggest creating a separate toolbox based on Cantera to do that math. The second case, though, fits neatly in what I was thinking, in terms of the |
@bryanwweber I can understand that it would be beyond the scope of the function. For my purposes, I'll just have to make some custom functionality for that. But I do think the |
@corykinney and @bryanwweber ... getting the interface right is probably the most difficult aspect of this. To throw yet another suggestion into the mix, what about set_equivalence_ratio(1.0, fuel="CH4", oxidizer="O2: 1, N2: 3.76", diluent="Ar",
fraction="diluent:0.7", basis="mass") This would just add two additional parameters, and cover all cases ( |
I like @ischoegl's last suggestion, as I think it offers a lot of flexibility without adding too many specialized arguments. I'm not sure what the best format for the |
If I understand correctly, with @ischoegl 's interface, the only change (at least in the python interface) would be to add the following code snippet at the end of the current set_equivalence_ratio function (after https://github.com/Cantera/cantera/blob/38bbc66e24a34bd9650a553e2d96994020890aac/interfaces/cython/cantera/thermo.pyx#L779):
I didn't test the code above, but conceptionally, this should do the requested calculations, right? |
Closed via Cantera/cantera#1206 |
Abstract
Currently the
ThermoPhase.set_equivalence_ratio
function includes parameters forphi
,fuel
, andoxidizer
. The proposed change would add optional parameters to increase utility.Motivation
In shock tube/combustion research it is common to define mixtures using equivalence ratio, fuel concentration, and a corresponding bath gas/diluent. This is very straightforward to do manually with simple mixtures, but with blends of fuels (e.g. natural gas) and oxidizers (e.g. air) a built-in method would be helpful.
Possible Solutions
Add additional parameters
bath
/diluent
/balance
(not sure what standard terminology would be) for gas that will fill the remainder of the mixture, and EITHERfuel_concentration
to specify the total mole fraction of all fuel constituents in the resultant mixture, ORbath_concentration
to specify the total mole fraction of the bath gas in the resultant mixtureAn example of the suggested implementation to make a mixture with a desired fuel concentration would be:
and for a desired bath gas concentration:
Don't add anything
If this doesn't seem that it would be useful enough for inclusion, obviously it is possible to do this with the existing function and a bit of extra manipulation:
set_equivalence_ratio
as isIt would just be useful to have this functionality standard.
The text was updated successfully, but these errors were encountered: