/Archives/

sneeze particle animation

2020-07-06T23:36:14+00:00

May 12th 2020

Recent outcomes, well done everyone!

And during this time when we are working from home we can get more computer modelling finished like this:

sneeze particle animation2020-07-06T23:36:14+00:00

Python Scripts

2020-01-14T12:21:01+00:00

Fluent in batch mode

os.system(r'"C:\Program Files\ANSYS Inc\v195\fluent\ntbin\win64/fluent.exe" 2d -g -t2 -i case4.jou' )

In these examples,

• fluent is the command you type to execute ANSYS FLUENT interactively.
• -g indicates that the program is to be run minimized in the taskbar.
• -i journal reads the specified journal file.
• -wait is the command you type in a DOS batch file or some other script in a situation where the script needs to wait until ANSYS FLUENT has completed its run.
• -hidden is similar to the -wait command, but also executes ANSYS FLUENT completely hidden and noninteractively.

To get an output (or transcript) file while running ANSYS FLUENT in the background on a Windows system, the journal file must contain the following command to write a transcript file:

 ; start transcript file /file/start-transcript outputfile.trn 

where the outputfile is a file that the background job will create and which will contain the output that ANSYS FLUENT would normally print to the screen (e.g., the menu prompts and residual reports).

Remove duplicate zones in Tecplot

#flist = flist[0:5] # just for testing on 5 files and not all of them!
import tecplot as tp
from tecplot.exception import *
from tecplot.constant import *
# Uncomment the following line to connect to a running instance of Tecplot 360:
tp.session.connect()

for fname in flist:
dataset = tp.data.load_tecplot(fname, read_data_option=2) #option 2 is replace, #option 1 is default which is append
zList = list(dataset.zone_names)
# Find duplicate zones and set to remove
dups = [i for i, x in enumerate(zList) if zList.count(x) > 1]
remDups = dups[0::2]
# Remove duplicate zones
dataset.delete_zones(remDups)
# Save data
tp.data.save_tecplot_plt(f'clean_{fname[4:]}', dataset=dataset, variables=None, zones=None)



DPM to Tec

fnameClean = 'cleanTemp.dat'
def cleanFile(filename):
fnameClean = 'cleanTemp.dat'
with open(filename, 'r') as infile, open(fnameClean, 'w') as outfile:
data = data.replace("(", "")
data = data.replace(")", "")
outfile.write(data)

def writeTec(pdData, suffx):
ffname = fname[:-4] + '_'+ suffx +'mic.dat'
ftec = open(ffname, 'w')
ftec.write(f'TITLE = "{fname[:-4]}_{suffx}mic"\n')
ftec.write('VARIABLES = "X", "Y", "Z", "u","v","w","diam" \n')
ftec.write(f'ZONE T="{fname[:-4]}_{suffx}mic" \n')
ftec.close()

Generate points in Fluent for monitoring

fname = 'points-for-monitoring.txt'
df = pd.read_csv(fname, skiprows=0, delim_whitespace=True, names=['x','y','z'])
fid = open('createPoints.jou','w')
count = 1
for index, row in df.iterrows():
fid.write(f'/surface/point-surf p{count:02} {row["x"]} {row["y"]} {row["z"]}\n')
count = count+1
fid.close()


Transient Flow Profile

import numpy as np
from matplotlib import pyplot as plt
cycle=1
tStart = (cycle-1)*4+1.65
density=1.225
timestep =0.0001 # timestep size
time = np.arange(timestep,2.35+timestep,timestep)
a1 =      0.3674
b1 =       1.429
a2 =      0.0351
b2 =       6.223
a3 =     0.08071
b3 =       3.572
# ===== THIS PRODUCES L/S convert kg/s by /1000*density
mfr =  (a1*np.sin(b1*time) + a2*np.sin(b2*time) + a3*np.sin(b3*time))/1000*density
# ===== THIS PRODUCES L/S convert kg/s by /1000*density
printTime = tStart + time
plt.plot(printTime, mfr)
nTerms = len(time)
# check the volume
np.trapz(mfr, x=time)
# write transient profile -mass FR
fileName = "exhale-mfr.prof"
nTerms = len(printTime)
fid = open(fileName,"w")      # Open the file for writing
fid.write(f"( (exhale_cycle1 transient {nTerms} 1)\n") #1 =periodic 0=not periodic
fid.write("(time ")
fid.write(" ".join(str(format(i, ".7f")) for i in printTime))
fid.write(")\n")
fid.write("(mass-flow ")
fid.write(" ".join(str(format(i, ".12f")) for i in mfr))
fid.write(")\n")
fid.write(")\n")
fid.close()
Python Scripts2020-01-14T12:21:01+00:00
2020-07-06T23:52:38+00:00

August 19th 2019

Kiao is presenting “Mapping the mucosal surface coverage from nasal irrigation” at ANZRS2019 in Melbourne 20-22 September 2019. Good luck Kiao! https://anzrs.consec.com.au/program.html?date=all

June 24th 2019

Welcome Kendra Shesthra, James Van Strien 🙂

November 9th 2018

SCONA & RMIT Biomedical Health Innovations Workshop

2020-07-06T23:52:38+00:00

LaTeX Solutions

2020-02-18T23:58:10+00:00

item spacing and itemize symbols

\usepackage{enumitem}
\setlist[itemize]{noitemsep, topsep=0pt} %spacing settings for enumitem
\begin{itemize}
\item[--] Dash
\item[$-$] Dash
\item[$\ast$] Asterisk
\end{itemize}

=========================

elsarticle natbib issue with author names starting with the initials, followed by surname.
To change this replace the line:

{ s nameptr
"{f.~}{vv~}{ll}{, jj}"
format.name$ with { s nameptr "{vv~}{ll}{, jj}{, f.~}" format.name$

in the .bst file. For example, elsarticle-num-names.bst, found at C:\Users\~\AppData\Local\Programs\MiKTeX 2.9\bibtex\bst\elsarticle

LaTeX Solutions2020-02-18T23:58:10+00:00

Ansys-Fluent Solutions

2019-07-09T03:13:39+00:00

Exporting Particle History

/file/export/p-h-d/cfdpost testingP (left-nostril-10mic) particle-diameter particle-velocity-mag () 5

When restarting a transient simulation, the error “Update_Time_Level: invalid data” occurs.
Solution:
In the journal file use:

/solve/iterate 1 /solve/dual-time-iterate 100 20

They say this is some kind of strange error that comes when you use it in command line mode (with -g option)

Change R-R model for size distib –> (rpsetvar ‘dpm/atomizer-spread-param 2.2)

Preventing Backflows (ppt) -extending outlets

• In Fluent meshing, use Boundary -> Create -> Swept Surface.
• Select the edges
• Extrude away!

Compiling UDFs

• Install the “Microsoft Visual C++ Build Tools” which contains just the basic compilation tools with no integrated development environment (IDE) and these are sufficient to compile UDFs. Build Tools can be downloaded from https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15
• Once installed, update the udf.bat file in the C:\Program Files\ANSYS Inc\v19.x\fluent\ntbin\win64 directory (rename the existing udf.bat first) and add the following line.
“if exist “%MSVC_DEFAULT%\BuildTools\VC\Auxiliary\Build\vcvarsall.bat” set MSVC=%MSVC_DEFAULT%\BuildTools”
• If the ‘nmake’ error still occurs after a compiler has been installed then this is normally due to Microsoft Visual Studio not being installed with sufficient permissions on Windows. The compiler needs to be installed with sufficient administrative rights that allow the registry to be edited. For example, it is possible for a user to have admin rights but not have rights to edit the registry. If this is the case then you will need to have IT install the compiler with full IT admin rights.
Ansys-Fluent Solutions2019-07-09T03:13:39+00:00

PhD Project Opportunity

2019-01-02T07:11:30+00:00

Project 1: Computational and Experimental Studies of Nasal Surgical Manoeuvres

Disordered nasal airflow can lead to significant impairment in quality-of-life. As the incidence of nasal airway obstruction is high, surgery to relieve nasal obstruction is a commonly performed elective procedure. The engineering discipline of fluid dynamics provides highly detailed information on airflow behaviour that can reveal precise causes of obstruction and the effects of corrective surgery. Experimental fluid dynamics (EFD) using PIV and PLIF at CSIRO, and computational fluid dynamics (CFD) using Ansys-Fluent to provides visualisation and analysis of flow properties.

This PhD project will:

•  use an integrated computational-experimental approach to study the effects of surgical manoeuvres in the nose, in the form of “virtual surgery” on computer models then compare the results with test subjects undergoing routine surgery, thus leading to a rational scientific basis for each technique
• exploit fluid dynamics principles as the scientific foundation to develop novel, efficacious, surgical techniques, without requiring experimentation on actual patients.
•  impact upon the practice of Otolaryngology by providing scientific evidence-based results that prove precisely which surgical manoeuvres are effective in nasal airway obstruction surgery.

The work will involve ENT surgeons, and fluid dynamics engineers

Value and duration
This is for a PhD Scholarship, or a top-up scholarship, for a period of 3 years. The value of the scholarship is up to $31,000 per year. For a candidate already holding a scholarship, a top-up of up to$10,000 per year is available for work on this project.

Number of scholarships available
One

Eligibility
To be eligible for this scholarship you must:
• have a Degree (or equivalent Masters by Research) in engineering or related discipline, biomedical, physics, or related discipline.
• be an Australian citizen, Australian Permanent Resident, or a self-funded international student.
• preferably have research experience involving computational modelling, image processing, and experimental techniques.
• possess a strong desire to study fluid dynamics using computational and experimental techniques, and passion for modern supercomputing.

How to apply
Applicants should contact Dr Kiao Inthavong (kiao.inthavong@rmit.edu.au) to discuss eligibility.

Open date
Applications are now open as of 14 Dec 2018

Terms and conditions
Up to $31,000 per year for 3 years as scholarship (or up to$10,000 per year as a top-up scholarship, for a candidate already in receipt of an APA or equivalent scholarship). The applicant should be an Australian citizen, Australian Permanent Resident, or a self-funded international student.

Project 2: Computational and Experimental Studies of Targeted Nasal Drug Delivery

Nasal drug delivery has emerged as a potential for systemic and possibly pulmonary treatment. It offers an interesting alternative for achieving systemic therapeutic effects of drugs that are comparable to the parenteral route, which can be inconvenient at times or oral administration, which can result in unacceptably low drug bioavailability. Targeted and controlled delivery devices will enable opportunities for new drugs to be delivered with targeted sites such as the olfactory region, sinuses, and even pulmonary.
Drug delivery efficiency in a realistic human nasal cavity for a variety of aerosol drug administration systems targeting the olfactory region will be investigated. Outcomes of this work will lead to new innovative delivery device designs for effective respiratory treatment

This project will involve experimental fluid dynamics (EFD) using PIV and PLIF at CSIRO, and computational fluid dynamics (CFD) using Ansys-Fluent aimed at providing practical solutions in order to improving drug delivery efficiency of inhalation therapy devices. Experimental measurements will be performed using both light scattering methods, and high speed photography.

Value and duration
This is for a PhD Scholarship, or a top-up scholarship, for a period of 3 years. The value of the scholarship is up to $31,000 per year. For a candidate already holding a scholarship, a top-up of up to$10,000 per year is available for work on this project.

Number of scholarships available
One

Eligibility
To be eligible for this scholarship you must:
• have a Degree (or equivalent Masters by Research) in engineering or related discipline, biomedical, physics, or related discipline.
• be an Australian citizen, Australian Permanent Resident, or a self-funded international student.
• preferably have research experience involving computational modelling, image processing, and experimental techniques.
• possess a strong desire to study fluid dynamics using computational and experimental techniques, and passion for modern supercomputing.

How to apply
Applicants should contact Dr Kiao Inthavong (kiao.inthavong@rmit.edu.au) to discuss eligibility.

Open date
Applications are now open as of 14 Dec 2018

Terms and conditions
Up to $30,000 per year for 3 years as scholarship (or up to$10,000 per year as a top-up scholarship, for a candidate already in receipt of an APA or equivalent scholarship). The applicant should be an Australian citizen, Australian Permanent Resident, or a self-funded international student.

PhD Project Opportunity2019-01-02T07:11:30+00:00

Examining mesh independence for flow dynamics in the human nasal cavity

2018-10-23T12:46:28+00:00

Download Paper >Examining mesh independence for flow dynamics in the human nasal cavity.pdf<

Scripts used in the paper with the velocity profile data on planes.

ABSTRACT:
Increased computational resources provide new opportunities to explore sophisticated respiratory modelling. A survey of recent publications showed a steady increase in the number of mesh elements used in computational models, with time. Complex geometries such as the nasal cavity exhibit sharp gradients, and irregular curvatures, leading to abnormal flow development occurring across its surface. This requires a robust method for examining the near wall mesh resolution. The non-dimensional wall unit y^+ (often used in turbulent flows) was used as a parameter to evaluate the near wall mesh in laminar flows.

Mesh independence analysis from line profiles showed that the line location had a significant influence on the result. Furthermore, using a single line profile as a measure for mesh convergence was unsuitable for representing the entire flow field. To improve this, we proposed a 2D cross-sectional plane subtraction method where scalar values (such as the velocity magnitude) on a cross-sectional plane were interpolated onto a regularly spaced grid. The new interpolated grid values, from any two meshed models, could then be compared for changes caused by the different meshed models. Its application to 3D volume subtraction was also demonstrated.
The results showed that if the near wall mesh was sufficiently refined, then narrowed passages were less reliant on the overall mesh size. However, in wider passages velocity magnitudes were sensitive to mesh size and this required a more refined mesh.

Keywords: mesh independence, nasal cavity, y^+, y-plus, laminar flow

2D plane subtraction results

3D subtraction results

Examining mesh independence for flow dynamics in the human nasal cavity2018-10-23T12:46:28+00:00

Common Tables & Conversions

2018-09-18T20:26:57+00:00
 L/min L/s m3/min m3/s kg/min kg/s 1 0.0167 0.0010 1.667E-05 1.225E-03 2.042E-05 2 0.0333 0.0020 3.333E-05 2.450E-03 4.083E-05 3 0.0500 0.0030 5.000E-05 3.675E-03 6.125E-05 4 0.0667 0.0040 6.667E-05 4.900E-03 8.167E-05 5 0.0833 0.0050 8.333E-05 6.125E-03 1.021E-04 6 0.1000 0.0060 1.000E-04 7.350E-03 1.225E-04 7 0.1167 0.0070 1.167E-04 8.575E-03 1.429E-04 8 0.1333 0.0080 1.333E-04 9.800E-03 1.633E-04 9 0.1500 0.0090 1.500E-04 1.103E-02 1.838E-04 10 0.1667 0.0100 1.667E-04 1.225E-02 2.042E-04 11 0.1833 0.0110 1.833E-04 1.348E-02 2.246E-04 12 0.2000 0.0120 2.000E-04 1.470E-02 2.450E-04 13 0.2167 0.0130 2.167E-04 1.593E-02 2.654E-04 14 0.2333 0.0140 2.333E-04 1.715E-02 2.858E-04 15 0.2500 0.0150 2.500E-04 1.838E-02 3.063E-04 16 0.2667 0.0160 2.667E-04 1.960E-02 3.267E-04 17 0.2833 0.0170 2.833E-04 2.083E-02 3.471E-04 18 0.3000 0.0180 3.000E-04 2.205E-02 3.675E-04 19 0.3167 0.0190 3.167E-04 2.328E-02 3.879E-04 20 0.3333 0.0200 3.333E-04 2.450E-02 4.083E-04 21 0.3500 0.0210 3.500E-04 2.573E-02 4.288E-04 22 0.3667 0.0220 3.667E-04 2.695E-02 4.492E-04 23 0.3833 0.0230 3.833E-04 2.818E-02 4.696E-04 24 0.4000 0.0240 4.000E-04 2.940E-02 4.900E-04 25 0.4167 0.0250 4.167E-04 3.063E-02 5.104E-04 26 0.4333 0.0260 4.333E-04 3.185E-02 5.308E-04 27 0.4500 0.0270 4.500E-04 3.308E-02 5.513E-04 28 0.4667 0.0280 4.667E-04 3.430E-02 5.717E-04 29 0.4833 0.0290 4.833E-04 3.553E-02 5.921E-04 30 0.5000 0.0300 5.000E-04 3.675E-02 6.125E-04 31 0.5167 0.0310 5.167E-04 3.798E-02 6.329E-04 32 0.5333 0.0320 5.333E-04 3.920E-02 6.533E-04 33 0.5500 0.0330 5.500E-04 4.043E-02 6.738E-04 34 0.5667 0.0340 5.667E-04 4.165E-02 6.942E-04 35 0.5833 0.0350 5.833E-04 4.288E-02 7.146E-04 36 0.6000 0.0360 6.000E-04 4.410E-02 7.350E-04 37 0.6167 0.0370 6.167E-04 4.533E-02 7.554E-04 38 0.6333 0.0380 6.333E-04 4.655E-02 7.758E-04 39 0.6500 0.0390 6.500E-04 4.778E-02 7.963E-04 40 0.6667 0.0400 6.667E-04 4.900E-02 8.167E-04 41 0.6833 0.0410 6.833E-04 5.023E-02 8.371E-04 42 0.7000 0.0420 7.000E-04 5.145E-02 8.575E-04 43 0.7167 0.0430 7.167E-04 5.268E-02 8.779E-04 44 0.7333 0.0440 7.333E-04 5.390E-02 8.983E-04 45 0.7500 0.0450 7.500E-04 5.513E-02 9.188E-04 46 0.7667 0.0460 7.667E-04 5.635E-02 9.392E-04 47 0.7833 0.0470 7.833E-04 5.758E-02 9.596E-04 48 0.8000 0.0480 8.000E-04 5.880E-02 9.800E-04 49 0.8167 0.0490 8.167E-04 6.003E-02 1.000E-03 50 0.8333 0.0500 8.333E-04 6.125E-02 1.021E-03
Common Tables & Conversions2018-09-18T20:26:57+00:00

Advances in Building Energy Research: Special Issue

2018-10-04T10:38:52+00:00

Since our COBEE2018 conference we worked on finalising the conference proceedings (found here: https://lnkd.in/e7Zsq52). Recently we have also been able to receive a special issue with the journal of Advances in Building Energy Research with the topic:

Instructions for submitting your paper to the special issue is found at:
https://bit.ly/2txiz4e

The journal is published with Taylor & Francis and
– is indexed in Scopus with Cite-Score 2017: 1.12, and
-ranking 63/161 in the Building and Construction category.

Advances in Building Energy Research: Special Issue2018-10-04T10:38:52+00:00

scimagojr journal rankings

2019-08-26T04:26:29+00:00

Other/General Engineering

scimagojr journal rankings2019-08-26T04:26:29+00:00

uv unwrapping method for respiratory airflows

2018-08-10T14:36:56+00:00

introduced in: Surface mapping for visualization of wall stresses during inhalation in a human nasal cavityRespiratory Physiology and Neurobiology (2014) 190(1): p.54-61.

Also applied in the following:

• Dong, J., Shang, Y., Inthavong, K., Chan, H.-K., & Tu, J. (2018). Numerical Comparison of Nasal Aerosol Administration Systems for Efficient Nose-to-Brain Drug Delivery. Pharmaceutical research, 35(1), 5.
• Dong, J., Shang, Y., Tian, L., Inthavong, K., & Tu, J. (2018). Detailed deposition analysis of inertial and diffusive particles in a rat nasal passage. Inhalation toxicology, 1-11.
• Shang, Y., Dong, J., Inthavong, K., & Tu, J. (2017). Computational fluid dynamics analysis of wall shear stresses between human and rat nasal cavities. European Journal of Mechanics-B/Fluids, 61, 160-169.
• Shang, Y., Inthavong, K., & Tu, J. (2015). Detailed micro-particle deposition patterns in the human nasal cavity influenced by the breathing zone. Computers & Fluids, 114, 141-150.
• Shang, Y. D., Dong, J. L., Inthavong, K., & Tu, J. Y. (2015). Comparative numerical modeling of inhaled micron-sized particle deposition in human and rat nasal cavities. Inhalation Toxicology, 27(13), 694-705.
• Tian, L., Shang, Y., Chen, R., Bai, R., Chen, C., Inthavong, K., & Tu, J. (2017). A combined experimental and numerical study on upper airway dosimetry of inhaled nanoparticles from an electrical discharge machine shop. Particle and fibre toxicology, 14(1), 24.

During respiration, a multitude of physiological functions occur simultaneously including air conditioning, filtering out foreign particles, olfaction, and clearance mechanisms. Airflow analysis can assist in better understanding the physiology however the human nasal cavity is an extremely complicated geometry that is difficult to visualize in 3D space, let alone in 2D space. In this paper, a computationally reconstructed nasal cavity is unwrapped and transformed into a 2D space, into a UV-domain (where u and v are the coordinates) to allow a complete view of the entire wrapped surface. This visualization technique allows surface flow parameters to be analysed with greater precision. A UV-unwrapping tool is developed and a strategy is presented to allow deeper analysis to be performed. This includes i) the ability to present instant comparisons of geometry and flow variables between any number of different nasal cavity models through normalization of the 2D unwrapped surface; ii) visualization of an entire surface in one view and; iii) a planar surface that allows direct 1D and 2D analytical solutions of diffusion of inhaled vapors and particles through the nasal walls. This work lays a foundation for future investigations that incorporates toxicology and health responses to local inhalation of gases and particles.

Animation of UV-unwrapping of the nasal cavity:

Surface unwrapping flow process
UV-Unwrapping Tool Matlab Executable
Matlab GUI

Instructions for Matlab v2017b

1. The GUI was created in Matlab2017b. Please make sure you installed the corresponding Matlab Runtime.
2. The folder contains 4 files. One is the executable GUI file named ‘Nasal_Cavity_Mapping.exe’ and the others are for tutorial.
3. Export a data file from Fluent including geometric information along with a variable (such as wall shear stress). The version of Fluent I am using is 18.0. I have exported a file named ‘DUN001_mapping_example_tec.dat’ as an example.
4. Open the executable file. Due to the Matlab Runtime environment, it may take as long as one minute to open, depending on your computer capability.
5. Copy the file name of the data file into the GUI, select data type as 3D, then click ‘Import’. Wait until a 3D model appearing in the bottom-left window for 3D visualisation.
6. If the model looks correct, click ‘Export .Obj’ button and you will find a new file named ‘Geometry.obj’ being created.
7. Open and edit the .obj file in a UV-Mapping software ‘Unfold3D’. I am using version 9 but the latest version is 10. Unwrap the geometry as you wish, and then save as another .obj file. Please see the example unwrapped file ‘Geometry_mapped.obj’. By the way, you can using other unwrapping tools such as Maya, 3dMax, Blender, Geomagic etc. But I can’t guarantee the GUI works fine with them because I have never tried.
8. Copy the unwrapped file name into the GUI and select data type as ‘2D’, click ‘Import’. You will see the unwrapped geometry appearing in the bottom-right window for 2D visualisation. In addition, division curves that are pre-defined in the unwrapping software will be added to geometries in both windows.
9. Export particle deposition coordinates from Fluent. You can find an example deposition file named ‘nc_deposition.dpm’. Copy the particle deposition file name into the GUI and select data type as ‘Particle’, click ‘Import’. Particles will be immediately appearing in the bottom-left window for 3D visualisation.
10. If the visualised particle distribution looks correct, click ‘Project Particles’ button, then particles will be automatically projected into the unwrapped domain in the bottom-right window.
11. You can tick on/off light shading, particle view and additional variable view (such as WSS) at the right sides of both windows for 3D and 2D visualisation. If you wish to export an image, simply click ‘Enlarge’ button and you will get a standard Matlab Figure Dialogue.

uv unwrapping method for respiratory airflows2018-08-10T14:36:56+00:00

Convert a single cine file to sequentially numbered tiffs

2018-08-10T14:20:37+00:00

Convert a single cine file to sequentially numbered tiffs
================================================================
credit:
“https://wiki.brown.edu/confluence/display/ctx/Convert+a+single+cine+file+to+sequentially+numbered+tiffs”
================================================================

In Phantom cine viewer open the cine file, for example “Kia_cam1_run33.cine”

Click on “Convert” button, in the lower right hand of the screen.

Choose the type of tiff: 8 or 12 or 16 bit tiff (the second number after the comma is for color images, e.g. so 8bit per channel =24)

Then in the file name box type: Kia_cam1_run33.+5.tiff

+5 inserts a image number starting from 1, thet 5 specifies how many digit counter places will be used for the image number.

don’t forget the dots (.) , if you want to have dots separating your original file name from the sequence number.

Now click “Save”

you should now have a image sequence like this:

Kia_cam1_run33.00001.tiff

Kia_cam1_run33.00002.tiff

Kia_cam1_run33.00003.tiff

Convert a single cine file to sequentially numbered tiffs2018-08-10T14:20:37+00:00

Using a batch file to automatically compress files of the same type or folders using 7-zip

2018-08-10T14:20:04+00:00

Compressing files of the same type
===============================
@echo off
cd /d %~dp0
rem 7z.exe path
set sevenzip=
if “%sevenzip%”==”” if exist “%ProgramFiles(x86)%\7-zip\7z.exe” set sevenzip=%ProgramFiles(x86)%\7-zip\7z.exe
if “%sevenzip%”==”” if exist “%ProgramFiles%\7-zip\7z.exe” set sevenzip=%ProgramFiles%\7-zip\7z.exe
set extension=.xls
for %%a in (*%extension%) do “%sevenzip%” a -mx “%%~na.7z” “%%a”
pause
Change the extension for the type of file being compressed.

Compressing folders
===============================

for /d %%X in (*) do “c:\Program Files\7-Zip\7z.exe” a -mx “%%X.7z” “%%X\”

Paste the code into notepad, and save as .bat file. Double click to start the batch process.

Using a batch file to automatically compress files of the same type or folders using 7-zip2018-08-10T14:20:04+00:00

Ansys-Fluent-CFD-Post-Scripts

2019-01-13T12:53:46+00:00

How-to-remove-partition-line-in-figures

Pre-setup commands for saving images

How to compile FLUENT 64-bit UDFs using Visual Studio Express 2010 and the 7.1 SDK

Extracting data from Fluent

Extract numerical values from Fluent xy-plot files using Matlab

Looping through cfx .trn files and exporting figures and data

Looping through cfx .trn files and exporting figures and data

Script to generate mass flow rate profile

RUNNING JOBS WITH GPU

• fluent command runs ANSYS Fluent interactively
• -g indicates that the program is to be run without the GUI or graphics
• <version> specifies the 3d or 3ddp version of ANSYS Fluent
• <nprocs> specifies the total number of CPU processors across all machines/nodes
• <ngpgpus> specifies the number of GPUs per machine/node available in parallel mode. Note that the number of processes per machine must be equal on all machines and ngpgpus must be chosen such that the number of processes per machine is an integer multiple of ngpgpus. That is, for nprocs solver processes running on M machines using ngpgpus GPUs per machine, we must have:
• (nprocs) mod (M) = 0
• (nprocs/M) mod (ngpgpus) = 0
• <journal_file_name> specifies the name of the journal or input file.
• <output_file_name> specifies the name of the output file. It is a file that the background job will create, which will contain the output that ANSYS Fluent would normally print to the screen (for example, the menu prompts and residual reports).

Journal File contains sequence of ANSYS Fluent commands that are identical to those that you would type interactively. Comments can be added in the file with a semicolon at the beginning of the line.

MODEL SUITABILITY FOR GPU ACCELERATION

A coupled solver benefits most from GPUs. In flow only problems, typically the coupled solver spends about 60 percent to 70 percent of its time solving the linear system using AMG, making GPUs a good choice. Since the segregated solver spends only 30 percent to 40 percent of its time in AMG, GPUs may not be advantageous because of memory transfer overhead costs. By default, GPU acceleration is applied automatically to coupled systems and not to scalar systems because scalar systems typically are not as computationally expensive. However, if desired you can enable/disable GPGPU acceleration of the AMG solver for coupled and scalar systems with the following text command and list each supported equation type allowing you to enable/disable GPGPU acceleration, choose between AMG and FGMRES solvers, and specify various solver options.

• The population balance model is active.
• The Eulerian multiphase model is active.
• The system has more than 5 coupled equations.

ACCELERATING DISCRETE ORDINATES (DO) RADIATION CALCULATIONS

The solver is based on OpenACC and can run on either architectures: CPUs or GPUs. The solver is currently not compatible with all the models and boundary conditions but is found to be extremely fast where applicable. Cases that need very high resolution in discretizing the radiation intensities benefit the most from this accelerated solver. Head lamp simulation is one such application area where the accelerated solver speeds up the computation by several times.

After you have selected the DO model in the Radiation Model dialog box, you can enable the accelerated DO solver by using the following text command:

The accelerated DO solver is incompatible with some models and settings; when necessary, Fluent will automatically revert to the standard DO solver when the calculation is started and print a message about the conflict.

If you plan to use GPUs with the accelerated DO solver, it is recommended that you run NVIDIA’s multi-process server (MPS) before launching ANSYS Fluent using the following command:

When using the raytracing_acc utility from outside an ANSYS Fluent session, the command line is

Scheme Programing Handouts

Ansys-Fluent-CFD-Post-Scripts2019-01-13T12:53:46+00:00

Tecplot Tips

2019-07-10T10:57:32+00:00

Extract Images

===========================

import os
os.chdir(r'F:\images\planes-bend')

import glob
flist=glob.glob('*planes.plt')

#flist = flist[0:5] # just for testing on 5 files and not all of them!
import tecplot as tp
from tecplot.exception import *
from tecplot.constant import *
# Uncomment the following line to connect to a running instance of Tecplot 360:
tp.session.connect()

#fname = 'p0.01_b0.02_planes.plt'
for fname in flist:
# 3D view
plot = tp.active_frame().plot(PlotType.Cartesian3D)
plot.activate()

tp.active_frame().plot().fieldmap(0).show=True #inlet contour
tp.active_frame().plot().fieldmap(1).show=False
tp.active_frame().plot().fieldmap(2).show=False
tp.active_frame().plot().fieldmap(3).show=False
tp.active_frame().plot().fieldmap(4).show=False

bendName = [f'{fname[:-4]}_bendInlet',f'{fname[:-4]}_bend225',f'{fname[:-4]}_bend450',f'{fname[:-4]}_bend675',f'{fname[:-4]}_bendOutlet']
#select contour
tp.active_frame().plot().show_contour=True

#to show pressure set index to 4
#to show vel mag set index to 3 based on results file
tp.active_frame().plot().contour(0).variable_index=3

tp.active_frame().plot().contour(0).legend.show=False
# tp.active_frame().plot().contour(0).colormap_name='Modified Rainbow - Dark ends'
#tp.active_frame().plot().contour(0).colormap_name='Diverging - Blue/Red'
tp.active_frame().plot().contour(0).colormap_name='Hot Metal'

tp.active_frame().plot().contour(0).levels.reset_to_nice(num_levels=81)
tp.active_frame().plot().axes.orientation_axis.show=False
tp.macro.execute_command('\$!FrameLayout ShowBorder = No')

tp.active_frame().plot(PlotType.Cartesian3D).use_lighting_effect=False

tp.active_frame().plot().view.position=(0,tp.active_frame().plot().view.position[1],tp.active_frame().plot().view.position[2])
tp.active_frame().plot().view.position=(tp.active_frame().plot().view.position[0],0.1,tp.active_frame().plot().view.position[2])
tp.active_frame().plot().view.position=(tp.active_frame().plot().view.position[0],tp.active_frame().plot().view.position[1],0.1)
tp.active_frame().plot().view.psi=0
tp.active_frame().plot().view.theta=0

if dataset.num_zones ==7:
tp.active_frame().plot().fieldmap(5).show=False
tp.active_frame().plot().fieldmap(6).show=False
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[0]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)
tp.active_frame().plot().fieldmap(0).show=False
plot.view.psi = 157.5
tp.active_frame().plot().fieldmap(1).show=True
tp.active_frame().plot().fieldmap(2).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[1]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(1).show=False
tp.active_frame().plot().fieldmap(2).show=False
plot.view.psi = 135
tp.active_frame().plot().fieldmap(3).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[2]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(3).show=False
plot.view.psi = 112.5
tp.active_frame().plot().fieldmap(4).show=True
tp.active_frame().plot().fieldmap(5).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[3]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(4).show=False
tp.active_frame().plot().fieldmap(5).show=False
plot.view.psi = 90
tp.active_frame().plot().fieldmap(6).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[4]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

#############################################################################
if dataset.num_zones ==6:
tp.active_frame().plot().fieldmap(5).show=False
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[0]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(0).show=False
plot.view.psi = 157.5
tp.active_frame().plot().fieldmap(1).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[1]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(1).show=False
plot.view.psi = 135
tp.active_frame().plot().fieldmap(2).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[2]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(2).show=False
plot.view.psi = 112.5
tp.active_frame().plot().fieldmap(3).show=True
tp.active_frame().plot().fieldmap(4).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[3]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(3).show=False
tp.active_frame().plot().fieldmap(4).show=False
plot.view.psi = 90
tp.active_frame().plot().fieldmap(5).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[4]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

#############################################################################
if dataset.num_zones ==5:
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[0]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)
for i in range(4):
plot.view.psi = 180-(22.5*(i+1))
tp.active_frame().plot().fieldmap(i).show=False
tp.active_frame().plot().fieldmap(i+1).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[i+1]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

Extract frames from video file
===========================

import cv2
print(cv2.__version__)
vidcap = cv2.VideoCapture(r'D:\_Local_Aero_Files\_Projects-AERO\tecplot-Files\transverse-slices-vel.mp4')
count = 0
success = True
while success:
cv2.imwrite("transverse-vel-%d.jpg" % count, image) # save frame as JPEG file
print (f'Read a new frame: {count}'), success
count += 1

How to calculate the velocity magnitude:
===========================
1. After importing Fluent data, some flow variables are not all passed on, in particular the velocity magnitude. To rectify,
2. Go to Analyze > Field Variables, and under Convective Variables, select the Velocity option, and click the Select button. Ensure that the velocity variables, are U, V, and W velocities to match the coordinate system. Then
3. Go to Analyze > Calculate Variables. Click the Select button, select Velocity Magnitude from the list, and click OK. Click Calculate. 4. The variable will now be available for selection

How to extract data from a line in Tecplot:
===========================
1. This is a handy tool which is a free add-on in Tecplot.
2. The Extract Precise Polyline add-on extracts a line of points defined by entering the (x,y,z) coordinates of a start and end points.