Skip to content

Instantly share code, notes, and snippets.

@akaszynski
akaszynski / print_errors.py
Created March 23, 2022 15:05
Print errors redirected from sphinx.
"""Read errors output from a sphinx build and remove duplicate groups"""
import os
import pathlib
import sys
sys.tracebacklimit = 0
my_path = pathlib.Path(__file__).parent.resolve()
errors = set()
error_file = os.path.join(my_path, "build_errors.txt")
@akaszynski
akaszynski / .emacs
Created May 17, 2022 19:55
My emacs init file
(require 'package);; init.el --- Emacs configuration
;; INSTALL PACKAGES
;; --------------------------------------
;; (add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
@akaszynski
akaszynski / lego.py
Created October 10, 2022 15:42
gmsh + pymapdl + cadquery
#!/usr/bin/env python
# coding: utf-8
# In[12]:
import cadquery as cq
import pyvista as pv
from ansys.mapdl.reader import save_as_archive
@akaszynski
akaszynski / measure_widget.py
Created November 1, 2022 16:01
Add measure widget example
import time
import vtk
import pyvista as pv
cube = pv.Cube()
pl = pv.Plotter(notebook=False)
pl.add_mesh(cube) # <-- Add pygeometry stuff
@akaszynski
akaszynski / qt_tips.md
Created July 11, 2023 21:37
General PyQt tips and tricks

Implement Scaling

Scaling can only be set on initialization (or restart)

# Enable High DPI display with PyQt
os.environ.setdefault("QT_SCALE_FACTOR", str(rcParams["scale_factor"]))
if hasattr(QApplication, "setAttribute"):
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
@akaszynski
akaszynski / gen_cyclic_gmsh.py
Created October 30, 2023 21:14
Generates a hexahedral mesh model for rotor and stator geometry using the Gmsh library.
"""
This script generates a mesh model for rotor and stator geometry using the Gmsh library.
The mesh is then written to disk and subsequently read and converted into an archive file
with mapdl-archive for further FEM analysis. The module uses pyvista for optional visualization.
Generates a single cyclic sector.
Requirements
------------
@akaszynski
akaszynski / surf_data_to_cells.py
Created June 6, 2024 22:13
Demonstrate mapping face centers from an external source to the cells of an unstructured grid.
"""
Demonstrate mapping face centers from an external source to the cells of an unstructured grid.
Assumptions:
- Points from the external source are close to the centers of the faces of the
extracted surface
"""
from pykdtree.kdtree import KDTree
@akaszynski
akaszynski / pyvista-hover-affine.py
Created April 29, 2025 14:19
PyVista - Hover on point and click to place affine widget
import pyvista as pv
import numpy as np
import vtk
import femorph
###############################################################################
from typing import cast, Sequence
import numpy as np
@akaszynski
akaszynski / Read in Fluent CAS
Last active April 29, 2025 16:28
read-cas-movie.py
"""
Generate one video.
Loads all ducts, identifies a pairing between all that minimizes distance
between, morphs two, and then interpolates the solution between those two.
"""
from tqdm import tqdm
from pathlib import Path