SU2_inviscid_Super.py errors

71 views
Skip to first unread message

Дмитрий Тарабащук

unread,
Aug 12, 2022, 1:24:38 PM8/12/22
to SUAVE FORUM
Dear SUAVE team,

I am trying to implement  SU2_inviscid_Super.py  method for Concorde tutorial (in my case a bit updated, but it based on Concorde). Instead of calculation Cd and CL  I use as input base_data.txt. 
So when I ran the tutorial with this method I get following errors (screenshots are attached).
Something wrong with Gaussian process, but I cannot understand what is not right.
My goal is include in suave CL, CD calculated in another cfd code into SUAVE. For me seemed a good idea to use SU2_inviscid_Super.py method in Concorde tutorial and add calculated coefficients for supersonic case.
 Dear team could you help me or guide in a right direction. (Thank you in advance!)

kind regards,
Dmitrii


2.png
1.png

Emilio

unread,
Aug 15, 2022, 4:48:15 PM8/15/22
to SUAVE FORUM
Hi,
It looks like this has to do with the version of scikit learn. The code that works for the latest version of scikit learn is included below and commented out below. So switch which one is commented out.

-Emilio

Дмитрий Тарабащук

unread,
Aug 16, 2022, 4:13:45 AM8/16/22
to SUAVE FORUM
Emilio, 
I tried different version of scikit learn, it didn't help to manage the error, so I decided change code in changed SU2_inviscid_Super.py a bit  to this (added Regressor):
        # Gaussian Process New
        regr_cl_sup = gaussian_process.GaussianProcessRegressor()
        regr_cl_sub = gaussian_process.GaussianProcessRegressor()
        cl_surrogate_sup = regr_cl_sup.fit(xy[xy[:,1]>=1.], CL_data[xy[:,1]>=1.])
        cl_surrogate_sub = regr_cl_sub.fit(xy[xy[:,1]<=1.], CL_data[xy[:,1]<=1.])  
        regr_cd = gaussian_process.GaussianProcessRegressor()
        cd_surrogate = regr_cd.fit(xy, CD_data)   

Now it works, but I faced with another error:
Reseting OpenVSP Model in Memory
Writing main_wing to OpenVSP Model
Writing fuselage_1 to OpenVSP Model
Saving OpenVSP File at C:\Users\Dmitry\Desktop\Suave_aero/base.vsp3
Traceback (most recent call last):
  File "C:\Users\Dmitry\Desktop\Suave_aero\Emerald_shape_ramjet_data.py", line 876, in <module>
    main()
  File "C:\Users\Dmitry\Desktop\Suave_aero\Emerald_shape_ramjet_data.py", line 50, in main
    analyses.finalize()
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Analysis.py", line 271, in finalize
    analysis.finalize(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Analysis.py", line 271, in finalize
    analysis.finalize(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Analysis.py", line 271, in finalize
    analysis.finalize(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Aerodynamics\SU2_Euler_Super.py", line 148, in initialize
    self.process.compute.lift.inviscid.initialize()
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Aerodynamics\SU2_inviscid_Super.py", line 103, in initialize
    self.build_surrogate()
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Aerodynamics\SU2_inviscid_Super.py", line 314, in build_surrogate
    CL_sur[ii,jj] = cl_surrogate_sub.predict(np.array([AoA_mesh[ii,jj],mach_mesh[ii,jj]]))
  File "C:\Users\Dmitry\anaconda3\lib\site-packages\sklearn\gaussian_process\_gpr.py", line 323, in predict
    X = check_array(X, ensure_2d=True, dtype="numeric")
  File "C:\Users\Dmitry\anaconda3\lib\site-packages\sklearn\utils\validation.py", line 63, in inner_f
    return f(*args, **kwargs)
  File "C:\Users\Dmitry\anaconda3\lib\site-packages\sklearn\utils\validation.py", line 637, in check_array
    raise ValueError(
ValueError: Expected 2D array, got 1D array instead:
array=[-0.01919862  0.2       ].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.\

For input I use calculated CD and CL1.png
Could you help what I do wrong, may be there is mistake in my input data?

P.S. 
Gaussian Process New works and show the same error as above
        # Gaussian Process New
        #regr_cl_sup = gaussian_process.GaussianProcessRegressor()
        #regr_cl_sub = gaussian_process.GaussianProcessRegressor()
        #regr_cd = gaussian_process.GaussianProcessRegressor()
        #cl_surrogate_sup = regr_cl_sup.fit(xy, CL_data)
        #cl_surrogate_sub = regr_cl_sub.fit(xy, CL_data)
        #cd_surrogate = regr_cd.fit(xy, CD_data)  
понедельник, 15 августа 2022 г. в 22:48:15 UTC+2, Emilio:

Emilio

unread,
Aug 16, 2022, 10:31:41 PM8/16/22
to SUAVE FORUM
Not sure what's going on here. This piece of code isn't really maintained by anyone right now.

It says it's expecting a 2-D array when a 1-D was provided. You could add extra brackets here, \SUAVE\Analyses\Aerodynamics\SU2_inviscid_Super.py", line 314

The training of the surrogate should be 2D by its nature, so don't flatten it.

-Emilio 

Дмитрий Тарабащук

unread,
Aug 17, 2022, 2:02:09 AM8/17/22
to SUAVE FORUM
Dear Emilio,
Thank you for advice, It helped me move forward a bit.
I did the following: Changed in SU2_inviscid_Super. py all brackets as in 314  line  '"predict(np.array([AoA_mesh[ii,jj],mach_mesh[ii,jj]]))"  to brackets as in SU2_inviscid. py ""predict([np.array([AoA_mesh[ii,jj],mach_mesh[ii,jj]])])""
But another one error happened.
Could you look or give advice?

Reseting OpenVSP Model in Memory
Writing main_wing to OpenVSP Model
Writing FuselageGeom_1 to OpenVSP Model
Saving OpenVSP File at C:\Users\Dmitry\Desktop\Emerald/base.vsp3

Traceback (most recent call last):
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Core\Data.py", line 67, in __getattribute__
    return dictgetitem(self,k)
KeyError: 'begin_drag_rise_mach_number'

During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "C:\Users\Dmitry\Desktop\Emerald\Emerald.py", line 876, in <module>
    main()
  File "C:\Users\Dmitry\Desktop\Emerald\Emerald.py", line 58, in main
    results = mission.evaluate()
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Mission\Segments\Segment.py", line 180, in evaluate
    self.process(self)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 96, in __call__
    return self.evaluate(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 67, in evaluate
    result = step(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Methods\Missions\Segments\Common\Sub_Segments.py", line 137, in sequential_sub_segments
    sub_segment.evaluate()
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Mission\Segments\Segment.py", line 180, in evaluate
    self.process(self)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 96, in __call__
    return self.evaluate(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 65, in evaluate
    result = step.evaluate(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 67, in evaluate
    result = step(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Methods\Missions\Segments\converge_root.py", line 50, in converge_root
    unknowns,infodict,ier,msg = root_finder( iterate,
  File "C:\Users\Dmitry\anaconda3\lib\site-packages\scipy\optimize\minpack.py", line 160, in fsolve
    res = _root_hybr(func, x0, args, jac=fprime, **options)
  File "C:\Users\Dmitry\anaconda3\lib\site-packages\scipy\optimize\minpack.py", line 226, in _root_hybr
    shape, dtype = _check_func('fsolve', 'func', func, x0, args, n, (n,))
  File "C:\Users\Dmitry\anaconda3\lib\site-packages\scipy\optimize\minpack.py", line 24, in _check_func
    res = atleast_1d(thefunc(*((x0[:numinputs],) + args)))
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Methods\Missions\Segments\converge_root.py", line 99, in iterate
    segment.process.iterate(segment)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 96, in __call__
    return self.evaluate(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 65, in evaluate
    result = step.evaluate(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 67, in evaluate
    result = step(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Methods\Missions\Segments\Common\Aerodynamics.py", line 189, in update_aerodynamics
    results = aerodynamics_model( segment.state )
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Analysis.py", line 155, in __call__
    return self.evaluate(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Aerodynamics\Markup.py", line 84, in evaluate
    results = self.process.compute(state,settings,geometry)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 96, in __call__
    return self.evaluate(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 65, in evaluate
    result = step.evaluate(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 65, in evaluate
    result = step.evaluate(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Analyses\Process.py", line 67, in evaluate
    result = step(*args,**kwarg)
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Methods\Aerodynamics\Supersonic_Zero\Drag\compressibility_drag_total.py", line 64, in compressibility_drag_total
    low_mach_cutoff  = settings.begin_drag_rise_mach_number
  File "C:\Users\Dmitry\AppData\Roaming\Python\Python39\site-packages\suave-2.5.2-py3.9.egg\SUAVE\Core\Data.py", line 69, in __getattribute__
    return objgetattrib(self,k)
AttributeError: 'Data' object has no attribute 'begin_drag_rise_mach_number'

kind regards,
Dmitrii
среда, 17 августа 2022 г. в 04:31:41 UTC+2, Emilio:
Reply all
Reply to author
Forward
0 new messages