-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
synchronize with commercial version 1.9.0
- Loading branch information
gongding
committed
Feb 4, 2016
1 parent
0d61cac
commit 391f830
Showing
656 changed files
with
59,129 additions
and
39,871 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/env python | ||
import os | ||
import subprocess | ||
import time | ||
|
||
|
||
# genius install dir | ||
GENIUS_PATH = '/opt/cogenda/current/' | ||
|
||
|
||
def gdmlgen(source_file): | ||
source_file = os.path.realpath(str(source_file)) | ||
file_dir = os.path.dirname(source_file) | ||
file_name, file_ext = os.path.splitext(os.path.basename(source_file)) | ||
|
||
format = '' | ||
|
||
if file_ext == '.unv' : | ||
format = 'UNVFILE' | ||
|
||
if file_ext == '.tif3d' : | ||
format = 'TIF3DFILE' | ||
|
||
|
||
params = { | ||
'source_file': source_file, | ||
'gdml_file' : os.path.join(file_dir, file_name+'.gdml'), | ||
'FORMAT' : format | ||
} | ||
|
||
|
||
tmpl_gdml=r''' | ||
GLOBAL T=300 cm=1e5 second=1e-5 | ||
IMPORT {FORMAT:s}="{source_file:s}" | ||
EXPORT GDML.SURFACE="{gdml_file:s}" | ||
''' | ||
|
||
inp_file = os.path.join(file_dir, 'gdml.inp') | ||
|
||
with open(inp_file, 'w') as fout: | ||
fout.write(tmpl_gdml.format(**params)) | ||
|
||
p = subprocess.Popen( [GENIUS_PATH + '/genius/bin/genius', '-i', inp_file]) | ||
out, err = p.communicate() | ||
|
||
|
||
#-------------------------------------- | ||
# !!! user input !!! | ||
#-------------------------------------- | ||
# source structure | ||
#source_file ='aa.unv' | ||
#gdmlgen(source_file) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from gdmlgen import gdmlgen | ||
|
||
from PyQt4.QtCore import * | ||
from PyQt4.QtGui import * | ||
|
||
import os | ||
|
||
class gdmlgen_dlg(QDialog): | ||
|
||
def __init__(self, parent=None): | ||
super(gdmlgen_dlg, self).__init__(parent) | ||
|
||
self.setWindowTitle(self.tr("gdml generator")) | ||
|
||
vLayout = QVBoxLayout() | ||
hLayout = QHBoxLayout() | ||
hLayout.addWidget(QLabel(self.tr("3D Model File: "))) | ||
self.leFPath = QLineEdit() | ||
hLayout.addWidget(self.leFPath) | ||
self.btFPath = QPushButton("...") | ||
self.btFPath.setMaximumWidth(50) | ||
self.btFPath.setMaximumHeight(25) | ||
hLayout.addWidget(self.btFPath) | ||
vLayout.addLayout(hLayout) | ||
|
||
hLayout = QHBoxLayout() | ||
self.btGdmlGen = QPushButton(self.tr("Generate GDML")) | ||
self.btGdmlGen.setMaximumWidth(120) | ||
hLayout.addWidget(self.btGdmlGen) | ||
self.btCancle = QPushButton(self.tr("Cancle")) | ||
self.btCancle.setMaximumWidth(120) | ||
hLayout.addWidget(self.btCancle) | ||
vLayout.addLayout(hLayout) | ||
|
||
self.setLayout(vLayout) | ||
|
||
self.resize(500, 100) | ||
|
||
self.connect(self.btFPath, SIGNAL('clicked()'), self.onBtFPathClicked) | ||
self.connect(self.btGdmlGen, SIGNAL('clicked()'), self.onbtGdmlGenClicked) | ||
self.connect(self.btCancle, SIGNAL('clicked()'), self.reject) | ||
|
||
def onBtFPathClicked(self): | ||
homepath = QDir.homePath() | ||
path = str( QFileDialog.getOpenFileName(self, self.tr("Open File"),\ | ||
homepath, self.tr("Model file(*.unv *.tif3d)")) ) | ||
if len(path)==0: return | ||
|
||
self.leFPath.setText(path) | ||
|
||
def onbtGdmlGenClicked(self): | ||
path = str(self.leFPath.text()) | ||
if not os.path.isfile(path): | ||
msg = self.tr("File '%s' does not exist"%path) | ||
QMessageBox.warning(None, self.tr("File Error!"), msg) | ||
return | ||
|
||
gdmlgen(path) | ||
|
||
def reject(self): | ||
super(gdmlgen_dlg, self).reject() | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
app = QApplication(sys.argv) | ||
dlg = gdmlgen_dlg() | ||
|
||
dlg.show() | ||
app.exec_() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/bin/env python | ||
import os | ||
import subprocess | ||
import time | ||
|
||
|
||
#-------------------------------------- | ||
# !!! user input !!! | ||
#-------------------------------------- | ||
|
||
|
||
# model file, UNV or TIF3D format | ||
#source_file ='aa.unv' | ||
|
||
# track of particle | ||
#track_file='t.dat' | ||
|
||
# position of inject particle | ||
#particle_file='p.dat' | ||
|
||
# weight of particle | ||
#weight=1.0 | ||
|
||
# background mesh resolution, cm | ||
#resolution = 0.05 | ||
|
||
# genius install dir | ||
GENIUS_PATH = '/opt/cogenda/current/' | ||
|
||
|
||
def run(source_file, track_file, particle_file, weight, resolution): | ||
source_file = os.path.realpath(str(source_file)) | ||
file_dir = os.path.dirname(source_file) | ||
file_name, file_ext = os.path.splitext(os.path.basename(source_file)) | ||
|
||
format = '' | ||
|
||
if file_ext == '.unv' : | ||
format = 'UNVFILE' | ||
|
||
if file_ext == '.tif3d' : | ||
format = 'TIF3DFILE' | ||
|
||
result_file = os.path.join(file_dir, file_name+'.vtu') | ||
|
||
params = { | ||
'source_file': source_file, | ||
'FORMAT' : format, | ||
'track_file' : track_file, | ||
'particle_file' : particle_file, | ||
'weight' : weight, | ||
'result_file' : result_file, | ||
'resolution' : resolution | ||
} | ||
|
||
|
||
|
||
tmpl_cmd=r''' | ||
GLOBAL T=300 cm=1e5 second=1e-5 | ||
IMPORT {FORMAT:s}="{source_file:s}" | ||
CONTACT Property=ElectrodeRegion Type=FixedPotential | ||
METHOD Type=RIC NS=Basic LS=gmres pc=lu Damping=no toler.relax=1e5 maxit=25 | ||
HOOK id=d1 Load=particle_capture_data string<track.data>="{track_file:s}" string<particle.data>="{particle_file:s}" \ | ||
real<weight>={weight:g} real<resolution>={resolution:g} real<fraction>=1 | ||
SOLVE Type=steadystate | ||
# export result | ||
EXPORT VTKFILE="{result_file:s}" | ||
''' | ||
|
||
inp_file = os.path.join(file_dir, 'run.inp') | ||
|
||
with open(inp_file, 'w') as fout: | ||
fout.write(tmpl_cmd.format(**params)) | ||
|
||
|
||
p = subprocess.Popen( [GENIUS_PATH + '/genius/bin/genius', '-i', inp_file]) | ||
out, err = p.communicate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
from run import run | ||
|
||
from PyQt4.QtCore import * | ||
from PyQt4.QtGui import * | ||
|
||
import os | ||
|
||
class run_dlg(QDialog): | ||
|
||
def __init__(self, parent=None): | ||
super(run_dlg, self).__init__(parent) | ||
|
||
fvalidate = QDoubleValidator() | ||
fvalidate.setNotation(QDoubleValidator.StandardNotation| | ||
QDoubleValidator.ScientificNotation) | ||
fvalidate.setBottom(0) | ||
|
||
self.setWindowTitle(self.tr("Run")) | ||
|
||
vLayout = QVBoxLayout() | ||
mLayout = QGridLayout() | ||
|
||
mLayout.addWidget(QLabel(self.tr("Source file")), 0, 0) | ||
self.leSrcFile = QLineEdit() | ||
self.btSrcFile = QPushButton("...") | ||
mLayout.addWidget(self.leSrcFile, 0, 1) | ||
mLayout.addWidget(self.btSrcFile, 0, 2) | ||
|
||
mLayout.addWidget(QLabel(self.tr("Track file")), 1, 0) | ||
self.leTrkFile = QLineEdit() | ||
self.btTrkFile = QPushButton("...") | ||
mLayout.addWidget(self.leTrkFile, 1, 1) | ||
mLayout.addWidget(self.btTrkFile, 1, 2) | ||
|
||
mLayout.addWidget(QLabel(self.tr("Particle file")), 2, 0) | ||
self.lePtkFile = QLineEdit() | ||
self.btPtkFile = QPushButton("...") | ||
mLayout.addWidget(self.lePtkFile, 2, 1) | ||
mLayout.addWidget(self.btPtkFile, 2, 2) | ||
|
||
mLayout.addWidget(QLabel(self.tr("Particle weight")), 3, 0) | ||
self.lePtkWeight = QLineEdit("1.0") | ||
self.lePtkWeight.setValidator(fvalidate) | ||
self.lePtkWeight.setMaximumWidth(100) | ||
mLayout.addWidget(self.lePtkWeight, 3, 1) | ||
|
||
mLayout.addWidget(QLabel(self.tr("Grid resolution(mm)")), 4, 0) | ||
self.leGridRslt = QLineEdit("0.05") | ||
self.leGridRslt.setValidator(fvalidate) | ||
self.leGridRslt.setMaximumWidth(100) | ||
mLayout.addWidget(self.leGridRslt, 4, 1) | ||
|
||
vLayout.addLayout(mLayout) | ||
|
||
hLayout = QHBoxLayout() | ||
self.btRun = QPushButton(self.tr("Run")) | ||
self.btRun.setMaximumWidth(120) | ||
hLayout.addWidget(self.btRun) | ||
self.btCancle = QPushButton(self.tr("Cancle")) | ||
self.btCancle.setMaximumWidth(120) | ||
hLayout.addWidget(self.btCancle) | ||
vLayout.addLayout(hLayout) | ||
|
||
self.setLayout(vLayout) | ||
|
||
self.resize(600, 200) | ||
|
||
self.connect(self.btSrcFile, SIGNAL('clicked()'), self.onBtSrcFileClicked) | ||
self.connect(self.btTrkFile, SIGNAL('clicked()'), self.onBtTrkFileClicked) | ||
self.connect(self.btPtkFile, SIGNAL('clicked()'), self.onBtPtkFileClicked) | ||
self.connect(self.btRun, SIGNAL('clicked()'), self.onBtRunClicked) | ||
self.connect(self.btCancle, SIGNAL('clicked()'), self.reject) | ||
|
||
def onBtSrcFileClicked(self): | ||
homepath = QDir.homePath() | ||
path = str( QFileDialog.getOpenFileName(self, self.tr("Open File"),\ | ||
homepath, self.tr("Model file(*.unv *.tif3d)")) ) | ||
if len(path)==0: return | ||
self.leSrcFile.setText(path) | ||
|
||
def onBtTrkFileClicked(self): | ||
homepath = QDir.homePath() | ||
path = str( QFileDialog.getOpenFileName(self, self.tr("Open File"),\ | ||
homepath, self.tr("Track file(*.*)")) ) | ||
if len(path)==0: return | ||
self.leTrkFile.setText(path) | ||
|
||
def onBtPtkFileClicked(self): | ||
homepath = QDir.homePath() | ||
path = str( QFileDialog.getOpenFileName(self, self.tr("Open File"),\ | ||
homepath, self.tr("Particle file(*.*)")) ) | ||
if len(path)==0: return | ||
self.lePtkFile.setText(path) | ||
|
||
def onBtRunClicked(self): | ||
srcFile = str(self.leSrcFile.text()) | ||
if not os.path.isfile(srcFile): | ||
msg = self.tr("Source File '%s' does not exist"%srcFile) | ||
QMessageBox.warning(None, self.tr("File Error!"), msg) | ||
return | ||
|
||
trkFile = str(self.leTrkFile.text()) | ||
if not os.path.isfile(trkFile): | ||
msg = self.tr("Track File '%s' does not exist"%trkFile) | ||
QMessageBox.warning(None, self.tr("File Error!"), msg) | ||
return | ||
|
||
ptkFile = str(self.lePtkFile.text()) | ||
if not os.path.isfile(ptkFile): | ||
msg = self.tr("Particle File '%s' does not exist"%ptkFile) | ||
QMessageBox.warning(None, self.tr("File Error!"), msg) | ||
return | ||
|
||
ptkWeight = str(self.lePtkWeight.text()) | ||
if len(ptkWeight)==0: | ||
msg = self.tr("Particle weight is not set") | ||
return | ||
ptkWeight = float(ptkWeight) | ||
|
||
gridRslt = str(self.leGridRslt.text()) | ||
if len(gridRslt)==0: | ||
msg = self.tr("Grid resolution is not set") | ||
return | ||
gridRslt = float(gridRslt) | ||
|
||
run(srcFile, trkFile, ptkFile, ptkWeight, gridRslt) | ||
|
||
def reject(self): | ||
super(run_dlg, self).reject() | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
app = QApplication(sys.argv) | ||
dlg = run_dlg() | ||
|
||
dlg.show() | ||
app.exec_() |
Oops, something went wrong.