Skip to content

Instantly share code, notes, and snippets.

@forest512
forest512 / ReadJamNp-panda.py
Created July 12, 2018 00:36
Used to get the number of discharged particles in jamming cases. At first, read the log.run/parallel file and then drop duplicates by "pandas" package of python.
#!/l/shanlin/anaconda3/bin/python
import numpy as np
import pandas as pd
from pandas import DataFrame
print("Read results of jamming cases.\n")
path= 'log.jamP'
ReadLines= open(path,'r')
data = []
@forest512
forest512 / JammingCountRatio.py
Created March 30, 2018 20:24
Curve fit, including the polynomial fit, the gauss function fit, the spline fit.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 22 13:43:04 2017
@author: forest
"""
# Generate the particle size which has a log-normal distribution with mean value (ln(d50)) and standard deviation sigma(ln((d85/d16)**0.5))
import numpy as np
@forest512
forest512 / plotGnuModel.gnu
Created March 13, 2018 18:55
This a gnuplot model which includes the label, the axis, the ticks, and the legend.
#!/usr/bin/gnuplot
# gnuplot model
# created by forest, 2018. 03. 11
reset
#set term png
#set output 'epsilon_0.png'
@forest512
forest512 / HookenLammpsParameters.py
Created March 13, 2018 00:30
Calculate the gamma_n of hookean contact force model
#!/usr/bin/env python
# clear all contents
import sys
sys.modules[__name__].__dict__.clear()
import numpy as np
import matplotlib.pyplot as plt
from math import log
from math import e
@forest512
forest512 / PlotMultiLines.py
Last active February 12, 2018 03:48
The sets up of the multilines' figure
#!/usr/bin/env python
# plot the analytical solutions
print("Calculate the analytical value of T")
x = np.arange(0,Lx,0.001)
Ta = np.zeros(len(x))
for i in range(len(x)):
Ta[i]=Ts+q_prime/k/2*(Lx**2-x[i]**2)
@forest512
forest512 / Read.py
Created February 12, 2018 01:56
Python read and write files
#!/l/shanlin/anaconda3/bin/python
print("Read results of jamming cases.\n")
path = 'Results.txt'
ReadLines= open(path,'r')
data = []
for line in ReadLines.readlines():#Results = ReadLines.readlines()
Results = [x.strip() for x in line.split(None)]
@forest512
forest512 / DiffPlot.gnu
Last active February 4, 2018 00:22
Plot different lines with different types and color
set term png # background "#ffffff" enhanced fontscale 1.0 size 640, 480 dashlength 2
set output 'PressureCompareFixedP.png'
# set style line 1 linecolor rgb "red" linewidth 3.000 pointsize default pointinterval 0
# set style line 2 linecolor rgb "orange" linewidth 2.000 pointsize default pointinterval 0
# set style line 3 linecolor rgb "yellow" linewidth 3.000 pointsize default pointinterval 0
# set style line 4 linecolor rgb "green" linewidth 2.000 pointsize default pointinterval 0
#set offsets 0.05, 0.05, 0, 0
#set style function linespoints
#unset xtics
# set xtics 0.01
@forest512
forest512 / mesh.py
Last active January 19, 2018 19:40
Plot the circle and gridlines to figure out the area size ratio of the inlet and outlet in jamming case
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 19 11:23:45 2018
@author: forest
"""
import numpy
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse, Circle
@forest512
forest512 / arithmeticOperator.C
Created January 14, 2018 02:07
Some explanation about the arithmetic operator of C++; understand the openFoan addParticleOpenFoam function
# include <iostream>
using namespace std;
int i, j = 0;
int nP = 0;
int main()
{
int reduceNumberFactor;
cout <<"test the arithmetic operation"<<endl;
cout << "Enter a reduceNumberFactor:" <<endl;
cin >> reduceNumberFactor;
@forest512
forest512 / ArrayDp-polySand.py
Last active June 14, 2018 19:55
SoilParticleSizeGeneration
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 22 13:43:04 2017
@author: forest
"""
# Generate the particle size which has a log-normal distribution with mean value (ln(d50)) and standard deviation sigma(ln((d85/d16)**0.5))
import numpy as np