This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This programmable filter can be used on an unstructured grid to display the | |
# numerical value of the cell type (i.e., tet, hex, wedge, ...) | |
output.CellData.append(inputs[0].CellTypes, 'Cell_type') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Fun with stiffness matrices! | |
The plotting routine is inspired by https://github.com/coudertlab/elate | |
The Voigt-Reuss-Hill Averaging was directly copied from there. | |
Note the following relationships of stresses and strains: | |
sigma_ij ... stress tensor | |
epsilon_ij ... strain tensor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
# do plotting: | |
#plt.dosomething(...) | |
# pil_kwargs can be used to pass things to PIL. | |
# the save function has **params which then passes the kwargs to the file format save function, for example: | |
# See https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#saving-tiff-images | |
# LZW compression is called tiff_lzw in pil... | |
plt.savefig('foobaz.tiff', pad_inches=0.05, bbox_inches='tight', pil_kwargs=dict(compression='tiff_lzw')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# Numpy array is xyz | |
img = np.zeros((10,20,30)) | |
a = slice(None) # all items, same as ':' | |
faces = { | |
'top': (-1, a, a), | |
'bottom': (0, a, a), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
A = np.array([[2,1,2.5], [1,3,1], [2.5,1,4]]) | |
# Eigenvalues and -vectors have the property such that: Ax = lx | |
# x ... Eigenvectors | |
# l ... Eigenvalues | |
l, x = np.linalg.eig(A) | |
# it follows: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"ColorSpace": "RGB", | |
"DefaultMap": true, | |
"Name": "Turbo", | |
"RGBPoints": [ | |
0.0, | |
0.18823529411764706, | |
0.07058823529411765, | |
0.23137254901960785, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What you would normaly do: | |
def some_divison(): | |
flag = True | |
val = 23 | |
divisor = 42 | |
if flag: | |
return val / divisor | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
################################# | |
# NOTE: | |
# This assumes you have a user `builder` and a folder `/home/builder/packages`. | |
# it will clone FreeCAD there and start pbuilder using pdebuild. | |
# For me this works using debian sid. (stretch/buster will probably not work!) | |
# | |
# After the build has finished, it will import the packes into a reprepro | |
# which is setup at /srv/repo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("Checking replacing all placements with default.") | |
print("===============================================") | |
for b in App.activeDocument().findObjects("PartDesign::Body"): | |
if not b.Placement.isNull(): | |
print("!!! Body {} has a non null placement --> resetting!".format(b.Label)) | |
b.Placement.Base = FreeCAD.Base.Vector() | |
b.Placement.Rotation = FreeCAD.Base.Rotation() | |
else: | |
print("Body {} looks fine...".format(b.Label)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from itertools import combinations | |
import scipy.linalg | |
x = [1.2, 1.3, 1.6, 2.5, 2.3, 2.8] | |
y = [167.0, 180.3, 177.8, 160.4, 179.6, 154.3] | |
z = [-0.3, -0.8, -0.75, -1.21, -1.65, -0.68] | |
f = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6]).transpose() | |
G = np.c_[x, y, z] |
NewerOlder