File size: 10,175 Bytes
b1b3bae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Runtime.Serialization
Imports System.Globalization
Imports System.Reflection
' Petroleum Assay Class
' Copyright 2012 Daniel Wagner O. de Medeiros
'
' This file is part of DWSIM.
'
' DWSIM is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' DWSIM is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with DWSIM. If not, see <http://www.gnu.org/licenses/>.
Namespace Utilities.PetroleumCharacterization.Assay
<System.Serializable()> Public Class Assay
Implements ICloneable, Interfaces.ICustomXMLSerialization
Private _name As String = ""
Private _isbulk As Boolean = False
Private _iscurve As Boolean = False
'Bulk fields
Private _mw As Double
Private _sg60 As Double
Private _nbpavg As Double
Private _t1 As Double
Private _t2 As Double
Private _v1 As Double
Private _v2 As Double
'Curve fields
Private _nbptype As Integer = 0
Private _hasmwcurve As Boolean = False
Private _hassgcurve As Boolean = False
Private _sgcurvetype As String = "SG20"
Private _hasvisccurves As Boolean = False
Private _curvebasis As String = ""
Private _api As Double
Private _k_api As Double
Private _px As ArrayList
Private _py_nbp As ArrayList
Private _py_mw As ArrayList
Private _py_sg As ArrayList
Private _py_v1 As ArrayList
Private _py_v2 As ArrayList
'Constructors
Sub New(ByVal k_api As Double, ByVal mw As Double, ByVal api As Double, ByVal t1 As Double, ByVal t2 As Double, ByVal nbptype As Integer, ByVal sgtype As String, ByVal px As ArrayList, ByVal pynbp As ArrayList, ByVal pymw As ArrayList, ByVal pysg As ArrayList, ByVal pyv1 As ArrayList, ByVal pyv2 As ArrayList)
Me.New()
_k_api = k_api
_mw = mw
_api = api
_t1 = t1
_t2 = t2
_nbptype = nbptype
_sgcurvetype = sgtype
_px = px
_py_nbp = pynbp
If pymw.Count = 0 Then _hasmwcurve = False Else _hasmwcurve = True
_py_mw = pymw
If pysg.Count = 0 Then _hassgcurve = False Else _hassgcurve = True
_py_sg = pysg
If pyv1.Count = 0 Then _hasvisccurves = False Else _hasvisccurves = True
_py_v1 = pyv1
_py_v2 = pyv2
_iscurve = True
End Sub
Sub New(ByVal mw As Double, ByVal sg60 As Double, ByVal nbpavg As Double, ByVal t1 As Double, ByVal t2 As Double, ByVal v1 As Double, ByVal v2 As Double)
Me.New()
_mw = mw
_sg60 = sg60
_nbpavg = nbpavg
_t1 = t1
_t2 = t2
_v1 = v1
_v2 = v2
_isbulk = True
End Sub
Sub New()
_px = New ArrayList
_py_nbp = New ArrayList
_py_mw = New ArrayList
_py_sg = New ArrayList
_py_v1 = New ArrayList
_py_v2 = New ArrayList
End Sub
'Properties
Public Property CurveBasis() As String
Get
Return _curvebasis
End Get
Set(ByVal value As String)
_curvebasis = value
End Set
End Property
Public Property PY_V2() As ArrayList
Get
Return _py_v2
End Get
Set(ByVal value As ArrayList)
_py_v2 = value
End Set
End Property
Public Property PY_V1() As ArrayList
Get
Return _py_v1
End Get
Set(ByVal value As ArrayList)
_py_v1 = value
End Set
End Property
Public Property PY_SG() As ArrayList
Get
Return _py_sg
End Get
Set(ByVal value As ArrayList)
_py_sg = value
End Set
End Property
Public Property PY_MW() As ArrayList
Get
Return _py_mw
End Get
Set(ByVal value As ArrayList)
_py_mw = value
End Set
End Property
Public Property PY_NBP() As ArrayList
Get
Return _py_nbp
End Get
Set(ByVal value As ArrayList)
_py_nbp = value
End Set
End Property
Public Property PX() As ArrayList
Get
Return _px
End Get
Set(ByVal value As ArrayList)
_px = value
End Set
End Property
Public Property K_API() As Double
Get
Return _k_api
End Get
Set(ByVal value As Double)
_k_api = value
End Set
End Property
Public Property API() As Double
Get
Return _api
End Get
Set(ByVal value As Double)
_api = value
End Set
End Property
Public Property SGCurveType() As String
Get
Return _sgcurvetype
End Get
Set(ByVal value As String)
_sgcurvetype = value
End Set
End Property
Public Property HasViscCurves() As Boolean
Get
Return _hasvisccurves
End Get
Set(ByVal value As Boolean)
_hasvisccurves = value
End Set
End Property
Public Property HasSGCurve() As Boolean
Get
Return _hassgcurve
End Get
Set(ByVal value As Boolean)
_hassgcurve = value
End Set
End Property
Public Property HasMWCurve() As Boolean
Get
Return _hasmwcurve
End Get
Set(ByVal value As Boolean)
_hasmwcurve = value
End Set
End Property
Public Property NBPType() As Integer
Get
Return _nbptype
End Get
Set(ByVal value As Integer)
_nbptype = value
End Set
End Property
Public Property V2() As Double
Get
Return _v2
End Get
Set(ByVal value As Double)
_v2 = value
End Set
End Property
Public Property V1() As Double
Get
Return _v1
End Get
Set(ByVal value As Double)
_v1 = value
End Set
End Property
Public Property T2() As Double
Get
Return _t2
End Get
Set(ByVal value As Double)
_t2 = value
End Set
End Property
Public Property T1() As Double
Get
Return _t1
End Get
Set(ByVal value As Double)
_t1 = value
End Set
End Property
Public Property NBPAVG() As Double
Get
Return _nbpavg
End Get
Set(ByVal value As Double)
_nbpavg = value
End Set
End Property
Public Property SG60() As Double
Get
Return _sg60
End Get
Set(ByVal value As Double)
_sg60 = value
End Set
End Property
Public Property MW() As Double
Get
Return _mw
End Get
Set(ByVal value As Double)
_mw = value
End Set
End Property
Public Property IsCurve() As Boolean
Get
Return _iscurve
End Get
Set(ByVal value As Boolean)
_iscurve = value
End Set
End Property
Public Property IsBulk() As Boolean
Get
Return _isbulk
End Get
Set(ByVal value As Boolean)
_isbulk = value
End Set
End Property
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Function Clone() As Object Implements System.ICloneable.Clone
Return ObjectCopy(Me)
End Function
Function ObjectCopy(ByVal obj As Assay) As Assay
Dim objMemStream As New MemoryStream(50000)
Dim objBinaryFormatter As New BinaryFormatter(Nothing, New StreamingContext(StreamingContextStates.Clone))
objBinaryFormatter.Serialize(objMemStream, obj)
objMemStream.Seek(0, SeekOrigin.Begin)
ObjectCopy = objBinaryFormatter.Deserialize(objMemStream)
objMemStream.Close()
End Function
Public Function LoadData(data As System.Collections.Generic.List(Of System.Xml.Linq.XElement)) As Boolean Implements Interfaces.ICustomXMLSerialization.LoadData
Return XMLSerializer.XMLSerializer.Deserialize(Me, data)
End Function
Public Function SaveData() As System.Collections.Generic.List(Of System.Xml.Linq.XElement) Implements Interfaces.ICustomXMLSerialization.SaveData
Return XMLSerializer.XMLSerializer.Serialize(Me)
End Function
End Class
End Namespace
|