Exemplo n.º 1
0
def batch_calc(Ys, Ps, Ts, NWs, Is, cors, verbose=False, dump_to_file=None):
    from itertools import product
    result = {}
    fmtstr="Y={}, P={}, T={}, NW={}, I={}, COR={}: {} {}"
    for conditions in product(Ys, Ps, Ts, NWs, Is, cors):
	result[conditions] = get_Delta_Y_cor_LS(*(conditions+(verbose,)))
	Y   = conditions[0]
	cor = conditions[5]
	unitless_val = result[conditions][cor]/Y_UNITS[Y]
	str_unit = Y_UNITS_STR[Y]
	print fmtstr.format(*(conditions+(unitless_val, str_unit)))

    if dump_to_file:
	try:
	    import cPickle as pickle
	except ImportError:
	    import pickle
	pickle.dump(result, open(dump_to_file, 'wb'))
Exemplo n.º 2
0
    parser.add_argument('-i', '--ion',		type=str,	default='sod',  help='Ion type, keywords: '+', '.join([k+": "+v for k,v in ION_NAMES.items()]))
    parser.add_argument('-v', '--verbose',    action='store_true',              help='Enable verbose output.')

    args = parser.parse_args()
    argd = vars(args)
    if argd['verbose']:
	fstr = "Calculating for P={}, T={}, N_W_val={}, ion={}"
	print fstr.format(*[argd[k] for k in ('pressure',
					      'temperature',
					      'nwater',
					      'ion')])

    result = get_Delta_Y_cor_LS(argd['property'],
				argd['pressure'],
				argd['temperature'],
				argd['nwater'],
				argd['ion'],
				argd['cortype'],
				argd['verbose'])

    Y = argd['property']
    if argd['cortype'] == 'all':
	loop_over = COR_TYPES
    else:
	loop_over = [argd['cortype']]
    for key in loop_over:
	fmtstr = "{0: >2}: {1} {2}"
	print fmtstr.format(key, str(result[key] / Y_UNITS[Y]),
			    Y_UNITS_STR[Y])