# Path: aeropy/structural/stable_solution.py
# class properties():
#     def __init__(self, young=70e9, poisson=.3, dimensions=[0.01, 0.01],
#                  crosssection='square'):
#         """Stores calculates material or structural properties. If 'square',
#         dimensions = [width, height]"""
#         self.young = young
#         self.poisson = poisson
#         self.dimensions = dimensions
#         self.length = 1
# 
#         if crosssection == 'square':
#             self.area = dimensions[0]*dimensions[1]
#             self.inertia = (dimensions[0]*dimensions[1]**3)/12.
#         if young < 0 or poisson < 0 or poisson > 1 or self.area <= 0:
#             raise Exception('Material properties need to make sense')
# 
# class boundary_conditions():
#     def __init__(self, concentrated_load=np.array([[0, 0, 0], ]), load_x=[1],
#                        distributed_load = 0):
#         self.concentrated_load = concentrated_load
#         self.concentrated_x = load_x
#         self.concentrated_n = len(concentrated_load)
#         self.distributed_load = None
# 
#         self.distributed_load = distributed_load
# 
#         if len(concentrated_load) != len(load_x):
#             raise Exception('load values and x lists have to match')


from aeropy.geometry.parametric import CoordinateSystem
from aeropy.structural.stable_solution import (properties, boundary_conditions)
from aeropy.structural.shell import shell
from aeropy.xfoil_module import output_reader
from optimization_tools.DOE import DOE
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
import pickle
print(EB_solution[2:4])
beam.minimum_potential(x0=[0,0], input_function = lambda x: [0,0] + list(x),
                       bounds = bounds)
# coefficients, results, arc_length = beam.stepped_loading(x0=[0,0],
#                                              input_function = lambda x: [0,0] + list(x),
#                                              bounds = bounds)
# print('arc_length')
# print(arc_length)
# plt.figure()
# plt.scatter(-1*np.array(results[:,0]), -1*np.array(results[:,1]))
# plt.plot([0, 1], [0, 0.00564])
# plt.show()
#
# plt.figure()
# plt.plot(arc_length[:,0], arc_length[:,1])
# plt.show()

# beam.g_c.a = input_function(x)
# beam.mesh.mesh_child()
# beam.calculate_position()
# beam.strain()
# beam.stress(loading_condition='plane_stress')
#
# print('x', x)
# print('f', beam.opt_f)
# print('Residual', beam.residual(x, input_type = 'Geometry',
#                                 loading_condition = 'plane_stress',
#                                 input_function = input_function))
print('Strain energy for min: ', beam.U)
[x,y,z] = eulerBernoulle.T

# Path: aeropy/structural/stable_solution.py
# class properties():
#     def __init__(self, young=70e9, poisson=.3, dimensions=[0.01, 0.01],
#                  crosssection='square'):
#         """Stores calculates material or structural properties. If 'square',
#         dimensions = [width, height]"""
#         self.young = young
#         self.poisson = poisson
#         self.dimensions = dimensions
#         self.length = 1
# 
#         if crosssection == 'square':
#             self.area = dimensions[0]*dimensions[1]
#             self.inertia = (dimensions[0]*dimensions[1]**3)/12.
#         if young < 0 or poisson < 0 or poisson > 1 or self.area <= 0:
#             raise Exception('Material properties need to make sense')
# 
# class boundary_conditions():
#     def __init__(self, concentrated_load=np.array([[0, 0, 0], ]), load_x=[1],
#                        distributed_load = 0):
#         self.concentrated_load = concentrated_load
#         self.concentrated_x = load_x
#         self.concentrated_n = len(concentrated_load)
#         self.distributed_load = None
# 
#         self.distributed_load = distributed_load
# 
#         if len(concentrated_load) != len(load_x):
#             raise Exception('load values and x lists have to match')


# Path: examples/structural/beam.py
from aeropy.geometry.parametric import CoordinateSystem
from aeropy.structural.stable_solution import (properties, boundary_conditions)
from aeropy.structural.shell import shell
from aeropy.xfoil_module import output_reader
from optimization_tools.DOE import DOE
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
import pickle

print(EB_solution[2:4])
beam.minimum_potential(x0=[0,0], input_function = lambda x: [0,0] + list(x),
                       bounds = bounds)
# coefficients, results, arc_length = beam.stepped_loading(x0=[0,0],
#                                              input_function = lambda x: [0,0] + list(x),
#                                              bounds = bounds)
# print('arc_length')
# print(arc_length)
# plt.figure()
# plt.scatter(-1*np.array(results[:,0]), -1*np.array(results[:,1]))
# plt.plot([0, 1], [0, 0.00564])
# plt.show()
#
# plt.figure()
# plt.plot(arc_length[:,0], arc_length[:,1])
# plt.show()

# beam.g_c.a = input_function(x)
# beam.mesh.mesh_child()
# beam.calculate_position()
# beam.strain()
# beam.stress(loading_condition='plane_stress')
#
# print('x', x)
# print('f', beam.opt_f)
# print('Residual', beam.residual(x, input_type = 'Geometry',
#                                 loading_condition = 'plane_stress',
#                                 input_function = input_function))
print('Strain energy for min: ', beam.U)
[x,y,z] = eulerBernoulle.T

beam.g_p.plot(label='Parent')