In the below code i need you to modify the code based on the new condition for calculating the values of 'gain', 'bw', 'ugf', 'pm',

meas_names = data.get_measure_names()

first we need to calculate the 'gain',
# Extract required measurements for 'gain'
gain_complex = data['gain'][0]  # Complex gain value
# Convert complex values of 'gain' to polar form and get required components
gain_magnitude = abs(gain_complex)  # Magnitude of gain in polar form
# Assign values to variables
gain = gain_magnitude

the 'gain' is negative value then assign the values of variables 'bw', 'ugf', 'pm' to '0'
bw = 0
ugf = 0
pm = 0

else 'gain' is positive then calculate values of variables 'bw', 'ugf', 'pm'

# Extract required measurements for 'bw', 'ugf', 'pm'
bw = data['bw_at'][0]  # Bandwidth
ugf = data['ugf'][0]  # Unity-Gain Frequency
pm_complex = data['pm'][0]  # Complex phase margin value

# Convert complex values of 'pm' to polar form and get required components
pm_angle_rad = cmath.phase(pm_complex)  # Angle of phase margin in polar form
pm_angle_deg = math.degrees(pm_angle_rad)  # Convert angle from radians to degrees

# Assign values to variables
bw = float(bw)
ugf = float(ugf)
pm = pm_angle_deg + 180 if pm_angle_deg < 0 else pm_angle_deg        

# Create a dictionary with the performance metrics
performance_metrics = {
    'gain': gain,
    'bw': bw,
    'ugf': ugf,
    'pm': pm
    }


def run_simulation(input_parameters):
    try:
        param_names = ['L1', 'L3', 'L5', 'L6', 'L7', 'W1', 'W3', 'W5', 'W6', 'W7', 'Ib', 'Cc', 'Vb']

        runner = SimRunner(output_folder='./PY_LTS', simulator=LTspice) 

        net = PyLTSpice.SpiceEditor(r"Netlist_Run_OTA1.net")  # Loading the Netlist
        
        # Set the parameters dynamically in the exact format required
        param_dict = {name: value for name, value in zip(param_names, input_parameters)}
        net.set_parameters(**param_dict)

        net.write_netlist("Netlist_Run_OTA1_mod.net")  # writes the modified netlist to the indicated file

        run_netlist_file = "Netlist_Run_OTA1_mod.net"
        temp_netlist_path = r'D:\OPAMP CIRCUITS\RLGNN_LTSpice\PY_LTS\Netlist_Run_OTA1_mod.net'
        
        runner.run(net, run_filename=run_netlist_file)

        runner.wait_completion()

        data = LTSpiceLogReader(r"D:\OPAMP CIRCUITS\RLGNN_LTSpice\PY_LTS\Netlist_Run_OTA1_mod.log")

        meas_names = data.get_measure_names()
        print('\t'.join([f"{data[name]}" for name in meas_names]), end='\n')
        # Extract required measurements based on provided names
        gain_complex = data['gain'][0]  # Complex gain value
        bw = data['bw_at'][0]  # Bandwidth
        ugf = data['ugf'][0]  # Unity-Gain Frequency
        pm_complex = data['pm'][0]  # Complex phase margin value


        # Convert complex values to polar form and get required components
        gain_magnitude = abs(gain_complex)  # Magnitude of gain in polar form
        pm_angle_rad = cmath.phase(pm_complex)  # Angle of phase margin in polar form
        pm_angle_deg = math.degrees(pm_angle_rad)  # Convert angle from radians to degrees


        # Assign values to variables
        gain = gain_magnitude
        bw = float(bw)
        ugf = float(ugf)
        pm_value = pm_angle_deg
        pm = pm_value + 180 if pm_value < 0 else pm_value
        
        # Create a dictionary with the performance metrics
        performance_metrics = {
            'gain': gain,
            'bw': bw,
            'ugf': ugf,
            'pm': pm
        }
        
        #print(f"Gain: {gain}")
        #print(f"Bandwidth (BW): {bw}")
        #print(f"Unity-Gain Frequency (UGF): {ugf}")
        #print(f"Phase Margin (PM): {pm}")
        print("Performance Metrics:", results)
        return performance_metrics, temp_netlist_path
    
    except Exception as e:
        print(f"Error running simulation: {e}")
        return None