鱼C论坛

 找回密码
 立即注册
查看: 931|回复: 1

求问,CompositionReader是个python的第三方库吗?

[复制链接]
发表于 2020-8-26 00:03:09 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
这个是cantera的一个事例,其中用到了import CompositionReader,求问CompositionReader怎么安装下载,我用pip失败了
# Clint Dunn, cdunn6754@gmail.com, 07-5-17
# written in Python 3.6.1 on cantera 2.3.0

## Description
# A PSR combustor. Two separate streams - one coal volatiles and the other air, both at
# 300 K and 1 atm flow into an adiabatic and constant pressure
# combustor where they mix and burn.

# Writen so that we can write out a csv file for a particular combination of 
# chemical mechanism and fuel composition. It writes these to the csv directory.
# The ppPsr.py script then reads these csv's and plots/ post processes them.

# From the original Cantera file starter thing that I kept:
# We are interested in the steady-state burning solution. Since at 300 K no
# reaction will occur between fuel and air, we need to use an 'igniter' to
# initiate the chemistry. A simple igniter is a pulsed flow of atomic hydrogen.
# After the igniter is turned off, the system approaches the steady burning
# solution.


# let me get at my utility functions
import sys 
import os
sys.path.append(os.path.abspath("/home/cdunn3/Python_3.6.1/Cantera/utilities"))

import math
import csv
import matplotlib.pyplot as plt
import cantera as ct
import numpy as np
import CompositionReader as cr

#..........................................................................#
## setup stuff

# user inputs
mechanism = 'drm'
fuel_name = 'heavy'

# Get the specified fuel compositions
fuel_dict = {'light':'light_fuel.txt',
             'heavy':'heavy_fuel.txt'
         }
composition = cr.read_compositions(fuel_dict[fuel_name])

# define the mechanism and gas
mech_dir = 'mechanisms/'
mechanism_dict = {'reduced':'r_creck_52.cti',
                  'full':'POLIMI_TOT_1412.cti',
                  'drm':'DRM_22_benzene.cti'
              }
gas = ct.Solution(mech_dir +  mechanism_dict[mechanism])

# ....................................................................#
## run the simulation

# create a reservoir for the fuel inlet, and set to pure methane.
gas.TPX = 300.0, ct.one_atm, composition
fuel_in = ct.Reservoir(gas)
fuel_mw = gas.mean_molecular_weight

# use predefined function Air() for the air inlet
air = ct.Solution('air.xml')
air_in = ct.Reservoir(air)
air_mw = air.mean_molecular_weight

# to ignite the fuel/air mixture, we'll introduce a pulse of radicals. The
# steady-state behavior is independent of how we do this, so we'll just use a
# stream of pure atomic hydrogen.
gas.TPX = 300.0, ct.one_atm, 'H:1.0'
igniter = ct.Reservoir(gas)

# create the combustor, and fill it in initially with N2
gas.TPX = 300.0, ct.one_atm, 'N2:1.0'
combustor = ct.IdealGasReactor(gas)
combustor.volume = 1.0

# create a reservoir for the exhaust
exhaust = ct.Reservoir(gas)

# adjust the ratio coming in
Z  = 0.15

# compute fuel and air mass flow rates (light crashes at 2.5)
total_mdot = lambda t:  1 + (2.*t)**2.0
air_mdot = lambda t: total_mdot(t) * (1.0 -Z)
fuel_mdot = lambda t: total_mdot(t) * Z

# create and install the mass flow controllers. Controllers m1 and m2 provide
# constant mass flow rates, and m3 provides a short Gaussian pulse only to
# ignite the mixture
m1 = ct.MassFlowController(fuel_in, combustor, mdot=fuel_mdot)

# note that this connects two reactors with different reaction mechanisms and
# different numbers of species. Downstream and upstream species are matched by
# name.
m2 = ct.MassFlowController(air_in, combustor, mdot=air_mdot)

# The igniter will use a Gaussian time-dependent mass flow rate.
fwhm = 0.2
amplitude = 0.01
t0 = 0.5
igniter_mdot = lambda t: amplitude * math.exp(-(t-t0)**2 * 4 * math.log(2) / fwhm**2)
m3 = ct.MassFlowController(igniter, combustor, mdot=igniter_mdot)

# put a valve on the exhaust line to regulate the pressure
v = ct.Valve(combustor, exhaust, K=1.0)

# the simulation only contains one reactor
sim = ct.ReactorNet([combustor])

# take single steps to 6 s, writing the results to a CSV file for later
# plotting.
tfinal = 40.0
dt = 0.0001
times = np.arange(dt,tfinal,dt)

# data output arrays
states = ct.SolutionArray(gas, extra=['t', 'tres', 'fuel_mdot', 'Z'])
for i, time in enumerate(times):
    sim.advance(time)
    tres = combustor.mass/(m1.mdot(time) + m2.mdot(time))    #v.mdot(time)
    states.append(gas.state, t=time, tres=tres, fuel_mdot=m1.mdot(time), Z=Z)

csv_dir = 'csv_files/'
states.write_csv(csv_dir + fuel_name + '_' + mechanism + '_states.csv')
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-8-26 08:03:21 | 显示全部楼层


应该不是,是自己写的代码吧

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-1-19 03:17

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表