Error raised in 'Battery_Propeller' energy network

442 views
Skip to first unread message

Nils Barner

unread,
Jan 15, 2022, 1:00:02 PM1/15/22
to SUAVE FORUM
Dear SUAVE team,

I hope you are well. I am currently in the process of electrifying the Embraer E190 AR from the regional jet tutorial, for which I am using the eVTOL and solar UAV tutorials as reference.

I have chosen the 'Battery_Propeller' network in combination with the standard 'Lithium_Ion.py' energy storage option. Unfortunately, my script ('E190_electric_single.py') raises the following error in the 'Battery_Propeller.py' file: 

AttributeError: 'Conditions' object has no attribute 'battery_discharge_flag'

I have been tracking the error back to the various mission segments, however, I was not able to discern its origin. Please find attached the full error message:

Traceback (most recent call last):
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Core\Data.py", line 67, in __getattribute__
    return dictgetitem(self,k)
KeyError: 'battery_discharge_flag'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Nils Barner/Desktop/PhD Phase/SUAVE Standard (local)/SUAVE-2.5.0/trunk/SUAVE/Embraer E190 Battery Powered/E190_electric_single.py", line 1100, in <module>
    main()    
  File "C:/Users/Nils Barner/Desktop/PhD Phase/SUAVE Standard (local)/SUAVE-2.5.0/trunk/SUAVE/Embraer E190 Battery Powered/E190_electric_single.py", line 78, in main
    results = mission.evaluate()
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Mission\Segments\Segment.py", line 180, in evaluate
    self.process(self)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Process.py", line 96, in __call__
    return self.evaluate(*args,**kwarg)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Process.py", line 67, in evaluate
    result = step(*args,**kwarg)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Methods\Missions\Segments\Common\Sub_Segments.py", line 137, in sequential_sub_segments
    sub_segment.evaluate()
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Mission\Segments\Segment.py", line 180, in evaluate
    self.process(self)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Process.py", line 96, in __call__
    return self.evaluate(*args,**kwarg)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Process.py", line 65, in evaluate
    result = step.evaluate(*args,**kwarg)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Process.py", line 67, in evaluate
    result = step(*args,**kwarg)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Methods\Missions\Segments\converge_root.py", line 56, in converge_root
    full_output = 1)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\optimize\minpack.py", line 147, in fsolve
    res = _root_hybr(func, x0, args, jac=fprime, **options)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\optimize\minpack.py", line 213, in _root_hybr
    shape, dtype = _check_func('fsolve', 'func', func, x0, args, n, (n,))
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\optimize\minpack.py", line 26, in _check_func
    res = atleast_1d(thefunc(*((x0[:numinputs],) + args)))
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Methods\Missions\Segments\converge_root.py", line 99, in iterate
    segment.process.iterate(segment)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Process.py", line 96, in __call__
    return self.evaluate(*args,**kwarg)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Process.py", line 65, in evaluate
    result = step.evaluate(*args,**kwarg)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Process.py", line 67, in evaluate
    result = step(*args,**kwarg)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Methods\Missions\Segments\Common\Energy.py", line 90, in update_thrust
    results   = energy_model.evaluate_thrust(segment.state)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Analyses\Energy\Energy.py", line 65, in evaluate_thrust
    results = network.evaluate_thrust(state)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Components\Energy\Networks\Network.py", line 133, in evaluate_thrust
    results_p = net.evaluate_thrust(state)
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Components\Energy\Networks\Battery_Propeller.py", line 139, in evaluate_thrust
    battery.discharge_flag           = conditions.propulsion.battery_discharge_flag
  File "C:\Users\Nils Barner\AppData\Local\Programs\Python\Python36\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Core\Data.py", line 69, in __getattribute__
    return objgetattrib(self,k)
AttributeError: 'Conditions' object has no attribute 'battery_discharge_flag'


Many thanks in advance for your time and please let me know if further details would be of any help.

Best wishes,
Nils


Emilio

unread,
Jan 17, 2022, 8:03:38 PM1/17/22
to SUAVE FORUM
Hi Nils,
I think I know what's going on. The new version of SUAVE requires a little bit of extra setup for the missions when using a battery powered aircraft. The previous versions didn't require this. Check to make sure you have a line like this in your mission setup.

Let me know how that works.

-Emilio

Nils Barner

unread,
Jan 18, 2022, 3:56:25 PM1/18/22
to SUAVE FORUM
Dear Emilio,

Thank you for your prompt reply. My understanding is that the line you indicated would be needed if I were to optimise an electrified Embraer E190 AR (as done in the regional jet tutorial for the wing area and cruise altitude, where said line is indeed missing).

However, as of now I merely aim to perform an analysis of a fully defined aircraft on a single mission (as shown in the standard B737-800 tutorial), using the 'Battery_Propeller.py' network in combination with 'Lithium_Ion.py', instead of the default 'Turbofan.py' network. I might not have been very clear before, apologies for that.

My code is literally a single self-contained script (similar to what you produced in your eVTOL tutorial), from which I would like to extract the standard set of mission performance plots.

I hope this helps and I would be grateful for any suggestions.

Best wishes,
Nils

Emilio

unread,
Jan 21, 2022, 12:30:03 AM1/21/22
to SUAVE FORUM
Hi Nils,
Have you tried the suggestion I provided?

-Emilio

Nils Barner

unread,
Jan 21, 2022, 3:19:03 AM1/21/22
to SUAVE FORUM
Dear Emilio,

I did implement the line you suggested (please see the attached image named 'Mission_setup.png'), however, I still get the error message from my first email.
I also attached an image of the 'Battery_propeller' network I am using. I hope this helps.

Thank you in advance for your time.

Best wishes,
Nils
Battery_propeller_network.png
Mission_setup.png

Emilio

unread,
Jan 26, 2022, 12:24:32 PM1/26/22
to SUAVE FORUM
Hi Nils,
The image is cut off a little bit. Do the segments inherit from base segment?

-Emilio

Luuk ten Damme

unread,
Jan 31, 2022, 4:58:05 AM1/31/22
to SUAVE FORUM
Dear Nils and Emilio,

I have the same problem as Nils. I tried to modify the eVTOL tutorial to my own UAV using only propellers and no rotors. Therefore, I changed from the Lift_Cruise network to the Battery_propeller network, resulting in a similar error as shown below. I do not understand how to make the script working properly .

Thank you in advance for your help.

Kind regards,

Luuk

  File "C:\ProgramData\Anaconda3\envs\vsppytools\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Components\Energy\Networks\Network.py", line 133, in evaluate_thrust
    results_p = net.evaluate_thrust(state)
  File "C:\ProgramData\Anaconda3\envs\vsppytools\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Components\Energy\Networks\Battery_Propeller.py", line 139, in evaluate_thrust
    discharge_flag                   = conditions.propulsion.battery_discharge_flag    
  File "C:\ProgramData\Anaconda3\envs\vsppytools\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Core\Data.py", line 69, in __getattribute__

    return objgetattrib(self,k)
AttributeError: 'Conditions' object has no attribute 'battery_discharge_flag'

Nils Barner

unread,
Jan 31, 2022, 8:06:04 AM1/31/22
to SUAVE FORUM
Dear Emilio,

Apologies for the delayed reply. All segments of my mission inherit from the base segment, as demonstrated in the "tut_mission_B737.py" tutorial. Seeing that it is difficult to take a screenshot of all relevant code sections, I have attached my script as ".py" file.
For your information, I have not made any modifications to the SUAVE standard install folder apart from the attached script. Also, do not mind the sub-system and mission input parameters, which still require fine-tuning, but perhaps you can infer what could be causing the AttributeError: 'Conditions' object has no attribute 'battery_discharge_flag'.

Hopefully this will help Luuk to crack on with his UAV analysis too.

Best wishes and many thanks in advance,
Nils
E190_electric_for_Emilio.py

Hu gePanic

unread,
Feb 1, 2022, 7:43:09 AM2/1/22
to SUAVE FORUM
I have the same problem with the  Estimate take off field length function.

I can run the typical analysis with the Battery_Propeller()-Network.

I have this error when using the estimate_take_off_field_length function

my code:
from SUAVE.Methods.Performance import estimate_take_off_field_length
from SUAVE.Attributes.Airports import Airport

vehicle = setup_vehicle()
vehicle.networks.battery_propeller.battery_energy =vehicle.networks.battery_propeller.battery.max_energy*0.95   #charge battery
airport = Airport()
airport
estimate_take_off_field_length(vehicle,analyses,airport,compute_2nd_seg_climb = 0)


Result:
image_2022-02-01_134252.png

Luuk ten Damme

unread,
Feb 7, 2022, 4:54:13 AM2/7/22
to SUAVE FORUM
Dear all,

I tried to solve it by adding "segment = vehicle.networks.battery_propeller.add_unknowns_and_residuals_to_segment(segment)" just before appending to the mission, since in the Battery_Propeller.py script it is stated that "This function sets up the information that the mission needs to run a mission segment using this network'". However, after running it, I obtain the error:
 
File "C:\ProgramData\Anaconda3\envs\vsppytools\lib\site-packages\suave-2.5.0-py3.6.egg\SUAVE\Components\Energy\Networks\Battery_Propeller.py", line 163, in evaluate_thrust
esc.inputs.voltagein = volts
AttributeError: 'NoneType' object has no attribute 'inputs'.

However, when I print(volts),  it shows the value of 400V that I set in my net.voltage and bat.max_voltage.  Does someone know how to solve this problem?
[[400.]
 [400.]
 [400.]
 [400.]
 [400.]
 [400.]
 [400.]
 [400.]]

Matthew Clarke

unread,
Feb 10, 2022, 3:09:38 PM2/10/22
to SUAVE FORUM
Hi Luuk, 

I wrote these scripts so maybe I can help with your issues.

A few things to check
  1. Since you changed the network, please check that in the mission, you are appending the unknowns,residuals etc. to the battery_propeller network not the lift_cruise network
  2. make sure you set the network voltage (can be maximum battery voltage)
  3. ensure that the first segment has an assigned battery energy
  4. you made want to add "base_segment.battery_discharge                           = True  " at the beginning to of the mission_setup.py where you define a base_segment so that you don't have to add this onto each segment.
  5. the header of the mission_setup.py() should read something like this:
   
    # base segment
    base_segment                                             = Segments.Segment()
    ones_row                                                 = base_segment.state.ones_row
    base_segment.process.initialize.initialize_battery       = SUAVE.Methods.Missions.Segments.Common.Energy.initialize_battery
    base_segment.process.finalize.post_process.update_battery_state_of_health = SUAVE.Methods.Missions.Segments.Common.Energy.update_battery_state_of_health  
    base_segment.process.iterate.conditions.planet_position  = SUAVE.Methods.skip
    base_segment.state.numerics.number_control_points        = control_points
    bat                                                      = vehicle.networks.battery_propeller.battery
    base_segment.charging_SOC_cutoff                         = bat.cell.charging_SOC_cutoff
    base_segment.charging_current                            = bat.charging_current
    base_segment.charging_voltage                            = bat.charging_voltage
    base_segment.battery_discharge                           = True  

RON SHAHRIER

unread,
Aug 25, 2025, 3:09:38 PMAug 25
to SUAVE FORUM
Hello Matthew, I am also getting the error:  File "C:\Users\Administrator\anaconda3\envs\openVSP\lib\site-packages\suave-2.5.2-py3.6.egg\SUAVE\Components\Energy\Networks\Battery_Propeller.py", line 162, in evaluate_thrust

    esc.inputs.voltagein = volts
AttributeError: 'NoneType' object has no attribute 'inputs'

 I tried your Solution and it does not work. 


Anyone else found any solution yet?

RON SHAHRIER

unread,
Aug 26, 2025, 4:19:19 AMAug 26
to SUAVE FORUM
Found the solution to my error. After going through output of print(vehicle), found out network.propeller esc was initialized, but network.esc was still none (My vehicle has only propellers, no lift rotors).
Solution: also initialize network.esc 

esc = SUAVE.Components.Energy.Distributors.Electronic_Speed_Controller()
esc.efficiency = 0.95
net.propeller_esc = esc
net.esc = esc
Reply all
Reply to author
Forward
0 new messages