Kraysent / OMTool

Modeling N-Body problem in galactic evolution application.
https://omtool.readthedocs.io/en/latest/
Apache License 2.0
0 stars 0 forks source link

Analysis tool leaks memory #148

Open Kraysent opened 1 year ago

Kraysent commented 1 year ago

See monologue in #147. Something's wrong, need to identify where the problem is.

Start with the same simulation as in the end of aforementioned ticket, then gradually decrease number of the tasks until memory does not stop leaking.

Kraysent commented 1 year ago
# You can use YAML anchors to substitute some values that repeat several times over the file.
# About YAML anchors: https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/
host: &host
  type: slice
  parts: [[0, 0.666666]]
host_color: &host_clr b

satellite: &satellite
  type: slice
  parts: [[0.666666, 1]]
sat_color: &sat_clr r

all_color: &all_clr y

# File with a set of snapshots.
input_file:
  format: fits
  filenames:
    - !env "{WORKING_DIR}/test_out.fits"

# You can specify filename where JSON logs would be saved.
logging:
  level: debug
  filename: !env "{WORKING_DIR}/test_json_log.txt"
  datefmt: "%Y-%m-%d %H:%M:%S"

# Visualizer module configuration. It specifies list of panels.
visualizer:
  output_dir: !env "{WORKING_DIR}/analysis"
  title: "Time: {time:07.01f} Myr"
  pickle_filename: "pickle-{i:03}.pickle"
  figsize: [20, 11]
  pic_filename: "img-{i:03d}.png"
  panels:
    - id: zy_plane
      coords: [0, 0.35, 0.35, 0.6]
      params:
        xlim: [-45, 45]
        ylim: [-40, 40]
        xlabel: "z, kpc"
        ylabel: "y, kpc"
        xticks: [0, 10]
        yticks: [0, 10]
    - id: xy_plane
      coords: [0.33, 0.35, 0.35, 0.6]
      params:
        xlim: [-45, 45]
        ylim: [-40, 40]
        xlabel: "x, kpc"
        yticks: []
        xticks: [0, 10]
    - id: potential_dist_plane
      coords: [0.72, 0.66, 0.14, 0.3]
      params:
        xlim: [0, 50]
        ylim: [0, 3]
        xlabel: "$r$, kpc"
        ylabel: "Potential, portion of the average"
        grid: True
    - id: bound_mass_evolution_plane
      coords: [0.72, 0.33, 0.14, 0.3]
      params:
        xlim: [0, 10000]
        ylim: [0, 3.e+11]
        xlabel: "Time, Myr"
        ylabel: "Bound mass, MSun"
        grid: True
    - id: separation_evolution_panel
      coords: [0, 0, 0.14, 0.3]
      params:
        xlim: [0, 10000]
        ylim: [0, 150]
        xlabel: "Time, Myr"
        ylabel: "Separation, kpc"
        grid: True
    - id: velocity_profile_panel
      coords: [0.18, 0, 0.32, 0.3]
      params:
        xlim: [0, 15]
        ylim: [0, 400]
        xlabel: "$r$, kpc"
        ylabel: "$v$, km/s"
        grid: True
    - id: density_profile_panel
      coords: [0.54, 0, 0.32, 0.3]
      params:
        xlim: [0, 50]
        ylim: [0, 4.e+8]
        xlabel: "$r$, kpc"
        ylabel: '$\rho$, MSun / kpc ** 3'
        grid: True

# List of tasks. Each one describes arguments to its constructor and list of actions.
tasks:
  - name: PotentialCenterTask
    id: host_potential_center
    actions_before:
      - *host
  - name: PotentialCenterTask
    id: sat_potential_center
    actions_before:
      - *satellite
  - name: PotentialCenterTask
    id: total_potential_center

  - name: ScatterTask
    args: &args
      expressions:
        x: "x"
        y: "y"
        z: "z"
        m: "m"
      units:
        x: !q [1, kpc]
        y: !q [1, kpc]
        z: !q [1, kpc]
        m: !q [1, MSun]
    actions_before:
      - *host
      - type: barion_filter
    actions_after:
      # You can plot one result several times in different projections.
      - type: visualizer
        id: xy_plane
        is_density_plot: True
        resolution: 700
        extent: [-45, 45, -40, 40]
        channel: *host_clr
        x: x
        y: y
        weights: m
      - type: visualizer
        id: zy_plane
        is_density_plot: True
        resolution: 700
        extent: [-45, 45, -40, 40]
        channel: *host_clr
        x: z
        y: y
        weights: m
  - name: ScatterTask
    args: *args
    actions_before:
      - *satellite
      - type: barion_filter
    actions_after:
      - type: visualizer
        id: xy_plane
        is_density_plot: True
        resolution: 700
        extent: [-45, 45, -40, 40]
        channel: *sat_clr
        x: x
        y: y
        weights: m
      - type: visualizer
        id: zy_plane
        is_density_plot: True
        resolution: 700
        extent: [-45, 45, -40, 40]
        channel: *sat_clr
        x: z
        y: y
        weights: m
  - name: ScatterTask
    args: *args
    actions_before:
      - type: slice
        id: 0
    actions_after:
      - type: visualizer
        id: xy_plane
        linestyle: solid
        color: *host_clr
        marker: o
        markersize: 5
        x: x
        y: y
      - type: visualizer
        id: zy_plane
        linestyle: solid
        color: *host_clr
        marker: o
        markersize: 5
        x: z
        y: y
  - name: ScatterTask
    args: *args
    actions_before:
      - type: slice
        id: 1000001
    actions_after:
      - type: visualizer
        id: xy_plane
        linestyle: solid
        color: *sat_clr
        marker: o
        markersize: 5
        x: x
        y: y
      - type: visualizer
        id: zy_plane
        linestyle: solid
        color: *sat_clr
        marker: o
        markersize: 5
        x: z
        y: y

  - name: PotentialTask
    inputs:
      center: host_potential_center.position
    actions_before:
      - *host
    actions_after:
      - type: visualizer
        id: potential_dist_plane
        linestyle: None
        color: *host_clr
        label: host
        x: radii
        y: potential
  - name: PotentialTask
    inputs:
      center: sat_potential_center.position
    actions_before:
      - *satellite
    actions_after:
      - type: visualizer
        id: potential_dist_plane
        linestyle: None
        color: *sat_clr
        label: satellite
        x: radii
        y: potential
  - name: PotentialTask
    inputs:
      center: total_potential_center.position
    actions_after:
      - type: visualizer
        id: potential_dist_plane
        linestyle: None
        color: *all_clr
        label: all
        x: radii
        y: potential

  - name: BoundMassTask
    args:
      number_of_iterations: 5
    actions_before:
      - *satellite
    actions_after:
      - type: visualizer
        id: bound_mass_evolution_plane
        linestyle: solid
        color: r
        x: times
        y: bound_mass
      - type: logging
        print_last: True
        id: bound_mass_data

  - name: DistanceTask
    inputs:
      start: host_potential_center.position
      end: sat_potential_center.position
    actions_after:
      - type: visualizer
        id: separation_evolution_panel
        linestyle: solid
        color: r
        x: times
        y: dist

  - name: VelocityProfileTask
    inputs:
      center: host_potential_center.position
      center_vel: host_potential_center.velocity
    actions_before:
      - *host
    actions_after:
      - type: visualizer
        id: velocity_profile_panel
        markersize: 0.5
        linestyle: None
        color: *host_clr
        label: host
        x: radii
        y: velocity
  - name: VelocityProfileTask
    inputs:
      center: sat_potential_center.position
      center_vel: sat_potential_center.velocity
    actions_before:
      - *satellite
    actions_after:
      - type: visualizer
        id: velocity_profile_panel
        markersize: 0.5
        linestyle: None
        color: *sat_clr
        label: satellite
        x: radii
        y: velocity
  - name: VelocityProfileTask
    inputs:
      center: total_potential_center.position
      center_vel: total_potential_center.velocity
    actions_after:
      - type: visualizer
        id: velocity_profile_panel
        markersize: 0.5
        linestyle: None
        color: *all_clr
        label: all
        x: radii
        y: velocity

  - name: DensityProfileTask
    inputs:
      center: host_potential_center.position
    actions_before:
      - *host
    actions_after:
      - type: visualizer
        id: density_profile_panel
        markersize: 0.5
        linestyle: None
        color: *host_clr
        label: host
        x: radii
        y: densities
  - name: DensityProfileTask
    inputs:
      center: sat_potential_center.position
    actions_before:
      - *satellite
    actions_after:
      - type: visualizer
        id: density_profile_panel
        markersize: 0.5
        linestyle: None
        color: *sat_clr
        label: satellite
        x: radii
        y: densities
  - name: DensityProfileTask
    inputs:
      center: total_potential_center.position
    actions_after:
      - type: visualizer
        id: density_profile_panel
        markersize: 0.5
        linestyle: None
        color: *all_clr
        label: all
        x: radii
        y: densities

image analysis1.txt

Kraysent commented 1 year ago

Removed scatter tasks

analysis2 analysis2.txt

Kraysent commented 1 year ago

Removed velocity profile task

analysis3.txt analysis3

Kraysent commented 1 year ago

Removed density profile tasks

analysis4 analysis4.txt

Kraysent commented 1 year ago

Removed distance task

analysis5 analysis5.txt

Kraysent commented 1 year ago

Removed potential tasks

analysis6.txt analysis6

Kraysent commented 1 year ago

Removed potential center tasks analysis7.txt analysis7

Kraysent commented 1 year ago

Removed bound mass task (no tasks left) analysis8.txt analysis8

Kraysent commented 1 year ago

Seems like there is something else that leaks memory