Skip to content

Commit c4440f6

Browse files
committed
Ruff format pylauncher notebook
1 parent dcd3af9 commit c4440f6

1 file changed

Lines changed: 81 additions & 1 deletion

File tree

examples/pylauncher_sweep.ipynb

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,87 @@
193193
"execution_count": null,
194194
"metadata": {},
195195
"outputs": [],
196-
"source": "input_dir_opensees = MYDATA / \"opensees_sweep\"\ninput_dir_opensees.mkdir(parents=True, exist_ok=True)\n\ncantilever_script = '''\\\n# Ex1a.Canti2D.Push — OpenSeesPy cantilever pushover\n# Based on the OpenSees Examples Manual\n# Units: kip, inch, second\n#\n# Command-line arguments (set by PyLauncher per task):\n# --NodalMass mass at free node\n# --LCol column length\n# --outDir output directory for this run\n\nimport argparse\nimport os\n\nif os.path.exists(\"opensees.so\"):\n import opensees as ops\nelse:\n import openseespy.opensees as ops\n\nparser = argparse.ArgumentParser()\nparser.add_argument(\"--NodalMass\", type=float, required=True)\nparser.add_argument(\"--LCol\", type=float, required=True)\nparser.add_argument(\"--outDir\", type=str, required=True)\nargs = parser.parse_args()\n\nNodalMass = args.NodalMass\nLCol = args.LCol\noutDir = args.outDir\n\nos.makedirs(outDir, exist_ok=True)\nprint(f\"Running: NodalMass={NodalMass}, LCol={LCol}, outDir={outDir}\")\n\nops.wipe()\nops.model(\"basic\", \"-ndm\", 2, \"-ndf\", 3)\n\n# Geometry\nops.node(1, 0, 0)\nops.node(2, 0, LCol)\nops.fix(1, 1, 1, 1)\nops.mass(2, NodalMass, 0.0, 0.0)\n\n# Element\nops.geomTransf(\"Linear\", 1)\nops.element(\"elasticBeamColumn\", 1, 1, 2, 3600000000, 4227, 1080000, 1)\n\n# Recorders\nops.recorder(\"Node\", \"-file\", f\"{outDir}/DFree.out\", \"-time\", \"-node\", 2, \"-dof\", 1, 2, 3, \"disp\")\nops.recorder(\"Node\", \"-file\", f\"{outDir}/RBase.out\", \"-time\", \"-node\", 1, \"-dof\", 1, 2, 3, \"reaction\")\nops.recorder(\"Element\", \"-file\", f\"{outDir}/FCol.out\", \"-time\", \"-ele\", 1, \"globalForce\")\n\n# Gravity analysis\nops.timeSeries(\"Linear\", 1)\nops.pattern(\"Plain\", 1, 1)\nops.load(2, 0.0, -2000.0, 0.0)\nops.wipeAnalysis()\nops.constraints(\"Plain\")\nops.numberer(\"Plain\")\nops.system(\"BandGeneral\")\nops.test(\"NormDispIncr\", 1.0e-8, 6)\nops.algorithm(\"Newton\")\nops.integrator(\"LoadControl\", 0.1)\nops.analysis(\"Static\")\nops.analyze(10)\nops.loadConst(\"-time\", 0.0)\n\n# Pushover analysis\nops.timeSeries(\"Linear\", 2)\nops.pattern(\"Plain\", 2, 2)\nops.load(2, 2000.0, 0.0, 0.0)\nops.integrator(\"DisplacementControl\", 2, 1, 0.1)\nops.analyze(1000)\n\nprint(f\"Done: NodalMass={NodalMass}, LCol={LCol}\")\n'''\n\n(input_dir_opensees / \"cantilever.py\").write_text(cantilever_script)\nprint(f\"Wrote {input_dir_opensees}/cantilever.py\")"
196+
"source": [
197+
"input_dir_opensees = MYDATA / \"opensees_sweep\"\n",
198+
"input_dir_opensees.mkdir(parents=True, exist_ok=True)\n",
199+
"\n",
200+
"cantilever_script = \"\"\"\\\n",
201+
"# Ex1a.Canti2D.Push — OpenSeesPy cantilever pushover\n",
202+
"# Based on the OpenSees Examples Manual\n",
203+
"# Units: kip, inch, second\n",
204+
"#\n",
205+
"# Command-line arguments (set by PyLauncher per task):\n",
206+
"# --NodalMass mass at free node\n",
207+
"# --LCol column length\n",
208+
"# --outDir output directory for this run\n",
209+
"\n",
210+
"import argparse\n",
211+
"import os\n",
212+
"\n",
213+
"if os.path.exists(\"opensees.so\"):\n",
214+
" import opensees as ops\n",
215+
"else:\n",
216+
" import openseespy.opensees as ops\n",
217+
"\n",
218+
"parser = argparse.ArgumentParser()\n",
219+
"parser.add_argument(\"--NodalMass\", type=float, required=True)\n",
220+
"parser.add_argument(\"--LCol\", type=float, required=True)\n",
221+
"parser.add_argument(\"--outDir\", type=str, required=True)\n",
222+
"args = parser.parse_args()\n",
223+
"\n",
224+
"NodalMass = args.NodalMass\n",
225+
"LCol = args.LCol\n",
226+
"outDir = args.outDir\n",
227+
"\n",
228+
"os.makedirs(outDir, exist_ok=True)\n",
229+
"print(f\"Running: NodalMass={NodalMass}, LCol={LCol}, outDir={outDir}\")\n",
230+
"\n",
231+
"ops.wipe()\n",
232+
"ops.model(\"basic\", \"-ndm\", 2, \"-ndf\", 3)\n",
233+
"\n",
234+
"# Geometry\n",
235+
"ops.node(1, 0, 0)\n",
236+
"ops.node(2, 0, LCol)\n",
237+
"ops.fix(1, 1, 1, 1)\n",
238+
"ops.mass(2, NodalMass, 0.0, 0.0)\n",
239+
"\n",
240+
"# Element\n",
241+
"ops.geomTransf(\"Linear\", 1)\n",
242+
"ops.element(\"elasticBeamColumn\", 1, 1, 2, 3600000000, 4227, 1080000, 1)\n",
243+
"\n",
244+
"# Recorders\n",
245+
"ops.recorder(\"Node\", \"-file\", f\"{outDir}/DFree.out\", \"-time\", \"-node\", 2, \"-dof\", 1, 2, 3, \"disp\")\n",
246+
"ops.recorder(\"Node\", \"-file\", f\"{outDir}/RBase.out\", \"-time\", \"-node\", 1, \"-dof\", 1, 2, 3, \"reaction\")\n",
247+
"ops.recorder(\"Element\", \"-file\", f\"{outDir}/FCol.out\", \"-time\", \"-ele\", 1, \"globalForce\")\n",
248+
"\n",
249+
"# Gravity analysis\n",
250+
"ops.timeSeries(\"Linear\", 1)\n",
251+
"ops.pattern(\"Plain\", 1, 1)\n",
252+
"ops.load(2, 0.0, -2000.0, 0.0)\n",
253+
"ops.wipeAnalysis()\n",
254+
"ops.constraints(\"Plain\")\n",
255+
"ops.numberer(\"Plain\")\n",
256+
"ops.system(\"BandGeneral\")\n",
257+
"ops.test(\"NormDispIncr\", 1.0e-8, 6)\n",
258+
"ops.algorithm(\"Newton\")\n",
259+
"ops.integrator(\"LoadControl\", 0.1)\n",
260+
"ops.analysis(\"Static\")\n",
261+
"ops.analyze(10)\n",
262+
"ops.loadConst(\"-time\", 0.0)\n",
263+
"\n",
264+
"# Pushover analysis\n",
265+
"ops.timeSeries(\"Linear\", 2)\n",
266+
"ops.pattern(\"Plain\", 2, 2)\n",
267+
"ops.load(2, 2000.0, 0.0, 0.0)\n",
268+
"ops.integrator(\"DisplacementControl\", 2, 1, 0.1)\n",
269+
"ops.analyze(1000)\n",
270+
"\n",
271+
"print(f\"Done: NodalMass={NodalMass}, LCol={LCol}\")\n",
272+
"\"\"\"\n",
273+
"\n",
274+
"(input_dir_opensees / \"cantilever.py\").write_text(cantilever_script)\n",
275+
"print(f\"Wrote {input_dir_opensees}/cantilever.py\")"
276+
]
197277
},
198278
{
199279
"cell_type": "markdown",

0 commit comments

Comments
 (0)