This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openmdao.api as om | |
import numpy as np | |
from openmdao.utils.array_utils import evenly_distrib_idxs | |
import mpi4py.MPI as MPI | |
N = 3 | |
class DistribComp(om.ExplicitComponent): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import openmdao.api as om | |
import time | |
class DelayComp(om.ExplicitComponent): | |
def initialize(self): | |
self.options.declare('time', default=3.0) | |
self.options.declare('size', default=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openmdao.api as om | |
import numpy as np | |
import time | |
from mpi4py import MPI | |
class SumComp(om.ExplicitComponent): | |
def __init__(self, size): | |
super(SumComp, self).__init__() | |
self.size = size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import openmdao.api as om | |
import time | |
from mpi4py import MPI | |
import unittest | |
from openmdao.utils.assert_utils import assert_near_equal | |
from openmdao.core.total_jac import _TotalJacInfo | |
import random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openmdao.api as om | |
import numpy as np | |
import mpi4py.MPI as MPI | |
# RUN THIS WITH 2 or more PROCS UNDER MPI | |
SRC_INDICES = [1,2] | |
FORCE_PETSCTRANSFER = True | |
# this should raise an error when COMP_DISTRIBUTED is false | |
# this should work when COMP_DISTRIBUTED is true | |
COMP_DISTRIBUTED = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openmdao.api as om | |
import numpy as np | |
# OpenConcept PhaseGroup will be used to hold analysis phases with time integration | |
# =============== These will go in OpenConcept Core ===============# | |
def find_duration_variables_in_phase(system, abs_namespace, listofvars): | |
durationvar = system._problem_meta['duration_var'] | |
# check if we are a group or not | |
if isinstance(system, om.Group): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openmdao.api as om | |
import numpy as np | |
class SellarDis1(om.ExplicitComponent): | |
""" | |
Component containing Discipline 1 -- no derivatives version. | |
""" | |
def setup(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openmdao.api as om | |
import numpy as np | |
from openconcept.utilities.math.integrals import NewIntegrator | |
import warnings | |
# OpenConcept PhaseGroup will be used to hold analysis phases with time integration | |
# =============== These will go in OpenConcept Core ===============# | |
def find_integrators_in_model(system, abs_namespace, timevars, states): | |
durationvar = system._problem_meta['oc_time_var'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openmdao.api as om | |
import numpy as np | |
class WorkingGroup(om.Group): | |
def setup(self): | |
iv = self.add_subsystem('iv', om.IndepVarComp('x2', val=3.0*np.ones((2,)))) | |
iv.add_output('x', 2.0) | |
self.add_subsystem('ec1', om.ExecComp('y=x', x={'value':1.0})) | |
self.add_subsystem('ec2', om.ExecComp('y2=x2', y2={'value':np.ones((2,))}, x2={'value':np.ones((2,))})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib import pyplot as plt | |
import openmdao.api as om | |
def rotations(theta): | |
# define rotation matrices per http://web.mit.edu/course/3/3.11/www/modules/laminates.pdf | |
s = np.sin(theta) | |
c = np.cos(theta) | |
# stress in fiber axis = A * stress in xy axis |