Ejemplo n.º 1
0
import cantera as ct
import torch

import reactorch as rt

cpu = torch.device('cpu')

cuda = torch.device('cuda:0')

device = cpu

mech_yaml = '../data/gri30.yaml'
composition = "CH4:0.5, O2:1.0, N2:3.76"

sol = rt.Solution(mech_yaml=mech_yaml, device=device,
                  vectorize=True,
                  is_clip=False, is_norm=False, is_wdot_vec=False)

gas = sol.gas
gas.TPX = 950, 20 * ct.one_atm, composition

r = ct.IdealGasReactor(gas)
sim = ct.ReactorNet([r])

time = 0.0
t_end = 10
idt = 0
states = ct.SolutionArray(gas, extra=['t'])
T0 = gas.T

print('%10s %10s %10s %14s' % ('t [s]', 'T [K]', 'P [atm]', 'u [J/kg]'))
Ejemplo n.º 2
0
import cantera as ct
import torch
import numpy as np

import reactorch as rt

import json

mech_yaml = 'gri30.yaml'
# mech_yaml = 'JP10skeletal.yaml'
# mech_yaml = 'h2o2.yaml'

sol = rt.Solution(mech_yaml=mech_yaml,
                  device=torch.device('cpu'),
                  vectorize=True,
                  is_clip=False,
                  is_norm=False,
                  is_wdot_vec=False)

gas = sol.gas

gas.TPY = 1200, ct.one_atm, np.ones(gas.n_species) / gas.n_species

molecular_weights = gas.molecular_weights.tolist()
reactant_stoich_coeffs = gas.reactant_stoich_coeffs()
product_stoich_coeffs = gas.product_stoich_coeffs()
Arrhenius_coeffs = sol.Arrhenius_coeffs
efficiencies_coeffs = sol.efficiencies_coeffs

np.savez(mech_yaml,
         molecular_weights=molecular_weights,
Ejemplo n.º 3
0
cpu = torch.device('cpu')

cuda = torch.device('cuda:0')

device = cpu
###################修改输入文件
mech_yaml = '../data/IC8H18_reduced.yaml'
# mech_yaml = '../data/gri30.yaml'
# mech_yaml = '../data/nc7_ver3.1_mech_chem.yaml'
# composition = 'IC8H18:0.5,O2:12.5,N2:34.0'
# composition='CH4:0.5,O2:12,N2:40.0'
composition = 'IC8H18:0.08,O2:11.0,N2:39.0'
# composition='NC7H16:0.5,O2:11.0,N2:40.0'

sol = rt.Solution(mech_yaml=mech_yaml,
                  device=device)  #here vectorize seems not change the results

#print(sol.species_names,sol.nasa_low[4,:],sol.nasa_high[4,:])

gas = sol.gas
gas.TPX = 1800, 5 * ct.one_atm, composition

# r = ct.IdealGasReactor(gas)
r = ct.IdealGasConstPressureReactor(gas)

sim = ct.ReactorNet([r])

# time = 0.0
# t_end=10
t_end = 1e-3
idt = 0
Ejemplo n.º 4
0
import cantera as ct
import torch

import reactorch as rt

cpu = torch.device('cpu')

cuda = torch.device('cuda:0')

device = cpu

mech_yaml = '../data/gri30.yaml'
composition = "CH4:0.5, O2:1.0, N2:3.76"

sol = rt.Solution(mech_yaml=mech_yaml, device=device)

gas = sol.gas
gas.TPX = 950, 20 * ct.one_atm, composition

r = ct.IdealGasReactor(gas)
sim = ct.ReactorNet([r])

time = 0.0
t_end = 10
idt = 0
states = ct.SolutionArray(gas, extra=['t'])
T0 = gas.T

print('%10s %10s %10s %14s' % ('t [s]', 'T [K]', 'P [atm]', 'u [J/kg]'))
        TPY.requires_grad = True

        jac_ = jacobian(self.TYdot_jac, TPY, create_graph=False)
        # print(jac_,np.size(jac_))


        return jac_

################################modified input
t0_start = perf_counter()

mech_yaml = '../../data/ic8_ver3_mech.yaml'
# mech_yaml = '../../data/nc7_ver3.1_mech_chem.yaml'
#mech_yaml = '../../data/gri30.yaml'

sol = rt.Solution(mech_yaml=mech_yaml, device=device,vectorize=True)

gas = ct.Solution(mech_yaml)



# Initial condition
P = ct.one_atm * 1
T = 1800
composition = 'IC8H18:0.5,O2:12.5,N2:34.0'
#composition = 'IC8H18:0.08,O2:1.0,N2:3.76'
#composition = 'CH4:0.5,O2:11,N2:40'
# composition='NC7H16:0.5,O2:11.0,N2:40.0'
# composition='NC7H16:0.4,O2:11.0,N2:41.36'
gas.TPX = T, P, composition
if (gas.Y<0).any():