Define case name

This is the solver case to be analysed


In [1]:
from collections import OrderedDict
"""
                          ('FFA-airfoilmesh2-4' , { 'alpha' : 180.0,
                                   'beta' : 0.0,
                                   'color': 'r',
                                 }),
                          ('FFA-airfoilmesh2-10' , { 'alpha' : 180.0,
                                   'beta' : 0.0,
                                   'color': 'g',
                                 }),              
                          ('FFA-airfoilmesh2-test' , { 'alpha' : 180.0,
                                   'beta' : 0.0,
                                   'color': 'b',
                                 }),
                          ('ffazf-a4' , { 'alpha' : 0.0,
                                   'beta' : 4.0,
                                   'color': 'y',
                                 }),              
                          ('ffazf-a10' , { 'alpha' : 0.0,
                                   'beta' : 10.0,
                                   'color': 'y',
                                 }),
"""
case_dict = OrderedDict(( 
                          ('ffaz' , { 'alpha' : 0.0,
                                   'beta' : 0.0,
                                   'color': 'y',
                                 }),              
                          ('ffaz-a4' , { 'alpha' : 0.0,
                                   'beta' : 4.0,
                                   'color': 'y',
                                 }),              
                          ('ffaz-a10' , { 'alpha' : 0.0,
                                   'beta' : 10.0,
                                   'color': 'y',
                                 }),
                          ('ffagmsh-a0' , { 'alpha' : 0.0,
                                   'beta' : 0.0,
                                   'color': 'r',
                                 }),              
                          ('ffagmsh-a4' , { 'alpha' : 0.0,
                                   'beta' : 4.0,
                                   'color': 'g',
                                 }),              
                          ('ffagmsh-a10' , { 'alpha' : 0.0,
                                   'beta' : 10.0,
                                   'color': 'b',
                                 }),
                          ('ffagmsh-f-a0' , { 'alpha' : 0.0,
                                   'beta' : 0.0,
                                   'color': 'r',
                                 }),              
                          ('ffagmsh-f-a4' , { 'alpha' : 0.0,
                                   'beta' : 4.0,
                                   'color': 'g',
                                 }),              
                          ('ffagmsh-f-a10' , { 'alpha' : 0.0,
                                   'beta' : 10.0,
                                   'color': 'b',
                                 }),
                           ))

Define Data Location

For remote data the interaction will use ssh to securely interact with the data
This uses the reverse connection capability in paraview so that the paraview server can be submitted to a job scheduler
Note: The default paraview server connection will use port 11111


In [2]:
remote_data = True

data_dir='FFA'
data_host='asrc'

remote_server_auto = True

paraview_cmd='mpiexec ~/apps/Paraview/bin/pvserver -rc --client-host=localhost -sp=11113'
if not remote_server_auto:
    paraview_cmd=None

if not remote_data:
    data_host='localhost'
    paraview_cmd=None

Initialise Environment


In [3]:
%pylab inline
from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()
import pylab as pl
import math


Populating the interactive namespace from numpy and matplotlib
paraview version 4.1.0-20-g45bf58c

Data Connection

This starts paraview server on remote host and connects


In [4]:
from zutil.post import pvserver_connect
if remote_data:
    pvserver_connect(data_host=data_host,data_dir=data_dir,paraview_cmd=paraview_cmd)


[asrc] Executing task 'pvserver'
[asrc] run: sleep 2;mpiexec ~/apps/Paraview/bin/pvserver -rc --client-host=localhost -sp=11113&>/dev/null
[asrc] out: 
[asrc] out: 		   _____ ______ __  __  _____ 
[asrc] out: 		  / ____|  ____|  \/  |/ ____|
[asrc] out: 		 | |    | |__  | \  / | (___  
[asrc] out: 		 | |    |  __| | |\/| |\___ \ 
[asrc] out: 		 | |____| |    | |  | |____) |
[asrc] out: 		  \_____|_|    |_|  |_|_____/ 
[asrc] out:                               
[asrc] out:                               
[asrc] out: 
[asrc] out: ++++++++++++++++++++++++++++: System Data :++++++++++++++++++++++++++++
[asrc] out: + Hostname = login01
[asrc] out: + Kernel = 2.6.18-164.el5
[asrc] out: + RHEL Release = Red Hat Enterprise Linux Server release 5.4 (Tikanga)
[asrc] out: + Uptime = 20:20:15 up 23 days, 4:52, 105 users,
[asrc] out: + CPU = 2x Intel Xeon X5570 @ 2.93GHz
[asrc] out: + Memory = 49432776 kB
[asrc] out: ++++++++++++++++++++++++++++: User Data :++++++++++++++++++++++++++++++
[asrc] out: + Username = jappa
[asrc] out: +++++++++++++++++++++++: Contact Information :+++++++++++++++++++++++++
[asrc] out: + in case of any problems, contact: support@cfms.org.uk
[asrc] out: + for feedback, contact: feedback@cfms.org.uk 
[asrc] out: +++++++++++++++++++++: Maintenance Information :+++++++++++++++++++++++
[asrc] out: + There may be some service disruption between 10:00 and 
[asrc] out: 12:00 on 20/06/14.
[asrc] out: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[asrc] out: 
[asrc] out: 

Get control dictionary


In [5]:
from zutil.post import get_case_parameters,print_html_parameters
for case_name in case_dict:
    parameters=get_case_parameters(case_name,data_host=data_host,data_dir=data_dir)

Get status file


In [6]:
from zutil.post import get_status_dict
for case_name in case_dict:
    status=get_status_dict(case_name,data_host=data_host,data_dir=data_dir)
    num_procs = str(status['num processor'])
    case_dict[case_name]['num procs'] = num_procs

Define test conditions


In [7]:
alpha = 180.0 # degrees
beta  = 0.0 # degrees
#reference_area = 0.557
reference_area = 1.0
reference_length = 1.0
pressure = 101325.0 # Pa
temperature = 294.5 # i.e. 21.35 degrees celcius
gas_constant = 287.0
density  = pressure/(gas_constant * temperature) # kg/m^3 - check
gamma = 1.4
speed_of_sound = math.sqrt(gamma*pressure/density) # m/s
mach = 0.0632
speed = mach*speed_of_sound

nu=1.5e-5

mu=nu*density

reynolds=density*speed/mu

from IPython.display import HTML
HTML(print_html_parameters(parameters))


Out[7]:
pressure101325.0
temperature294.5
Reynolds No1600000.0
Ref length1.0
Speed0.0
Mach No0.065

Calculate forces


In [8]:
from zutil.post import calc_force_wall,get_case_root


for case_name in case_dict:
    alpha = case_dict[case_name]['alpha']
    beta = case_dict[case_name]['beta']
    num_procs = case_dict[case_name]['num procs']
    
    force = []
    ignore_zones = []
        
    pf,ff = calc_force_wall(get_case_root(case_name,num_procs),set(ignore_zones),False,alpha=alpha,beta=beta)
    for i in range(0,3):
        pf[i] /= reference_area
        ff[i] /= reference_area
        force.append(pf[i] + ff[i])
            
    C_D = force[0]
    C_L = force[1]
    C_S = force[2]
            
    print 'alpha = ' + ('%.4f' %alpha)
    print 'beta = ' + ('%.4f' %beta)
    print 'reference area = ' + ('%.4f' %reference_area) 
    print 'reference length = ' + ('%.4f' %reference_length) 
    print 'pressure = ' + ('%.4f' %pressure)  
    print 'temperature = ' + ('%.4f' %temperature)  
    print 'gas_constant = ' + ('%.4f' %gas_constant)  
    print 'density = ' + ('%.4f' %density) 
    print 'gamma = ' + ('%.4f' %gamma) 
    print 'speed of sound = ' + ('%.4f' %speed_of_sound) 
    print 'mach = ' + ('%.4f' %mach)  
        
    print 'C_S = ' + ('%.4f' %C_S)     
    print 'C_D = ' + ('%.4f' %C_D) 
    print 'C_L = ' + ('%.4f' %C_L) 
    print 'C_D_pressure = ' + ('%.4f' %pf[0])
    print 'C_D_friction = ' + ('%.4f' %ff[0])
    print 'C_L_pressure = ' + ('%.4f' %pf[1])
    print 'C_L_friction = ' + ('%.4f' %ff[1])
    
    import string
        
    html_template='''<table>
    <tr><th colspan="3">Pressure Forces</th><th colspan="3">Friction Forces</th><th colspan="3">Total Forces</th></tr>
    <tr><td>Cd</td><td>Cs</td><td>Cl</td><td>Cd</td><td>Cs</td><td>Cl</td><td>Cd</td><td>Cs</td> <td>Cl</td</tr>
    <tr><td>Cd</td><td>Cs</td><td>Cl</td><td>Cd</td><td>Cs</td><td>Cl</td><td>Cd</td><td>Cs</td> <td>Cl</td</tr>
    </table>'''
    html_template='''
    <div>
    <div style="display:inline-block;"><table>
    <tr><th colspan="2">Pressure Forces</th></tr>
    <tr><td>Cd</td><td>0.0</td></tr>
    <tr><td>Cs</td><td>0.0</td></tr>
    <tr><td>Cl</td><td>0.0</td></tr>
    </table>
    </div>
    <div style="display:inline-block;"><table>
    <tr><th colspan="2">Friction Forces</th></tr>
    <tr><td>Cd</td><td>0.0</td></tr>
    <tr><td>Cs</td><td>0.0</td></tr>
    <tr><td>Cl</td><td>0.0</td></tr>
    </table>
    </div>
    <div style="display:inline-block;"><table>
    <tr><th colspan="2">Total Forces</th></tr>
    <tr><td>Cd</td><td>0.0</td></tr>
    <tr><td>Cs</td><td>0.0</td></tr>
    <tr><td>Cl</td><td>0.0</td></tr>
    </table>
    </div>
    </div>'''
    html_output=string.Template(html_template)
    
    HTML(html_output.substitute({}))


alpha = 0.0000
beta = 0.0000
reference area = 1.0000
reference length = 1.0000
pressure = 101325.0000
temperature = 294.5000
gas_constant = 287.0000
density = 1.1988
gamma = 1.4000
speed of sound = 343.9914
mach = 0.0632
C_S = -0.0000
C_D = 0.0171
C_L = 0.2708
C_D_pressure = 0.0094
C_D_friction = 0.0077
C_L_pressure = 0.2707
C_L_friction = 0.0001
alpha = 0.0000
beta = 4.0000
reference area = 1.0000
reference length = 1.0000
pressure = 101325.0000
temperature = 294.5000
gas_constant = 287.0000
density = 1.1988
gamma = 1.4000
speed of sound = 343.9914
mach = 0.0632
C_S = 0.0000
C_D = 0.0219
C_L = 0.7337
C_D_pressure = 0.0141
C_D_friction = 0.0078
C_L_pressure = 0.7335
C_L_friction = 0.0003
alpha = 0.0000
beta = 10.0000
reference area = 1.0000
reference length = 1.0000
pressure = 101325.0000
temperature = 294.5000
gas_constant = 287.0000
density = 1.1988
gamma = 1.4000
speed of sound = 343.9914
mach = 0.0632
C_S = 0.0000
C_D = 0.0416
C_L = 1.3308
C_D_pressure = 0.0341
C_D_friction = 0.0075
C_L_pressure = 1.3301
C_L_friction = 0.0008
alpha = 0.0000
beta = 0.0000
reference area = 1.0000
reference length = 1.0000
pressure = 101325.0000
temperature = 294.5000
gas_constant = 287.0000
density = 1.1988
gamma = 1.4000
speed of sound = 343.9914
mach = 0.0632
C_S = -0.0000
C_D = 0.0037
C_L = 0.0269
C_D_pressure = 0.0029
C_D_friction = 0.0008
C_L_pressure = 0.0269
C_L_friction = 0.0000
alpha = 0.0000
beta = 4.0000
reference area = 1.0000
reference length = 1.0000
pressure = 101325.0000
temperature = 294.5000
gas_constant = 287.0000
density = 1.1988
gamma = 1.4000
speed of sound = 343.9914
mach = 0.0632
C_S = -0.0000
C_D = 0.0044
C_L = 0.0705
C_D_pressure = 0.0037
C_D_friction = 0.0008
C_L_pressure = 0.0705
C_L_friction = 0.0000
alpha = 0.0000
beta = 10.0000
reference area = 1.0000
reference length = 1.0000
pressure = 101325.0000
temperature = 294.5000
gas_constant = 287.0000
density = 1.1988
gamma = 1.4000
speed of sound = 343.9914
mach = 0.0632
C_S = -0.0000
C_D = 0.0070
C_L = 0.1265
C_D_pressure = 0.0063
C_D_friction = 0.0007
C_L_pressure = 0.1264
C_L_friction = 0.0001
alpha = 0.0000
beta = 0.0000
reference area = 1.0000
reference length = 1.0000
pressure = 101325.0000
temperature = 294.5000
gas_constant = 287.0000
density = 1.1988
gamma = 1.4000
speed of sound = 343.9914
mach = 0.0632
C_S = 0.0000
C_D = 0.0052
C_L = 0.0287
C_D_pressure = 0.0044
C_D_friction = 0.0008
C_L_pressure = 0.0287
C_L_friction = 0.0000
alpha = 0.0000
beta = 4.0000
reference area = 1.0000
reference length = 1.0000
pressure = 101325.0000
temperature = 294.5000
gas_constant = 287.0000
density = 1.1988
gamma = 1.4000
speed of sound = 343.9914
mach = 0.0632
C_S = -0.0000
C_D = 0.0061
C_L = 0.0673
C_D_pressure = 0.0054
C_D_friction = 0.0008
C_L_pressure = 0.0673
C_L_friction = 0.0000
alpha = 0.0000
beta = 10.0000
reference area = 1.0000
reference length = 1.0000
pressure = 101325.0000
temperature = 294.5000
gas_constant = 287.0000
density = 1.1988
gamma = 1.4000
speed of sound = 343.9914
mach = 0.0632
C_S = -0.0000
C_D = 0.0095
C_L = 0.1150
C_D_pressure = 0.0087
C_D_friction = 0.0007
C_L_pressure = 0.1150
C_L_friction = 0.0001

In [9]:
from zutil.post import cp_profile_wall_from_file

def cp_plot(data_array,pts_array,**kwargs):
    ax = kwargs['axis']
    ax.plot(data_array.GetPointData()['chord'], data_array.GetPointData()['cp'],label=kwargs['label'],color=kwargs['color'])
    ax2 = kwargs['axis2']
    ax2.plot(data_array.GetPointData()['chord'],pts_array.GetPoints()[:,1], color='grey',linestyle='-',marker='None',markersize=4)
    
    #print 'X'
    #print data_array.GetPointData()['chord']
    #print 'Y'
    #print pts_array.GetPoints()[:,1]

fig = figure(figsize=(20, 10),dpi=100, facecolor='w', edgecolor='k')
fig.suptitle('FFA-W3-241', fontsize=20, fontweight='bold')
ax = fig.add_subplot(1,1,1)
ax.grid(True)
ax.set_xlabel('x/c')
ax.set_ylabel('$C_p$')
ax.axis([0,1,1.0,-3.0])
ax2 = ax.twinx()
ax2.set_ylabel('z [m]')
ax2.axis([0,1,-0.25,0.25])
for case_name in case_dict:
    alpha = case_dict[case_name]['alpha']
    beta = case_dict[case_name]['beta']
    f=cp_profile_wall_from_file(get_case_root(case_name,num_procs),[0,0,1],[0,0,0.005],
                                alpha=alpha,beta=beta,axis=ax,axis2=ax2,func=cp_plot,label=r'$\alpha$='+str(beta),
                                color=case_dict[case_name]['color'])
ax.legend(loc='upper right', shadow=True)
from matplotlib.backends.backend_pdf import PdfPages
fig.savefig("images/ffa_cp_profile.pdf")
from IPython.display import FileLink, display 
display(FileLink('images/ffa_cp_profile.pdf'))
show()




Convergence


In [15]:
from zutil.post import residual_plot, get_case_report
for case_name in case_dict:
    residual_plot(get_case_report(case_name))
show()



In [10]:
if remote_data:
    #print 'Disconnecting from remote paraview server connection'
    Disconnect()
    pass

In [11]: