Beispiel #1
0
def circle_pressure_coef_spm_test():
    circle = figure.Circle(10, num_points=100)
    spm = SPMCircle(circle, 1.0)

    grid = figure.Grid(np.pi, -1.0, 2.0 * np.pi, 4.0)
    plt = Plot(grid)
    tetta = np.linspace(0.0, 2.*np.pi, 360)
    cp = 1. - 4. * (np.sin(tetta) ** 2)
    analytic_coef = figure.Figure('Pressure coef', tetta, cp)
    plt.plot_figure(analytic_coef)

    spm_coef = figure.Figure('Spm coef', spm.geometry.angle_cp, spm.surface_cp)
    plt.plot_figure(spm_coef, '*b')

    plt.show()
Beispiel #2
0
    def __init__(self, aDefect_Study):
        """
        :param aDefect_Study: Defect_Study or Material_Study object
        """

        # DEFECT STUDIES & MATERIAL STUDIES

        # Plot parameters
        self.E_range = [0, max(aDefect_Study.gaps.values()) * 1.05]  # Fermi energy range displayed
        self.for_range = ['auto', 'auto']  # formation energy range displayed
        self.display_transition_levels = True  # if True, display the transitions levels
        self.display_charges = True  # if True, display the charges associated with the formation energy lines

        # Figure parameters
        self.figure = pf.Figure(1, 1, 'New Figure')  # PyDEF Figure object
        self.subplot_nb = 1  # subplot number
        self.title = aDefect_Study.title
        self.label_display = False  # if True, the display of the axis labels is controlled by 'xlabel_display'
                                    # and 'ylabel_display'
        self.xlabel_display = True  # if True, the x axis label is displayed
        self.ylabel_display = True  # if True, the y axis label is displayed
        self.common_ylabel_display = False  # if True, a common y axis label is displayed
        self.xticklabels_display = True  # if True, the x axis ticks labels are displayed
        self.yticklabels_display = True  # if True, the y axis ticks labels are displayed
        self.text_size = 24  # size of the text

        # MATERIAL STUDIES
        self.display_colored_lines = True  # if True, display a light version of the defect name
        self.display_charges_light = True  # if True, display only the charge of the associated line
        self.highlight_charge_change = True  # if True, highlight charge change
        self.lines_colors = ['red', 'yellowgreen', 'blue', 'y', 'black', 'brown', 'darkgreen', 'navy', 'gold',
                             'm', 'teal', 'darkmagenta']*10
        self.display_gaps_legend = True
Beispiel #3
0
 def __init__(self,
              fullscreen=False,
              screen=(800, 600),
              width=10,
              height=20):
     pygame.display.set_caption("Pentix")
     self.fullscreen = fullscreen
     self.screen_size = screen
     self.width = width
     self.height = height
     self.block_size = 0
     self.surface = None
     self.screen = None
     self.paused = False
     self.quit = False
     self.level = [[0 for _ in range(width)] for _ in range(height)]
     self.current = figure.Figure(self)
     self.fpsClock = pygame.time.Clock()
     self.score = 0
     self.lvl = 1
     self.highscore = 0
     self.draw_main()
     self.draw()
     pygame.time.set_timer(pentix.FALLING, 270 // self.lvl)
     pygame.time.set_timer(pentix.BOOSTING, 60)
Beispiel #4
0
 def fix_current(self):
     for i in range(len(self.current.figure)):
         for j in range(len(self.current.figure[0])):
             if self.current.y + i >= 0 and self.current.figure[i][j]:
                 self.score += 1
                 self.level[self.current.y + i][self.current.x + j] =\
                     self.current.figure[i][j]
     self.current = figure.Figure(self)
     self.del_rows()
Beispiel #5
0
 def __init__(self):
     print("Starting game")
     print("Loading board...")
     self.board = board.Board()
     all_starts = [13, 26, 29, 34, 50, 53, 91, 94, 103, 112, 117, 132, 138, 141, 155, 174, 197, 198]
     start = random.sample(all_starts, 5)
     self.figures = []
     for i in range(0, 5):
         self.figures.append(figure.Figure(i, start[i]))
     self.turns = 0
     self.mrx_last_used_ticket = None
     self.logger = logger.Logger()
     self.logger.log("## SCOTLAND YARD: MR. X VS. 4 AGENTS")
Beispiel #6
0
    def __init__(self, name):

        self.Cells = {}  # dictionary containing VASP calculations results
        self.Defects = {}  # dictionary containing defects labels
        self.Defect_Studies = {}  # dictionary containing defect studies
        self.Material_Studies = {}  # dictionary containing material studies
        self.Figures = {
            'New Figure': pf.Figure(1, 1, 'New Figure')
        }  # dictionary containing pydef figures

        self.name = name  # name of the project

        self.dd_vasp = ''  # VASP data default directory
        self.dd_pydef = ''  # PyDED data default directory
Beispiel #7
0
    def __init__(self, aCell):
        """
        :param aCell: Cell object
        """

        # Plot parameters
        self.display_proj_dos = True  # if True, display the projected DOS
        self.dos_type = 'OPAS'  # type of DOS plotted ('OPA' : s,p,d orbitals projected DOS for each atom or 'OPAS' : s,p,d orbitals projected DOS for each atomic species)
        self.tot_proj_dos = False  # if True, then the total projected DOS is plotted (according to 'dos_type')
        self.choice_opas = aCell.atoms_types  # list of atomic species
        self.choice_opa = aCell.atoms  # list of atoms
        self.E_range = np.sort([aCell.emin,
                                aCell.emax])  # energy range (list of float)
        self.DOS_range = [0, aCell.dosmax]  # DOS range (list of float)
        if len(aCell.orbitals) == 4:  # s p d f orbitals
            self.colors_proj = [
                '#990000', '#e60000', '#ff6666', '#ff66cc', '#003399',
                '#0000e6', '#9999ff', '#cc66ff'
                '#00802b', '#00b33c', '#1aff66', '#99ff99'
                '#999900', '#e6e600', '#ffff33', '#ffff99'
            ]  # list of colors for orbital projected plots
        else:
            self.colors_proj = [
                '#990000', '#e60000', '#ff6666', '#003399', '#0000e6',
                '#9999ff', '#00802b', '#00b33c', '#1aff66', '#999900',
                '#e6e600', '#ffff33'
            ]  # list of colors for orbital projected plots
        self.colors_tot = ['#ff0000', '#0033cc', '#33cc33', '#e6e600'
                           ]  # list of colors for total projected plots
        self.fermi_shift = False  # if True, then the zero of energy is the fermi level
        self.normalise_dos = False  # if True, normalise the DOS
        self.display_total_dos = False  # if True, display the total DOS
        self.display_BM_levels = False  # if True, display the band maxima levels
        self.display_Fermi_level = True  # if True, display the fermi levels
        self.input_shift = 0.0

        # Figure and axis parameters
        self.figure = fc.Figure(1, 1, 'New Figure')  # figure object
        self.subplot_nb = 1  # subplot number
        self.text_size = 24  # size of the text displayed
        self.title = aCell.title  # Title of the plot
        self.label_display = False  # if True, the xlabel and ylabel display depend on 'xlabel_display' and 'ylabel_display'. Else, the xlabel and ylabel are smartly displayed
        self.xlabel_display = True  # if True, the xlabel is displayed
        self.ylabel_display = True  # if True, the ylabel is displayed
        self.common_ylabel_display = False  # if True, a common ylabel is displayed in the middle of the left side
        self.xticklabels_display = True  # if True, display the tick labels of the x-axis
        # self.yticks_display = False  # if True, display the ticks of the y-axis
        # self.yticklabels_display = False  # if True, display the tick labels of the y-axis
        self.display_legends = True  # if True, display the legends
Beispiel #8
0
def airfoil_pressure_coef_spm_test():
    # Write your own path here
    path = r'C:\Users\User\Documents\python\aero\airfoils_data'
    # Airfoil name
    name = 'naca2412.txt'
    test_fig = figure.Airfoil(name, path)
    spm = SourcePanelMethod(test_fig, 1, 0.0 * np.pi / 180.0)

    cp_upper = spm.surface_cp[spm.geometry.yc >= 0]
    x_upper = spm.geometry.xc[spm.geometry.yc >= 0]
    cp_lower = spm.surface_cp[spm.geometry.yc < 0]
    x_lower = spm.geometry.xc[spm.geometry.yc < 0]
    fgr_upper = figure.Figure('', x_upper, cp_upper)
    fgr_lower = figure.Figure('', x_lower, cp_lower)
    x01, y01, dx1, dy1 = fgr_upper.rect
    x02, y02, dx2, dy2 = fgr_lower.rect

    grid = figure.Grid(min(x01, x02), min(y01, y02),
                       max(dx1, dx2), max(dy1, dy2))
    plt = Plot(grid)
    plt.plot_figure(fgr_upper, '*b')
    plt.plot_figure(fgr_lower, '-r')
    plt.invert_y_axis()
    plt.show()
Beispiel #9
0
    def __init__(self, aDefect_Study):

        # Plot parameters
        self.E_range = [-0.5, max(aDefect_Study.gaps.values()) * 1.05]  # Fermi energy range
        self.gap_choice = 'Calculated gap'  # gap displayed (i.e. position of the CBM with respect to the VBM)

        # Figure parameters
        self.figure = pf.Figure(1, 1, 'New Figure')  # Figure
        self.subplot_nb = 1  # subplot number
        self.title = aDefect_Study.title
        self.text_size = 24  # size of the text
        self.label_display = False  # if True, the display of the axis labels is controlled by 'xlabel_display'
                                    # and 'ylabel_display' variables
        self.ylabel_display = True  # if True, the y axis label is displayed
        self.common_ylabel_display = False  # if True, a common y axis label is displayed
        self.yticklabels_display = False  # if True, the y axis ticks labels are displayed

        # Onlt for Material_Study object
        self.display_formation_energy = True
Beispiel #10
0
BackColor = "DarkOliveGreen4"

MainFigure = fg.Figure([
# House
{"tag":"line", "x_start": 500, "y_start": 350, "x_end": 275, "y_end": 350, "figure": None},
{"tag":"line", "x_start": 500, "y_start": 550, "x_end": 275, "y_end": 550, "figure": None},
{"tag":"line", "x_start": 275, "y_start": 350, "x_end": 275, "y_end": 550, "figure": None},
{"tag":"line", "x_start": 500, "y_start": 350, "x_end": 500, "y_end": 550, "figure": None},
# Roof
{"tag":"line", "x_start": 275, "y_start": 350, "x_end": 330, "y_end": 275, "figure": None},
{"tag":"line", "x_start": 330, "y_start": 275, "x_end": 500, "y_end": 350, "figure": None},
# Window 1
{"tag":"line", "x_start": 300, "y_start": 400, "x_end": 300, "y_end": 500, "figure": None},
{"tag":"line", "x_start": 300, "y_start": 500, "x_end": 420, "y_end": 500, "figure": None},
{"tag":"line", "x_start": 420, "y_start": 500, "x_end": 420, "y_end": 400, "figure": None},
{"tag":"line", "x_start": 420, "y_start": 400, "x_end": 300, "y_end": 400, "figure": None},
{"tag":"line", "x_start": 360, "y_start": 500, "x_end": 360, "y_end": 380},
{"tag":"arc", "arc": arc, "figure": None},
# Window 2
{"tag":"line", "x_start": 460, "y_start": 380, "x_end": 460, "y_end": 500, "figure": None},
{"tag":"line", "x_start": 440, "y_start": 440, "x_end": 480, "y_end": 440, "figure": None},
{"tag":"oval", "oval": oval, "figure": None},
# Window 3
{"tag":"line", "x_start": 320, "y_start": 313, "x_end": 350, "y_end": 297, "figure": None},
{"tag":"line", "x_start": 322, "y_start": 323, "x_end": 356, "y_end": 305, "figure": None},
{"tag":"line", "x_start": 328, "y_start": 332, "x_end": 360, "y_end": 316, "figure": None},
{"tag":"oval", "oval": circle, "figure": None}
])

class MainWindow(object):
    def __init__(self, x_size, y_size, title, main_color, tk):
Beispiel #11
0
 def _create_figure(self):
     _figure = random.choice(list(figures))
     turn = random.randint(1, 4)
     color = random.choice(list(colors))
     return figure.Figure(color, _figure, turn)
Beispiel #12
0
    def plot_dos(self):
        """ Plot the DOS of the host cell and each defect cell in the study """

        Host_Cell = copy.deepcopy(self.Host_Cell)
        defect_cell_studies = copy.deepcopy(self.defect_cell_studies)

        if hasattr(Host_Cell, 'doscar') is False:
            print('DOSCAR missing')
            return None

        for study in defect_cell_studies.values():
            if hasattr(study.Defect_Cell, 'doscar') is False:
                print('DOSCAR missing')
                return None

        nb_rows = len(defect_cell_studies) + 1

        # Figure
        figure = pf.Figure(nb_rows, 1, 'Comparison of the DOS of %s' % self.ID)

        # Host Cell
        Host_Cell.dpp = cc.Dos_Plot_Parameters(Host_Cell)
        Host_Cell.dpp.figure = figure
        Host_Cell.dpp.DOS_range = self.dpp.DOS_range
        Host_Cell.dpp.display_Fermi_level = False
        Host_Cell.dpp.display_BM_levels = True
        Host_Cell.dpp.E_range = self.dpp.E_range
        Host_Cell.dpp.label_display = True
        Host_Cell.dpp.xlabel_display = False
        Host_Cell.dpp.ylabel_display = False
        Host_Cell.dpp.common_ylabel_display = True
        Host_Cell.dpp.xticklabels_display = False
        Host_Cell.dpp.title = Host_Cell.display_rname

        cell_studies = defect_cell_studies.values()
        cell_charges = [f.Defect_Cell.charge for f in cell_studies]

        # Change the plot parameters for all defect cell
        for i, j in zip(np.argsort(cell_charges), range(2, len(cell_charges) + 2)):
            cell_studies[i].Defect_Cell.dpp = cc.Dos_Plot_Parameters(cell_studies[i].Defect_Cell)
            cell_studies[i].Defect_Cell.dpp.figure = figure
            cell_studies[i].Defect_Cell.dpp.subplot_nb = j
            cell_studies[i].Defect_Cell.dpp.DOS_range = self.dpp.DOS_range
            cell_studies[i].Defect_Cell.dpp.E_range = self.dpp.E_range
            cell_studies[i].Defect_Cell.dpp.title = cell_studies[i].title
            cell_studies[i].Defect_Cell.dpp.label_display = True
            cell_studies[i].Defect_Cell.dpp.xlabel_display = False
            cell_studies[i].Defect_Cell.dpp.ylabel_display = False
            cell_studies[i].Defect_Cell.dpp.display_legends = False
            cell_studies[i].Defect_Cell.dpp.xticklabels_display = False
            if self.dpp.align_potential is True:
                cell_studies[i].Defect_Cell.dpp.input_shift = cell_studies[i].pa_corr_temp
                print cell_studies[i].Defect_Cell.dpp.input_shift
            #if atoms is not False:
            #    cell_studies[i].Defect_Cell.dpp.dos_type = 'OPA'
            #    cell_studies[i].Defect_Cell.dpp.choice_opa = [f.atom[-1] for f in self.DefectS]

            if j == len(cell_charges) + 1:
                cell_studies[i].Defect_Cell.dpp.xticklabels_display = True
                cell_studies[i].Defect_Cell.dpp.xlabel_display = True

            cell_studies[i].Defect_Cell.plot_dos()

        Host_Cell.plot_dos()
Beispiel #13
0
def mr_x():
    return figure.Figure(0, 45)
Beispiel #14
0
def agent():
    return figure.Figure(1, 11)
Beispiel #15
0
X1 = []
X2 = []
Y1 = []
Y2 = []

for line in lines:
    splits = line.split()
    if 'Socket0' in line:
        X1.append(float(splits[2]))
        Y1.append(float(splits[3]))
    elif 'Socket1' in line:
        X2.append(float(splits[2]))
        Y2.append(float(splits[3]))

fig = figure.Figure()
ax1 = fig.add_subplot()
ax1.set_ylabel("Y Axis")
ax1.set_xlabel("X Axis")

ax1.plot(X1, Y1, linewidth=2, color='#33B5E5', label='Socket 1', clip_on=False)

ax1.plot(X2, Y2, linewidth=2, color='#99CC00', label='Socket 2', clip_on=False)

ax1.set_ylim([0, max(max(Y2), max(Y1))])
ax1.set_xlim([0, max(max(X2), max(X1))])

fig.set_legend(ax1, 'upper left')
fig.plt.savefig(output_file + ".pdf", format="pdf", bbox_inches='tight')
input_file.close()