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

1 d continuation #541

Closed
wants to merge 69 commits into from
Closed

1 d continuation #541

wants to merge 69 commits into from

Conversation

axbriones
Copy link

Please fill in the issue number this pull request is fixing:

Fixes #534

Changes proposed in this pull request:

  • One dimensional continuation techniques (one- and two-point)

axbriones added 30 commits May 22, 2018 14:21
This function is used to transfer control between the python code and C++ Cantera code.  The information passed is Dom, StrainEq, UnityLewisNumber, OnePointControl, TwoPointControl, Tfuel_fixed, Tfuel_j, Toxid_fixed, Toxid_j, EnableReaction.
This cython definition calls setFlameControl and passes arguments. The information passed is Dom, StrainEq, UnityLewisNumber, OnePointControl, TwoPointControl, Tfuel_fixed, Tfuel_j, Toxid_fixed, Toxid_j, EnableReaction. This function can be called from python scripts by instantiating cantera.CounterFlowDiffusionFlame(arg1, arg2).
For two-point control continuation methods the oxidizer velocity is not known and needs to computed.
The modifications allow for continuation procedures as well as application of Unity Lewis number, alternative pseudo-one dimensional equation. The latter replaces the pressure curvature with the strain rate eigenvalue.  In addition, the net reaction rate of species needs to be deactivated to facilitate the calculationof the lower branch.
In numerical continuation methods interior boundaries replace exterior boundaries. When one or two point control continuation methods are enabled at least one mass flux is obtained as a result of the calculation for opposed flow flamems.
Reinstating c_offset_P with index 3
ePotential variable and uo variable shared the same index right now. This means that continuation methods and ion flow models are incompatible.
@speth speth force-pushed the 1D-continuation branch from 7aa2e63 to 4a5f264 Compare July 4, 2018 19:17
@speth
Copy link
Member

speth commented Jul 4, 2018

I fixed the merge conflict, which was caused by the fact that both a change to master and this PR modified the very end of test_onedim.py -- not a big deal, but also not something that Git can figure out on its own.

However, I think most of the comments that I previously made on this set of changes in the previous PR (#534) still need to be addressed. Also note that a unity Lewis number transport model has been added (see #510), so it is not necessary to implement that feature as part of this PR.

Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running the test added here (after fixing the path to the h2o2.cti file), I get the output:

test_diffusion_flame_cont (cantera.test.test_onedim.TestOneDimNumCont) ... Start flamelet generation of FPV type
 Precalculations
  Pressure      Tmax Fuel_mdot
  101325.0     3095.4       0.10
     #n      Tmax       Amax         dT     branch   FlameControl?   # gridpoints
     1     3094.9      131.7      20.00      upper      False           85
     2     3093.0      327.7      20.00      upper      False           87
     3     3090.1      652.1      20.00      upper      False           91
     4     3084.9     1134.8      20.00      upper      False           94
     5     3077.0     1805.4      20.00      upper      False           95
     6     3066.5     2692.6      20.00      upper      False           95
     7     3051.8     3824.2      20.00      upper      False           97
     8     3032.1     5227.0      20.00      upper      False           97
     9     3008.9     6910.7      20.00      upper      False           99
     #n      Tmax       Amax         dT     branch   FlameControl?   # gridpoints
    10     2981.0     8929.0      20.00      upper      False          100
False True False True 2664.53392123918 37 2703.1656996269094 52
Calculation failed; the new value of dT is 10.000000
False True False True 2674.53392123918 37 2713.165699626909 52
Calculation failed; the new value of dT is 5.000000
False True False True 2679.53392123918 37 2718.165699626909 52
Calculation failed; the new value of dT is 2.500000
False True False True 2682.03392123918 37 2720.665699626909 52
Calculation failed; the new value of dT is 1.250000
False True False True 2683.28392123918 37 2721.915699626909 52
Calculation failed; the new value of dT is 1.000000
    11      300.0   819517.4       1.00      lower      False          100

which suggests that at least for this example, it is unable to find solutions along the middle branch. Can we at start with an example that actually exercises the the control algorithm working in each branch? I think this issue needs to be resolved before we put any effort into modifying things so that this fits nicely with Cantera's existing code.

@wandadars
Copy link
Contributor

@speth Two questions.

A.) If this PR gets out-of-date a bit with respect to changes on the main cantera master branch, what would be the best way for me to set up a clone of this repo so that I could create a new PR with changes? Something like this?
1.) Clone this repo
2.) Push the 1D-continuation branch up to my cantera fork
3.) Create new PR?

B.) I'm trying to replicate the error that you posted most recently. This is what I'm doing:
1.) Create conda environment with necessary cantera dependencies
2.) Clone the repo by @axbriones and checkout the 1D-continuation branch
3.) scons build python_package=full prefix=<blahBlah/cantera_1D_continuation_build
4.) scons test (but this runs all the tests and takes several minutes)

If I go into build/python2/cantera/test and run: python test_onedim.py , I get import errors (which I'm pretty sure are because that is not how the tests are supposed to be run).

@bryanwweber
Copy link
Member

@wandadars Regarding the tests, you can run just the Python tests by

scons test-python

My suggestion to bring this PR up-to-date is to rebase it onto the current master branch. The following code will checkout a new branch with the existing changes:

git checkout -b axbriones-1D-continuation master
git pull https://github.com/axbriones/cantera.git 1D-continuation

Then, assuming that you have Cantera/cantera as a remote named upstream, you can do

git fetch upstream
git rebase upstream/master

Most likely this will cause merge conflicts that you'll have to fix.

@speth
Copy link
Member

speth commented Jan 28, 2019

I'm a little torn on the best way to move forward here. Normally, I would agree with Bryan's suggestion of rebasing onto the current master and fixing the conflicts where they occur. However, given that the code doesn't work as-is, I'd hesitate to suggest investing time on dealing with resolving merge conflicts while untangling the commit history (which risks introducing new bugs) before seeing if you can get this code working. On the other hand, the rebase will just become harder as you do more work on this branch.

To just run the tests of the 1D solver, you can run scons test-python2-onedim. You can also run just a specific test, outside of SCons after running scons build. It should be something like
PYTHONPATH=build/python2 python -m unittest -k TESTNAMEPATTERN cantera.test.

@bryanwweber
Copy link
Member

@speth Is the reason you're suggesting test-python2-onedim because this code is based before the removal of Python 2 support? Would it be better to run test-python3-onedim until it is rebased and then just test-python-onedim after?

@axbriones
Copy link
Author

@speth @bryanweber Hello, sorry that I've out of the loop for a while. I'm planning to start working in this project again in about two weeks .

@speth
Copy link
Member

speth commented Jan 28, 2019

@bryanwweber I mentioned Python 2 because @wandadars specified that path in his message. Running the tests with Python 3 would be slightly preferable, but is well behind the two major issues that need to be resolved here.

@speth speth changed the base branch from master to main June 30, 2020 23:08
@ischoegl
Copy link
Member

Superseded by #766 via #759 - closing.

@ischoegl ischoegl closed this Feb 20, 2022
This was referenced Jun 21, 2023
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

Successfully merging this pull request may close these issues.

5 participants