コード例 #1
0
ファイル: carouselsim.py プロジェクト: drewm1980/rawesome
                print (section_list,key)
                if key is not None:
                    print 'The "%s" key in the section "%s" failed validation' % (key, ', '.join(section_list))
                elif isinstance(confdict[key],dict):
                    niceErr(confdict[key],resultsdict[key])
                else:
                    print 'The following section was missing:%s ' % key
        niceErr(conf,results)
        sys.exit(1)
    
    print "creating model"
    x0 = setC0(x0,conf)

    sim = simutils.Sim(ts=0.02, sloMoFactor=4, state0=simutils.SimState(pdOn = False, x = x0))

    dae = carouselmodel.model(conf)
    sxfun = dae.sxFun()
    sxfun.init()

    print "creating outputs function"
    fOutputs = dae.outputsFun()
    fOutputs.init()

    print "creating communicator"
    communicator = simutils.Communicator(fOutputs,dae._outputNames)

    print "creating integrator"
    f = C.IdasIntegrator(sxfun)
    f.setOption("reltol",1e-6)
    f.setOption("abstol",1e-8)
    f.setOption("t0",0)
コード例 #2
0
    ocp.setupCollocation(ocp.lookup('endTime'))
    ocp.setupSolver( solverOpts=solverOptions,
                     callback=MyCallback() )
    return ocp


if __name__=='__main__':
    context   = zmq.Context(1)
    publisher = context.socket(zmq.PUB)
    publisher.bind("tcp://*:5563")

    print "reading config..."
    conf = readConfig('config.ini','configspec.ini')
    
    print "creating model..."
    dae = carouselmodel.model(conf,extraParams=['endTime'])

    print "setting up ocp..."
    ocp = setupOcp(dae,conf,publisher,nk=50)

    xOpt = None
    for w0 in [10]:
        ocp.bound('w0',(w0,w0),force=True)
        opt = ocp.solve(xInit=xOpt)
        xup = opt['vardict']
        xOpt = opt['X_OPT']
        
        for k in range(0,ocp.nk):
            j = ocp.nicp*(ocp.deg+1)*k
            oldKites.append( kiteproto.toKiteProto(C.DMatrix(opt['x'][:,j]),C.DMatrix(opt['u'][:,j]),C.DMatrix(opt['p']), conf['kite']['zt'], conf['carousel']['rArm']) )