@@ -30,20 +30,62 @@ void init_exago_tcopflow(pybind11::module &m) {
30
30
31
31
pybind11::class_<TCOPFLOW_wrapper>(m, " TCOPFLOW" )
32
32
.def (pybind11::init ())
33
- .def (" set_tolerance " ,
34
- [](TCOPFLOW_wrapper &w, double tol ) {
33
+ .def (" set_network_data " ,
34
+ [](TCOPFLOW_wrapper &w, std::string filename ) {
35
35
PetscErrorCode ierr;
36
- ierr = TCOPFLOWSetTolerance (w.tcopf , tol );
36
+ ierr = TCOPFLOWSetNetworkData (w.tcopf , filename. c_str () );
37
37
ExaGOCheckError (ierr);
38
+ .def (" set_solver" ,
39
+ [](TCOPFLOW_wrapper &w, std::string solver) {
40
+ PetscErrorCode ierr;
41
+ ierr = TCOPFLOWSetSolver (w.tcopf , solver.c_str ());
42
+ ExaGO
43
+ });
44
+
45
+ .def (" setup" ,
46
+ [](TCOPFLOW_wrapper &w) {
47
+ PetscErrorCode ierr;
48
+ ierr = TCOPFLOWSetUp (w.tcopf );
49
+ ExaGOCheckError (ierr);
50
+ });
51
+
52
+ .def (" get_convergence_status" ,
53
+ [](TCOPFLOW_wrapper &w) -> bool {
54
+ PetscErrorCode ierr;
55
+ PetscBool flag;
56
+ ierr = TCOPFLOWGetConvergenceStatus (w.tcopf , &flag);
57
+ ExaGOCheckError (ierr);
58
+ return flag;
38
59
})
39
- .def (" get_tolerance " ,
60
+ .def (" get_objective " ,
40
61
[](TCOPFLOW_wrapper &w) -> double {
41
62
PetscErrorCode ierr;
42
- PetscReal tol;
43
- ierr = TCOPFLOWGetTolerance (w.tcopf , &tol);
63
+ double obj;
64
+ ierr = TCOPFLOWGetObjective (w.tcopf , &obj);
65
+ ExaGOCheckError (ierr);
66
+ return obj;
67
+ })
68
+ .def (" get_num_iterations" ,
69
+ [](TCCOPFLOW_wrapper &w) -> int {
70
+ PetscErrorCode ierr;
71
+ PetscInt n;
72
+ ierr = TCOPFLOWGetNumIterations (w.tcopf , &n);
73
+ ExaGOCheckError (ierr);
74
+ return n;
75
+ })
76
+ .def (" save_solution" ,
77
+ [](TCOPFLOW_wrapper &w, OutputFormat fmt, std::string outfile) {
78
+ PetscErrorCode ierr;
79
+ ierr = TCOPFLOWSaveSolution (w.tcopf , fmt, outfile.c_str ());
44
80
ExaGOCheckError (ierr);
45
- return tol;
46
81
});
82
+ .def (" save_solution_all" ,
83
+ [](TCCOPFLOW_wrapper &w, OutputFormat fmt, std::string outdir) {
84
+ PetscErrorCode ierr;
85
+ ierr = TCCOPFLOWSaveSolutionAll (w.tcopf , fmt, outdir.c_str ());
86
+ ExaGOCheckError (ierr);
87
+ });
88
+
47
89
}
48
90
49
91
0 commit comments