CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Plot the residuals using pyFoamPlotWatcher

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 3 Post By mmohaqeqf
  • 3 Post By mmohaqeqf

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 26, 2020, 18:15
Default Plotting the residuals using pyFoamPlotWatcher from bash under windows 10
  #1
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Hi guys;


I am using OpenFOAM version 2006 (20 06) in Windows 10, through Ubuntu 18.04 (Ubuntu 18.04.2 LTS, bionic, bash version 4.4.19(1)-release).


The OpenFOAM itself has been running flawlessly so far.

My question is about setting up the requirements to use pyFoamPlotWatcher to monitor the residuals from simpleFoam.


So, I ran one of my cases and also output a log file called log.simpleFoam in my case directory. When I type pyFoamPlotWatcher.py log.simpleFoam in the bash, first the bash opens the log file and at the end it says:


gnuplot: unable to open display ''
gnuplot: X11 aborted.


I currently have python (Version 3.8.0a1), gnuplot (Version 5.2 patchlevel 8), and Xming (Version 6.9), installed on my windows.


I have been spending the last 5 hours digging into different discussion forums, but have been unable to come up with a solution for my issue.


I have also taken a look at this post (Tutorial of how to plot residuals !), which did not help me much.


Any help is appreciated.


Thanks

Last edited by mmohaqeqf; November 27, 2020 at 23:10. Reason: better title
mmohaqeqf is offline   Reply With Quote

Old   November 27, 2020, 00:42
Default
  #2
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Ok I found the answer for my own question, so I am posting the solution here in case others get stuck with similar issue.

Please refer to the following link for the solution:


https://askubuntu.com/questions/9488...-on-windows-10
dlahaye, HappyS5 and Dohyun like this.
mmohaqeqf is offline   Reply With Quote

Old   November 27, 2020, 23:08
Default
  #3
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Just a few more points for future reference, in order to be able to plot anything using gnuplot from the bash that is installed within the windows:


1) You need gnuplot only installed on your bash, not on your windows.


2) You need Xming on your windows, not on your bash.


3) You need to add the following line to your bashrc (and source it once) to set a terminal for the gnuplot to be able to show the plots:


export DISPLAY=:0 gnuplot



Note: Make sure the Xming is active and running on your Windows (double click on the Xming icon and look at the taskbar to make sure it is running) when you try to plot residuals from the bash terminal.


Hope this information helps some one.

Last edited by mmohaqeqf; December 2, 2020 at 12:09.
mmohaqeqf is offline   Reply With Quote

Old   January 22, 2021, 02:55
Default
  #4
New Member
 
Join Date: Dec 2020
Posts: 26
Rep Power: 5
OlivierM is on a distinguished road
Quote:
Originally Posted by mmohaqeqf View Post
Just a few more points for future reference, in order to be able to plot anything using gnuplot from the bash that is installed within the windows:


1) You need gnuplot only installed on your bash, not on your windows.


2) You need Xming on your windows, not on your bash.


3) You need to add the following line to your bashrc (and source it once) to set a terminal for the gnuplot to be able to show the plots:


export DISPLAY=:0 gnuplot



Note: Make sure the Xming is active and running on your Windows (double click on the Xming icon and look at the taskbar to make sure it is running) when you try to plot residuals from the bash terminal.


Hope this information helps some one.
Hi,

I am a bit lost because your last step is:
export DISPLAY=:0 gnuplot

but in tle link you shared the last step was:
export DISPLAY=localhost:0.0

and then the way you succeed to monitor the residuals remains unclear for me.

do you use a script ?
which command do you use ?
do you launch a specific program ?

I am able to run simpleFoam but all I have tested so far, pyFoam or gnuplot, has failed ...

would you mind clarifying your monitoring process ?

thanks
OlivierM is offline   Reply With Quote

Old   January 23, 2021, 12:14
Default
  #5
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Quote:
Originally Posted by OlivierM View Post
Hi,

I am a bit lost because your last step is:
export DISPLAY=:0 gnuplot

but in tle link you shared the last step was:
export DISPLAY=localhost:0.0

and then the way you succeed to monitor the residuals remains unclear for me.

do you use a script ?
which command do you use ?
do you launch a specific program ?

I am able to run simpleFoam but all I have tested so far, pyFoam or gnuplot, has failed ...

would you mind clarifying your monitoring process ?

thanks

Hi there;
Regarding the link I sent in the above post, I was talking about the answer by the user Ptheguy.


Regarding the plotting itself, first you have to make sure you are logging the residuals from the simpleFoam. When you want to run simpleFoam, use the following command, this will create a log file:


$ simpleFoam > log.simpleFoam


(NOTE: you don't need to type the $ sign; it is actually the prompt!)



Once the simulation is finished, make sure the log.simpleFoam is present in your case root directory. Then run the following command (make sure Xming is running in your Windows before running the following command):


$ pyFoamPlotWatcher.py log.simpleFoam



(NOTE= depending on your system setting, you may not need to use .py at the end of the pyFoamPlotWatcher. If you use the tab to auto-complete the command, the auto-complete tells you which one you have to use.)


Let me know if it works for you.

Last edited by mmohaqeqf; January 26, 2021 at 00:57.
mmohaqeqf is offline   Reply With Quote

Old   January 25, 2021, 03:12
Default
  #6
New Member
 
Join Date: Dec 2020
Posts: 26
Rep Power: 5
OlivierM is on a distinguished road
Hi,
thanks for your help

I did it on the icoFoam cavity case.

The log.icoFoam goes properly in the case root directory.
Also 'VcXsrv windows xserver' is running (which includes Xming)

Then here is what I got whit the command 'pyFoamPlotWatcher.py':

#
$ pyFoamPlotWatcher.py log.icoFoam

> Traceback (most recent call last):
File "/usr/local/bin/pyFoamPlotWatcher.py", line 4, in <module>
__import__('pkg_resources').run_script('PyFoam==20 20.5', 'pyFoamPlotWatcher.py')
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 667, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1452, in run_script
raise ResolutionError(pkg_resources.ResolutionError: Script 'scripts/pyFoamPlotWatcher.py' not found in metadata at
'/home/<USER>/.local/lib/python3.8/site-packages/PyFoam-2020.5.dist-info'
#

Do you have any idea of what's going on ?
OlivierM is offline   Reply With Quote

Old   January 26, 2021, 00:56
Default
  #7
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Quote:
Originally Posted by OlivierM View Post
Hi,
thanks for your help

I did it on the icoFoam cavity case.

The log.icoFoam goes properly in the case root directory.
Also 'VcXsrv windows xserver' is running (which includes Xming)

Then here is what I got whit the command 'pyFoamPlotWatcher.py':

#
$ pyFoamPlotWatcher.py log.icoFoam

> Traceback (most recent call last):
File "/usr/local/bin/pyFoamPlotWatcher.py", line 4, in <module>
__import__('pkg_resources').run_script('PyFoam==20 20.5', 'pyFoamPlotWatcher.py')
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 667, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1452, in run_script
raise ResolutionError(pkg_resources.ResolutionError: Script 'scripts/pyFoamPlotWatcher.py' not found in metadata at
'/home/<USER>/.local/lib/python3.8/site-packages/PyFoam-2020.5.dist-info'
#

Do you have any idea of what's going on ?



Try typing pyFoamPlotW (note that it is missing the last few letters) and then hit tab, if it doesn't auto complete it, then it means you don't have pyFoam installed.


More info: https://openfoamwiki.net/index.php/Contrib/PyFoam


Otherwise, I am not really sure where the issue is coming from.
mmohaqeqf is offline   Reply With Quote

Old   March 29, 2022, 04:57
Default
  #8
Member
 
Sakun
Join Date: Nov 2019
Location: United Kingdom
Posts: 93
Rep Power: 6
Sakun is on a distinguished road
Quote:
Originally Posted by OlivierM View Post
Hi,
thanks for your help

I did it on the icoFoam cavity case.

The log.icoFoam goes properly in the case root directory.
Also 'VcXsrv windows xserver' is running (which includes Xming)

Then here is what I got whit the command 'pyFoamPlotWatcher.py':

#
$ pyFoamPlotWatcher.py log.icoFoam

> Traceback (most recent call last):
File "/usr/local/bin/pyFoamPlotWatcher.py", line 4, in <module>
__import__('pkg_resources').run_script('PyFoam==20 20.5', 'pyFoamPlotWatcher.py')
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 667, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1452, in run_script
raise ResolutionError(pkg_resources.ResolutionError: Script 'scripts/pyFoamPlotWatcher.py' not found in metadata at
'/home/<USER>/.local/lib/python3.8/site-packages/PyFoam-2020.5.dist-info'
#

Do you have any idea of what's going on ?

did you mange to get the solution ?
Sakun is offline   Reply With Quote

Old   September 5, 2022, 14:16
Talking A better Way to do this
  #9
New Member
 
Brandon Johnson
Join Date: Jul 2017
Posts: 6
Rep Power: 8
denbjornen is on a distinguished road
Thought I'd chime in.

I've never had luck using a Windows X Server like XMing, VcXsrv, etc (maybe got it to work once on one of my machines after hours and hours of testing). I've found an excellent tutorial on using an RDP connection to your WSL Ubuntu instance that works much better.

This video shows how to setup xrdp on WSL Ubuntu. This solution is much easier to achieve, and produced no errors for me. I'll post the steps followed here, in case this video gets taken down.

# Refresh/upgrade apt/ubuntu
Code:
sudo apt update && sudo apt -y upgrade
# Install xrdp
Code:
sudo apt install xrdp
# Install our desktop "xfce4" use another if you like
Code:
sudo apt install -y xfce4
Select "gdm3" when prompted

# Install additional goodies for xfce4
Code:
sudo apt install -y xfce4-goodies
# Make Changes to the xfce4 configuration. Primarily, we are changing the screen resolution and default connection port from 3389 to 3390. This is recommended but not necessary
Code:
sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' /etc/xrdp/xrdp.ini
# Edit the startup script
Code:
sudo nano /etc/xrdp/startwm.sh
Comment out the last two lines
Add the line:
Code:
startxfce4
# Save changes to the xsession
Code:
echo xfce4-session > ~/.xsession
# Start the xrdp server
Code:
sudo /etc/init.d/xrdp start
# Access ubuntu via the xrdp server on windows
Open up RDP (Remote Desktop Connection)
Address: localhost:3390 (or default port 3389, or whatever you changed it to)
Login using your ubuntu credentials.

As long as you have gnuplot, etc installed, you should be able to run your commands via this RDP and have zero issues getting UIs like gnuplot to work.

Happy foaming.
denbjornen is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorials] Tutorial of how to plot residuals ! wolle1982 OpenFOAM Community Contributions 171 February 20, 2024 02:55
Plot Residuals in Postprocessing Dog766 FLUENT 8 March 23, 2023 12:52
Plot the residuals over all the domain Douglas OpenFOAM Post-Processing 0 June 27, 2017 16:01
Odd residuals plot using NITA Jehosh Fluent Multiphase 1 January 8, 2016 00:02
plot of residuals hawkeye321 OpenFOAM 5 December 7, 2012 09:05


All times are GMT -4. The time now is 03:56.