Skip to content

Instantly share code, notes, and snippets.

View Kenneth-T-Moore's full-sized avatar

Kenneth Moore Kenneth-T-Moore

View GitHub Profile
import numpy as np
import openmdao.api as om
from openmdao.utils.assert_utils import assert_near_equal
import dymos as dm
from dymos.examples.brachistochrone.brachistochrone_ode import BrachistochroneODE
class ParamComp(om.ExplicitComponent):
@Kenneth-T-Moore
Kenneth-T-Moore / lincon_bug.py
Created April 21, 2022 14:31
Pyoptsparse linear constraint bug.
"""
Equivalent OpenMDAO example.
import numpy as np
import openmdao.api as om
prob = om.Problem()
model = prob.model
model.add_subsystem('comp', om.ExecComp(['y=2.0*x + 100', 'y2=3.0*x', 'obj=sum(-3.0*x**2)']))
@Kenneth-T-Moore
Kenneth-T-Moore / gist:510f3be4cad0f1a7858b574d9eb05a9a
Created January 6, 2022 20:00
CS across nested problem with derivs.
import numpy as np
import openmdao.api as om
from openmdao.test_suite.components.paraboloid import Paraboloid
class SubProblem(om.ExplicitComponent):
def setup(self):
self.add_input('x', val=0.0)
import unittest
import numpy as np
import openmdao.api as om
from openmdao.utils.assert_utils import assert_near_equal, assert_check_partials
class CrossSectionProperties(om.ExplicitComponent):
""" Calculates the cross-section area and area moments of inertia. """
import numpy as np
import openmdao.api as om
from openmdao.components.interp_util.interp_semi import InterpNDSemi
grid = np.array([
[1.0, 5.0, 8.0],
[1.0, 5.0, 9.0],
[1.0, 5.0, 10.0],
[1.0, 5.0, 20.0],
import numpy as np
import openmdao.api as om
from openmdao.utils.array_utils import evenly_distrib_idxs
from openmdao.utils.mpi import MPI
class Distrib_Derivs(om.ExplicitComponent):
"""Simplest example that combines distributed and serial inputs and outputs."""
import numpy as np
import openmdao.api as om
from openmdao.utils.array_utils import evenly_distrib_idxs
from openmdao.utils.mpi import MPI
class Distrib_Derivs(om.ExplicitComponent):
"""Simplest example that combines distributed and serial inputs and outputs."""
@Kenneth-T-Moore
Kenneth-T-Moore / gist:02e1004cd9aaf0f6d5b05465c955fcc8
Created January 2, 2021 19:02
VGMDB check artist draft vs. legacy links
"""
Compares a draft to the original link and finds issues.
"""
from __future__ import print_function
from collections import OrderedDict
import re
import urllib
ALBUMID = 46185
@Kenneth-T-Moore
Kenneth-T-Moore / gist:a4df46c7e5491bf6e1b5ab8d9e4c2006
Created November 13, 2020 22:26
Example: complex step to compute derivs around euler integration of openmdao problem.
import numpy as np
from scipy.optimize import minimize
import openmdao.api as om
class DynamicPressureComp(om.ExplicitComponent):
def setup(self):
self.add_input(name='rho', val=1.0, units='kg/m**3',
@Kenneth-T-Moore
Kenneth-T-Moore / gist:1b420c28c7561f35079b8955fcbe60f4
Created August 21, 2020 19:37
Problem with src_indices dissapearing from _var_abs2meta.
import numpy as np
import openmdao.api as om
class RHS(om.Group):
def initialize(self):
self.options.declare('size', 1)