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

Help: Errors about running Cantera 2.3.0b1 with Fortran code #531

Closed
ericpan2018 opened this issue Apr 30, 2018 · 7 comments
Closed

Help: Errors about running Cantera 2.3.0b1 with Fortran code #531

ericpan2018 opened this issue Apr 30, 2018 · 7 comments

Comments

@ericpan2018
Copy link

Cantera version

Cantera/.experimental-2.3.0b1

Operating System

Linux

Python/MATLAB version

Python/2.7.14-anaconda5.1.0

Expected Behavior

print out results like:

******** Fortran 77 Test Program ********
Initial state properties:

Temperature: 1200.0 K
Pressure: 0.10132E+06 Pa
Density: 0.12190 kg/m3
Molar Enthalpy: 0.29400E+08 J/kmol
Molar Entropy: 0.20356E+06 J/kmol-K
Molar cp: 32470. J/kmol-K

Equilibrium state properties:

Temperature: 3374.3 K
Pressure: 0.24765E+06 Pa
Density: 0.12190 kg/m3
Molar Enthalpy: 0.50402E+08 J/kmol
Molar Entropy: 0.25978E+06 J/kmol-K
Molar cp: 44395. J/kmol-K

Viscosity: 0.10487E-03 Pa-s
Thermal conductivity: 0.56831 W/m/K_

Actual Behavior

1) --- 1st error:

*** collision_integrals ***
Collision Integral Polynomial Fits
T*_min = 0.5
T*_max = 100
Collision integral fits at each tabulated T* vs. delta*.
These polynomial fits are used to interpolate between columns (delta*)
in the Monchick and Mason tables. They are only used for nonzero delta*.
polynomial coefficients not printed (log_level < 4)
max RMS errors in fits vs. delta*:
omega_22 = 0.00662161
A* = 0.002546
B* = 0.00134994
C* = 0.00127001
max RMS errors in fits vs. delta*:
omega_22 = 0.00662161
A* = 0.002546
B* = 0.00276527
C* = 0.00127001
tstar_fits
fits to A*, B*, and C* vs. log(T*).
These are done only for the required dstar(j,k) values.

*** polynomial coefficients not printed (log_level < 3) ***
*** end of collision_integrals ***
*** property fits ***
*** polynomial coefficients not printed (log_level < 2) ***
Polynomial fits for viscosity:
viscosity/sqrt(T) fit to polynomial of degree 4 in log(T)Maximum viscosity absolute error: 2.6675e-07
Maximum viscosity relative error: 0.00353897

Polynomial fits for conductivity:
conductivity/sqrt(T) fit to polynomial of degree 4 in log(T)Maximum conductivity absolute error: 0.00330222
Maximum conductivity relative error: 0.00788855

binary diffusion coefficients:
D/T**(3/2) fit to polynomial of degree 4 in log(T)Maximum binary diffusion coefficient absolute error: 1.50845
Maximum binary diffusion coefficient relative error: 0.0133331*** end of property fits *****_

2) --- 2nd error: about "advance" function: (similar error when using "step()" function)

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0 0x7faa50bcd26f in ???
#1 0x7faa4cd08f7b in ???
#2 0x7faa565c8e49 in ???
#3 0x7faa57d215c9 in ???
#4 0x7faa589dfecf in ???
#5 0x7faa589c588e in ???
#6 0x7faa589cc44d in ???
#7 0x669d69 in _ZN7Cantera16CVodesIntegrator9integrateEd
at src/numerics/CVodesIntegrator.cpp:439
#8 0x4d8687 in ZN7Cantera10ReactorNet7advanceEd
at src/zeroD/ReactorNet.cpp:134
#9 0x410680 in ???
#10 0x40ebdb in demo
at /scratch/j/jwallace/kangpan/f77nox_phi1/demo.f:47
#11 0x40aecc in main
at /scratch/j/jwallace/kangpan/f77nox_phi1/demo.f:104
Segmentation fault
**

Steps to reproduce

1.Since I ran simulation in University Computer Center, so the module is installed by them. To run the code, some modules needed to load in my account in Computer Center as:

Currently Loaded Modules:

  1. gcc/7.3.0 2) sundials/2.7.0 3) cantera/.experimental-2.3.0b1 (H) 4) mkl/2018.2
  2. python/2.7.14-anaconda5.1.0
  1. I am using Fortran code to call Cantera, so the fortran77 code is like:
      program demo
      implicit double precision (a-h,o-z)
      parameter (MAXSP = 20, MAXRXNS = 100)
      double precision q(MAXRXNS), qf(MAXRXNS), qr(MAXRXNS)
      double precision diff(MAXSP)
      character*80 eq
      character*20 name

      write(*,*)
      write(*,*) '********   Fortran 77 Test Program   ********'

      call newIdealGasMix('test.xml','gas','mix')
      t = 1200.d0
      p = 101325.d0
      call setState_TPX_String(t, p,  'CH4:1.0, O2:1.0')

      write(*,*) 'Initial state properties:'
      write(*,10) temperature(), pressure(), density(),
     $     enthalpy_mole(), entropy_mole(), cp_mole()
     
      call reactor()
      call insertgas()
      call reactornet()
      call insertreactor()
      call setenergy(1)

      tstep=1.d-5
      tnow=tstep
      tend=1.d-4
       do while (tnow .lt. tend)     
      
             call advance(tnow)

             tnow=tnow+tstep
       end do


      write(*,*) 'Equilibrium state properties:'
      write(*,10) temperature(), pressure(), density(),
     $     enthalpy_mole(), entropy_mole(), cp_mole()

 10   format(//'Temperature:   ',g14.5,' K'/
     $         'Pressure:      ',g14.5,' Pa'/
     $         'Density:       ',g14.5,' kg/m3'/
     $         'Molar Enthalpy:',g14.5,' J/kmol'/
     $         'Molar Entropy: ',g14.5,' J/kmol-K'/
     $         'Molar cp:      ',g14.5,' J/kmol-K'//)

c
c     Transport properties
c
      dnu = viscosity()      
      dlam = thermalConductivity()
      write(*,30) dnu, dlam
 30   format(//'Viscosity:             ',g14.5,'  Pa-s'/
     $         'Thermal conductivity:  ',g14.5,'  W/m/K'/)

      stop
      end
  1. the key functions included in interface file demo_ftnlib.cpp are like:
    void newidealgasmix_(char* file, char* id, char* transport,
                         ftnlen lenfile, ftnlen lenid, ftnlen lentr)
    {
        string trmodel = "";
        try {
            string fin = string(file, lenfile);
            string fth = string(id, lenid);
            trmodel = string(transport, lentr);
            delete _gas;
            _gas = new IdealGasMix(fin, fth);
        } catch (CanteraError& err) {
            handleError(err);
        }
        try {
            delete _trans;
            _trans = newTransportMgr(trmodel,_gas,1);
        } catch (CanteraError& err) {
            _trans = newTransportMgr("",_gas,1);
        }
    }

    void advance_(doublereal* dt)
    {
        try {
            _recnet->advance(*dt);
        } catch (CanteraError& err) {
            handleError(err);
        }
    }

	doublereal step_()
    {
        return _recnet->step();
    }
  1. The makefile is like:
include ${SCINET_CANTERA_ROOT}/include/cantera/Cantera.mak

FC=gfortran
RM=rm -f
FFLAGS=-g -03 
LDFLAGS=
LDLIBS=$(CANTERA_FORTRAN_LIBS)
CPPFLAGS=$(CANTERA_INCLUDES) -03

OBJS=demo_f77.o demo_ftnlib.o

all: demo

demo: $(OBJS)
        $(FC) $(LDFLAGS) -o demo $(OBJS) $(LDLIBS)

clean:
        $(RM) $(OBJS)

dist-clean: clean
        $(RM) *~

@bryanwweber
Copy link
Member

@ericpan2018 Is this the same issue you posted about on the User Group: https://groups.google.com/forum/#!topic/cantera-users/9OKA1CmLV2s ?

@ericpan2018
Copy link
Author

@bryanwweber Yes, it is the same issue. Since there is no one reply in Google Group, I just post it here with more details to expect someone can help.

My code works well under old system with Cantera-2.2.1 + intel-15.0.2 + python-2.7.8+ sundials-2.6.2+gcc-5.2.0, but now it has errors under new system with Cantera/.experimental-2.3.0b1 + gcc/7.3.0+ sundials/2.7.0+python/2.7.14-anaconda5.1.0+mkl/2018.2.

I have no idea where the errors are caused by? Is it by the change in Cantera-2.3.0b1 compared to Cantera-2.2.1, or by the change of using gcc instead of intel, or by installation issue (the technician mentioned he met issue when install Cantera due to the Cython issue)?

@ericpan2018
Copy link
Author

@bryanwweber Another question about installation of Cantera-2.2.1, When the technician installed Cantera-2.2.1, it fails due to some changes of Cython. Is there anyway to solve this problem? Or does anyone meet this issue? Thanks a lot.

@bryanwweber
Copy link
Member

@ericpan2018 You posted that question less than 48 hours ago, and we are an all-volunteer community (with many of our volunteers entering final exam season here in the US); probably no one has had time yet to look into the issue and respond. Could you please add the extra details from this post to the User's Group post and we'll focus the discussion there do avoid duplicating conversation (and can you also add to the user group post which git commit is specified as 2.3.0b1? How did they install Cantera 2.3.0b1? Why are they using an out-of-date version?)? Thank you!

@bryanwweber
Copy link
Member

@ericpan2018 This is a known and solved issue: #465 You should be using at least the full version of 2.3.0 (not 2.3.0b1) with an older version of Cython, or use the most recent master commit (although you will need to update when we release 2.4.0 sometime in the next few months).

@ericpan2018
Copy link
Author

@bryanwweber Thanks a lot for your help. I am not very clear with the installation details. In addition, I would like to ask if we can still install 2.2.1 and use method in #465 to fix the installation issue?

@bryanwweber
Copy link
Member

@ericpan2018 You can, although the patch may not apply cleanly because it was applied post-2.3.0. However, you should be able to fairly easily install an older version of Cython using pip if you really want to build 2.2.1. We will really need the installation details (posted to the User Group post please) to be able to help debug.

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