예제 #1
0
	def __init__(self, params = None, **kwargs):
		if params == None:
			params = AttributeDict(kwargs)
			
		self.V = params.V
		if (isinstance(params.fluid, CP.Fluid)):
			self.fluid = params.fluid
		else:
			self.fluid = CP.Fluid(params.fluid)
			
		self.fState = CP.FluidState(self.fluid)
		self.fluidPort = DMS.DynamicCPort(DMS.FluidPort, state = self.fState)
예제 #2
0
    def __init__(self, params=None, **kwargs):
        if params == None:
            params = AttributeDict(kwargs)

        self.fluid = params.fluid

        self.fStateIn = CP.FluidState(self.fluid)
        self.fStateOut = CP.FluidState(self.fluid)
        self.fStateDown = CP.FluidState(self.fluid)
        self.fStateTmp = CP.FluidState(self.fluid)

        self.flowOut = DMS.FluidFlow()
        self.heatOut = DMS.HeatFlow()
        self.portIn = DMS.FluidPort('C', self.fStateDown)
        self.portOut = DMS.FluidPort('R', self.flowOut)
        self.thermalPort = DMS.ThermalPort('R', self.heatOut)
예제 #3
0
    def __init__(self, params=None, **kwargs):
        if params == None:
            params = AttributeDict(kwargs)

        self.fluid = params.fluid
        self.fState = CP.FluidState(self.fluid)
        self.port1 = DMS.FluidPort('C', self.fState)
예제 #4
0
파일: HeatFlow.py 프로젝트: birdol/SmoWeb
 def test():
     c = ConvectionHeatTransfer()
     c.fluidPort.state = CP.FluidState('ParaHydrogen')
     c.fluidPort.state.update_Tp(288, 1e5)
     c.wallPort.state.T = 350.0
     c.compute()
     print("qDotFluid = {}, qDotWall = {}".format(c.fluidPort.flow.HDot,
                                                  c.wallPort.flow.QDot))
예제 #5
0
	def setUp(self):
		fState = CP.FluidState('Oxygen')
		tState = DMS.ThermalState()
		self.fp1 = DMS.FluidPort('C', fState)
		self.fp2 = DMS.FluidPort('R')
		self.fp3 = DMS.DynamicCPort(DMS.FluidPort, CP.FluidState('Oxygen'))
		self.fp4 = DMS.FluidPort('R')
		self.tp1 = DMS.ThermalPort('C', tState)
		self.tp2 = DMS.ThermalPort('R')
		self.tp3 = DMS.ThermalPort('R')
		
		self.fp1.state.update_Tp(300, 2e5)
		self.fp2.flow.mDot = 3.0
		self.fp2.flow.HDot = 4.0e3
		self.fp4.flow.mDot = 5.0
		self.fp4.flow.HDot = 7.0e3
		self.tp1.state.T = 23
		self.tp2.flow.QDot = 2.0e3
예제 #6
0
    def __init__(self, params=None, **kwargs):
        if params == None:
            params = AttributeDict(kwargs)

        self.fluid = params.fluid
        self.fState = CP.FluidState(self.fluid)
        self.TOutModel = lambda obj: params.TOut
        self.mDot = params.mDot
        self.flow = DMS.FluidFlow(mDot=self.mDot)
        self.port1 = DMS.FluidPort('R', self.flow)
예제 #7
0
    def __init__(self, params=None, **kwargs):
        if params == None:
            params = AttributeDict(kwargs)

        self.fluid = params.fluid  #fluid
        self.etaS = params.etaS  #isentropic efficiency
        self.fQ = params.fQ  #fraction of heat loss to ambient
        self.V = params.V  #displacement volume

        self.n = 0.0  #number of revolutions per second
        self.fStateOut = CP.FluidState(self.fluid)

        self.flow = DMS.FluidFlow()
        self.portOut = DMS.FluidPort('R', self.flow)
        self.portIn = DMS.FluidPort('R', -self.flow)
예제 #8
0
def testFluidChamber_Fueling():
	from SourcesSinks import FlowSource

	print "=== START: Test FluidChamber ==="
	
	# Open csv file
	import csv
	csvfile = open('./test/FluidChamber_Results.csv', 'wb')
	csv_writer = csv.writer(csvfile, delimiter=',')
	csv_writer.writerow(["Time[s]", "Tank pressure [bar]", "Tank temperature [K]", "Tank density [kg/m**3]", "Inlet enthalpy flow rate [W]"])
	
	# Parameters
	mDot = 50./3600 #[kg/s]
	Tin = 250.0 #[K]

	# Create Fluid
	fluid = CP.Fluid('ParaHydrogen')
	# Create fluid source
	fluidSource = FlowSource(fluid, mDot = mDot, TOut = Tin)
	# Create tank
	tank = FluidChamber(
		fluid = fluid, 
		V = 0.100 #[m**3] 100 L
	)
	# Connect tank and flow source
	tank.fluidPort.connect(fluidSource.port1)
	
	# Initial tank state
	TTank_init = 300 #[K]
	pTank_init = 2e5 #[Pa]
	tank.initialize(TTank_init, pTank_init)
	rhoTank = tank.fState.rho
	TTank = tank.fState.T

	t = 0.0
	dt = 0.01
	tPrintInterval = dt * 100
	tNextPrint = 0
	
	# Run simulation
	while True:
		# Set tank state
		tank.setState(TTank, rhoTank)
		
		# Set source state
		fluidSource.compute()
		
		# Write to csv file
		if t >= tNextPrint:
			csv_writer.writerow([t, tank.p / 1.e5, tank.T, tank.rho, fluidSource.flow.HDot, fluidSource.fState.h])
			tNextPrint = t + tPrintInterval - dt/10
		t += dt
				
		# Compute tank
		tank.compute()
		if (tank.p > 200e5):
			break
		TTank += tank.TDot * dt
		rhoTank += tank.rhoDot *dt
		
	# Close csv
	csvfile.close()	
	print "=== END: Test FluidChamber ==="
예제 #9
0
def testTankModel():
    print "=== BEGIN: testTankModel ==="
    # Settings
    simulate = True  #True - run simulation; False - plot an old results

    # Create the model
    tankModel = TankModelFactory.create(
        updateProgress=lambda x, y: x,  #:TRICKY: not used
        fluid=CP.Fluid('ParaHydrogen'),
        ambientFluid=CP.Fluid('Air'),
        TAmbient=288.15,
        controller=AttributeDict(
            #initialState = TC.FUELING,
            initialState=TC.EXTRACTION,
            tWaitBeforeExtraction=150.,
            tWaitBeforeFueling=150.,
            pMin=20e5,
            pMax=300e5,
            mDotExtr=30 / 3600.,
            nCompressor=0.53 * 1.44,
        ),
        fuelingSource=AttributeDict(
            sourceType=DM.FluidStateSource.PQ,
            T=15,  #:TRICKY: unused
            p=2.7e5,
            q=0.,
        ),
        compressor=AttributeDict(
            etaS=0.9,
            fQ=0.,
            V=0.5e-3,
        ),
        cooler=AttributeDict(
            workingState=1.,
            epsilon=1.0,
            TCooler=200,
        ),
        tank=AttributeDict(
            wallArea=1.8,
            volume=0.1,
            TInit=300.,
            pInit=20e5,
            linerMaterial='Aluminium6061',
            linerThickness=0.004,
            compositeMaterial='CarbonFiberComposite',
            compositeThickness=0.0105,
            hConvExternal=100.,
            hConvInternalWaiting=10.,
            hConvInternalExtraction=20.,
            hConvInternalFueling=100.,
        ),
    )

    # Run simulation or load old results
    if (simulate):
        tankModel.prepareSimulation()
        tankModel.run(tFinal=2000., tPrint=1.0)
    else:
        tankModel.loadResult(simIndex=1)

    # Export to csv file
    #tankModel.resultStorage.exportToCsv(fileName = csvFileName)

    # Plot results
    tankModel.plotHDFResults()

    print "=== END: testTankModel ==="
예제 #10
0
 def createFluidState(self):
     return CP.FluidState(self.fluidName)