Exemplo n.º 1
0
    def setup_neutron(self):
        """
        Creates Neutron Plotter GUI
        """

        self.globals.logger.debug("Creating neutron plotter frame GUI...")

        # MENU
        ID = self.NEUTRON_ID
        self.menu_buttons[ID] = tk.Button(self.menu_frame, text="Neutron", relief=tk.FLAT,
                                                   command=lambda page=ID: self.page(page))

        # PAGE
        self.pages[ID] = Neutron(self.main_frame, self.globals)

        self.globals.logger.debug("Neutron plotter frame GUI created.")
Exemplo n.º 2
0
    credentials = { 'user' : os.environ['OS_USERNAME'],
                    'password' : os.environ['OS_PASSWORD'],
                    'project' : os.environ['OS_TENANT_NAME'] }
    auth_url = os.environ['OS_AUTH_URL']
else:
    print "Can't find OpenStack auth credentials in environment or spec file, giving up..."
    sys.exit(1)

if args.auth:
    print "credentials string:\nexport OS_USERNAME=%s OS_PASSWORD=%s OS_TENANT_NAME=%s OS_AUTH_URL=%s" % (credentials['user'],credentials['password'],credentials['project'],auth_url)
    sys.exit(0)

config = {}
config['external_network_name'] = spec['external network name']
config['dns'] = spec['dns']
neutron = Neutron(auth_url, credentials, config)
nova    = novaclient.client.Client("2",
                                   username = credentials['user'],
                                   api_key = credentials['password'],
                                   project_id = credentials['project'],
                                   auth_url = auth_url)

servers = nova.servers.list()
server_list = {}
for server in servers:
    server_list[server.name] = (server.id,server.status)

def server_suspend(name):
    for s in servers:
        if s.name == name:
            (id,status) = server_list[name]
Exemplo n.º 3
0
        super(IPPool, self).__init__()
        self.log = logger.setup_logging(self.__class__.__name__)
        self.schema_class = 'ip_pool_schema.IpPoolSchema'

        if neutron is not None:
            self.set_connection(neutron.get_connection())

        self.set_create_endpoint('/pools/ip-pools')
        self.id = None


if __name__ == '__main__':
    import base_client
    from neutron import Neutron
    from ip_pool_schema import IpPoolSchema
    nu = Neutron('10.110.30.9', 'admin', 'default')
    ip_pool_client = IPPool(nu)
    py_dict = {
        'subnets': [{
            'static_routes': [{
                'next_hop': '192.168.10.5',
                'destination_cidr': '192.168.10.0/24'
            }],
            'allocation_ranges': [{
                'start': '192.168.1.2',
                'end': '192.168.1.6'
            }, {
                'start': '192.168.1.10',
                'end': '192.168.1.100'
            }],
            'dns_nameservers': ['10.10.10.11', '10.10.10.12'],
Exemplo n.º 4
0
def main(neutron_cycle, cycle):

    # Fission and neutron source bank
    neutron_bank = np.zeros((cycle * neutron_cycle, 8))
    # [No., site_x, site_y, travel_length, velocity_angle, reaction_type, number_neutron]

    rand_num = np.zeros((2, neutron_cycle), float)

    for n in range(neutron_cycle):
        rand_num[0][n] = random.uniform(-b, b)
        rand_num[1][n] = random.uniform(-b, b)

    fission_num = neutron_cycle

    for i in range(cycle):
        m = 0
        print rand_num
        for j in range(neutron_cycle):

            row_num = neutron_cycle * i + j
            neutron = Neutron(row_num, 1)

            neutron_bank[row_num, 1] = neutron.no

            if j < fission_num:
                x_rand = rand_num[0][j]
                y_rand = rand_num[1][j]
            else:
                site_num = random.randint(0, fission_num - 1)
                x_rand = rand_num[0][site_num]
                y_rand = rand_num[1][site_num]

            energy = 1e6
            # unit: eV
            angle = -1

            neutron_status = {
                'x_rand': x_rand,
                'y_rand': y_rand,
                'x_next': 0,
                'y_next': 0,
                'energy': 1e6,
                'angle': -1,
                'iso_col': ''
            }
            neutron.status(neutron_status)

            neutron_bank[row_num, 2] = neutron.x_rand
            neutron_bank[row_num, 3] = neutron.y_rand

            # print neutron_bank[row_num,2];
            # generate the first collision position
            circle_flag = geo_circle(neutron.x_rand, neutron.y_rand)

            if circle_flag == 1:
                neutron.domain(1)
            else:
                neutron.domain(2)

            neutron = new_position(neutron)

            geo_intersc(neutron)

            #neutron_bank[j,4] = neutron['x_next'];
            #neutron_bank[j,5] = neutron['y_next'];

            # loop core
            react_judge(neutron)
            # print neutron_bank[row_num,2];
            neutron_bank[row_num, 4] = neutron.x_next
            neutron_bank[row_num, 5] = neutron.y_next
            neutron_bank[row_num, 6] = neutron.col
            neutron_bank[row_num, 7] = neutron.type

            if neutron.iso_col:
                x = neutron.iso_col.name
            else:
                x = 'NaN'

            print neutron.no, neutron.col, neutron_bank[
                row_num, 2], neutron_bank[row_num, 3], neutron_bank[
                    row_num,
                    4], neutron_bank[row_num,
                                     5], neutron.energy, x, neutron.type

            # filter out fission sites
            if neutron.type == 1:
                rand_num[0][m] = neutron.x_next
                rand_num[1][m] = neutron.y_next
                m = m + 1

            print m
            del neutron

        print m
        fission_num = m
        fission_yield = 2.5
        print 'Keff = %f' % (fission_num * fission_yield / neutron_cycle)

    end = time.time()
    print(end - start)
    plt.subplot(2, 2, 1)
    circle1 = plt.Circle((0, 0), r, alpha=0.1)
    point1 = plt.scatter(neutron_bank[0:neutron_cycle, 2],
                         neutron_bank[0:neutron_cycle, 3])
    fig = plt.gcf()
    fig.gca().add_artist(circle1)
    fig.gca().add_artist(point1)
    plt.title('Neutron source - 1st cycle')
    plt.xlim([-b, b])
    plt.ylim([-b, b])

    plt.subplot(2, 2, 2)
    circle1 = plt.Circle((0, 0), r, alpha=0.1)
    point1 = plt.scatter(neutron_bank[0:neutron_cycle, 4],
                         neutron_bank[0:neutron_cycle, 5])
    fig = plt.gcf()
    fig.gca().add_artist(circle1)
    fig.gca().add_artist(point1)
    plt.title('Fission site - 1st cycle')
    plt.xlim([-b, b])
    plt.ylim([-b, b])

    plt.subplot(2, 2, 3)
    circle1 = plt.Circle((0, 0), r, alpha=0.1)
    point1 = plt.scatter(neutron_bank[neutron_cycle:neutron_cycle * 2, 2],
                         neutron_bank[neutron_cycle:neutron_cycle * 2, 3])
    fig = plt.gcf()
    fig.gca().add_artist(circle1)
    fig.gca().add_artist(point1)
    plt.title('Neutron source - 2nd cycle')
    plt.xlim([-b, b])
    plt.ylim([-b, b])

    plt.subplot(2, 2, 4)
    circle1 = plt.Circle((0, 0), r, alpha=0.1)
    point1 = plt.scatter(neutron_bank[neutron_cycle:neutron_cycle * 2, 4],
                         neutron_bank[neutron_cycle:neutron_cycle * 2, 5])
    fig = plt.gcf()
    fig.gca().add_artist(circle1)
    fig.gca().add_artist(point1)
    plt.title('Fission site - 2nd cycle')
    plt.xlim([-b, b])
    plt.ylim([-b, b])

    plt.show()
Exemplo n.º 5
0
def main(neutron_cycle,cycle):

    
    # Fission and neutron source bank
    neutron_bank = np.zeros((cycle*neutron_cycle,8));
    # [No., site_x, site_y, travel_length, velocity_angle, reaction_type, number_neutron]

    rand_num = np.zeros((2,neutron_cycle),float);
    
    for n in range(neutron_cycle):
        rand_num[0][n] = random.uniform(-width,width);
        rand_num[1][n] = random.uniform(-width,width);

    rand_num_new = np.zeros((2,neutron_cycle),float);


    fission_num = neutron_cycle;
    
    for i in range(cycle):
        m = 0;
        #print rand_num;
        for j in range(neutron_cycle):

            row_num = neutron_cycle * i + j;
            neutron = Neutron(row_num,1);
            
            neutron_bank[row_num,1] = neutron.no;

            if j < fission_num:
                x_rand = rand_num[0][j];
                y_rand = rand_num[1][j];
            else:
                site_num = random.randint(0,fission_num-1);
                x_rand = rand_num[0][site_num];
                y_rand = rand_num[1][site_num];

            energy = 2*1e6; # unit: eV
            angle = -1;

            neutron_status = {'x_rand':x_rand,'y_rand':y_rand,'x_next':0,'y_next':0,'energy':1e6,'angle':-1,'iso_col':'','type':0};
            neutron.status(neutron_status);

            
            neutron_bank[row_num,2] = neutron.x_rand;
            neutron_bank[row_num,3] = neutron.y_rand;

            # print neutron_bank[row_num,2];
            # generate the first collision position
            circle_flag = geo_circle(neutron.x_rand, neutron.y_rand);

            if circle_flag == 1:
                neutron.domain(1);
            else:
                neutron.domain(2);
            
            neutron = new_position(neutron);
            
            geo_intersc(neutron);
            
            
            #neutron_bank[j,4] = neutron['x_next'];
            #neutron_bank[j,5] = neutron['y_next'];
            
            # loop core
            react_judge(neutron);
            # print neutron_bank[row_num,2];                
            neutron_bank[row_num,4] = neutron.x_next;
            neutron_bank[row_num,5] = neutron.y_next;
            neutron_bank[row_num,6] = neutron.col;
            neutron_bank[row_num,7] = neutron.type;

            if neutron.iso_col:
                x= neutron.iso_col.name;
            else:
                x= 'NaN';

            #print neutron.no, neutron.col, neutron_bank[row_num,2], neutron_bank[row_num,3], neutron_bank[row_num,4], neutron_bank[row_num,5], neutron.energy, x, neutron.type;
            # filter out fission sites
            if neutron.type == 2:
                rand_num_new[0][m] = deepcopy(neutron.x_next);
                rand_num_new[1][m] = deepcopy(neutron.y_next);
                #print rand_num_new[0][:]
                
                #try:
#                    print rand_num[0][:]
#                except:
#                    print 'xxx'
                m = m + 1;
                

            #print m;
            del neutron;
            #print rand_num;

        #print m;
        fission_num = m;
        fission_yield = 2.5;
        keff[i] = fission_num * fission_yield / neutron_cycle;
        print ('Keff = %f' % (fission_num * fission_yield / neutron_cycle));
        #del rand_num
        rand_num = deepcopy(rand_num_new);
        #del rand_num_new;

        
    end = time.time();
    print(end - start);