Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve preprocessing time #77

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions CADETProcess/dynamicEvents/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, *args, **kwargs):
self._durations = []
self._lock = False

@property
@cached_property_if_locked
def events(self):
"""list: All Events ordered by event time.

Expand All @@ -109,7 +109,7 @@ def events(self):
"""
return sorted(self._events, key=lambda evt: evt.time)

@property
@cached_property_if_locked
def events_dict(self):
"""dict: Events and Durations orderd by name."""
evts = {evt.name: evt for evt in self.events}
Expand Down Expand Up @@ -276,7 +276,7 @@ def remove_duration(self, duration_name):
self._durations.remove(dur)
self.__dict__.pop(duration_name)

@property
@cached_property_if_locked
def durations(self):
"""List of all durations in the process."""
return self._durations
Expand Down Expand Up @@ -392,37 +392,37 @@ def remove_event_dependency(self, dependent_event, independent_events):
for indep in independent_events:
self.events[dependent_event].remove_dependency(indep)

@property
@cached_property_if_locked
def independent_events(self):
"""list: All events that are not dependent on other events."""
return list(filter(lambda evt: evt.is_independent, self.events))

@property
@cached_property_if_locked
def dependent_events(self):
"""list: All events that are dependent on other events."""
return list(
filter(lambda evt: evt.is_independent is False, self.events)
)

@property
@cached_property_if_locked
def event_parameters(self):
"""list: Event parameters."""
return list({evt.parameter_path for evt in self.events})

@property
@cached_property_if_locked
def event_performers(self):
"""list: Event peformers."""
return list({evt.performer for evt in self.events})

@property
@cached_property_if_locked
def event_times(self):
"""list: Time of events, sorted by Event time."""
event_times = list({evt.time for evt in self.events})
event_times.sort()

return event_times

@property
@cached_property_if_locked
def section_times(self):
"""list: Section times.

Expand Down
3 changes: 0 additions & 3 deletions CADETProcess/modelBuilder/carouselBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,10 @@ def _add_inter_zone_connections(self, flow_sheet):

flow_sheet.add_connection(origin, destination)

flow_rates = self.flow_sheet.get_flow_rates()
for zone in self.zones:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is even necessary here. I think that output states are entirely handled by Events.

output_state = self.flow_sheet.output_states[zone]
flow_sheet.set_output_state(zone.outlet_unit, output_state)

zone_flow_flow_rate = flow_rates[zone.name].total_out

def _add_intra_zone_connections(self, flow_sheet):
"""Add connections within zones."""
for zone in self.zones:
Expand Down