Skip to content

Commit 879fca4

Browse files
completed all functions except the 'execute' function
1 parent 5846e40 commit 879fca4

1 file changed

Lines changed: 102 additions & 28 deletions

File tree

lib/solver.py

Lines changed: 102 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,14 @@ def total_flow(self, value):
6666
self._total_flow = value
6767
@property
6868
def polymer_flow(self):
69-
return self._total_flow*self._water.concetration_scalar
69+
return self.total_flow*self._water.concetration_scalar
7070
@property
7171
def surfactant_flow(self):
72-
return self._total_flow*self._surfactant.concentration
73-
## Water Saturation Matrix
74-
@property
75-
def water_saturation(self):
76-
return self._water.water_saturation
77-
## Aqueous Viscosity
78-
@property
79-
def aqueous_viscosity(self):
80-
return self._water.viscosity_array
72+
return self.total_flow*self._surfactant.concentration
8173
## Oil Viscosity
8274
@property
8375
def oil_viscosity(self):
8476
return self._water.miuo
85-
## Surfactant concentration matrix
86-
@property
87-
def surfactant_concentration(self):
88-
return self._surfactant.concentration
89-
## Polymer concentration matrix
90-
@property
91-
def polymer_concentration(self):
92-
return self._polymer.concentration_matrix
9377
## Elliptic pressure
9478
_pressure = None
9579
@property
@@ -107,7 +91,7 @@ def velocity(self):
10791
def velocity(self, value):
10892
self._velocity = value
10993
## Permeability Matrix
110-
_permeability_matrix
94+
_permeability_matrix = None
11195
@property
11296
def permeability_matrix(self):
11397
return self._permeability_matrix
@@ -153,6 +137,31 @@ def critical_capillary_oleic_initial(self): #Nco0
153137
return SimulationConstants.Oleic_Phase_Critical_Capillary_Num.value
154138

155139
# Functions for parameter definitions (TODO: need to make sure that when current property value is None, respective calculations are automatically done when property is called)
140+
## Surfactant concentration matrix
141+
@property
142+
def surfactant_concentration(self):
143+
return self._surfactant.concentration_matrix
144+
@surfactant_concentration.setter
145+
def surfactant_concentration(self, value):
146+
self._surfactant.concentration_matrix = value
147+
## Polymer concentration matrix
148+
@property
149+
def polymer_concentration(self):
150+
return self._polymer.concentration_matrix
151+
@polymer_concentration.setter
152+
def polymer_concentration(self, value):
153+
self._polymer.concentration_matrix = value
154+
## Water Saturation Matrix
155+
@property
156+
def water_saturation(self):
157+
return self._water.water_saturation
158+
@water_saturation.setter
159+
def water_saturation(self, value):
160+
self._water.water_saturation = value
161+
## Aqueous Viscosity
162+
@property
163+
def aqueous_viscosity(self):
164+
return self._water.viscosity_array
156165
## Residual saturations
157166
@property
158167
def swr_0(self):
@@ -385,7 +394,7 @@ def _compute_lambda_a(
385394
modified_water_saturation: np.ndarray | None = None,
386395
):
387396
if(modified_water_saturation is not None):
388-
self._water.compute_mobility(
397+
self.lambda_a = self._water.compute_mobility(
389398
self.polymer_concentration,
390399
self.sor,
391400
self.swr,
@@ -394,7 +403,7 @@ def _compute_lambda_a(
394403
modified_water_saturation
395404
)
396405
else:
397-
self._water.compute_mobility(
406+
self.lambda_a = self._water.compute_mobility(
398407
self.polymer_concentration,
399408
self.sor,
400409
self.swr,
@@ -408,7 +417,7 @@ def _compute_lambda_o(
408417
modified_water_saturation: np.ndarray | None = None,
409418
):
410419
if(modified_water_saturation is not None):
411-
self._water.compute_mobility(
420+
self.lambda_o = self._water.compute_mobility(
412421
self.polymer_concentration,
413422
self.sor,
414423
self.swr,
@@ -417,7 +426,7 @@ def _compute_lambda_o(
417426
modified_water_saturation
418427
)
419428
else:
420-
self._water.compute_mobility(
429+
self.lambda_o = self._water.compute_mobility(
421430
self.polymer_concentration,
422431
self.sor,
423432
self.swr,
@@ -529,11 +538,43 @@ def dpc_dg(self):
529538
def dpc_dg(self, value):
530539
self._dpc_dg = value
531540

541+
def _compute_capillary_pressure(self, sigma):
542+
self.pc = (
543+
sigma
544+
* self.omega[1]
545+
* np.sqrt(self.porosity)
546+
) / (
547+
np.matmul(
548+
self.permeability_matrix ** (0.5),
549+
fractional_matrix_power(
550+
1 - self.nso, 1 / self.omega[0]
551+
),
552+
)
553+
)
554+
532555
def _derivative_capillary_pressure(self, sigma, dsigma_dg):
533556
self.dpc_ds = self.pc / (self.omega[0]*(1-self.nso))
534557
self.dpc_dg = (self.pc/sigma)*dsigma_dg + self.dpc_ds
535558

536559
def execute(self):
560+
"""
561+
Primary function to execute Transport Equation calculations
562+
"""
563+
564+
# Initialize Parameters
565+
566+
567+
# Water Saturation Computations
568+
569+
570+
# Polymer Concentration Computations
571+
572+
573+
# Surfactant Concentration Computation
574+
575+
576+
# Calculations for ROIP
577+
537578
pass
538579

539580
def _main_loop_computation(self, flag):
@@ -625,9 +666,9 @@ def _water_saturation_matrix_processing(self):
625666
self._derivative_capillary_pressure(self._surfactant.eval_IFT, self._surfactant.eval_dIFT_dGamma)
626667

627668
#executing main loop function
628-
self._main_loop_computation(1)
629-
669+
self.water_saturation = self._main_loop_computation(1)
630670

671+
return water_saturation_old, self.water_saturation #[old matrix, new matrix]
631672

632673
def _polymer_concentration_matrix_processing(self, water_saturation_old):
633674
"""
@@ -644,13 +685,46 @@ def _polymer_concentration_matrix_processing(self, water_saturation_old):
644685
polymer_concentration_modified = self._matrix_reordering(np.copy(self.polymer_concentration), xmod, ymod)
645686

646687
# executing main loop functions
647-
self._main_loop_computation(2)
688+
self.polymer_concentration = self._main_loop_computation(2)
648689

649-
def _surfactant_concentration_matrix_processing(self):
690+
return polymer_concentration_old, self.polymer_concentration # [old matrix, new matrix]
691+
692+
def _surfactant_concentration_matrix_processing(self, water_saturation_old, water_saturation_modified):
650693
"""
651694
run through computations for the surfactant concentration matrix
652695
"""
653-
pass
696+
# redefine coordinates
697+
[xmod, ymod] = self._characteristic_coordinates(
698+
3,
699+
water_saturation_old,
700+
self.water_saturation,
701+
)
702+
703+
#saving old surfactant concentration matrix and then modifying the current surfactant concentration matrix for calculations
704+
surfactant_concentration_old = np.copy(self.surfactant_concentration)
705+
surfactant_concentration_modified = self._matrix_reordering(np.copy(self.surfactant_concentration), xmod, ymod)
706+
707+
#updating relevant coefficients using interpolated surfactant concentration matrix
708+
709+
##interfacial tension calculations
710+
sigma_modified = self._surfactant.eval_IFT(surfactant_concentration_modified)
711+
dsigma_dg_modified = self._surfactant.eval_dIFT_dGamma(surfactant_concentration_modified)
712+
713+
##compute residual saturations
714+
[swr, sor] = self._water.compute_residual_saturations(sigma_modified, self.pressure, self.velocity)
715+
self._compute_effective_saturations(water_saturation_modified)
716+
717+
##compute mobilities
718+
self._compute_lambda_a(RelativePermeabilityFormula.CoreyTypeEquation, water_saturation_modified)
719+
self._compute_lambda_o(RelativePermeabilityFormula.CoreyTypeEquation, water_saturation_modified)
720+
721+
##compute capillary pressues derivatives
722+
self._derivative_capillary_pressure(sigma_modified, dsigma_dg_modified)
723+
724+
# running main loop functions
725+
self.surfactant_concentration = self._main_loop_computation(3)
726+
727+
return surfactant_concentration_old, self.surfactant_concentration # [old matrix, new matrix]
654728

655729
def _leftmost_grid_calculations(self, flag, row_index, cnt, i, j, AA, BB, CC, DD, TMM):
656730
"""

0 commit comments

Comments
 (0)