Пример #1
0
INPUTS = []
FORMULA = {"w": "noise"}
           
x0 = {'w':0}
M = 2
params = {'d':np.ones(M)}

T = 0.001
fs = 1000

stochastic = True
gpu = False

if gpu:
    time, outs = run_ode( FORMULA, FUNCTION, INPUTS,  x0, params, T , fs, inputs = None, stochastic = stochastic, Tterm = 0, gpu = gpu , dtype = np.float32)
    w = outs['w']

else:
    
    outs = run_ode( FORMULA, FUNCTION, INPUTS,  x0, params, T , fs, inputs = None, stochastic = stochastic, nthreads= 1, Tterm = 0, gpu = gpu , dtype = np.float32,debug=True,seed=1234)
    
    w = np.zeros((int(T*fs),len(outs)))
    for i,o in enumerate(outs):
        w[:,i] = o['out'][1]['w'].T
    

pl.figure()
pl.plot(w)

pl.figure()
Пример #2
0
# -*- coding: utf-8 -*-

from __future__ import division

from gpuODE import run_ode
import numpy as np
import pylab as pl

        
FUNCTION = { "func" : ( ["x"], "sin(x)" )}

INPUTS = []
FORMULA = {"ph": "w",
           "w": "-g*func(ph)-e*w "}
           
x0 = {'ph':np.pi-0.01,'w':-40.}
params = {"e":[1.0],"g":[1000]}

T = 10.0
fs = 10000

outs = run_ode( FORMULA, FUNCTION, INPUTS,  x0, params, T , fs, inputs = None, stochastic = False, Tterm = 0, gpu = False, nthreads = 1 , dtype = np.float32)

ph = outs[0]['out'][1]['ph']
w = outs[0]['out'][1]['w']

t = np.arange(T*fs)/fs

pl.plot(t,ph)
pl.xlabel("Time (s)")
pl.ylabel("Phase")