Propagate the solver log file name to the solver (#247)
* Propagate the solver log file name to the solver Previously, the PyPSA network solving functions were not told about the solver logfile specified in the Snakemake file. * Pass solver_logfile on as kwargs The `solve_network` function passes any additional arguments on to the pypsa `network_lopf` and `ilopf` functions. Now we also pass `solver_logfile` on as part of kwargs.
This commit is contained in:
parent
11af828c39
commit
e0215bc5a9
@ -241,7 +241,7 @@ def extra_functionality(n, snapshots):
|
||||
add_battery_constraints(n)
|
||||
|
||||
|
||||
def solve_network(n, config, solver_log=None, opts='', **kwargs):
|
||||
def solve_network(n, config, opts='', **kwargs):
|
||||
solver_options = config['solving']['solver'].copy()
|
||||
solver_name = solver_options.pop('name')
|
||||
cf_solving = config['solving']['options']
|
||||
@ -282,8 +282,9 @@ if __name__ == "__main__":
|
||||
with memory_logger(filename=fn, interval=30.) as mem:
|
||||
n = pypsa.Network(snakemake.input[0])
|
||||
n = prepare_network(n, solve_opts)
|
||||
n = solve_network(n, config=snakemake.config, solver_dir=tmpdir,
|
||||
solver_log=snakemake.log.solver, opts=opts)
|
||||
n = solve_network(n, config=snakemake.config, opts=opts,
|
||||
solver_dir=tmpdir,
|
||||
solver_logfile=snakemake.log.solver)
|
||||
n.export_to_netcdf(snakemake.output[0])
|
||||
|
||||
logger.info("Maximum memory usage: {}".format(mem.mem_usage))
|
||||
|
@ -111,8 +111,9 @@ if __name__ == "__main__":
|
||||
fn = getattr(snakemake.log, 'memory', None)
|
||||
with memory_logger(filename=fn, interval=30.) as mem:
|
||||
n = prepare_network(n, solve_opts=snakemake.config['solving']['options'])
|
||||
n = solve_network(n, config, solver_dir=tmpdir,
|
||||
solver_log=snakemake.log.solver, opts=opts)
|
||||
n = solve_network(n, config=config, opts=opts,
|
||||
solver_dir=tmpdir,
|
||||
solver_logfile=snakemake.log.solver)
|
||||
n.export_to_netcdf(snakemake.output[0])
|
||||
|
||||
logger.info("Maximum memory usage: {}".format(mem.mem_usage))
|
||||
|
Loading…
Reference in New Issue
Block a user