File size: 1,800 Bytes
9fe032c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import gradio as gr
import pandas as pd

# Function to find solutions with floating-point comparison tolerance
def find_solutions(i_1, i_2):
    m1_range = range(3, 7)  # m1 between 3 and 7
    m2_range = range(3, 7)  # m2 between 3 and 7
    valid_solutions = []
    
    # z1 and z3 ranges under 50
    z1_range = range(18, 40)
    z3_range = range(18, 40)

    tolerance = 1e-9  # Set a tolerance for floating-point comparison

    # Iterating over all possible combinations
    for m1 in m1_range:
        for m2 in m2_range:
            for z1 in z1_range:
                for z3 in z3_range:
                    # Calculate left-hand side and right-hand side of the equation
                    lhs = (i_1 + 1) * m1 * z1
                    rhs = (i_2 + 1) * m2 * z3
                    
                    # Use a tolerance to compare floating-point numbers
                    if abs(lhs - rhs) < tolerance:
                        valid_solutions.append((m1, m2, z1, z3))

    # Convert the list of solutions to a pandas DataFrame
    df = pd.DataFrame(valid_solutions, columns=['m1', 'm2', 'z1', 'z3'])

    return df

# Create the Gradio app
demo = gr.Interface(
    fn=find_solutions,
    inputs=[gr.Number(label="i_1"), gr.Number(label="i_2")],
    outputs=gr.DataFrame(label="Solutions"),
    title="iSolver | Find Valid Parameter Sets",
    description="""
    **Find all valid solutions** to satisfy the axle spacing equation of a two-speed manual transmission system.

    - **Equation**: (i_1 + 1) * m_1 * z_1 = (i_2 + 1) * m_2 * z_3
    - **i_i**: Conversion rates between gears
    - **m_i**: Modules of gears
    - **z_1** and **z_3**: The number of teeth on gears 1 and 3

    Enter two values for **i_1** and **i_2** below:
    """
)

# Launch the app
demo.launch(share=True)