Skip to content

DSinghania13/xarray-visualization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Visualization of Shear Force and Bending Moment Diagrams

Using Xarray and Plotly (MIDAS-style Post-Processing)


πŸ“Œ Submission Details

  • Project Title: Visualization of Shear Force and Bending Moment Diagrams using Xarray and Plotly
  • Organization: Osdag (FOSSEE, IIT Bombay)
  • Task Type: Technical Screening Assignment
  • Domain: Structural Engineering / Software Development

  • Submitted by: Divit Singhania
  • Program: B.Tech Computer Science (AI & ML)
  • Institution: VIT Bhopal University

πŸŽ₯ Video Demonstration

A short screen-recorded demonstration of the code execution and generated plots is available below:

πŸ”— YouTube (Unlisted) Video Link: Click here


🧠 Project Overview

This repository contains Python scripts to generate 2D and 3D Shear Force Diagrams (SFD) and Bending Moment Diagrams (BMD) from an Xarray dataset, closely replicating MIDAS Civil post-processing visualizations.

The project demonstrates:

  • Correct use of FEM element connectivity
  • Accurate node-based geometric reconstruction
  • Preservation of sign conventions from the dataset
  • Professional-quality 2D and 3D structural plots

πŸ“ Repository Structure

xarray-visualization/
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ screening_task.nc
β”‚   β”œβ”€β”€ node.py
β”‚   └── element.py
β”‚
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ xarray_usage.py
β”‚   β”œβ”€β”€ task1_2d.py
β”‚   └── task2_3d.py
β”‚
β”œβ”€β”€ figures/
β”‚   β”œβ”€β”€ dataset_visualization.png
β”‚   β”œβ”€β”€ node_element_connectivity.png
β”‚   β”œβ”€β”€ SDF_2D.png
β”‚   β”œβ”€β”€ BMD_2D.png
β”‚   β”œβ”€β”€ SDF_3D.png
β”‚   └── BMD_3D.png
β”‚
β”œβ”€β”€ report/
β”‚   └── Report.pdf
β”‚
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
└── .gitignore


πŸ“Š Dataset Description

screening_task.nc (Xarray Dataset)

  • Dimensions

  • Element β†’ Beam element IDs

  • Component β†’ Internal force components

  • Force Components Used

  • Vy_i, Vy_j β†’ Shear force at start/end node

  • Mz_i, Mz_j β†’ Bending moment at start/end node

Suffix meaning:

  • _i β†’ Start node of element
  • _j β†’ End node of element

dataset_visualization

Figure 1: Xarray dataset structure and force components


🧩 Node Coordinates & Element Connectivity

node.py defines node geometry:

node_id β†’ (x, y, z)

element.py defines FEM connectivity:

element_id β†’ (start_node, end_node)

node_element_conectivity

Figure 2: Node coordinates and element connectivity. All plots use actual geometry β€” no assumed or artificial coordinates.


πŸ§ͺ Scripts Overview

1️⃣ xarray_usage.py

Inspects dataset structure

  • Identifies force components.
  • Extracts tabular force data for verification.

2️⃣ task1_2d.py β€” Task-1 (2D Plots)

Generates 2D Shear Force (SFD) and Bending Moment (BMD) diagrams for the Central Longitudinal Girder elements: [15, 24, 33, 42, 51, 60, 69, 78, 83].

Plotting Logic:

  • SFD: Step-wise (constant per element).
  • BMD: Linear interpolation between nodes.
  • Sign Convention: Preserved exactly from the dataset.

SFD_2D

Figure 3: 2D Shear Force Diagram

BMD_2D

Figure 4: 2D Bending Moment Diagram

3️⃣ task2_3d.py β€” Task-2 (3D MIDAS-Style Plots)

Generates 3D SFD & BMD for all five longitudinal girders.

Visualization Features:

  • X: Bridge length | Z: Bridge width | Y: Force magnitude (vertical extrusion).
  • Vertical Hatching: "Fence" style plotting for transparency.
  • Heat-map Coloring: Jet colormap (Blue β†’ Red) based on magnitude.
  • Global Scaling: Auto-scaled to maintain visual proportions.

SFD_3D

Figure 5: 3D Shear Force Diagram (SFD) β€” All Girders

BMD_3D

Figure 6: 3D Bending Moment Diagram (BMD) β€” All Girders


▢️ How to Run the Code

# 1. Install dependencies
pip install -r requirements.txt

# 2. Navigate to scripts folder
cd scripts

# 3. Run verification script
python xarray_usage.py

# 4. Run Task 1 (2D Plots)
python task1_2d.py

# 5. Run Task 2 (3D Plots)
python task2_3d.py

🧾 Report Documentation

A detailed PDF report is available, covering dataset inspection, code logic, plot construction, and verification against marking criteria.

πŸ“„ Read the Report


πŸ› οΈ Tech Stack

  • Python 3.11
  • Xarray – Dataset handling
  • NumPy – Numerical operations
  • Plotly – 2D & 3D visualization
  • netCDF4 – Dataset backend
  • Pandas - Dataset visualization

βœ… Alignment with Marking Criteria

Criterion Status Implementation
Correct node coordinates βœ… Imported directly from node.py
Correct element connectivity βœ… Imported directly from element.py
Sign convention preserved βœ… No manual flipping; visualization matches raw data
Visual clarity & scaling βœ… Proper axes labels, 1.5x Z-expansion, auto-scaling
MIDAS-style 3D plots βœ… Vertical extrusion + vertical hatching + heat-map colors

πŸ“¦ Files Included

  • xarray_usage.py – Dataset inspection
  • task1_2d.py – 2D SFD & BMD
  • task2_3d.py – 3D MIDAS-style SFD & BMD
  • node.py, element.py – Structural data
  • screening_task.nc – Force dataset
  • SFD_BMD_Report.pdf – Documentation

🏁 Conclusion

This project demonstrates how professional structural post-processingβ€”commonly available in commercial tools like MIDAS Civilβ€”can be reproduced using open-source Python libraries, while maintaining engineering correctness, geometric fidelity, and visual clarity.


πŸ“œ License

This project is licensed under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license, as required by FOSSEE for screening task submissions.


About

Structural analysis post-processor using Xarray and Plotly to generate 2D and 3D Shear Force (SFD) and Bending Moment Diagrams (BMD). Replicates MIDAS Civil-style visualizations with FEM element connectivity, heat-map scaling, and geometric fidelity for bridge girder analysis.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages