|
12 | 12 |
|
13 | 13 | exago_ignore = -1000000
|
14 | 14 |
|
15 |
| - |
16 |
| -@pytest.mark.nocomm |
17 |
| -@pytest.mark.MPI |
| 15 | +''' cannot run just creating tcopflow object bc opflow sub objects |
| 16 | + won't be allocated (done in TCOPFLOWSetUp) so destructor seg faults |
18 | 17 | def test_creating_tcopflow():
|
19 |
| - '''Testing creation of tcopflow object''' |
20 | 18 | tcopf = exago.TCOPFLOW()
|
| 19 | +''' |
| 20 | +def run_tcopflow(solver): |
| 21 | + tcopf = exago.TCOPFLOW() |
| 22 | + path = exago.prefix() |
| 23 | + |
| 24 | + tcopf.set_tolerance(1.0E-03) |
| 25 | + tcopf.set_network_data(os.path.join( |
| 26 | + path, 'share', 'exago', 'datafiles', 'case9', 'case9mod_gen3_wind.m')) |
| 27 | + tcopf.set_solver(solver) |
| 28 | + #set_time_step_and_duration |
| 29 | + #set_load_profiles |
| 30 | + #set_wind_gen_profiles |
| 31 | + |
| 32 | + tcopf.setup() |
| 33 | + tcopf.solve() |
| 34 | + |
| 35 | + assert tcopf.get_convergence_status() |
21 | 36 |
|
| 37 | + obj = tcopf.get_objective() |
| 38 | + assert isinstance(obj, float) |
22 | 39 |
|
| 40 | + n = tcopf.get_num_iterations() |
| 41 | + assert isinstance(n, int) |
| 42 | + |
| 43 | + #get_solution |
| 44 | + #print_solution |
| 45 | + |
| 46 | + oname = os.path.join(tempfile.gettempdir(), "tcopflow_test_solution.csv") |
| 47 | + tcopf.save_solution(0, exago.OutputFormat.CSV, oname) |
| 48 | + assert os.path.exists(oname) |
| 49 | + os.unlink(oname) |
| 50 | + |
| 51 | + oname = os.path.join(tempfile.gettempdir(), "tcopflow_test_solution.m") |
| 52 | + tcopf.save_solution(0, exago.OutputFormat.MATPOWER, oname) |
| 53 | + assert os.path.exists(oname) |
| 54 | + os.unlink(oname) |
| 55 | + |
| 56 | + oname = os.path.join(tempfile.gettempdir(), "tcopflow_test_solution_dir") |
| 57 | + tcopf.save_solution_all(exago.OutputFormat.MATPOWER, oname) |
| 58 | + assert os.path.exists(oname) |
| 59 | + shutil.rmtree(oname) |
| 60 | + |
| 61 | + |
| 62 | +# From sopflow_multicontingency.toml: |
| 63 | +# description = |
| 64 | +# 'datafiles/case9/case9mod_gen3_wind.m IPOPT 3scen contingencies SOPFLOW' |
23 | 65 | @pytest.mark.nocomm
|
24 | 66 | @pytest.mark.MPI
|
25 |
| -def test_get_prefix(): |
26 |
| - '''Test retrieving datafile path''' |
27 |
| - path = exago.prefix() |
28 |
| - assert isinstance(path, str) |
| 67 | +def test_tcopflow_1(): |
| 68 | + run_tcopflow('IPOPT') |
| 69 | + |
29 | 70 |
|
30 | 71 |
|
31 | 72 | ''' example
|
|
0 commit comments