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

Integration of reactor with water fails below Temperature of 328 K #475

Closed
ulrich1a opened this issue Sep 21, 2017 · 9 comments
Closed

Integration of reactor with water fails below Temperature of 328 K #475

ulrich1a opened this issue Sep 21, 2017 · 9 comments

Comments

@ulrich1a
Copy link

Cantera version 2.3

Operating System: Windows 10 64-bit

Python 3.5

Expected Behavior: reactor should integrate to next time step

Actual Behavior:

CanteraError thrown by Substance::set_T:
illegal temperature: 272.5

Steps to reproduce: run the following python script

import cantera as ct
myWater = ct.Water()
myWater.TP = 327.0, 1.0*ct.one_atm
r2 = ct.Reactor(contents=myWater)
sim = ct.ReactorNet([r2])
sim.advance(4.e-4)

@bryanwweber
Copy link
Member

bryanwweber commented Sep 22, 2017

This is expected behavior. The minimum temperature allowed for the Water phase is 273.16 K, which you can check with

>>> myWater.min_temp
273.16

@bryanwweber
Copy link
Member

bryanwweber commented Sep 22, 2017

On second thought, the Reactor shouldn't be doing anything. There aren't any energy transfers, so the temperature shouldn't decrease, so I'm not sure what's happening here. This might require looking into the solver.

You can get this to advance if you turn off the energy equation:

r2.energy_enabled = False
sim = ct.ReactorNet([r2])
sim.advance(4.0E-4)

Can you please give some more detail of your use case that raises this issue?

@ulrich1a
Copy link
Author

I am interested in the temperature of a reactive gas pressurized in a reactor with water. The inflow of water is modeled with a valve. Also the heat transfer to the water is needed in this case.
This worked for me with Cantera 2.2. So it looks like a regression.

@skyreflectedinmirrors
Copy link
Contributor

skyreflectedinmirrors commented Sep 22, 2017

@bryanwweber could this be due to the FD Jacobian?
If there's any non-zero (potentially spurious) derivative of the temperature, you would end up evaluating the RHS at a temperature ~ T + dT/dt * epsilon, which could account for the "drop"

edit: on second thought, that looks like a pretty large deltaT to be evaluating at

@bryanwweber
Copy link
Member

@ulrich1a Can you provide a complete script that worked with Cantera 2.2?

@ulrich1a
Copy link
Author

Here is a version, that worked with water, although I used here
myWater = ct.Solution('liquidvapor.xml', 'water')
gas_compression.zip

@bryanwweber
Copy link
Member

With the script you provided and Cantera 2.2.1 (and 2.2.0), I get an updateState error in the Reactor on macOS, so the script doesn't work for me. Can you confirm that it works for you?

@speth
Copy link
Member

speth commented Sep 25, 2017

I also couldn't get this to work with Cantera 2.2, but the changes that generate the current behavior are the ones introduced in 1dc0ced which were implemented to resolve #257.

I think the issue here is that while the bracket_and_solve_root function is generally more robust than the Newton's method algorithm that was previously implemented, it does need some work so that it doesn't run into trouble trying to evaluate properties outside the valid temperature range for the state.

@ulrich1a
Copy link
Author

ulrich1a commented Oct 4, 2017

The code in 1dc0ced contains the line:

+            TT = bmt::bracket_and_solve_root(
+                u_err, T, 1.2, true, bmt::eps_tolerance<double>(48), maxiter);

The reported temperature in the error message is just by a factor 1/1.2 smaller than the starting temperature. So for me it seems, that the factor 1.2 hardcoded in the function call has to be adjusted in case of pure liquids to avoid a temperature outside of the limits.

The following script was running without error in version 2.2.1:

# -*- coding: utf-8 -*-

import cantera as ct

#myWater = ct.Water()
myWater = ct.Solution('liquidvapor.xml', 'water')
#myWater.TP = 328.0, 7.0*ct.one_atm 
#myWater.TX = 328.0, 1.0 
myWater.TPX = (300.0, 7.0*ct.one_atm, 'H2O:1.0') # Temperatur 35°C
r2 = ct.Reactor(contents=myWater)
#r2.volume = 0.000001
r2.syncState()

print('Temperatur 1:',r2.T)
print(r2.thermo.P)
sim = ct.ReactorNet([r2])
sim.verbose = True
#print(r2.get_state())
sim.advance(4.e-4)
print('Temperatur 2:',r2.T)
print(r2.thermo.P)

speth added a commit to speth/cantera that referenced this issue Dec 2, 2017
@speth speth closed this as completed in #487 Dec 3, 2017
srikanthallu pushed a commit to srikanthallu/cantera that referenced this issue Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants