mirror of https://gitlab.com/pamhyr/pamhyr2
BC: Add D50 and sigma edition for solid BC.
parent
fb9c2a4308
commit
0c06b4cb2a
|
|
@ -89,6 +89,9 @@ class Solid(BoundaryCondition):
|
||||||
def __init__(self, id:int = -1, name:str = "", status = None):
|
def __init__(self, id:int = -1, name:str = "", status = None):
|
||||||
super(Solid, self).__init__(id=id, name=name, status=status)
|
super(Solid, self).__init__(id=id, name=name, status=status)
|
||||||
|
|
||||||
|
self.d50 = 0.002
|
||||||
|
self.sigma = 1
|
||||||
|
|
||||||
self._type = "SL"
|
self._type = "SL"
|
||||||
self._header = ["time", "solid"]
|
self._header = ["time", "solid"]
|
||||||
self._types = [TimeOverDischarge.time_convert, float]
|
self._types = [TimeOverDischarge.time_convert, float]
|
||||||
|
|
|
||||||
|
|
@ -554,13 +554,23 @@ class Mage8(Mage):
|
||||||
files.append(f"{name}.QSO")
|
files.append(f"{name}.QSO")
|
||||||
|
|
||||||
for bound in bounds:
|
for bound in bounds:
|
||||||
|
# File header
|
||||||
name = f"{bound.node.id:3}".replace(" ", "x")
|
name = f"{bound.node.id:3}".replace(" ", "x")
|
||||||
f.write(f"* {bound.node.name} ({name}) {bound.bctype}\n")
|
f.write(f"* {bound.node.name} ({name}) {bound.bctype}\n")
|
||||||
f.write(f"${name} 0.002 1 default\n")
|
|
||||||
# f.write(f"${name}\n")
|
d50 = bound.d50
|
||||||
|
sigma = bound.sigma
|
||||||
|
|
||||||
|
if len(bound.data) == 0:
|
||||||
|
f.write(f"${name} {d50} {sigma} default\n")
|
||||||
|
else:
|
||||||
|
f.write(f"${name} {d50} {sigma}\n")
|
||||||
|
|
||||||
|
# Table header
|
||||||
header = bound.header
|
header = bound.header
|
||||||
f.write(f"*{header[0]:>9}|{header[1]:>10}\n")
|
f.write(f"*{header[0]:>9}|{header[1]:>10}\n")
|
||||||
|
|
||||||
|
# Data
|
||||||
for d in bound.data:
|
for d in bound.data:
|
||||||
f.write(f"{d[0]:10.3f}{d[1]:10.3f}\n")
|
f.write(f"{d[0]:10.3f}{d[1]:10.3f}\n")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
|
|
@ -25,6 +27,8 @@ from PyQt5.QtWidgets import (
|
||||||
|
|
||||||
from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class SetDataCommand(QUndoCommand):
|
class SetDataCommand(QUndoCommand):
|
||||||
def __init__(self, data, index, column, new_value):
|
def __init__(self, data, index, column, new_value):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
@ -42,6 +46,32 @@ class SetDataCommand(QUndoCommand):
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._data._set_i_c_v(self._index, self._column, self._new)
|
self._data._set_i_c_v(self._index, self._column, self._new)
|
||||||
|
|
||||||
|
class SetMetaDataCommand(QUndoCommand):
|
||||||
|
def __init__(self, data, column, new_value):
|
||||||
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
|
self._data = data
|
||||||
|
self._column = column
|
||||||
|
if self._column == "d50":
|
||||||
|
self._old = self._data.d50
|
||||||
|
elif self._column == "sigma":
|
||||||
|
self._old = self._data.sigma
|
||||||
|
|
||||||
|
self._new = float(new_value)
|
||||||
|
|
||||||
|
def undo(self):
|
||||||
|
if self._column == "d50":
|
||||||
|
self._data.d50 = self._old
|
||||||
|
elif self._column == "sigma":
|
||||||
|
self._data.sigma = self._old
|
||||||
|
|
||||||
|
def redo(self):
|
||||||
|
if self._column == "d50":
|
||||||
|
self._data.d50 = self._new
|
||||||
|
elif self._column == "sigma":
|
||||||
|
self._data.sigma = self._new
|
||||||
|
|
||||||
|
|
||||||
class AddCommand(QUndoCommand):
|
class AddCommand(QUndoCommand):
|
||||||
def __init__(self, data, index):
|
def __init__(self, data, index):
|
||||||
QUndoCommand.__init__(self)
|
QUndoCommand.__init__(self)
|
||||||
|
|
|
||||||
|
|
@ -18,33 +18,77 @@
|
||||||
|
|
||||||
from tools import timer, trace
|
from tools import timer, trace
|
||||||
|
|
||||||
from View.ASubWindow import ASubMainWindow
|
from View.ASubWindow import ASubMainWindow, AWidget
|
||||||
from View.ListedSubWindow import ListedSubWindow
|
from View.ListedSubWindow import ListedSubWindow
|
||||||
|
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import (
|
||||||
QKeySequence,
|
QKeySequence,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from PyQt5 import QtCore
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
Qt, QVariant, QAbstractTableModel, QCoreApplication,
|
Qt, QVariant, QAbstractTableModel, QCoreApplication,
|
||||||
|
pyqtSlot, pyqtSignal,
|
||||||
)
|
)
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialogButtonBox, QPushButton, QLineEdit,
|
QDialogButtonBox, QPushButton, QLineEdit,
|
||||||
QFileDialog, QTableView, QAbstractItemView,
|
QFileDialog, QTableView, QAbstractItemView,
|
||||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||||
QHeaderView,
|
QHeaderView, QDoubleSpinBox, QVBoxLayout,
|
||||||
)
|
)
|
||||||
|
|
||||||
from View.Plot.MplCanvas import MplCanvas
|
from View.Plot.MplCanvas import MplCanvas
|
||||||
from View.Plot.navigation_toolbar_2qt import PamHyrNavigationToolbar2QT
|
from View.Plot.navigation_toolbar_2qt import PamHyrNavigationToolbar2QT
|
||||||
|
|
||||||
from View.BoundaryCondition.translate import long_types
|
from View.BoundaryCondition.translate import long_types
|
||||||
|
from View.BoundaryCondition.Edit.UndoCommand import SetMetaDataCommand
|
||||||
from View.BoundaryCondition.Edit.Table import TableModel, ExTimeDelegate
|
from View.BoundaryCondition.Edit.Table import TableModel, ExTimeDelegate
|
||||||
from View.BoundaryCondition.Edit.Plot import Plot
|
from View.BoundaryCondition.Edit.Plot import Plot
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
class WD50Sigma(AWidget):
|
||||||
|
d50Changed = pyqtSignal(float)
|
||||||
|
sigmaChanged = pyqtSignal(float)
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super(WD50Sigma, self).__init__(
|
||||||
|
ui="d50sigma",
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
self.parent = parent
|
||||||
|
|
||||||
|
self.spinBox_d50 = self.find(QDoubleSpinBox, "doubleSpinBox_d50")
|
||||||
|
self.spinBox_sigma = self.find(QDoubleSpinBox, "doubleSpinBox_sigma")
|
||||||
|
|
||||||
|
self.spinBox_d50.valueChanged.connect(self.valueChangedD50)
|
||||||
|
self.spinBox_sigma.valueChanged.connect(self.valueChangedSigma)
|
||||||
|
|
||||||
|
def set_d50(self, d50):
|
||||||
|
self.spinBox_d50.valueChanged.disconnect(self.valueChangedD50)
|
||||||
|
self.spinBox_d50.setValue(float(d50))
|
||||||
|
self.spinBox_d50.valueChanged.connect(self.valueChangedD50)
|
||||||
|
|
||||||
|
def get_d50(self):
|
||||||
|
return float(self.spinBox_d50.value())
|
||||||
|
|
||||||
|
def set_sigma(self, sigma):
|
||||||
|
self.spinBox_sigma.valueChanged.disconnect(self.valueChangedSigma)
|
||||||
|
self.spinBox_sigma.setValue(float(sigma))
|
||||||
|
self.spinBox_sigma.valueChanged.connect(self.valueChangedSigma)
|
||||||
|
|
||||||
|
def get_sigma(self):
|
||||||
|
return float(self.spinBox_sigma.value())
|
||||||
|
|
||||||
|
@QtCore.pyqtSlot(float)
|
||||||
|
def valueChangedD50(self, value):
|
||||||
|
self.d50Changed.emit(value)
|
||||||
|
|
||||||
|
@QtCore.pyqtSlot(float)
|
||||||
|
def valueChangedSigma(self, value):
|
||||||
|
self.sigmaChanged.emit(value)
|
||||||
|
|
||||||
class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
def __init__(self, title="Edit boundary condition",
|
def __init__(self, title="Edit boundary condition",
|
||||||
data=None, study=None, parent=None):
|
data=None, study=None, parent=None):
|
||||||
|
|
@ -63,6 +107,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self.setup_sc()
|
self.setup_sc()
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
self.setup_plot()
|
self.setup_plot()
|
||||||
|
self.setup_data()
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
|
||||||
def compute_title(self):
|
def compute_title(self):
|
||||||
|
|
@ -84,6 +129,17 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
||||||
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
||||||
|
|
||||||
|
def setup_data(self):
|
||||||
|
self._is_solid = self._data.bctype == "SL"
|
||||||
|
|
||||||
|
if self._is_solid:
|
||||||
|
layout = self.find(QVBoxLayout, "verticalLayout_table")
|
||||||
|
self._d50sigma = WD50Sigma(parent = self)
|
||||||
|
layout.addWidget(self._d50sigma)
|
||||||
|
|
||||||
|
self._d50sigma.set_d50(self._data.d50)
|
||||||
|
self._d50sigma.set_sigma(self._data.sigma)
|
||||||
|
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
table = self.find(QTableView, "tableView")
|
table = self.find(QTableView, "tableView")
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
|
|
@ -138,6 +194,31 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
|
|
||||||
self._table.dataChanged.connect(self.update)
|
self._table.dataChanged.connect(self.update)
|
||||||
|
|
||||||
|
if self._is_solid:
|
||||||
|
self._d50sigma.d50Changed.connect(self.d50_changed)
|
||||||
|
self._d50sigma.sigmaChanged.connect(self.sigma_changed)
|
||||||
|
|
||||||
|
def d50_changed(self, value):
|
||||||
|
self._undo_stack.push(
|
||||||
|
SetMetaDataCommand(
|
||||||
|
self._data,
|
||||||
|
"d50", value
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def sigma_changed(self, value):
|
||||||
|
self._undo_stack.push(
|
||||||
|
SetMetaDataCommand(
|
||||||
|
self._data,
|
||||||
|
"sigma", value
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def widget_update(self):
|
||||||
|
if self._is_solid:
|
||||||
|
self._d50sigma.set_d50(self._data.d50)
|
||||||
|
self._d50sigma.set_sigma(self._data.sigma)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.plot.update()
|
self.plot.update()
|
||||||
|
|
||||||
|
|
@ -221,7 +302,9 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._table.undo()
|
self._table.undo()
|
||||||
self.plot.update()
|
self.plot.update()
|
||||||
|
self.widget_update()
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._table.redo()
|
self._table.redo()
|
||||||
self.plot.update()
|
self.plot.update()
|
||||||
|
self.widget_update()
|
||||||
|
|
|
||||||
|
|
@ -26,15 +26,12 @@
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QSplitter" name="splitter">
|
<widget class="QSplitter" name="splitter">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QWidget" name="verticalLayoutWidget_2">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_table">
|
||||||
|
<item>
|
||||||
<widget class="QTableView" name="tableView">
|
<widget class="QTableView" name="tableView">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
|
|
@ -43,6 +40,9 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="verticalLayoutWidget">
|
<widget class="QWidget" name="verticalLayoutWidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>256</width>
|
||||||
|
<height>46</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<property name="locale">
|
||||||
|
<locale language="English" country="Europe"/>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_d50">
|
||||||
|
<property name="text">
|
||||||
|
<string>D50</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBox_d50">
|
||||||
|
<property name="locale">
|
||||||
|
<locale language="English" country="Europe"/>
|
||||||
|
</property>
|
||||||
|
<property name="decimals">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_sigma">
|
||||||
|
<property name="text">
|
||||||
|
<string>Sigma</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBox_sigma">
|
||||||
|
<property name="decimals">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Loading…
Reference in New Issue