ludwig-cf / ludwig

A lattice Boltzmann code for complex fluids
https://ludwig.epcc.ed.ac.uk
Other
53 stars 35 forks source link

python script (extract.py) for post-processing #167

Closed JRAgrawal closed 2 years ago

JRAgrawal commented 2 years ago

Greetings,

I am trying to run tutorial tests 2 and 3; and was able to produce the output files successfully, but for the post-processing of data, a python script (extract.py) is required according to the tutorial document. which seems to be missing from the code files. Can you let me know if there is any alternative for this or am I missing something.

Thank You. Regards

ohenrich commented 2 years ago

@godfatherkills @kevinstratford Hi there, I think you are on the master branch, which is not completely up-to-date in the tutorial materials. I updated the develop branch a few months ago, but this hasn't been merged yet with master. The develop branch contains an example of a bash script that you can write instead.

JRAgrawal commented 2 years ago

Hello,

Thank you for your response, I found the updated tutorial materials. But I had a query:

I get an error while converting the latex tutorial files to pdf using 'make' command.

pdflatex ludwig.tex make: pdflatex: Command not found make: *** [Makefile:23: pdf] Error 127

I am using wsl, and quite new to this environment. I would be grateful if you help me sort this out. I converted the file to pdf using other tools available online but they fail to convert image files.

Thank You.

ohenrich commented 2 years ago

You're welcome. But this is a problem with your system setup. Unfortunately, I'm not familiar with wsl, only Unix command line. Thus, there is not much I can do from this end.

I would try to install the TeX Live (https://www.tug.org/texlive/) as it has pdflatex. pdflatex takes all common picture formats (.pdf, .png, .jpg, .tiff), whereas latex in dvi-mode, which is what you seem to have, supports only .eps files.

Another solution would be to convert all .png files to .eps files and change the corresponding filenames in the tex source code. It should work, but is perhaps not preferable.

JRAgrawal commented 2 years ago

Thank You for your response. When I try to run test 3 while changing domain size, I changed the size to (64)^3 and number of colloids to 50 with vf=0.0384. I made similar changes in the colloid_init.c and extract_colloid.c too. After running the code in working directory using 'mpirun -np 4 ./Ludwig.exe input', I get the system size as 64 64 64 but the local domain as 32 32 64. And the timeloop fails to start. I have attached the image for the error.

test3error

Moreover, I had few general queries (they may sound silly but I am kinda' new to this environment) : 1) Can we change the geometry; as in I guess currently It is a square geometry (a box), so can I change it to an arbitrary geometry according to my problem statement? If yes, can you please share the steps.

2) Can I change the parameters' data I want in the output file. For example: In a pipe flow in test1 the output parameters are geometry and velocity components. Can I print the pressure values or any other hydrodynamic parameter too in the output file? If yes, where can we change these parameters to get the intended values in output files.

3) Can I change the colloid shape, surface conditions, and positions?

Any kind of help/insights are highly appreciated.

Thank You. Regards.

ohenrich commented 2 years ago

Thank You for your response. When I try to run test 3 while changing domain size, I changed the size to (64)^3 and number of colloids to 50 with vf=0.0384. I made similar changes in the colloid_init.c and extract_colloid.c too. After running the code in working directory using 'mpirun -np 4 ./Ludwig.exe input', I get the system size as 64 64 64 but the local domain as 32 32 64. And the timeloop fails to start. I have attached the image for the error.

test3error

It is impossible to say what is going wrong without input files and complete parameters. Have you tried running with just one colloid? Can you provide more information by sending the input file and the modifications you made in colloid_init.c (or by sending the whole C-file)? Most likely, this is because of an ill-posed colloid state.

The domain size, of which you seem to be unsure, is OK. You are running on 4 MPI-tasks and the first two dimensions are decomposed. If you don't specify the decomposition in the input file, Ludwig will distribute the processes evenly starting with the x-dimension.

Moreover, I had few general queries (they may sound silly but I am kinda' new to this environment) :

  1. Can we change the geometry; as in I guess currently It is a square geometry (a box), so can I change it to an arbitrary geometry according to my problem statement? If yes, can you please share the steps.

Yes, you can change it to any cuboidal geometry without any problem. This is done by setting size in the input file (see /src/input.ref for a reference input file).

Other geometries are also possible, e.g. a tube with a circular or elliptic cross section. But this requires porous media setup. What you basically need to do is define solid, immobile sites around the boundaries to obtain the desired geometry. Kevin @kevinstratford would be able to tell you more.

  1. Can I change the parameters' data I want in the output file. For example: In a pipe flow in test1 the output parameters are geometry and velocity components. Can I print the pressure values or any other hydrodynamic parameter too in the output file? If yes, where can we change these parameters to get the intended values in output files.

Pressure is trivially given in LB through the ideal gas equation of state as P = c_s^2 rho with c_s as lattice speed of sound and rho as density. This is the reason why LB doesn't solve a Poisson equation for the pressure. The density is only reported among the standard output, but is not really interesting as LB is only very weakly compressible.

I'm afraid but the output quantities are set by the free energy model you use. For instance without free energy and for a simple fluid, you obtain only the velocity- files, which have the pressure and velocity field. A binary mixture gives you an phi- file that contains the binary order parameter.

I recommend you compile the documentation in /docs/ with make pdf and look into these models.

  1. Can I change the colloid shape, surface conditions, and positions?

I don't think we have non-spherical colloids implemented. Kevin @kevinstratford can advise. Surface conditions in the sense of wetting angle, liquid crystal anchoring strength, etc can be changed. You can initialise colloids at any point you desire. This can be done for a small number of colloids through the input file and colloid_one_r x1_y1_y2, colloid_two_r x2_y2_z2, ... or by hacking or replacing the randomising routine colloid_init_random() in colloid_init.c line 242 ff. You could think of replacing the random number with a regular array index.

Any kind of help/insights are highly appreciated.

Thank You. Regards.

No worries.

JRAgrawal commented 2 years ago

I am very thankful for your help and comprehensive responses.

I am sharing the entire C file for the problem statement I am working for your reference through this drive link. For this problem, I am using a 32^3 domain size with 3 colloids initialized in the input file with periodic BC in x-direction and solid walls (No-slip bc) in remaining walls.

The code gets compiled with 3 colloids but during the post processing part it only writes 1 colloid.

Capture

Moreover, while using the bash script for post-processing, codes gets dumped with a segmentation fault.

Capture1

Similar error is shown for 'q' too.

CODE: https://drive.google.com/file/d/1N0nrQTYvtdzfs0vTLtVJNSZuep6rrWYW/view?usp=sharing

Also, can we input an external electric field (potential difference across walls) apart from imposing charge on colloid particle

Please view this once and please let me know what you think. Any kind of inputs would be helpful.

Thank You. Regards.

ohenrich commented 2 years ago

I am very thankful for your help and comprehensive responses.

No worries. You're very welcome.

I am sharing the entire C file for the problem statement I am working for your reference through this drive link. For this problem, I am using a 32^3 domain size with 3 colloids initialized in the input file with periodic BC in x-direction and solid walls (No-slip bc) in remaining walls.

The code gets compiled with 3 colloids but during the post processing part it only writes 1 colloid.

I believe you mean the code is initialised with 3 colloids (it isn't, see below) as the number of colloids is nowhere hardcoded. Compilation is when the executable is produced from the source code.

Capture

I had a look at your input file in /test3/ and think you haven't initialised 3 colloids as you have only one sequence of colloid_onecommands. What you need is something like this:

colloid_one_a0 1.25 colloid_one_ah 1.25 colloid_one_r 6.0_6.0_6.0

colloid_two_a0 1.25 colloid_two_ah 1.25 colloid_two_r 6.0_6.0_3.1

colloid_three_a0 1.25 colloid_three_ah 1.25 colloid_three_r 6.0_6.0_8.8

This might be why there is only one colloid in the output. The stdout (screen output) tells you as well how many colloids were initialised.

Moreover, while using the bash script for post-processing, codes gets dumped with a segmentation fault.

Capture1

This is because you are trying to process timestep vel-0000000. Ludwig never creates velocity output for the initial timestep. The first one according to your input script is timestep vel-00001000.

Similar error is shown for 'q' too.

Same reason.

CODE: https://drive.google.com/file/d/1N0nrQTYvtdzfs0vTLtVJNSZuep6rrWYW/view?usp=sharing

For simplicity it normally suffices if you just send the input file and e.g. colloid_init.c, etc in case you make modifications to utility codes.

Also, can we input an external electric field (potential difference across walls) apart from imposing charge on colloid particle

You can initialise an external electric field and charge on the colloid as well.

The former would be set with electric_e0 Ex_Ey_Ez. Have a look at input.ref in /src/. Note it says magnetic field in the comment, which is not correct.

The charge on colloids is set in colloid_init.c

I suggest we close this issue as it goes more in a direction of support and you contact me on my email address oliver.henrich@strath.ac.uk. OK?