moment_coefficient.py
- class openaerostruct.functionals.moment_coefficient.MomentCoefficient(**kwargs)[source]
Bases:
ExplicitComponent
Compute the coefficient of moment (CM) for the entire aircraft.
- Parameters:
- b_pts[nx-1, ny, 3]numpy array
Bound points for the horseshoe vortices, found along the 1/4 chord.
- widths[ny-1]numpy array
The spanwise widths of each individual panel.
- chords[ny]numpy array
The chordwise length of the entire airfoil following the camber line.
- S_reffloat
The reference area of the lifting surface.
- sec_forces[nx-1, ny-1, 3]numpy array
Contains the sectional forces acting on each panel. Stored in Fortran order (only relevant with more than one chordwise panel).
- cg[3]numpy array
The x, y, z coordinates of the center of gravity for the entire aircraft.
- vfloat
Freestream air velocity in m/s.
- rhofloat
Air density in kg/m^3.
- S_ref_totalfloat
Total surface area of the aircraft based on the sum of individual surface areas.
- Returns:
- CM[3]numpy array
The coefficient of moment around the x-, y-, and z-axes at the cg point.
Store some bound methods so we can detect runtime overrides.
- abs_name_iter(iotype, local=True, cont=True, discrete=False)
Iterate over absolute variable names for this System.
By setting appropriate values for ‘cont’ and ‘discrete’, yielded variable names can be continuous only, discrete only, or both.
- Parameters:
- iotypestr
Either ‘input’ or ‘output’.
- localbool
If True, include only names of local variables. Default is True.
- contbool
If True, include names of continuous variables. Default is True.
- discretebool
If True, include names of discrete variables. Default is False.
- Yields:
- str
- add_discrete_input(name, val, desc='', tags=None)
Add a discrete input variable to the component.
- Parameters:
- namestr
Name of the variable in this component’s namespace.
- vala picklable object
The initial value of the variable being added.
- descstr
Description of the variable.
- tagsstr or list of strs
User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.
- Returns:
- dict
Metadata for added variable.
- add_discrete_output(name, val, desc='', tags=None)
Add an output variable to the component.
- Parameters:
- namestr
Name of the variable in this component’s namespace.
- vala picklable object
The initial value of the variable being added.
- descstr
Description of the variable.
- tagsstr or list of strs or set of strs
User defined tags that can be used to filter what gets listed when calling list_inputs and list_outputs.
- Returns:
- dict
Metadata for added variable.
- property checking
Return True if check_partials or check_totals is executing.
- Returns:
- bool
True if we’re running within check_partials or check_totals.
- property comm
Return the MPI communicator object for the system.
- Returns:
- MPI.Comm
MPI communicator object.
- comm_info_iter()
Yield comm size for this system and all subsystems.
- Yields:
- tuple
A tuple of the form (abs_name, comm_size).
- convert2units(name, val, units)
Convert the given value to the specified units.
- Parameters:
- namestr
Name of the variable.
- valfloat or ndarray of float
The value of the variable.
- unitsstr
The units to convert to.
- Returns:
- float or ndarray of float
The value converted to the specified units.
- convert_from_units(name, val, units)
Convert the given value from the specified units to those of the named variable.
- Parameters:
- namestr
Name of the variable.
- valfloat or ndarray of float
The value of the variable.
- unitsstr
The units to convert to.
- Returns:
- float or ndarray of float
The value converted to the specified units.
- convert_units(name, val, units_from, units_to)
Wrap the utility convert_units and give a good error message.
- Parameters:
- namestr
Name of the variable.
- valfloat or ndarray of float
The value of the variable.
- units_fromstr
The units to convert from.
- units_tostr
The units to convert to.
- Returns:
- float or ndarray of float
The value converted to the specified units.
- declare_coloring(wrt=('*',), method='fd', form=None, step=None, per_instance=True, num_full_jacs=3, tol=1e-25, orders=None, perturb_size=1e-09, min_improve_pct=5.0, show_summary=True, show_sparsity=False)
Set options for deriv coloring of a set of wrt vars matching the given pattern(s).
- Parameters:
- wrtstr or list of str
The name or names of the variables that derivatives are taken with respect to. This can contain input names, output names, or glob patterns.
- methodstr
Method used to compute derivative: “fd” for finite difference, “cs” for complex step.
- formstr
Finite difference form, can be “forward”, “central”, or “backward”. Leave undeclared to keep unchanged from previous or default value.
- stepfloat
Step size for finite difference. Leave undeclared to keep unchanged from previous or default value.
- per_instancebool
If True, a separate coloring will be generated for each instance of a given class. Otherwise, only one coloring for a given class will be generated and all instances of that class will use it.
- num_full_jacsint
Number of times to repeat partial jacobian computation when computing sparsity.
- tolfloat
Tolerance used to determine if an array entry is nonzero during sparsity determination.
- ordersint
Number of orders above and below the tolerance to check during the tolerance sweep.
- perturb_sizefloat
Size of input/output perturbation during generation of sparsity.
- min_improve_pctfloat
If coloring does not improve (decrease) the number of solves more than the given percentage, coloring will not be used.
- show_summarybool
If True, display summary information after generating coloring.
- show_sparsitybool
If True, display sparsity with coloring info after generating coloring.
- dist_size_iter(io, top_comm)
Yield names and distributed ranges of all local and remote variables in this system.
- Parameters:
- iostr
Either ‘input’ or ‘output’.
- top_commMPI.Comm or None
The top-level MPI communicator.
- Yields:
- tuple
A tuple of the form ((abs_name, rank), start, end).
- get_coloring_fname(mode)
Return the full pathname to a coloring file.
- Parameters:
- modestr
The type of coloring file desired. Must be either ‘input’ or ‘output’.
- Returns:
- pathlib.Path
Full pathname of the coloring file.
- get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None, get_remote=False, rank=None, return_rel_names=True)
Retrieve metadata for a filtered list of variables.
- Parameters:
- iotypesstr or iter of str
Will contain either ‘input’, ‘output’, or both. Defaults to both.
- metadata_keysiter of str or None
Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.
- includesstr, iter of str or None
Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.
- excludesstr, iter of str or None
Collection of glob patterns for pathnames of variables to exclude. Default is None.
- is_indep_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.
- is_design_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.
- tagsstr or iter of strs
User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.
- get_remotebool
If True, retrieve variables from other MPI processes as well.
- rankint or None
If None, and get_remote is True, retrieve values from all MPI process to all other MPI processes. Otherwise, if get_remote is True, retrieve values from all MPI processes only to the specified rank.
- return_rel_namesbool
If True, the names returned will be relative to the scope of this System. Otherwise they will be absolute names.
- Returns:
- dict
A dict of metadata keyed on name, where name is either absolute or relative based on the value of the return_rel_names arg, and metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.
- get_outputs_dir(*subdirs, mkdir=True)
Get the path under which all output files of this system are to be placed.
- Parameters:
- *subdirsstr
Subdirectories nested under the relevant problem output directory. To create {prob_output_dir}/a/b one would pass system.get_outputs_dir(‘a’, ‘b’).
- mkdirbool
If True, attempt to create this directory if it does not exist.
- Returns:
- pathlib.Path
The path of the outputs directory for the problem.
- get_promotions(inprom=None, outprom=None)
Return all promotions for the given promoted variable(s).
In other words, how and where did promotions occur to convert absolute variable names into the given promoted name(s) at the current System level.
- Parameters:
- inpromstr or None
The promoted input variable name.
- outpromstr or None
The promoted output variable name.
- Returns:
- dict
Dictionary keyed on system pathname containing input and/or output promotion lists for each System where promotions occurred to produce the given promoted variable(s).
- get_reports_dir()
Get the path to the directory where the report files should go.
If it doesn’t exist, it will be created.
- Returns:
- str
The path to the directory where reports should be written.
- get_source(name)
Return the source variable connected to the given named variable.
The name can be a promoted name or an absolute name. If the given variable is an input, the absolute name of the connected source will be returned. If the given variable itself is a source, its own absolute name will be returned.
- Parameters:
- namestr
Absolute or promoted name of the variable.
- Returns:
- str
The absolute name of the source variable.
- get_val(name, units=None, indices=None, get_remote=False, rank=None, vec_name='nonlinear', kind=None, flat=False, from_src=True)
Get an output/input/residual variable.
Function is used if you want to specify display units.
- Parameters:
- namestr
Promoted or relative variable name in the root system’s namespace.
- unitsstr, optional
Units to convert to before return.
- indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional
Indices or slice to return.
- get_remotebool or None
If True, retrieve the value even if it is on a remote process. Note that if the variable is remote on ANY process, this function must be called on EVERY process in the Problem’s MPI communicator. If False, only retrieve the value if it is on the current process, or only the part of the value that’s on the current process for a distributed variable. If None and the variable is remote or distributed, a RuntimeError will be raised.
- rankint or None
If not None, only gather the value to this rank.
- vec_namestr
Name of the vector to use. Defaults to ‘nonlinear’.
- kindstr or None
Kind of variable (‘input’, ‘output’, or ‘residual’). If None, returned value will be either an input or output.
- flatbool
If True, return the flattened version of the value.
- from_srcbool
If True, retrieve value of an input variable from its connected source.
- Returns:
- object
The value of the requested output/input variable.
- get_var_dup_info(name, io)
Return information about how the given variable is duplicated across MPI processes.
- Parameters:
- namestr
Name of the variable.
- iostr
Either ‘input’ or ‘output’.
- Returns:
- tuple
A tuple of the form (is_duplicated, num_zeros, is_distributed).
- get_var_sizes(name, io)
Return the sizes of the given variable on all procs.
- Parameters:
- namestr
Name of the variable.
- iostr
Either ‘input’ or ‘output’.
- Returns:
- ndarray
Array of sizes of the variable on all procs.
- is_explicit()
Return True if this is an explicit component.
- Returns:
- bool
True if this is an explicit component.
- list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, all_procs=False, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')
Write a list of inputs and outputs sorted by component in execution order.
- Parameters:
- valbool, optional
When True, display output values. Default is True.
- prom_namebool, optional
When True, display the promoted name of the variable. Default is True.
- residualsbool, optional
When True, display residual values. Default is False.
- residuals_tolfloat, optional
If set, limits the output of list_outputs to only variables where the norm of the resids array is greater than the given ‘residuals_tol’. Default is None.
- unitsbool, optional
When True, display units. Default is False.
- shapebool, optional
When True, display/return the shape of the value. Default is False.
- global_shapebool, optional
When True, display/return the global shape of the value. Default is False.
- boundsbool, optional
When True, display/return bounds (lower and upper). Default is False.
- scalingbool, optional
When True, display/return scaling (ref, ref0, and res_ref). Default is False.
- descbool, optional
When True, display/return description. Default is False.
- print_arraysbool, optional
When False, in the columnar display, just display norm of any ndarrays with size > 1. The norm is surrounded by vertical bars to indicate that it is a norm. When True, also display full values of the ndarray below the row. Format is affected by the values set with numpy.set_printoptions Default is False.
- tagsstr or list of strs
User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.
- print_tagsbool
When true, display tags in the columnar display.
- includesNone, str, or iter of str
Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.
- excludesNone, str, or iter of str
Collection of glob patterns for pathnames of variables to exclude. Default is None.
- is_indep_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.
- is_design_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.
- all_procsbool, optional
When True, display output on all processors. Default is False.
- list_autoivcsbool
If True, include auto_ivc outputs in the listing. Defaults to False.
- out_streamfile-like
Where to send human readable output. Default is sys.stdout. Set to None to suppress.
- print_minbool
When true, if the output value is an array, print its smallest value.
- print_maxbool
When true, if the output value is an array, print its largest value.
- return_formatstr
Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.
- Returns:
- list of (name, metadata) or dict of {name: metadata}
List or dict of output names and other optional information about those outputs.
- load_case(case)
Pull all input and output variables from a Case into this System.
Override this method if the System requires special handling when loading a case.
- Parameters:
- caseCase or dict
A Case from a CaseReader, or a dictionary with key ‘inputs’ mapped to the output of problem.model.list_inputs and key ‘outputs’ mapped to the output of prob.model.list_outputs. Both list_inputs and list_outputs should be called with prom_name=True and return_format=’dict’.
- load_model_options()
Load the relevant model options from Problem._metadata[‘model_options’].
This method examines each path filter and corresponding options in self._problem_meta[‘model_options’]. If this System’s pathname matches the given path filter, it will assume the value for each given option which it possesses.
- local_range_iter(io)
Yield names and local ranges of all local variables in this system.
- Parameters:
- iostr
Either ‘input’ or ‘output’.
- Yields:
- tuple
A tuple of the form (abs_name, start, end).
- property msginfo
Our instance pathname, if available, or our class name. For use in error messages.
- Returns:
- str
Either our instance pathname or class name.
- set_constraint_options(name, ref=UNDEFINED, ref0=UNDEFINED, equals=UNDEFINED, lower=UNDEFINED, upper=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)
Set options for constraints in the model.
Can be used to set options that were set using add_constraint.
- Parameters:
- namestr
Name of the response variable in the system, or alias if given.
- reffloat or ndarray, optional
Value of response variable that scales to 1.0 in the driver.
- ref0float or ndarray, optional
Value of response variable that scales to 0.0 in the driver.
- equalsfloat or ndarray, optional
Equality constraint value for the variable.
- lowerfloat or ndarray, optional
Lower boundary for the variable.
- upperfloat or ndarray, optional
Upper boundary for the variable.
- adderfloat or ndarray, optional
Value to add to the model value to get the scaled value for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.
- scalerfloat or ndarray, optional
Value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.
- aliasstr, optional
Alias for this response. Necessary when adding multiple constraints on different indices or slices of a single variable.
- set_design_var_options(name, lower=UNDEFINED, upper=UNDEFINED, scaler=UNDEFINED, adder=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED)
Set options for design vars in the model.
Can be used to set the options outside of setting them when calling add_design_var
- Parameters:
- namestr
Name of the variable in this system’s namespace.
- lowerfloat or ndarray, optional
Lower boundary for the input.
- upperupper or ndarray, optional
Upper boundary for the input.
- scalerfloat or ndarray, optional
Value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.
- adderfloat or ndarray, optional
Value to add to the model value to get the scaled value for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.
- reffloat or ndarray, optional
Value of design var that scales to 1.0 in the driver.
- ref0float or ndarray, optional
Value of design var that scales to 0.0 in the driver.
- set_objective_options(name, ref=UNDEFINED, ref0=UNDEFINED, adder=UNDEFINED, scaler=UNDEFINED, alias=UNDEFINED)
Set options for objectives in the model.
Can be used to set options after they have been set by add_objective.
- Parameters:
- namestr
Name of the response variable in the system, or alias if given.
- reffloat or ndarray, optional
Value of response variable that scales to 1.0 in the driver.
- ref0float or ndarray, optional
Value of response variable that scales to 0.0 in the driver.
- adderfloat or ndarray, optional
Value to add to the model value to get the scaled value for the driver. adder is first in precedence. adder and scaler are an alterantive to using ref and ref0.
- scalerfloat or ndarray, optional
Value to multiply the model value to get the scaled value for the driver. scaler is second in precedence. adder and scaler are an alterantive to using ref and ref0.
- aliasstr
Alias for this response. Used to disambiguate variable names when adding multiple objectives on different indices or slices of a single variable. Deprecated.
- set_output_solver_options(name, lower=UNDEFINED, upper=UNDEFINED, ref=UNDEFINED, ref0=UNDEFINED, res_ref=UNDEFINED)
Set solver output options.
Allows the user to set output solver options after the output has been defined and metadata set using the add_ouput method.
- Parameters:
- namestr
Name of the variable in this system’s namespace.
- lowerfloat or list or tuple or ndarray or None
Lower bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no lower bound. Default is None.
- upperfloat or list or tuple or ndarray or None
Upper bound(s) in user-defined units. It can be (1) a float, (2) an array_like consistent with the shape arg (if given), or (3) an array_like matching the shape of val, if val is array_like. A value of None means this output has no upper bound. Default is None.
- reffloat
Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 1. Default is 1.
- ref0float
Scaling parameter. The value in the user-defined units of this output variable when the scaled value is 0. Default is 0.
- res_reffloat
Scaling parameter. The value in the user-defined res_units of this output’s residual when the scaled value is 1. Default is None, which means residual scaling matches output scaling.
- set_solver_print(level=2, depth=1e+99, type_='all')
Control printing for solvers and subsolvers in the model.
- Parameters:
- levelint
Iprint level. Set to 2 to print residuals each iteration; set to 1 to print just the iteration totals; set to 0 to disable all printing except for failures, and set to -1 to disable all printing including failures.
- depthint
How deep to recurse. For example, you can set this to 0 if you only want to print the top level linear and nonlinear solver messages. Default prints everything.
- type_str
Type of solver to set: ‘LN’ for linear, ‘NL’ for nonlinear, or ‘all’ for all.
- set_val(name, val, units=None, indices=None)
Set an input or output variable.
- Parameters:
- namestr
Promoted or relative variable name in the system’s namespace.
- valobject
Value to assign to this variable.
- unitsstr, optional
Units of the value.
- indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional
Indices or slice to set.
- setup_partials()
Declare partials.
This is meant to be overridden by component classes. All partials should be declared here since this is called after all size/shape information is known for all variables.
- property under_approx
Return True if under complex step or finite difference.
- Returns:
- bool
True if under CS or FD.
- use_fixed_coloring(coloring=<object object>, recurse=True)
Use a precomputed coloring for this System.
- Parameters:
- coloringstr
A coloring filename. If no arg is passed, filename will be determined automatically.
- recursebool
If True, set fixed coloring in all subsystems that declare a coloring. Ignored if a specific coloring is passed in.