`optimize.assign_solution` does not copy nominal capacities to optimal for fixed assets
<!-- Please do not post usage questions here. Ask them on the PyPSA mailing list: https://groups.google.com/forum/#!forum/pypsa -->

## Checklist

- [x] I am using the current [`master`](https://github.com/pypsa/pypsa/tree/master) branch or the latest [release](https://github.com/pypsa/pypsa/releases). Please indicate:

## Describe the Bug

https://github.com/PyPSA/PyPSA/blob/af49562c08cb2bbbb755cda576a7a5035b9ba8f9/pypsa/optimization/optimize.py#L275-L278
does not trigger as soon as there are any extendable assets.


diff --git a/pypsa/optimization/optimize.py b/pypsa/optimization/optimize.py
index c464ac72..e5544075 100644
--- a/pypsa/optimization/optimize.py
+++ b/pypsa/optimization/optimize.py
@@ -274,8 +274,9 @@ def assign_solution(n):
 
     # if nominal capacity was no variable set optimal value to nominal
     for (c, attr) in lookup.query("nominal").index:
-        if f"{c}-{attr}" not in m.variables:
-            n.df(c)[attr + "_opt"] = n.df(c)[attr]
+        fix_i = n.get_non_extendable_i(c)
+        if not fix_i.empty:
+            n.df(c).loc[fix_i, f"{attr}_opt"] = n.df(c).loc[fix_i, attr]
 
     # recalculate storageunit net dispatch
     if not n.df("StorageUnit").empty:
['pypsa/optimization/optimize.py']