Skip to content

Instantly share code, notes, and snippets.

@bbrelje
bbrelje / bootstrap3-load-spinner.css
Last active December 20, 2019 14:12
Script for rendering Tecplot structured CFD surface data (in .dat point format) using Plotly
.glyphicon-refresh-animate {
-animation: spin .7s infinite linear;
-webkit-animation: spin2 .7s infinite linear;
}
@-webkit-keyframes spin2 {
from { -webkit-transform: rotate(0deg);}
to { -webkit-transform: rotate(360deg);}
}
@bbrelje
bbrelje / monte_carlo.py
Created January 3, 2020 17:20
Plots for computing optimal strategy in winner-take-all games with many opponents
from __future__ import division
from matplotlib import pyplot as plt
import numpy as np
sigma_mine = 2.0
sigma_they = 1.0
mean_mine = 0.3
mean_they = 0.0
N_other_players = 4
FROM tacc/tacc-centos7
RUN yum -y install wget && docker-clean
# install omnipath drivers
RUN yum -y install \
libibverbs-devel \
numactl-devel \
libibmad-devel \
libibumad-devel \
import openmdao.api as om
import numpy as np
from openmdao.utils.array_utils import evenly_distrib_idxs
N = 3
class DistribComp(om.ExplicitComponent):
def initialize(self):
import openmdao.api as om
prob = om.Problem()
model = prob.model
model.add_subsystem('p1', om.IndepVarComp('x', 1.0))
model.add_subsystem('p2', om.IndepVarComp('x', 1.0))
parallel = model.add_subsystem('parallel', om.ParallelGroup())
parallel.add_subsystem('c1', om.ExecComp(['y=-2.0*x']))
@bbrelje
bbrelje / distrib_jacobian.py
Last active April 19, 2020 11:13
Defining distributed partials element-by-element doesn't work
import openmdao.api as om
import numpy as np
from openmdao.utils.array_utils import evenly_distrib_idxs
N = 3
class DistribCompNoWork(om.ExplicitComponent):
def initialize(self):
import openmdao.api as om
import mpi4py.MPI as MPI
class TestComp(om.ExplicitComponent):
def initialize(self):
self.options['distributed'] = False
def setup(self):
self.add_input('x', shape=1)
@bbrelje
bbrelje / illegal_remote_connection.py
Last active April 19, 2020 19:12
Local transfer with out of bounds src_index
import openmdao.api as om
import mpi4py.MPI as MPI
SRC_INDICES = 1
class TestComp(om.ExplicitComponent):
def initialize(self):
self.options['distributed'] = False
@bbrelje
bbrelje / src_indices_nondist_comp.py
Created April 19, 2020 20:23
Adding a distributed component in the group forces the correct behavior
import openmdao.api as om
import numpy as np
import mpi4py.MPI as MPI
SRC_INDICES = [1,2]
FORCE_PETSCTRANSFER = False
class TestCompDist(om.ExplicitComponent):
def initialize(self):
@bbrelje
bbrelje / src_indices_oob.py
Created April 19, 2020 21:58
out of bounds src_indices not caught when 1D list of indices used
import openmdao.api as om
import numpy as np
import mpi4py.MPI as MPI
# The system will catch that 21 is out of bounds if specified as a list of tuples
# SRC_INDICES = [(1,),(21,)]
# The system will catch that 21 is out of bounds if it is first in the flat list
# It interprets this the same way as a list of 1D tuples
# SRC_INDICES = [21, 1]
# The system will NOT catch that 21 is out of bounds if it is not first in the flat list