Skip to content

Commit

Permalink
JSON pressure file output and version bump.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xero64 committed Dec 16, 2019
1 parent 46013e6 commit 8e6ca28
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
59 changes: 59 additions & 0 deletions pyvlm/outputs/prf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from json import dump
from pyvlm.classes import LatticeSystem
from numpy.matlib import zeros

def latticeresult_to_prf(lsys: LatticeSystem, prffilepath: str):
data = {}
data['name'] = lsys.name
srfclist = []
for srfc in lsys.srfcs:
srfcdict = {}
xle, yle, zle, chords = [], [], [], []
csps = srfc.cspace
cspace = []
for csp in csps:
cspace.append(csp[0])
cspace.append(csp[-1])
for i in range(srfc.pnts.shape[0]):
pntle = srfc.pnts[i, 0]
pntte = srfc.pnts[i, -1]
x, y, z = pntle.x, pntle.y, pntle.z
chord = pntte.x-pntle.x
xle.append(x)
yle.append(y)
zle.append(z)
chords.append(chord)
srfcdict['name'] = srfc.name
srfcdict['xle'] = xle
srfcdict['yle'] = yle
srfcdict['zle'] = zle
srfcdict['chords'] = chords
srfcdict['cspace'] = cspace
srfclist.append(srfcdict)
data['surfaces'] = srfclist
resultlist = []
for case in lsys.results:
result = lsys.results[case]
dynprs = result.qfs
casedata = []
for srfc in lsys.srfcs:
prtop = zeros(srfc.pnls.shape)
prbot = zeros(srfc.pnls.shape)
for i in range(srfc.pnls.shape[0]):
for j in range(srfc.pnls.shape[1]):
pnl = srfc.pnls[i, j]
lpid = pnl.lpid
pnlfrc = result.nfres.nffrc[lpid, 0]
frcnrm = pnl.nrml*pnlfrc
deltap = frcnrm/pnl.area
prtop[i, j] = dynprs+deltap/2
prbot[i, j] = dynprs-deltap/2
srfresdata = {}
srfresdata['name'] = srfc.name
srfresdata['top pressure [Pa]'] = prtop.tolist()
srfresdata['bottom pressure [Pa]'] = prbot.tolist()
casedata.append(srfresdata)
resultlist.append(casedata)
data['results'] = resultlist
with open(prffilepath, 'wt') as prffile:
dump(data, prffile, indent=4)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pyvlm",
version="0.0.4",
version="0.0.5",
author="Xero64",
author_email="xero64@gmail.com",
description="Vortex Lattice Method in Python",
Expand Down

0 comments on commit 8e6ca28

Please sign in to comment.