## Ilyass's books

Ilyass's favorite books »

At the USNCCM13, we discussed the fact that (currently) Peridigm only accepts Exodus II mesh files. The only software that generates Exodus II mesh files is the powerful Cubeit. Cubeit’s license can also be expensive, especially for someone who only wants to use the conversion to Exodus II feature to import geometries in PeridigmPatrick discussed the possibility of writing our own conversion script that converts a widely used free meshing format to Exodus II. We eventually decided to use Gmsh as an input for our script, which then converts Gmsh meshes to Exodus II.

The code is available here, everything is written in python so the only requirement is VTK >=5.8 with the python wrapper (sudo apt-get install python-vtk). We currently support triangles and quadrangles for 2D elements and tetrahedrons for 3D elements.

## Examples

#### 2D

 Mesh generated with gmsh Exodus geometry visualized with paraview

#### 3D

 Mesh generated with gmsh Exodus geometry visualized with paraview

## Get started

It was great working with Patrick on this project, I learned a lot about meshes and VTK. #notscaredofmeshesanymore

If you liked this post, you can share it with your followers or follow me on Twitter!

A 3D-printed mold was designed to hold 6 steel fibers (basically steel wire of 900$$\mu m$$ arranged in two parallel lines of 3 fibers. The drawings show the side and front view of the mold, the red line represents one unique fiber. It is attached to the bottom of the mold using hooks that are directly 3D-printed in the mold.

Epoxy is then poured in the mold and cures around the fibers. The mold is then horizontally cut (following the scissor lines on the drawing) to provide several dogbone specimen, containing transversally embedded steel fibers. Click on the picture and move your mouse around to change the focus point and perspective.

One of the specimens was polished, then covered with light polarizing film on the front and back to reveal the photoelastic properties of Epoxy. If you ever need polarizing film, you can either buy some but it is quite hard to find large sheets. You can also get high quality filters by taking an old LCD computer monitor apart (that is what I did here), it is an easy operation that still needs you to be slightly careful (a tutorial to do so). Other surfaces were covered with black ink (Sharpy) to avoid non-polarized light diminushing the contrast of polarized light. It is then possible to qualitatively see the residual stresses in the specimen due to cooling after curing and the mismatch of coefficient of thermal expansion between the fibers and the matrix.

The density of fringes (isolines of same colours) qualitatively shows the stress concentration. The more colours there are in an area, the higher the stress concentration is. It is possible to distinguish the residual stresses due to the interaction with the mold and the residual stress around each fiber.

If you liked this post, you can share it with your followers or follow me on Twitter!

A transparent photoelastic polymer containing a single hole of $$500\mu m$$ is loaded under tensile stress. The same experiment is done again using Digital Image Correlation (DIC) as an analysis method this time. The contour plot shown in the DIC experiment are percentiles of $$\epsilon_1$$ - $$\epsilon_2$$, where $$\epsilon_{1}$$ is the deformation in the first principal direction and $$\epsilon_2$$ the deformation in the second principal direction. The number of photoelastic fringes passing through a material point on the specimen’s surface is also proportional to $$\epsilon_1- \epsilon_2$$, allowing a qualitative comparison of both methods by looking at:

• The fringes concentration
• The number of fringes passing through a single material point and their direciton

This video compares both methods.

Both specimens’ dimensions were chosen according to the ASTM D632 Type V. Test speed: $$0.1mm/min$$

It is possible to see that the photoelastic specimen firstly reveals large fringes going through the whole specimen from left to right, that is probably because the specimen is experimenting torsion, due to the fact it was not perfectly straight between the grips. Once the whole specimen emits an almost uniform color (second 40), 6 petal fringes (circular) are cricling the hole.

Experiments done in collaboration with Rolland Delorme, at Ecole Polytechnique Montreal during November 2015.

If you liked this post, you can share it with your followers or follow me on Twitter!

When capturing images from a lab camera, you might find yourself with a bunch of .tiff images.

The first thing you will need is the ImageMagick package for Ubuntu. You can get it using:

sudo apt-get install imagemagick


This package contains a very convenient convert function, it can be used to convert a .tiff image into a .png while keeping transparency using:

convert inputfile.tiff -transparent white outputfile.png


You can then use this command to recursively treat any file in the folder with a simple grep and some batch scripting:

    #!/bin/sh
for file in ls | grep tif
do
convert "$file" -transparent white "${file}.png"
echo "writing ${file}.png" done  To use it, you simply need to put a bunch of .tiff files in the same folder, and execute the script. If your files are recorded as .tif and not .tiff, you will need to change it in the second line of the script. Final tip: If any other file in the folder (it can be the script itself) contains the letters T-I-F-F in this order, it will be transformed into a .png even if it is a text file. Source, more details: http://ospublish.constantvzw.org/blog/tools/convert-tiff-to-transparent-png If you liked this post, you can share it with your followers or follow me on Twitter! Implementing nice looking plots in a $$\LaTeX$$ document was harder than expected. I use R (through Rstudio) combined with ggplot2 (Grammar of Graphics plot) to plot my data and wanted a convenient way to insert my plots into Latex documents. I use something similar with Inkscape. It automatically sets the right font, properly writes Latex symbols and respects the proper font sizes. The best solution I found is using the tikzDevice package for R and the tikz (available in the pgf package) package from LaTeX. TikZ plots will consist of vectors that will directly be coded into the LaTeX document so that there is no loss in image quality. First you need to install tikzDevice in R through install.packages("tikzDevice"). For the following example to work, you will also need to install ggplot2. Once you have both R packages, you can use this Rscript as an example:  library(tikzDevice) library(ggplot2) #For some reason, Rstudio needs to know the time zone... options(tz="CA") #Dummy data for the plot y <- exp(seq(1,10,.1)) x <- 1:length(y) data <- data.frame(x = x, y = y) #Create a .tex file that will contain your plot as vectors #You need to set the size of your plot here, if you do it in LaTeX, font consistency with the rest of the document will be lost tikz(file = "plot_test.tex", width = 5, height = 5) #Simple plot of the dummy data using LaTeX elements plot <- ggplot(data, aes(x = x, y = y)) + geom_line() + #Space does not appear after Latex ggtitle( paste("Fancy \\LaTeX ", "\\hspace{0.01cm} title")) + labs( x = "$x$= Time", y = "$\\Phi\$ = Innovation output") +
theme_bw()
#This line is only necessary if you want to preview the plot right after compiling
print(plot)
#Necessary to close or the tikxDevice .tex file will not be written
dev.off()


The output provided by this script in R looks like this:

As you can see, the LaTeX codes are clearly visible. The font is R’s default font for now. If you check the folder where you sourced your file, you will find a test.tex file(you can check its content for this specific case by clicking on it) which contains the plot information as vectors. Every line, word or symbol is included as latex instructions in this .tex file. You should now create a .tex (any name will do) in the same folder your plot_test.tex file is in and use this simple LaTeX code to implement the image in it:

	\documentclass{article}
%The package tikz is available in pgf
\usepackage{tikz}
\begin{document}

\begin{figure}
%Do not try to scale figure in .tex or you loose font size consistency
\centering
%The code to input the plot is extremely simple
\input{plot_test.tex}
%Captions and Labels can be used since this is a figure environment
\caption{Sample output from tikzDevice}
\label{plot:test}
\end{figure}
\end{document}


The result should look like this. As you can see, LaTeX symbols are now properly written, the font is also similar to the rest of the document and the plot can be inserted in your LaTeX document !

A problem you might still have: the font size of the plot title and axis legend and their positions. You can easily modify the sizes using the rel() function to scale the font size of each element. To modify the position of the axis legends or title plot, you can use the vjust and hjust parameters for vertical and horizontal positioning. R will not prepare your plot for the LaTeX font and sizes, so you will probably need to move the title and axis titles or they will probably touch the plot itsel at some point (visible in the previous LaTeX plot). To correct it, use something similar to this:

        plot + theme(plot.title = element_text(size = rel(1), vjust = 0),
axis.title = element_text(size = rel(0.8)),
axis.title.y = element_text( vjust=2 ),
axis.title.x = element_text( vjust=-0.5 ))


If you liked this post, you can share it with your followers or follow me on Twitter!

After the Windows 10 update, Miktex refused to download new packages and kept signaling a Windows API Error 2. The worst part was that the uninstall file for Miktex was nowhere to be found, which made it impossible to properly uninstall it using Windows Program manager. On the machine’s Admin account, Miktex was not even reported in the Program manager anymore.

A simple and efficient fix that worked for me is to rename you current Miktex folder Miktex_old, install Miktex where the old install was and simply delete the Miktex_old folder, and that’s it !

This trick might also repair some of the other numerous bugs Miktex meets on a Windows system (especially 64bits).

If you liked this post, you can share it with your followers or follow me on Twitter!

You can easily check if someone is connected to a Wifi network using a simple function provided in the Network MAP package. Nmap is a security package designed to discover hosts, services and machines on a network.

## Setting up

First, you need to install Nmap and its python wrapper:

	sudo apt-get install nmap
sudo pip install python-nmap


## Use it

You can either use the python console to perform unique scans or script your scans to perform them on a regular basis. You will need to be root in order to use nmap.

#First, you need a Postscanner object that will be used to do the scan
nm = nmap.PortScanner()
#You can then do a scan of all the IPV4 addresses provided by the network you are connected to
nm.scan(hosts = '192.168.1.0/24', arguments = '-sn')


The 3 first numbers of the IP address (192.168.1) used as hosts might need to be changed depending of the network. Check the IP address of a machine connected to that same network to know which hosts you should scan. You can then check the all_hosts() function attached to the PortScanner object which provides a list containing information about each IP address available in the network. For each element, you can check several values such as the MAC address.

	for host in nm.all_hosts():
#If the status of an IP address is not down, print it
if nm[host]['status']['state'] != "down":
print "STATUS:", nm[host]['status']['state']
try:
except:
mac = 'unknown'


For some devices, the MAC address is not openly displayed.

## Implementation

The best way to use this is to set up a Raspberry Pi running a script with a Cron job regularly scanning your network and notifying you through an intranet webpage, mail or SMS if any interesting event happens. To do so, you need to know the MAC address of your roommates’ smartphones or laptops. You can also use it for network discovery. You will quickly notice that you can attach MAC addresses to people by performing Nmap is a much more powerful tool than what is presented here. This is just a fun trick that can be used with roommates to play an intro music when they get home for example.

Now that I know that anyone can get my MAC addresses by performing simple scans when I am connected to a WiFi network and when I am not, what I would like to know is how can one be protected from such attempts? Is it possible to voluntarily hide your MAC address from the netowrk?

PS: Check NMap’s presence in blockbuster movies

If you liked this post, you can share it with your followers or follow me on Twitter!