Beispiel #1
0
chartline = P.find_line('<!-- charts -->') + 1

# Build the substance menu
# Include all multiphase collection members
values = []
for name in pm.dat.data:
    if name.startswith('mp.'):
        values.append(name)

#Try to parse the user's inputs
try:
    species, p1, T1, up, uT, uE, uM, uV = pmcgi.argparse([
        ('id', str, 'mp.H2O'),
        ('p1', float, -9999),  #-9999 indicates no value was entered
        ('T1', float, -9999),
        ('up', str, 'kPa'),
        ('uT', str, 'K'),
        ('uE', str, 'kJ'),
        ('uM', str, 'kg'),
        ('uV', str, 'm3')
    ])
except:
    #An example way to get here is by entering letters into the boxes
    lu.perror(
        P,
        'Unable to parse one of the inputs. Make sure you are using valid numbers.',
        errline)

#Set up the unit selector
lu.unitsetup(P, up, uT, uE, uM, uV, unitline)

#Set up the species spinner
Beispiel #2
0
unitline = P.find_line('<!-- units -->')+4 #line where we begin the unit selector mess
resline = P.find_line('<!-- results -->')+1 #line where we begin the results
errline = P.find_line('<!-- errors -->') +1 #line where we insert errors
chartline = P.find_line('<!-- charts -->')+1 #line where we begin inserting a chart
coordsline = P.find_line('<!-- coordinates -->')+42 #line where we begin inserting chart coords


try:
    species, p1, p2, T3, mdot, syscost, FuelEff, eta_pump, eta_turb, up, uT, uE, uM, uV = pmcgi.argparse([
        ('id',str,'mp.H2O'), 
        ('p1',float,100),
        ('p2',float,8000),
        ('T3',float,450),
        ('mdot',float,5),
        ('syscost',float,1000000),
        ('FuelEff',float,0.85),
        ('eta_pump',float,0.85),
        ('eta_turb',float,0.85),
        ('up',str,'kPa'),
        ('uT',str,'C'),
        ('uE',str,'kJ'),
        ('uM',str,'kg'),
        ('uV',str,'m3') ])
except:
    #An example way to get here is by entering letters into the boxes
    lu.perror(P,'Unable to parse one of the inputs. Make sure you are using valid numbers.',errline)

#Set up the unit selector
lu.unitsetup(P,up,uT,uE,uM,uV,unitline)

#Set up the species spinner
Beispiel #3
0
import io
import sys


#Silence STDOUT warnings
#https://stackoverflow.com/questions/2828953/silence-the-stdout-of-a-function-in-python-without-trashing-sys-stdout-and-resto
@contextlib.contextmanager
def nostdout():
    save_stdout = sys.stdout
    sys.stdout = io.BytesIO()
    yield
    sys.stdout = save_stdout


species, type, plin, Tlin, vlin, hlin, slin, up, uT, uE, uM, uV = pmcgi.argparse(
    [('id'), ('type', str, 'Ts'), ('plin', str, 'false'),
     ('Tlin', str, 'false'), ('vlin', str, 'false'), ('hlin', str, 'false'),
     ('slin', str, 'false'), ('up'), ('uT'), ('uE'), ('uM'), ('uV')])

# Apply the units
pm.config['unit_temperature'] = uT
pm.config['unit_pressure'] = up
pm.config['unit_matter'] = uM
pm.config['unit_energy'] = uE
pm.config['unit_volume'] = uV

this = pm.get(species)

# Calculate the states
F = pm.get(species)

if plin == 'true':
Beispiel #4
0
import io
import sys


#Silence STDOUT warnings
#https://stackoverflow.com/questions/2828953/silence-the-stdout-of-a-function-in-python-without-trashing-sys-stdout-and-resto
@contextlib.contextmanager
def nostdout():
    save_stdout = sys.stdout
    sys.stdout = io.BytesIO()
    yield
    sys.stdout = save_stdout


species, T1, up, uT, uE, uM, uV = pmcgi.argparse([('id'), ('T1', float),
                                                  ('up'), ('uT'), ('uE'),
                                                  ('uM'), ('uV')])

# Apply the units
pm.config['unit_temperature'] = uT
pm.config['unit_pressure'] = up
pm.config['unit_matter'] = uM
pm.config['unit_energy'] = uE
pm.config['unit_volume'] = uV

this = pm.get(species)

# Calculate the states
F = pm.get(species)

# We don't know where the state will be exactly
Beispiel #5
0
#find critical lines in the
speciesline = P.find_line(
    '<!-- inputs -->') + 3  #line to insert the species spinner
inpline = P.find_line('<!-- inputs -->') + 4  #line to begin the input boxes
unitline = P.find_line(
    '<!-- units -->') + 4  #line where we begin the unit selector mess
resline = P.find_line('<!-- results -->') + 1  #line where we begin the results
errline = P.find_line('<!-- errors -->') + 1  #line where we insert errors
#coordsline = 112

#Try to parse the user's inputs
try:
    species, T1, h1, up, uT, uE, uM, uV = pmcgi.argparse([
        ('id', str, 'ig.air'), ('T1', float, -999999), ('h1', float, -999999),
        ('up', str, 'kPa'), ('uT', str, 'K'), ('uE', str, 'kJ'),
        ('uM', str, 'kg'), ('uV', str, 'm3')
    ])
except:
    #An example way to get here is by entering letters into the boxes
    lu.perror(
        P,
        'Unable to parse one of the inputs. Make sure you are using valid numbers.',
        errline)

#Set up the unit selector
lu.unitsetup(P, up, uT, uE, uM, uV, unitline)

#Set up the species spinner
lu.setspeciesselect_ig(P, species, speciesline, 56)
Beispiel #6
0
import io
import sys


#Silence STDOUT warnings
#https://stackoverflow.com/questions/2828953/silence-the-stdout-of-a-function-in-python-without-trashing-sys-stdout-and-resto
@contextlib.contextmanager
def nostdout():
    save_stdout = sys.stdout
    sys.stdout = io.BytesIO()
    yield
    sys.stdout = save_stdout


species, p1, p2, T3, eta_pump, eta_turb, up, uT, uE, uM, uV = pmcgi.argparse([
    ('id'), ('p1', float), ('p2', float), ('T3', float), ('eta_pump', float),
    ('eta_turb', float), ('up'), ('uT'), ('uE'), ('uM'), ('uV')
])

# Apply the units
pm.config['unit_temperature'] = uT
pm.config['unit_pressure'] = up
pm.config['unit_matter'] = uM
pm.config['unit_energy'] = uE
pm.config['unit_volume'] = uV

this = pm.get(species)

# Calculate the states
F = pm.get(species)

with nostdout():
Beispiel #7
0
source = '/var/www/html/live/rankine.html'
param_line = 32
units_line = 43


# Print the header so the page will display even if something goes wrong
print("Content-type: text/html")
print("")

species, p1, p2, eta12, eta23, eta34, up, uT, uE, uM, uV = pmcgi.argparse([
        ('id',str,'mp.H2O'), 
        ('p1',float,1.01325), 
        ('p2',float,10),
        ('eta12',float,1),
        ('eta23',float,1),
        ('eta34',float,1),
        ('up',str,'bar'),
        ('uT',str,'K'),
        ('uE',str,'kJ'),
        ('uM',str,'kg'),
        ('uV',str,'m3') ])

P = pmcgi.PMPage(source)

# Build the substance menu
# Include all multiphase collection members
values = []
for name in pm.dat.data:
    if name.startswith('mp.'):
        values.append(name)
        
Beispiel #8
0
resline = P.find_line('<!-- results -->') + 1
errline = P.find_line('<!-- errors -->') + 1
chartline = P.find_line('<!-- charts -->') + 2

# Build the substance menu
# Include all multiphase collection members
values = []
for name in pm.dat.data:
    if name.startswith('mp.'):
        values.append(name)

#Try to parse the user's inputs
try:
    species, plin, Tlin, vlin, hlin, slin, up, uT, uE, uM, uV = pmcgi.argparse(
        [('id', str, 'mp.H2O'), ('plines', str, 'false'),
         ('Tlines', str, 'false'), ('vlines', str, 'false'),
         ('hlines', str, 'false'), ('slines', str, 'false'),
         ('up', str, 'kPa'), ('uT', str, 'K'), ('uE', str, 'kJ'),
         ('uM', str, 'kg'), ('uV', str, 'm3')])
except:
    #should be impossible to get here
    pass

#Set up the unit selector
lu.unitsetup(P, up, uT, uE, uM, uV, unitline)

#Set up the species spinner
lu.setspeciesselect(P, species, speciesline, 56)

# Apply the units within pyromat
pm.config['unit_temperature'] = uT
pm.config['unit_pressure'] = up