@@ -1093,9 +1093,31 @@ function underscore_to_D(v::AbstractVector, sys)
1093
1093
for (k, v) in maps
1094
1094
push! (get! (() -> valtype (inv_maps)[], inv_maps, v), k)
1095
1095
end
1096
- map (Base. Fix2 (underscore_to_D, inv_maps), v)
1096
+ iv = get_iv (sys)
1097
+ map (x -> underscore_to_D (x, iv, inv_maps), v)
1097
1098
end
1098
1099
1099
- function underscore_to_D (v, inv_map)
1100
- only (get (inv_map, v, [v]))
1100
+ function underscore_to_D (v, iv, inv_map)
1101
+ if haskey (inv_map, v)
1102
+ only (get (inv_map, v, [v]))
1103
+ else
1104
+ v = ModelingToolkit. detime_dvs (v)
1105
+ s = split (string (getname (v)), ' ˍ' )
1106
+ if length (s) > 1
1107
+ n, suffix = s
1108
+ else
1109
+ n, suffix = first (s), " "
1110
+ end
1111
+ repeats = length (suffix) ÷ length (string (iv))
1112
+ D = Differential (iv)
1113
+ wrap_with_D (Symbol (n), D, repeats)
1114
+ end
1101
1115
end
1116
+
1117
+ function wrap_with_D (n, D, repeats)
1118
+ if repeats <= 0
1119
+ return n
1120
+ else
1121
+ wrap_with_D (D (n), D, repeats - 1 )
1122
+ end
1123
+ end
0 commit comments