Exemple #1
0
    def load(cls, path):

        if path.endswith(".json"):
            with open(path, 'r') as importfile:
                parametricglider = jsonify.load(importfile)["data"]
        elif path.endswith(".ods"):
            parametricglider = ParametricGlider.import_ods(path)
        else:
            raise ValueError

        return cls(parametric_glider=parametricglider)
Exemple #2
0
 def __init__(self, obj, parametric_glider=None, import_path=None):
     obj.addProperty('App::PropertyPythonObject', 'GliderInstance',
                     'object', 'GliderInstance', 2)
     obj.addProperty('App::PropertyPythonObject', 'ParametricGlider',
                     'object', 'ParametricGlider', 2)
     if parametric_glider:
         obj.ParametricGlider = parametric_glider
     else:
         import_path = import_path or os.path.dirname(
             __file__) + '/../glider2d.json'
         with open(import_path, 'r') as importfile:
             obj.ParametricGlider = jsonify.load(importfile)['data']
     obj.GliderInstance = obj.ParametricGlider.get_glider_3d()
     super(OGGlider, self).__init__(obj)
Exemple #3
0
def import_2d(glider):
    filename = QtGui.QFileDialog.getOpenFileName(parent=None,
                                                 caption='import glider',
                                                 directory='~')
    if filename[0].endswith('.json'):
        with open(filename, 'r') as importfile:
            glider.ParametricGlider = load(importfile)['data']
            glider.ParametricGlider.get_glider_3d(glider.GliderInstance)
            glider.ViewObject.Proxy.updateData()
    elif filename.endswith('ods'):
        glider.ParametricGlider = ParametricGlider.import_ods(filename)
        glider.ParametricGlider.get_glider_3d(glider.GliderInstance)
        glider.ViewObject.Proxy.updateData()
    else:
        FreeCAD.Console.PrintError('\nonly .ods and .json are supported')
Exemple #4
0
 def import_file_dialog(self):
     filename = QtGui.QFileDialog.getOpenFileName(
         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.QList_View.addItem(
                 QAirfoil_item(BezierProfile2D.import_from_dat(
                     filename[0])))
         elif format == ".json":
             with open(filename[0], "r") as fp:
                 airfoil = jsonify.load(fp)["data"]
                 self.QList_View.addItem(QAirfoil_item(airfoil))
Exemple #5
0
def import_2d(glider):
    file_name = QtGui.QFileDialog.getOpenFileName(
        parent=None,
        caption="import glider",
        directory='~')
    if file_name[0] != "":
        file_name = file_name[0]
        file_type = file_name.split(".")[1]
        if file_type == "json":
            with open(file_name, 'r') as importfile:
                glider.ParametricGlider = load(importfile)["data"]
                glider.ParametricGlider.get_glider_3d(glider.GliderInstance)
                glider.ViewObject.Proxy.updateData()
        elif file_type == "ods":
            glider.ParametricGlider = ParametricGlider.import_ods(file_name)
            glider.ParametricGlider.get_glider_3d(glider.GliderInstance)
            glider.ViewObject.Proxy.updateData()
Exemple #6
0
 def create_glider_with_dialog(self):
     file_name = QtGui.QFileDialog.getOpenFileName(parent=None,
                                                   caption='import glider',
                                                   directory='~')
     if file_name[0].endswith('.json'):
         if self.glider_obj:
             # replace current active par-glider with the imported par-glider
             with open(file_name[0], 'r') as importfile:
                 self.glider_obj.Proxy.setParametricGlider(
                     jsonify.load(importfile)['data'])
         else:
             # no active glider: create a new one
             CreateGlider.create_glider(import_path=file_name[0])
     elif file_name[0].endswith('ods'):
         par_glider = openglider.glider.ParametricGlider.import_ods(
             file_name[0])
         if self.glider_obj:
             # replace current active par-glider with the imported par-glider
             self.glider_obj.Proxy.setParametricGlider(par_glider)
         else:
             # no active glider: create a new one
             CreateGlider.create_glider(parametric_glider=par_glider)
     else:
         FreeCAD.Console.PrintError('\nonly .ods and .json are supported')
Exemple #7
0
import time
from openglider import jsonify
from openglider.glider import ParametricGlider

#gl = Glider2D.import_ods('acro.ods')
num = 3
#with open('acro.json', 'w') as outfile:
#    jsonify.dump(gl, outfile)

start = time.time()

for i in range(num):
    with open('acro.json') as infile:
        glider_2d = jsonify.load(infile)["data"]
    glider_3d = glider_2d.get_glider_3d()
    glider_3d.return_polygon_indices()

stop = time.time()
print((stop - start) / num)
 def setUp(self):
     with open("./fehler_nahtzugabe.gl3d.json", "r") as importfile:
         self.glider = load(importfile)["data"]
         for i, cell in enumerate(self.glider.cells):
             cell.panels = [Panel([-1, -1, 3, 0.012], [1, 1, 3, 0.012], i)]
         self.plots = flatten_glider(self.glider)
Exemple #9
0
import numpy as np

from openglider.jsonify import load
from openglider.utils.distribution import Distribution
from openglider.glider.in_out.export_3d import paraBEM_Panels

import paraBEM
from paraBEM.pan3d import DirichletDoublet0Source0Case3 as Case
from paraBEM.vtk_export import CaseToVTK
from paraBEM.utils import v_inf_deg_range3

n_x = 30

with open("glider/referenz_schirm_berg.json") as _file:
    glider_2d = load(_file)["data"]
    glider_2d.shape.set_const_cell_dist()
    glider = glider_2d.get_glider_3d()

_, panels, trailing_edge = paraBEM_Panels(
    glider,
    midribs=3,
    profile_numpoints=n_x,
    distribution=Distribution.from_cos_2_distribution(n_x),
    num_average=0,
    symmetric=False)

v_inf = [8, 0, 1]

case = Case(panels, trailing_edge)
case.mom_ref_point = paraBEM.Vector3(1.25, 0, 0)
case.A_ref = glider_2d.shape.area
Exemple #10
0
 def setUp(self):
     self.glider_2d = jsonify.load("../common/glider2d.json")
     self.glider_3d = self.glider_2d.get_glider_3d()
Exemple #11
0
from matplotlib import pyplot as plt

# from openglider.glider.parametric import ParametricGlider
from openglider.jsonify import dump, load
from openglider.glider.in_out.export_3d import paraBEM_Panels
from openglider.utils.distribution import Distribution

import paraBEM
from paraBEM.pan3d import DirichletDoublet0Source0Case3 as Case
from paraBEM.vtk_export import CaseToVTK
from paraBEM.utils import check_path, v_inf_deg_range3

count = 0
#   load the glider
with open("glider/referenz_schirm_berg.json") as _file:
    glider2d = load(_file)["data"]
    area = glider2d.shape.area
    aspect_ratio = glider2d.shape.aspect_ratio


def glider_set_controlpoint(glider2d, x):
    c = deepcopy(glider2d.shape.front_curve.controlpoints)
    c[0, 0] = x
    glider2d.shape.front_curve.controlpoints = list(c)
    c = deepcopy(glider2d.shape.back_curve.controlpoints)
    c[0, 0] = x
    glider2d.shape.back_curve.controlpoints = list(c)
    glider2d.shape.set_aspect_ratio(aspect_ratio, "span")
    # glider2d.set_flat_area(area, "aspect_ratio")
    glider2d.shape.set_const_cell_dist()
Exemple #12
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)
Exemple #13
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)
Exemple #14
0
# -*- coding: utf-8 -*-
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from openglider.jsonify import load
from openglider.utils.distribution import Distribution
from openglider.glider.in_out.export_3d import paraBEM_Panels

import paraBEM
from paraBEM.pan3d import DirichletDoublet0Source0Case3 as Case
from paraBEM.vtk_export import CaseToVTK
from paraBEM.utils import v_inf_deg_range3, check_path

with open("glider/referenz_schirm_berg.json") as _file:
    parametricGlider = load(_file)["data"]
    parametricGlider.shape.set_const_cell_dist()
    glider = parametricGlider.get_glider_3d()

_, panels, trailing_edge = paraBEM_Panels(
    glider,
    midribs=3,
    profile_numpoints=70,
    distribution=Distribution.from_cos_2_distribution,
    num_average=0,
    symmetric=False)

v_inf = [8, 0, 1]

case = Case(panels, trailing_edge)
case.mom_ref_point = paraBEM.Vector3(1.25, 0, -6)
Exemple #15
0
# -*- coding: utf-8 -*-
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from openglider.jsonify import load
from openglider.utils.distribution import Distribution
from openglider.glider.in_out.export_3d import paraBEM_Panels

import paraBEM
from paraBEM.pan3d import DirichletDoublet0Source0Case3 as Case
from paraBEM.vtk_export import CaseToVTK
from paraBEM.utils import v_inf_deg_range3, check_path

with open("glider/referenz_schirm_berg.json") as _file:
    parametricGlider = load(_file)["data"]
    parametricGlider.shape.set_const_cell_dist()
    glider = parametricGlider.get_glider_3d()

_, panels, trailing_edge = paraBEM_Panels(
    glider,
    midribs=3,
    profile_numpoints=70,
    distribution=Distribution.from_cos_2_distribution,
    num_average=0,
    symmetric=False)

v_inf = [8, 0, 1]

case = Case(panels, trailing_edge)
case.mom_ref_point = paraBEM.Vector3(1.25, 0, -6)
Exemple #16
0
from openglider.glider.in_out.export_3d import paraBEM_Panels
from openglider.jsonify import load
import paraBEM
from paraBEM.pan3d import DirichletDoublet0Source0Case3 as Case
from paraBEM.vtk_export import CaseToVTK

with open("../openglider/glider/referenz_schirm_berg.json") as _file:
    glider = load(_file)["data"]
    panels = paraBEM_Panels(glider.get_glider_3d() , 0, 30, 0, False)

case = Case(panels[1], panels[2])
case.v_inf = paraBEM.Vector(glider.v_inf)
case.drag_calc = "on_body"
case.A_ref = glider.shape.area

#wake parallel to the x axis
print("*    wake parallel to the x-axis")
case.create_wake(50, 100, paraBEM.Vector3(1., 0., 0.))
case.run()
writer = CaseToVTK(case, "results/wake/x-parallel")
writer.write_panels()
writer.write_wake_panels()
print("F_l = ", case.cL * case.A_ref * 1.2 * 11**2 / 2.,
      "F_w = ", case.cD * case.A_ref * 1.2 * 11**2 / 2.)


#wake parallel to v_inf
print("*    wake parallel to v_inf")
case.create_wake(50, 100, case.v_inf)
case.run()
writer = CaseToVTK(case, "results/wake/v_inf-parallel")