Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenSEES #3

Open
pizofreude opened this issue Dec 6, 2024 · 0 comments
Open

Add OpenSEES #3

pizofreude opened this issue Dec 6, 2024 · 0 comments

Comments

@pizofreude
Copy link
Owner

Source OpenSEES
Use OpenSEES as main analysis program, and post-processing with python libraries. Here chatgpt comes to the picture to write some post-processing scripts. It wrote a script for to pipeline opensees analysis results to directly .vtk format so that we can open it with Paraview.

Here are the step-by-step instructions to pipeline OpenSEES analysis results to the .vtk format using a Python script:

  1. Install OpenSEES and Python: Ensure that you have OpenSEES and Python installed on your system.
  2. Create a new Python script: Open your preferred text editor or Python IDE and create a new script file.
  3. Import necessary libraries: At the beginning of the script, import the required libraries:
    import os
    import subprocess
  4. Define the OpenSEES command: Define the command to run the OpenSEES analysis. Replace your_analysis_script.tcl with the path to your OpenSEES analysis script.
    opensees_cmd = "opensees -file your_analysis_script.tcl"
  5. Run the OpenSEES analysis: Use the subprocess module to run the OpenSEES command and save the output to a text file.
    subprocess.run(opensees_cmd, shell=True, stdout=open("output.txt", "w"))
  6. Parse the OpenSEES output: Write a function to parse the OpenSEES output text file and extract the necessary data for the .vtk format.
  7. Generate the .vtk file: Write a function to generate the .vtk file using the parsed data. Use the os module to specify the output file path and name.
    vtk_file_path = "output.vtk"
    with open(vtk_file_path, "w") as vtk_file:
        vtk_file.write("VTKFile\n")
        vtk_file.write("Type: UnstructuredGrid\n")
        vtk_file.write("Version: 0.1\n")
        vtk_file.write("ByteOrder: LittleEndian\n")
        vtk_file.write("DataMode: ASCII\n")
        vtk_file.write("NumberOfPoints: " + str(num_points) + "\n")
        vtk_file.write("Points\nfloat\n")
        # Write point coordinates here
        vtk_file.write("NumberOfCells: " + str(num_cells) + "\n")
        vtk_file.write("Cells\n" + str(num_cells) + " " + str(cell_type) + "\n")
        # Write cell connectivity and types here
  8. Use Paraview to open the .vtk file
@pizofreude pizofreude changed the title Add OpneSEES Add OpenSEES Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant