How to use the pysces.Scanner function in pysces

To help you get started, we’ve selected a few pysces examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PySCeS / pysces / pysces / examples / testparscanner.py View on Github external
#!/usr/bin/env python
# Testing the new parallel scanner class

import os
backupdir = os.getcwd()

import numpy as np
import pysces

tbox=pysces.PyscesUtils.TimerBox()
import time

m=pysces.model('isola2a')

ser = pysces.Scanner(m)

print("Serial execution...")
print("Start: ", tbox.normal_timer('SER'))
print(next(tbox.SER))
t1=time.time()
ser.quietRun = True
ser.addScanParameter('V4',60,100,11)
ser.addScanParameter('V1',100,160,16)
ser.addScanParameter('V2',100,130,16,slave=True)
ser.addScanParameter('V3',80,90,6)
ser.addUserOutput('J_R1', 'A', 'ecR4_X','ccJR1_R1')
#ser.addUserOutput('J_R1', 'A')
ser.Run()
print("Done: ", next(tbox.SER))
t2=time.time()
print("Duration: %.2f seconds" % (t2-t1))
github PySCeS / pysces / pysces / examples / testinvalidstate.py View on Github external
#!/usr/bin/env python
# Testing the new parallel scanner class - detection of invalid states
# --jr20101218

import os
backupdir = os.getcwd()

import numpy as np
import pysces

tbox=pysces.PyscesUtils.TimerBox()
import time

m=pysces.model('isola2a')

ser = pysces.Scanner(m)

print("Serial execution...")
print("Start: ", tbox.normal_timer('SER'))
print(next(tbox.SER))
t1=time.time()
ser.quietRun = True
ser.addScanParameter('V4',0.01,200,2000,log=True)
ser.addUserOutput('J_R1', 'A')
ser.Run()
print("Done: ", next(tbox.SER))
t2=time.time()
print("Duration: %.2f seconds" % (t2-t1))
ser.statespersecond = len(ser.ScanSpace)/(t2-t1)
print("States per second: %.1f" % ser.statespersecond)

print("\n\nParallel execution...scans per run =", 36)
github PySCeS / pysces / pysces / RateChar.py View on Github external
mod.mode_solver = solver
        mod.doState()
        mod.mode_elas_deriv = 1
        setattr(mod,fixed,getattr(basemod,fixed+'_ss'))
        mod.doMcaRC()
        # get fluxes directly linked to fixed species
        FixSubstrateFor = ['J_' + r for r in getattr(mymap, fixed).isSubstrateOf()]
        FixProductFor = ['J_' + r for r in getattr(mymap, fixed).isProductOf()]
        print('Fixed species is Substrate for: ', FixSubstrateFor)
        print('Fixed species is Product for:   ', FixProductFor)
        # set scan distances
        scan_min = getattr(basemod,fixed+'_ss')/self.min_concrange_factor
        scan_max = getattr(basemod,fixed+'_ss')*self.max_concrange_factor
        # do scan               
        rng = scipy.logspace(scipy.log10(scan_min),scipy.log10(scan_max),self.scan_points)
        sc1 = pysces.Scanner(mod)
        sc1.quietRun = True
        sc1.printcnt = 50
        sc1.addScanParameter(fixed, scan_min, scan_max, self.scan_points,log=True)
        args = [fixed] + FixProductFor + FixSubstrateFor
        print('Scanner user output: ',args)
        sc1.addUserOutput(*args)
        sc1.Run()  
        print(sc1.UserOutputResults)          
        
        
        if len(sc1.invalid_state_list) != 0:
            newUserOutputResults = [] 
            midpart = 0 
            # the number of results between invalid steady states at the ends
            resultsperdimension = sc1.UserOutputResults.shape[1]
            startpoint = 0
github PySCeS / pysces / pysces / kraken / KrakenServer.py View on Github external
for set in range(int(args[0])):
            ctmp = []
            for t in range(2, 8):
                cpoint += 1
                ctmp.append(args[t+shift].strip())
            commands.append(ctmp)
            shift += 6
        output = []
        for out in range(int(args[1])):
            cpoint += 1
            output.append(args[cpoint].strip())

        print('\n', commands)
        print(output, '\n')

        scan = pysces.Scanner(self.model)
        scan.quietRun = True
        for gen in commands:
            print(gen)
            print(gen[0], float(gen[1]), float(gen[2]), int(gen[3]), bool(int(gen[4])), bool(int(gen[5])))

            scan.addGenerator(gen[0], float(gen[1]), float(gen[2]), int(gen[3]),\
                                log=bool(int(gen[4])), slave=bool(int(gen[5])))
        scan.addUserOutput(*output)
        scan.Run()
        self.RESULT = scan.UserOutputResults
        self.setStatus('DONE_SCAN')
        del scan
        return True