So could you tell me how can I modify the variable_costs (original value is 0.22) of node.outputs.data[bel].variable_costs? when I tried to print out this node.outputs.data[bel].variable_costs, I got empty list [ ].
I dont really know but you should be able to pass a list with as many items as your length of the datetime index of your energysystem. But I dont get at what point do you want to alter the variable_costs?
Do you want to change the variable_costs before adding the node to the energysystem?
Have you already added the node to your energysystem?
Do you want to change the variable_costs in the flow before solving the model?
I do not really understand your problem without your code.
Supposing that I have a python (executable) program/script (e.g. base.py) which is used to created nodes, energy_system and also to solve the optimization model. The problem is that I can not modify anything in this python script base.py but this base.py allows me to get nodes or energy_system created by itself to add/modify the attributes in an external python script before solve optimization model.
So what I am trying to do is found in external_script.py which nodes created by base.py. Indeed I want not only to modify the node attributes but to add new ones as well.
Finally, I think that I could you the following script to update variable_costs. I’m not sure this is a best way but at least it works
for node in nodes:
if isinstance(node,solph.network.Source):
if node.label=="grid_elec":
node.label="grid_electricity"
node.outputs[bel].variable_costs = [0.3]*len(energy_system.timeindex)