当前位置: 首页>>代码示例>>Python>>正文


Python FileParser.transfer_keyvar方法代码示例

本文整理汇总了Python中openmdao.util.filewrap.FileParser.transfer_keyvar方法的典型用法代码示例。如果您正苦于以下问题:Python FileParser.transfer_keyvar方法的具体用法?Python FileParser.transfer_keyvar怎么用?Python FileParser.transfer_keyvar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openmdao.util.filewrap.FileParser的用法示例。


在下文中一共展示了FileParser.transfer_keyvar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_output_parse_keyvar

# 需要导入模块: from openmdao.util.filewrap import FileParser [as 别名]
# 或者: from openmdao.util.filewrap.FileParser import transfer_keyvar [as 别名]
    def test_output_parse_keyvar(self):

        data = "Anchor\n" + \
               " Key1 1 2 3.7 Test 1e65\n" + \
               " Key1 3 4 3.2 ibg 0.0003\n" + \
               " Key1 5 6 6.7 Tst xxx\n"

        outfile = open(self.filename, 'w')
        outfile.write(data)
        outfile.close()

        gen = FileParser()
        gen.set_file(self.filename)
        gen.set_delimiters(' ')

        gen.mark_anchor('Anchor')
        val = gen.transfer_keyvar('Key1', 3)
        self.assertEqual(val, 3.7)
        val = gen.transfer_keyvar('Key1', 4, -2)
        self.assertEqual(val, 'ibg')
        val = gen.transfer_keyvar('Key1', 4, -2, -1)
        self.assertEqual(val, 'Test')

        try:
            gen.transfer_keyvar('Key1', 4, 0)
        except ValueError, err:
            msg = "The value for occurrence must be a nonzero integer"
            self.assertEqual(str(err), msg)
开发者ID:ChanChiChoi,项目名称:OpenMDAO-Framework,代码行数:30,代码来源:test_filewrap.py

示例2: parse_output

# 需要导入模块: from openmdao.util.filewrap import FileParser [as 别名]
# 或者: from openmdao.util.filewrap.FileParser import transfer_keyvar [as 别名]
 def parse_output(self):
     """Parses the PCYL output file and extracts data."""
     
     infile = FileParser()
     infile.set_file(self.stdout)
     
     self.wwingt = infile.transfer_keyvar("Total Wing Structural Weight", 1)
     self.wfuselaget = infile.transfer_keyvar("Fuselage Total Structural Weight", 1)
开发者ID:JustinSGray,项目名称:OpenMDAO-Framework,代码行数:10,代码来源:pdcyl_comp.py

示例3: parse_output

# 需要导入模块: from openmdao.util.filewrap import FileParser [as 别名]
# 或者: from openmdao.util.filewrap.FileParser import transfer_keyvar [as 别名]
    def parse_output(self,FabriOrSub):
        """Parses the DREA output file and extracts data."""
        
        infile = FileParser()
        infile.set_file('ejectd.out')
        infile.mark_anchor('EJECTOR SOLUTION')

        if FabriOrSub == 'Fabri':
            self.GrossThrust = infile.transfer_keyvar("SUPERSONIC GROSS THRUST (OVERALL)=", 1)
            self.ExitMassFlow = infile.transfer_keyvar("SUPERSONIC EXIT MASS FLOW RATE=", 1)
            self.ExitVelocity = infile.transfer_keyvar("SUP VELOCITY=", 1)
            self.ExitMach = infile.transfer_keyvar("SUPERSONIC MACH=", 1)
            self.ExitStaticTemp = infile.transfer_keyvar("SUP TEMPERATURE=", 1)
            self.ExitTotalTemp = infile.transfer_keyvar("SUPERSONIC TOTAL TEMPERATURE=", 1)
            self.CFG = infile.transfer_keyvar("SUPERSONIC CFG=", 1)
        if FabriOrSub == 'Subsonic':
            self.GrossThrust = infile.transfer_keyvar("SUBSONIC GROSS THRUST (OVERALL)=", 1)
            self.ExitMassFlow = infile.transfer_keyvar("SUBSONIC EXIT MASS FLOW RATE=", 1)
            self.ExitVelocity = infile.transfer_keyvar("SUB VELOCITY=", 1)
            self.ExitMach = infile.transfer_keyvar("SUBSONIC MACH=", 1)
            self.ExitStaticTemp = infile.transfer_keyvar("SUB TEMPERATURE=", 1)
            self.ExitTotalTemp = infile.transfer_keyvar("SUBSONIC TOTAL TEMPERATURE=", 1)
            self.CFG = infile.transfer_keyvar("SUBSONIC CFG=", 1)
            
        self.flow_out.pri.Vel = infile.transfer_keyvar("U1D=",1)
        self.flow_out.sec.Vel = infile.transfer_keyvar("U2D=",1)
        self.flow_out.pri.W = infile.transfer_keyvar("RMD1D=",1)*2*32.17405 #Doubled since half of the area is used
        self.flow_out.sec.W = infile.transfer_keyvar("RMD2D=",1)*2*32.17405 #Doubled since half of the area is used
        self.PumpingRatio = infile.transfer_keyvar("PUMPING RATIO W2/W1=",1)
        self.flow_out.sec.Mach = infile.transfer_keyvar("RM2=", 1)
        self.DegreeOfMixing = infile.transfer_keyvar("DEGREE OF MIXING IN PRESSURE CONSTRAINT",0,rowoffset=1)
        self.NPR = infile.transfer_keyvar("NPR=",1)
开发者ID:OpenMDAO-Plugins,项目名称:drea_wrapper,代码行数:34,代码来源:DREA.py

示例4: load_model

# 需要导入模块: from openmdao.util.filewrap import FileParser [as 别名]
# 或者: from openmdao.util.filewrap.FileParser import transfer_keyvar [as 别名]
 def load_model(self, filename="test.input"):
     """Loads an existing HSRNOISE input file."""
    
     infile = FileParser()
     infile.set_file(filename)
     
     infile.mark_anchor('$GEOM')
     self.HMIC = float(infile.transfer_keyvar("HMIC", 2))
     self.SL = float(infile.transfer_keyvar("SL", 2))
     infile.mark_anchor('$FLIPATH')
     self.ALTEVO = float(infile.transfer_keyvar("ALTEVO", 2))
         
     self.HMIC = int(infile.transfer_keyvar("JETMETHOD", 2))
     
     infile.mark_anchor('$JET1IN')
     self.geo_in.Apri = float(infile.transfer_keyvar("APRI", 2))
     self.geo_in.Asec = float(infile.transfer_keyvar("ASEC", 2))
     self.ATHP = float(infile.transfer_keyvar("ATHP", 2))
     self.DELMIX = float(infile.transfer_keyvar("DELMIX", 2))
     self.DELPE = float(infile.transfer_keyvar("DELPE", 2))
     self.DELPI = float(infile.transfer_keyvar("DELPI", 2))
     self.geo_in.ChuteAngles = float(infile.transfer_keyvar("DIVANG", 2))
     self.geo_in.AR = float(infile.transfer_keyvar("EJASP", 2))
     self.EJD = float(infile.transfer_keyvar("EJD", 2))
     self.geo_in.length = float(infile.transfer_keyvar("EJL", 2))
     self.EJLIN = float(infile.transfer_keyvar("EJLIN", 2))
     self.FLIN = float(infile.transfer_keyvar("FLIN", 2))
     self.geo_in.LhMh = float(infile.transfer_keyvar("PEN", 2))
     self.PLUGD = float(infile.transfer_keyvar("PLUGD", 2))
     self.PSI0 = float(infile.transfer_keyvar("PSI0", 2))
     self.SPOKE = float(infile.transfer_keyvar("SPOKE", 2))
     self.flow_in.pri.Tt = float(infile.transfer_keyvar("TPRI", 2))
     self.flow_in.sec.Tt = float(infile.transfer_keyvar("TSEC", 2))
     self.flow_in.pri.Vel = float(infile.transfer_keyvar("VPRI", 2))
     self.flow_in.sec.Vel = float(infile.transfer_keyvar("VSEC", 2))
     self.flow_in.pri.W = float(infile.transfer_keyvar("WPRI", 2))
     self.flow_in.sec.W = float(infile.transfer_keyvar("WSEC", 2))
     self.geo_in.AeAt = float(infile.transfer_keyvar("XMAR", 2))
     
     infile.mark_anchor('$JET2IN')
     self.APT = float(infile.transfer_keyvar("APT", 2))
     self.AS = float(infile.transfer_keyvar("AS", 2))
     self.CER = float(infile.transfer_keyvar("CER", 2))
     self.DHP = float(infile.transfer_keyvar("DHP", 2))
     self.DL = float(infile.transfer_keyvar("DL", 2))
     self.DM = float(infile.transfer_keyvar("DM", 2))
     self.FPK = float(infile.transfer_keyvar("FPK", 2))
     self.GAMMAC = float(infile.transfer_keyvar("GAMMAC", 2))
     self.HEX = float(infile.transfer_keyvar("HEX", 2))
     self.IEX = int(infile.transfer_keyvar("IEX", 2))
     self.ISUPPR = int(infile.transfer_keyvar("ISUPPR", 2))
     self.LBE = float(infile.transfer_keyvar("LBE", 2))
     self.LBS = float(infile.transfer_keyvar("LBS", 2))
     self.LE = float(infile.transfer_keyvar("LE", 2))
     self.LPE = float(infile.transfer_keyvar("LPE", 2))
     self.LPS = float(infile.transfer_keyvar("LPS", 2))
     self.MMC = float(infile.transfer_keyvar("MMC", 2))
     self.MPD = float(infile.transfer_keyvar("MPD", 2))
     self.PC = float(infile.transfer_keyvar("PC", 2))
     self.PEN = float(infile.transfer_keyvar("PEN", 2))
     self.SAR = float(infile.transfer_keyvar("SAR", 2))
     self.SUPPK = float(infile.transfer_keyvar("SUPPK", 2))
     self.TC = float(infile.transfer_keyvar("TC", 2))
     self.TEX = float(infile.transfer_keyvar("TEX", 2))
     self.VEX = float(infile.transfer_keyvar("VEX", 2))
     self.WEX = float(infile.transfer_keyvar("WEX", 2))
     self.WSWP = float(infile.transfer_keyvar("WSWP", 2))
     
     # Set derived values down in the variable trees.
     self.LinFrac = self.EJLIN/self.geo_in.length
     self.phi = degrees(arcsin(0.1*self.SL))
     self.geo_in.Num_Lobes = self.SPOKE
     self.geo_in.Aexit = pi*(0.5*self.EJD)**2
     
     # Where does gamma come from?
     self.flow_in.gamma = 1.4
     
     # use fixed-point iteration to solve for mach 
     mach = 1.0
     gam = self.flow_in.gamma
     apri = self.geo_in.Apri
     athp = self.ATHP
     
     term1 = ((gam+1)/2)**((-gam-1)/(2*(gam-1)))
     exp1 = ((gam+1)/(2*(gam-1)))
     
     for i in range(135):
         mach = athp/(apri/(term1*(1+(gam-1)/2*mach**2)**exp1))
         
     
     self.flow_in.pri.Mach = mach
开发者ID:OpenMDAO-Plugins,项目名称:hsrnoise_wrapper,代码行数:93,代码来源:hsrnoise.py


注:本文中的openmdao.util.filewrap.FileParser.transfer_keyvar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。