linopf doesn't report time-dependent optimisation results if components are added after an optimisation
The `pyomo=False` version of LOPF in `linopf` has a small bug. If you:

- run an optimisation
- then add a generator/link/store
- rerun the optimisation
- then the time-dependent variables (p, p1) for the new components are not saved in `n.generators_t.p` etc

In the old code in `opf.py` a function called `allocate_series_dataframes` from `descriptors.py` was called before assigning results to avoid this behaviour. It essentially reindexes the dataframes with the latest component names.
Probably @FabianHofmann doesn't like this solution, otherwise I would add it myself :-).
diff --git a/pypsa/linopf.py b/pypsa/linopf.py
index 72fb71eb..345bc8f4 100644
--- a/pypsa/linopf.py
+++ b/pypsa/linopf.py
@@ -950,7 +950,7 @@ def assign_solution(n, sns, variables_sol, constraints_dual,
         elif pnl[attr].empty:
             pnl[attr] = df.reindex(n.snapshots, fill_value=0)
         else:
-            pnl[attr].loc[sns, :] = df.reindex(columns=pnl[attr].columns)
+            pnl[attr].loc[sns, df.columns] = df
 
     pop = not keep_references
     def map_solution(c, attr):
diff --git a/test/test_bugs.py b/test/test_bugs.py
index 8842c36f..7c17c283 100644
--- a/test/test_bugs.py
+++ b/test/test_bugs.py
@@ -15,3 +15,14 @@ def test_344():
     network.add("Generator", "a", bus="a", p_nom=5)
 
     network.lopf(pyomo=False)
+
+
+def test_331():
+    n = pypsa.Network()
+    n.add("Bus", 'bus')
+    n.add('Load', 'load', bus='bus', p_set=10)
+    n.add('Generator', 'generator1', bus='bus', p_nom=15, marginal_cost=10)
+    n.lopf(pyomo=False)
+    n.add('Generator', 'generator2', bus='bus', p_nom=5, marginal_cost=5)
+    n.lopf(pyomo=False)
+    assert 'generator2' in n.generators_t.p
['test/test_bugs.py', 'pypsa/linopf.py']