-
Notifications
You must be signed in to change notification settings - Fork 240
/
Driver_template
95 lines (76 loc) · 2.57 KB
/
Driver_template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from openmdao.core.driver import Driver
class {class_name}(Driver):
"""
Describe driver class here...
"""
def __init__(self, **kwargs):
"""
Initialize the {class_name} driver.
Parameters
----------
**kwargs : dict of keyword arguments
Keyword arguments that will be mapped into the Driver options.
"""
super().__init__(**kwargs)
# Specify what we support and what we don't
self.supports['integer_design_vars'] = False
self.supports['inequality_constraints'] = False
self.supports['equality_constraints'] = False
self.supports['multiple_objectives'] = False
self.supports['two_sided_constraints'] = False
self.supports['linear_constraints'] = False
self.supports['simultaneous_derivatives'] = False
self.supports['active_set'] = False
# other initialization here...
def _declare_options(self):
"""
Declare options before kwargs are processed in the init method.
"""
# for example ...
# self.options.declare('print_results', types=bool, default=True,
# desc='Print opt results if True')
pass
def _setup_driver(self, problem):
"""
Prepare the driver for execution.
This is the final thing to run during setup.
Parameters
----------
problem : <Problem>
Pointer to the containing problem.
"""
super()._setup_driver(problem)
# perform setup actions here...
def _setup_comm(self, comm):
"""
Perform any driver-specific setup of MPI communicators for the model.
Parameters
----------
comm : MPI.Comm or <FakeComm> or None
The communicator for the Problem.
Returns
-------
MPI.Comm or <FakeComm> or None
The communicator to be used by the model.
"""
# if your driver splits the comm in some way, do it here, else
return comm
def _get_name(self):
"""
Get name of current Driver. Typically class name or some abbreviated form of class name.
Returns
-------
str
Name of current Driver.
"""
return {class_name}
def run(self):
"""
Execute the driver.
Returns
-------
boolean
Failure flag; True if failed to converge, False is successful.
"""
# perform optimization (or whatever this driver does) here...
return False # success