Commit 63dd7475 authored by Andrea Giannetti's avatar Andrea Giannetti
Browse files

Applied floor temperature and fixed bug in determination of temperature profile.

parent 08b6426e
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -101,6 +101,20 @@ def load_config_file(config_file_path: str,
                config[key][subkey] = _override_config[key][subkey]
            except KeyError:
                config[key] = {subkey: _override_config[key][subkey]}

    try:
        if config['density_powerlaw_idx'] == 0:
            config['central_density'] = config['density_at_reference']
            config['density_at_reference'] = None
    except KeyError:
        pass

    try:
        if config['dust_temperature_powerlaw_idx'] == 0:
            config['dust_temperature'] = config['dust_temperature_at_reference']
            config['dust_temperature_at_reference'] = None
    except KeyError:
        pass
    return config


+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ def get_parallel_args_and_nprocesses() -> Tuple[Iterator, int]:
    _tdust_model_type, _model_type, dust_temperatures, densities, line_pairs, n_processes = parse_input_main()
    line_set = set(chain.from_iterable(line_pairs))
    density_keyword = 'central_density' if _model_type == 'homogeneous' else 'density_at_reference'
    dust_temperature_keyword = 'dust_temperature' if _model_type == 'isothermal' else 'dust_temperature_at_reference'
    dust_temperature_keyword = 'dust_temperature' if _tdust_model_type == 'isothermal' else 'dust_temperature_at_reference'
    parallel_args = product(dust_temperatures, densities, line_set, [density_keyword], [dust_temperature_keyword])
    return parallel_args, n_processes

+9 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ def get_profiles(grid_metadata: dict) -> dict:
        },
        'dust_temperature': {
            'central_value': float(grid_metadata['dust_temperature']),
            'power_law_index': float(grid_metadata['density_powerlaw_idx']),
            'power_law_index': float(grid_metadata['dust_temperature_powerlaw_idx']),
            'value_at_reference': tdust_ref['value_at_reference'],
            'distance_reference': tdust_ref['distance_reference']
        },
@@ -216,6 +216,13 @@ def get_profiles(grid_metadata: dict) -> dict:
    if grid_metadata['velocity_field'] == 'solid':
        profiles['velocity_x'], profiles['velocity_z'] = get_solid_body_rotation_y(grid_metadata=grid_metadata)
    profiles['velocity_field'] = np.array([profiles['velocity_x'], profiles['velocity_y'], profiles['velocity_z']])

    if 'floor_temperature' in grid_metadata.keys():
        profiles['dust_temperature'] = np.where(
            profiles['dust_temperature'] < float(grid_metadata['floor_temperature']),
            float(grid_metadata['floor_temperature']),
            profiles['dust_temperature']
        )
    return profiles


@@ -637,6 +644,7 @@ def main(run_id: str,
            logger.info('Using cached dust temperature distribution')
            shutil.copy(os.path.join(execution_dir, 'model', 'data', 'dust_temperature.dat'),
                        os.path.join('.', 'dust_temperature.dat'))
            # TODO: Should I apply the floor temperature here as well?
    os.chdir(execution_dir)

    if engine is None:
+20 −1
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ import numpy as np
from stg.stg_radmc_input_generator import (get_solid_body_rotation_y,
                                           get_grid_name,
                                           read_abundance_variation_schema,
                                           compute_molecular_number_density_hot_core)
                                           compute_molecular_number_density_hot_core,
                                           compute_power_law_radial_profile)
from astropy import units as u
from unittest import TestCase
from assets.commons import (load_config_file,
@@ -22,6 +23,24 @@ class Test(TestCase):
    def setUp(self):
        self.config_filename = 'config.yml'

    def test_compute_power_law_radial_profile(self):
        profile = compute_power_law_radial_profile(central_value=2000.0,
                                                   power_law_index=0,
                                                   distance_matrix=np.array([
                                                       [np.sqrt(2), 1, np.sqrt(2)],
                                                       [1, 0, 1],
                                                       [np.sqrt(2), 1, np.sqrt(2)],
                                                   ]),
                                                   maximum_radius=np.sqrt(2),
                                                   value_at_reference=15.0,
                                                   distance_reference=3e18)
        expected_result = np.array([
            [15, 15, 15],
            [15, 15, 15],
            [15, 15, 15],
        ])
        self.assertTrue(np.allclose(profile, expected_result, 1.0e-5))

    def test_read_abundance_variation_schema(self):
        line_config = {
            'species_to_include': ['e-ch3oh'],