I have done some scripts, while working on a code_saturne project, to makes it easier to have information, I put them in case it is useful for someone one day.
First come some bash aliases that should be put in the .bashrc
Code: Select all
alias csw="watch -n 15 \"cat listing | grep \\\"INSTANT\\\" | wc -l\""
Code: Select all
alias cdl="cd \`ls -1r | head -n 1 \`"
Code: Select all
alias lli="less listing"
Code: Select all
alias pvr="paraview postprocessing/RESULTS.case"
Code: Select all
alias xmp="xmgrace -nxy monitoring/probes_Pressure.dat"
Code: Select all
alias csexplain="~/explain.rb"
csexplain should be called in a result folder and write a nice sum up of the parameter of the simulation that I need to now (so mostly turbo-machinery related, I don't change the physical parameter and so they are not displayed). Ruby should be available in every mainstream distro, but if there is interest for a script like that, I can rewrite it in python, in English and with flag support like "csexplain -aT" to display all general information and turbomachinery "csexplain -p" to only display physics and so forth
Last but not least, a Python script that slowly accelerate a turbomachine by launching a frozen rotor simulation at a chosen velocity, wait for the simulation to converge and launch a new simulation a bit faster with de data from the previous one. This script launches from inside DATA and need to have a valid initial setup.
I am sorry that the comments are in French for the two last script, I'll translate them if there is any interest.
Code: Select all
# Import module pour appeler du bash et un module pour lire/écrire du xml
import subprocess
from lxml import etree
# Condition initiale
# Que vous voudrez probablement changer
NB_PAS = 2325
CHECKPOINT= "20180309-1338"
ROTOR_VITESSE=75
Dossier= "Vitesse"
# Boucle tant que l'on n'a pas atteinds 350 rad/s
while ROTOR_VITESSE<=350:
#===== Cree fichier setup ======
# Lire fichier xml source
tree = etree.parse("setup.xml")
for elem in tree.xpath('//iterations'):
# Mettre à jour le nombre de pas
elem.text = str(NB_PAS)
for elem in tree.xpath('//velocity//value'):
# Mettre à jour la vitesse du Rotor
elem.text = str(ROTOR_VITESSE)
for elem in tree.xpath('//start_restart//restart'):
# Mettre à jour le fichier checkpoint
elem.attrib['path'] = "RESU/"+str(CHECKPOINT)+"/checkpoint"
#===== écrire nouveau fichier setup dans DATA/ ======
with open("setup"+str(ROTOR_VITESSE)+".xml", 'w') as setup:
setup.write(etree.tostring(tree, pretty_print=True, encoding='utf8'))
#===== Lancer le calcul ======
# Le dosier où est lancé le calcul est le futur checkpoint
CHECKPOINT=Dossier+str(ROTOR_VITESSE)
# Code lancé sur 4 MPI 2 OPENMP
p = subprocess.Popen("cd ../SCRIPTS && code_saturne run --param setup"+str(ROTOR_VITESSE)+".xml --threads-per-task 2 --nprocs 4 --id "+str(CHECKPOINT), stdout=subprocess.PIPE, shell=True)
#Attendre la fin du calcul avant de repartir
(output, err) = p.communicate()
p_status = p.wait()
print("Vitesse: "+ str(ROTOR_VITESSE))
#La prochaine itération sera 25rad/s plus vite et sur 1000 pas
NB_PAS+=1000
ROTOR_VITESSE+=25
#end