Coverage for backend/django/core/auxiliary/models/Scenario.py: 100%
43 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-03-26 20:57 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-03-26 20:57 +0000
1from django.db import models
2from .PropertyInfo import PropertyInfo
3from .PropertyValue import PropertyValue
4from flowsheetInternals.unitops.models.SimulationObject import SimulationObject
6from core.managers import AccessControlManager
8class ScenarioTabTypeEnum(models.TextChoices):
10 SteadyState = "steady state"
11 MultiSteadyState = "mss"
12 Dynamic = "dynamic"
14class SolverOptionEnum(models.TextChoices):
15 Ipopt= "ipopt"
16 Ipopt_v2 = "ipopt_v2"
17 Ipopt_WaterTAP = "ipopt-watertap"
18 Bomin = "bonmin"
19 Conopt = "conopt"
23class Scenario(models.Model):
24 """
25 Stores all relevant information about an optimization
26 """
27 flowsheet = models.ForeignKey("Flowsheet", on_delete=models.CASCADE, related_name="Optimizations")
28 # owner of the optimization
29 simulationObject = models.ForeignKey(SimulationObject, on_delete=models.CASCADE, related_name="optimizations", null=True)
30 displayName = models.CharField(max_length=64, blank=True, default="Scenario")
31 enable_optimization = models.BooleanField(default=False)
32 enable_dynamics = models.BooleanField(default=False)
33 state_name = models.CharField(max_length=64, blank=True, choices=ScenarioTabTypeEnum.choices, default=ScenarioTabTypeEnum.SteadyState)
34 num_time_steps = models.IntegerField(default=1)
35 simulation_length = models.FloatField(default=1.0)
36 simulation_length_units = models.CharField(max_length=32, blank=True)
37 Uploaded_fileName = models.CharField(max_length=64, blank=True, default="No file Chosen")
38 enable_rating = models.BooleanField(default=False)
39 solver_option = models.CharField(max_length=64, blank=True, choices=SolverOptionEnum.choices, default=SolverOptionEnum.Ipopt)
40 is_LiveData = models.BooleanField(default=False)
41 disable_initialization = models.BooleanField(default=False)
42 degreesOfFreedom : models.QuerySet["OptimizationDegreesOfFreedom"]
44 # expression to minimize or maximize
45 objective = models.ForeignKey(PropertyInfo, on_delete=models.SET_NULL, null=True)
46 # boolean to find minimum or maximum or the objective
47 minimize = models.BooleanField(default=True)
49 created_at = models.DateTimeField(auto_now_add=True)
51 objects = AccessControlManager()
57class OptimizationDegreesOfFreedom(models.Model):
58 flowsheet = models.ForeignKey("Flowsheet", on_delete=models.CASCADE, related_name="OptimizationDegreesOfFreedoms")
59 scenario = models.ForeignKey(Scenario, on_delete=models.CASCADE, related_name="degreesOfFreedom", null=True)
60 propertyValue: PropertyValue = models.ForeignKey(PropertyValue, on_delete=models.CASCADE, null=True)
61 upper_bound = models.FloatField(null=True, blank=True)
62 lower_bound = models.FloatField(null=True, blank=True)
63 created_at = models.DateTimeField(auto_now_add=True)
64 objects = AccessControlManager()