Exemplo n.º 1
0
def export_2d(glider):
    filename = QtGui.QFileDialog.getSaveFileName(
        parent=None,
        caption="export glider",
        directory='~')
    if filename[0] != "":
        with open(filename[0], 'w') as exportfile:
            dump(glider.ParametricGlider, exportfile)
Exemplo n.º 2
0
 def export_file_dialog(self):
     filename = QtGui.QFileDialog.getSaveFileName(
         parent=None,
         caption='import airfoil',
         directory='~',
         filter='*.dat *.json',
         selectedFilter='*.dat *.json')
     if filename[0] != '':
         name, format = os.path.splitext(filename[0])
         if format == ".dat":
             self.current_airfoil.export_dat(filename[0])
         elif format == ".json":
             with open(filename[0], "w") as fp:
                 jsonify.dump(self.current_airfoil, fp)
Exemplo n.º 3
0
def export_2d(glider):
    file_types = "OpenOffice (*.ods);;JSON (*json)"
    filename = QtGui.QFileDialog.getSaveFileName(parent=None,
                                                 caption='export glider',
                                                 directory='~',
                                                 filter=file_types)
    if filename[0] != "":
        if filename[0].endswith(".ods"):
            glider.ParametricGlider.export_ods(filename[0])
        elif filename[0].endswith('.json'):
            with open(filename[0], 'w') as exportfile:
                dump(glider.ParametricGlider, exportfile)
        else:
            FreeCAD.Console.PrintError('\nonly .ods and .json are supported')
Exemplo n.º 4
0
plt.close()
plt.figure(figsize=(10, 4))
plt.plot(y_positions, 0.6 / np.array(cD), marker="x")
plt.xlabel('y-Position der Kontrollpunkte [m]', fontsize=15)
plt.ylabel('Gleitzahl $\\epsilon$', fontsize=15)
plt.grid(True)
plt.savefig(check_path('results/vtk_opt/glide.png'),  bbox_inches='tight')
plt.close()


best_ind = list(cD).index(min(cD))
best_y = y_positions[best_ind]

glider_set_controlpoint(glider2d, best_y)
with open(check_path("results/glider/optimized.json"), "w") as _file:
    dump(glider2d, _file)

plt.figure(figsize=(10, 5))
plt.axes().set_aspect("equal", "datalim")
plt.grid(True)
plt.plot(*shape_plot(glider2d), color="0", label="optimal", linewidth=2)

glider_set_controlpoint(glider2d, y_positions[0])
with open(check_path("results/glider/min.json"), "w") as _file:
    dump(glider2d, _file)
plt.plot(*shape_plot(glider2d), color="r", label="untere Grenze")


glider_set_controlpoint(glider2d, y_positions[-1])
with open(check_path("results/glider/max.json"), "w") as _file:
    dump(glider2d, _file)
Exemplo n.º 5
0
# # plt.show()
plt.close()
plt.figure(figsize=(10, 4))
plt.plot(y_positions, 0.6 / np.array(cD), marker="x")
plt.xlabel('y-Position der Kontrollpunkte [m]', fontsize=15)
plt.ylabel('Gleitzahl $\\epsilon$', fontsize=15)
plt.grid(True)
plt.savefig(check_path('results/vtk_opt/glide.png'), bbox_inches='tight')
plt.close()

best_ind = list(cD).index(min(cD))
best_y = y_positions[best_ind]

glider_set_controlpoint(glider2d, best_y)
with open(check_path("results/glider/optimized.json"), "w") as _file:
    dump(glider2d, _file)

plt.figure(figsize=(10, 5))
plt.axes().set_aspect("equal", "datalim")
plt.grid(True)
plt.plot(*shape_plot(glider2d), color="0", label="optimal", linewidth=2)

glider_set_controlpoint(glider2d, y_positions[0])
with open(check_path("results/glider/min.json"), "w") as _file:
    dump(glider2d, _file)
plt.plot(*shape_plot(glider2d), color="r", label="untere Grenze")

glider_set_controlpoint(glider2d, y_positions[-1])
with open(check_path("results/glider/max.json"), "w") as _file:
    dump(glider2d, _file)
Exemplo n.º 6
0
 def test_export_glider_json2(self):
     with open(self.tempfile("kite_2d.json"), "w+") as outfile:
         jsonify.dump(self.glider_2d, outfile)
         outfile.seek(0)
         glider = jsonify.load(outfile)['data']
     self.assertEqualGlider2D(self.glider_2d, glider)
Exemplo n.º 7
0
 def test_export_glider_json(self):
     with open(self.tempfile('kite_3d.json'), "w+") as tmp:
         jsonify.dump(self.glider, tmp)
         tmp.seek(0)
         glider = jsonify.load(tmp)['data']
     self.assertEqualGlider(self.glider, glider)