"""
Tests for Acoustic Model module
"""

import pytest
import numpy as np
from src.core.acoustic_model import AcousticModel


class TestAcousticModel:
    """Test suite for AcousticModel"""
    
    def test_initialization(self):
        """Test initialization"""
        acoustic = AcousticModel(temperature=2.0, salinity=34.7, depth=10911)
        assert acoustic.temperature == 2.0
        assert acoustic.salinity == 34.7
        assert acoustic.depth == 10911
    
    def test_sound_speed_surface(self):
        """Test sound speed at surface"""
        acoustic = AcousticModel(temperature=10.0, salinity=35.0, depth=0)
        c = acoustic.sound_speed()
        
        # Surface sound speed should be around 1500 m/s
        assert 1400 < c < 1600
    
    def test_sound_speed_challenger(self):
        """Test sound speed at Challenger Deep"""
        acoustic = AcousticModel(temperature=1.9, salinity=34.68, depth=10911)
        c = acoustic.sound_speed()
        
        # Sound speed should be reasonable
        assert 1600 < c < 1700
    
    def test_travel_time(self):
        """Test travel time calculation"""
        acoustic = AcousticModel(depth=10911)
        
        # 5 km distance
        time = acoustic.travel_time(5000)
        assert 3 < time < 4  # Should be around 3 seconds
    
    def test_refraction_index(self):
        """Test refraction index calculation"""
        acoustic = AcousticModel(depth=10911)
        n = acoustic.refraction_index()
        
        # Refraction index should be >1
        assert n > 1.0
        assert n < 1.2
    
    def test_acoustic_impedance(self):
        """Test acoustic impedance"""
        acoustic = AcousticModel(depth=10911)
        Z = acoustic.acoustic_impedance(density=1050)
        assert Z > 0
    
    def test_sofar_channel(self):
        """Test SOFAR channel depth estimation"""
        acoustic = AcousticModel()
        depth = acoustic.sofar_channel_depth()
        assert depth > 0
