Exemple #1
0
from numpy import pi, sqrt
from numpy import zeros

filename = "finite_lattice_all_inclusions"
write_solver_input(
    filename + ".msh",
    dimension=2,
    bc_type="Dir",
    parameter=[],
    eq="EM",
    sol_type="Stationary",
    analysis_param=["y", "y", 15, 15, 20, 20, 2],
    bc_filename=filename + ".bc",
)

simu = Simulation()
simu.read_solver_input(filename + ".msh")
simu.domain.read_mesh_file(filename + ".msh", True)
simu.domain.read_bc_file(simu.bc_filename)

reg_filename = simu.bc_filename.split(".bc")[0]
simu.domain.read_regions_file(reg_filename)

inter = Interpreter()
eq = inter.build_harmonic_EM_eq(simu)
g = eq["sol_vec"]

my_solver = Solver()
value, fields = my_solver.solve_spectral(simu, eq)
print len(fields), "value", sqrt(value)
quads = my_solver.substract_1(simu.domain.elements.quads.el_set)
Exemple #2
0
import os, sys
lib_path = os.path.abspath('..')
sys.path.append(lib_path)
from Classes import Simulation
from Interpreter import Interpreter
from Solver import Solver
from write import write_vtk, write_solver_input 
import matplotlib.pyplot as plt
from matplotlib import rc

filename = 'unit_cell_1-02_two_reg'
write_solver_input(filename +'.msh',dimension = 2, bc_type = 'Bloch', \
parameter = [], eq = 'EM', sol_type = 'Stationary',analysis_param \
= ['y', 'y', 15, 15, 21, 21, 5], bc_filename = filename +'_guide.bc')  

simu = Simulation()
simu.read_solver_input(filename +'.msh')
simu.domain.read_mesh_file(filename +'.msh',simu)

inter = Interpreter(vectorial = True)
eq = inter.build_EM_bloch_eq(simu)
my_solver = Solver()
k_coords, energy = my_solver.solve_bloch_Brillouin(simu, eq)

fig = plt.figure()
ax = fig.add_subplot(111)
plt.title("Dispersion relations for Square lattice")
k_div = k_coords.shape[0]/3

from numpy import sqrt, around
print max(energy[:,-1])
Exemple #3
0
Created on Sat Apr  6 20:06:58 2013

@author: santiago
"""


from Classes import Simulation
from Interpreter import Interpreter
from Solver import Solver
from write import write_vtk, write_solver_input 

write_solver_input('whole_cylinder.msh',dimension = 2, bc_type = 'Dir', \
parameter = [], eq = 'Harm_Elec', sol_type = 'Stationary',analysis_param \
= ['y', 'y', 4, 4, 20, 20, 2], bc_filename = 'whole_cylinder.bc')  

simu = Simulation()
simu.read_solver_input('whole_cylinder.msh')
simu.domain.read_mesh_file('whole_cylinder.msh', True)

inter = Interpreter()
eq = inter.build_static_EM_eq(simu)
g = eq['sol_vec']
my_solver = Solver()
fields = my_solver.solve_stationary(simu, eq)
quads = my_solver.substract_1(simu.domain.elements.quads.el_set)
quads = quads[:,1:]
from numpy import zeros
field3 =  zeros((simu.domain.nodes.n,3))
field3[:,0:2] = fields
fields = field3
"""
Created on Tue Mar 19 11:31:57 2013

@author: santiago
"""

from Classes import Simulation
from Interpreter import Interpreter
from Solver import Solver
from write import write_vtk, write_solver_input 

write_solver_input('two_cylinders.msh',dimension = 2, bc_type = 'Dir', \
parameter = [], eq = 'Harm_Elec', sol_type = 'Stationary',analysis_param \
= ['y', 'y', 4, 4, 20, 20, 2], bc_filename = 'two_cylinders2.bc')  

simu = Simulation()
simu.read_solver_input('two_cylinders.msh')
simu.domain.read_mesh_file('two_cylinders.msh', True)

inter = Interpreter()
eq = inter.build_static_EM_eq(simu)
g = eq['sol_vec']
my_solver = Solver()
fields = my_solver.solve_stationary(simu, eq)
quads = my_solver.substract_1(simu.domain.elements.quads.el_set)
quads = quads[:,1:]
from numpy import zeros
field3 =  zeros((simu.domain.nodes.n,3))
field3[:,0:2] = fields
fields = field3
Exemple #5
0
#!/usr/bin/env python

import rospy
from geometry_msgs.msg import Pose
from gazebo_msgs.msg import ModelState
from Queue import Queue
from Classes.Simulation import *

if __name__ == "__main__":
    sim = Simulation()
    sim.r = rospy.Rate(100)
    while not rospy.is_shutdown():
        sim.r.sleep()
"""
Created on Tue Mar 19 11:31:57 2013

@author: santiago
"""

from Classes import Simulation
from Interpreter import Interpreter
from Solver import Solver
from write import write_vtk, write_solver_input 

write_solver_input('square8_cap.msh',dimension = 2, bc_type = 'Dir', \
parameter = [], eq = 'Harm_Elec', sol_type = 'Stationary',analysis_param \
= ['y', 'y', 4, 4, 20, 20, 2], bc_filename = 'square.bc')  

simu = Simulation()
simu.read_solver_input('square8_cap.msh')
simu.domain.read_mesh_file('square8_cap.msh',simu)

inter = Interpreter()
eq = inter.build_static_EM_eq(simu)
my_solver = Solver()
fields = my_solver.solve_stationary(simu, eq)
quads = my_solver.substract_1(simu.domain.elements.quads.el_set)
quads = quads[:,1:]
from numpy import zeros
field3 =  zeros((simu.domain.nodes.n,3))
field3[:,0:2] = fields
fields = field3

write_vtk('newman_cap'+'.vtk', 'MyTitle', 'UNSTRUCTURED_GRID' ,simu.domain.nodes.coords,\
Exemple #7
0
#Choices:
#demand_is = 'Unknown'                     # 'Unknown' or 'Known'
NumberOfStations = 35  # keep it to 35 for the moment
NumberOfTrucks = 6  # Number of repositioning trucks
TruckCapacity = 40  # Capacity of each repositioning truck
UseMTZ = True  # MTZ constraints or DL
ValidInequalities = True  # Use of a model with valid inequalities
InitialNoOfBikesPerStation = 5  # Number of bikes at the beginning in each station
NumberOfDays = 3  # Number of days to repeat the simulation
TimeLimit = 1e75  # Maximum seconds to solve the rebalancing model

#Initialise the Rebalancing Operations and simulation classes:
t1 = time.time()
Rebalancing = RebalancingOperations(mtz=UseMTZ, vi=ValidInequalities)
Simulation = Simulation(nSt=NumberOfStations,
                        FirstBikesPerStation=InitialNoOfBikesPerStation)

#Initialise the results lists
UnknownCost = []
UnknownLostDemandList = []
UnknownConfigIniList = []
UnknownConfigFinList = []
UnknownSimTime = []
UnknownRebTime = []
KnownCost = []
KnownLostDemandList = []
KnownConfigIniList = []
KnownConfigFinList = []
KnownSimTime = []
KnownRebTime = []
Trucks = []