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 pandas as pd | |
import matplotlib.pyplot as plt | |
import matplotlib | |
import random | |
import pickle | |
import matplotlib.dates as mdates | |
from matplotlib.ticker import LinearLocator |
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 | |
class SIRvec(om.ExplicitComponent): | |
"""Basic epidemiological infection model | |
S (suceptible), I (infected), R (recovered). | |
""" | |
def initialize(self): | |
self.options.declare('num_nodes', types=int) |
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 | |
class SIRvec(om.ExplicitComponent): | |
"""Basic epidemiological infection model | |
S (suceptible), I (infected), R (recovered). | |
""" | |
def initialize(self): | |
self.options.declare('num_nodes', types=int) |
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
4 21 894 | |
419 794 987 | |
424 797 125 | |
651 305 558 | |
655 631 963 | |
2 628 436 | |
736 50 363 | |
657 707 408 | |
252 705 98 | |
532 173 878 |
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
from openmdao.core.explicitcomponent import ExplicitComponent | |
from openmdao.api import Problem, Group, ExecComp, IndepVarComp | |
from openmdao.devtools.generate_derivative import GenerateDerivative | |
class Paraboloid(ExplicitComponent): | |
""" | |
Evaluates the equation f(x,y) = (x-3)^2 + xy + (y+4)^2 - 3. | |
""" |
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 matplotlib.pyplot as plt | |
from scipy.optimize import fmin, fminbound, fmin_bfgs | |
from scipy.misc import ascent | |
import pywt | |
from scipy.stats import kurtosis | |
true_image = ascent() | |
sigma = 25.0 | |
test_image = true_image + sigma * np.random.randn(*true_image.shape) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
from petsc4py import PETSc | |
rank = PETSc.COMM_WORLD.getRank() | |
num_ranks = PETSc.COMM_WORLD.getSize() | |
x = PETSc.Vec().createMPI(4) # VecCreateMPI: Creates a parallel vector. size=4 | |
x.setValues([0,1,2,3], [10,20,30,40]) # VecSetValues: Inserts or adds values into certain locations of a vector. x[0]=10, x[1]=20, x[2]=30, x[3]=40 | |
print ('Rank',rank,'has this portion of the MPI vector:', x.getArray() ) # VecGetArray: Returns a pointer to a contiguous array that contains this processor's portion of the vector data. | |
vec_sum = x.sum() # VecSum: Computes the sum of all the components of a vector. 10+20+30+40=100 |
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 openmdao.core.component import Component | |
from pycycle.constants import R_UNIVERSAL_ENG, MIN_VALID_CONCENTRATION | |
from openmdao.core.options import OptionsDictionary | |
from openmdao.components.indep_var_comp import IndepVarComp | |
from ad import adnumber |
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
from openmdao.api import * | |
import numpy as np | |
""" | |
Test model: | |
------------- | |
Find value of state variable "x" such that the line 2*x + 1 has a specific | |
value of 'y1' | |
""" |
NewerOlder