Skip to content

Commit 1b3800d

Browse files
committed
Update OpenFOAM example
1 parent 2eeb642 commit 1b3800d

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

examples/openfoam/openfoam-minimal.ipynb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@
633633
},
634634
{
635635
"cell_type": "code",
636-
"execution_count": 18,
636+
"execution_count": null,
637637
"metadata": {},
638638
"outputs": [
639639
{
@@ -649,17 +649,21 @@
649649
],
650650
"source": [
651651
"# Plot drag coefficient (Cd) vs time\n",
652-
"plt.plot(data.iloc[100:, 0], data.iloc[100:, 2])\n",
652+
"# Convert the pandas Series to NumPy arrays using .to_numpy()\n",
653+
"plt.plot(data.iloc[100:, 0].to_numpy(), data.iloc[100:, 2].to_numpy())\n",
654+
"# Alternatively, you could use .values:\n",
655+
"# plt.plot(data.iloc[100:, 0].values, data.iloc[100:, 2].values)\n",
656+
"\n",
653657
"plt.xlabel(\"Time\")\n",
654-
"plt.ylabel(\"$C_d$\")\n",
658+
"plt.ylabel(\"$C_d$\") # Using LaTeX for C_d\n",
655659
"plt.title(\"Drag Coefficient vs Time\")\n",
656-
"plt.grid(False)\n",
660+
"plt.grid(False) # As per your original code, grid is off. Set to True if you want a grid.\n",
657661
"plt.show()"
658662
]
659663
},
660664
{
661665
"cell_type": "code",
662-
"execution_count": 19,
666+
"execution_count": null,
663667
"metadata": {},
664668
"outputs": [
665669
{
@@ -675,7 +679,8 @@
675679
],
676680
"source": [
677681
"# Plot lift coefficient (Cl) vs time\n",
678-
"plt.plot(data.iloc[100:, 0], data.iloc[100:, 3])\n",
682+
"plt.plot(data.iloc[100:, 0].to_numpy(), data.iloc[100:, 3].to_numpy())\n",
683+
"# plt.plot(data.iloc[100:, 0], data.iloc[100:, 3])\n",
679684
"plt.xlabel(\"Time\")\n",
680685
"plt.ylabel(\"$C_l$\")\n",
681686
"plt.title(\"Lift Coefficient vs Time\")\n",

examples/openfoam/openfoam.ipynb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,11 +1110,15 @@
11101110
],
11111111
"source": [
11121112
"# Plot drag coefficient (Cd) vs time\n",
1113-
"plt.plot(data.iloc[100:, 0], data.iloc[100:, 2])\n",
1113+
"# Convert the pandas Series to NumPy arrays using .to_numpy()\n",
1114+
"plt.plot(data.iloc[100:, 0].to_numpy(), data.iloc[100:, 2].to_numpy())\n",
1115+
"# Alternatively, you could use .values:\n",
1116+
"# plt.plot(data.iloc[100:, 0].values, data.iloc[100:, 2].values)\n",
1117+
"\n",
11141118
"plt.xlabel(\"Time\")\n",
1115-
"plt.ylabel(\"$C_d$\")\n",
1119+
"plt.ylabel(\"$C_d$\") # Using LaTeX for C_d\n",
11161120
"plt.title(\"Drag Coefficient vs Time\")\n",
1117-
"plt.grid(True)\n",
1121+
"plt.grid(False) # As per your original code, grid is off. Set to True if you want a grid.\n",
11181122
"plt.show()"
11191123
]
11201124
},
@@ -1136,7 +1140,8 @@
11361140
],
11371141
"source": [
11381142
"# Plot lift coefficient (Cl) vs time\n",
1139-
"plt.plot(data.iloc[100:, 0], data.iloc[100:, 3])\n",
1143+
"plt.plot(data.iloc[100:, 0].to_numpy(), data.iloc[100:, 3].to_numpy())\n",
1144+
"# plt.plot(data.iloc[100:, 0], data.iloc[100:, 3])\n",
11401145
"plt.xlabel(\"Time\")\n",
11411146
"plt.ylabel(\"$C_l$\")\n",
11421147
"plt.title(\"Lift Coefficient vs Time\")\n",

0 commit comments

Comments
 (0)