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

Different results using python vs shell

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 24, 2020, 20:46
Default Different results using python vs shell
  #1
Senior Member
 
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8
joshmccraney is on a distinguished road
Hi FOAMers!

Liquid is sucked of a tank, where the velocity at this outlet (suction point) is controlled by a python script. The script changes the entire 4th line below to a different number

Code:
    outlet
    {
	type            fixedValue;
        value           uniform (0 -2.6254593e-03 0); 
    }
When I run the script, the volumetric flow rate is off by a lot (simple enough to calculate). However, when I hard code the outlet BC and run it through bash, it runs fine.

THIS IS THE WEIRD PART: after running through bash, when I re-run through python, the volumetric flow rate is perfect. WHAT'S EVEN WEIRDER is after it works fine, if I copy the entire work file and run it again, the same error occurs.

Anyone have any experience with this? Very confusing for me.
joshmccraney is offline   Reply With Quote

Old   April 25, 2020, 12:52
Default
  #2
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
have you checked how many decimals were dumped by python and bash separately. should be some syntax error.
HPE is offline   Reply With Quote

Old   April 25, 2020, 12:56
Default
  #3
Senior Member
 
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8
joshmccraney is on a distinguished road
Quote:
Originally Posted by HPE View Post
have you checked how many decimals were dumped by python and bash separately. should be some syntax error.
I have not: how would I do this?

But is this the reason? I copy exactly what the python script writes and I get good results. The odd thing is, after I run it through bash, when I rerun through Python it works fine, and it still pastes over whatever I hardcoded (though it's the same).
joshmccraney is offline   Reply With Quote

Old   April 26, 2020, 21:11
Default
  #4
Senior Member
 
Josh McCraney
Join Date: Jun 2018
Posts: 220
Rep Power: 8
joshmccraney is on a distinguished road
UPDATE: the solution was given here. To summarize, disc operations, like reading and writing, can take a very long time compared to the operation of the program, and they run independently of the thread of your program. The solution here is to invoke Popen.wait.

Thanks for the interest!
joshmccraney 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
Error Interpolating Results onto New Mesh nammeh CFX 1 March 26, 2019 12:08
How to get Python Shell into ParaView 3.8.1? blaise OpenFOAM Installation 3 July 24, 2012 04:58
shell conduction ezabille FLUENT 2 December 15, 2010 17:42
ParaView 33 Python Shell error and fix mschoenberg OpenFOAM Bugs 1 August 21, 2008 04:43
[OpenFOAM] ParaView 33 Python Shell error mschoenberg ParaView 2 August 20, 2008 10:42


All times are GMT -4. The time now is 02:33.