Olympus Blog

In the Olympus blog you'll find the latest news about the community, tutorials, helpful resources and much more! React to the news with the emotion stickers and have fun!

Python Operators and Expressions: Statements vs. Expressions

Understanding the difference between expressions and statements is crucial for writing effective Python code. In this guide, you’ll learn how operators work, how expressions produce values, and how statements control program flow. Practice with exercises and workshops to solidify your skills.

Expressions vs. Statements

What is an Expression?

An expression is a piece of code that evaluates to a value. Examples include arithmetic operations, function calls, or comparisons.

2 + 3          # Evaluates to 5
len("Hello")   # Evaluates to 5
3 > 2          # Evaluates to True

What is a Statement?

A statement is an instruction that performs an action. Examples include loops, conditionals, and variable assignments.

if x > 0:       # if statement
    print(x)

for i in range(5):  # for loop statement
    print(i)

Python Operators

1. Arithmetic Operators

print(10 + 3)   # 13 (Addition)
print(10 - 3)   # 7 (Subtraction)
print(10 * 3)   # 30 (Multiplication)
print(10 ** 3)  # 1000 (Exponentiation)
print(10 / 3)   # 3.333... (Division)
print(10 // 3)  # 3 (Floor Division)
print(10 % 3)   # 1 (Modulus)

2. Comparison Operators

print(5 == 5)   # True
print(5 != 3)   # True
print(5 > 3)    # True
print(5 <= 5)   # True

3. Logical Operators

print(True and False)  # False
print(True or False)   # True
print(not True)        # False

4. Assignment Operators

x = 5
x += 3   # Equivalent to x = x + 3 (x becomes 8)

Practice Work

Exercise 1: Identify Expressions vs. Statements

Label the following as expression or statement:

5 * (10 - 3)
x = 25
print("Hello")
sum = 2 + 3
Solution:

  • 5 * (10 – 3) → Expression
  • x = 25 → Statement
  • print(“Hello”) → Statement
  • sum = 2 + 3 → Statement (assignment is a statement)

Exercise 2: Fix Invalid Expressions

Correct the invalid code below:

result = 10 + * 3
if 5 > 3 and < 10:
    print("Valid")
Solution:

result = 10 * 3
if 5 > 3 and 5 < 10:
    print("Valid")

Exercise 3: Evaluate Expressions

What do these expressions evaluate to?

15 % 4
(5 > 3) or (2 == 3)
not (10 <= 5)
Solution:

  • 15 % 4 → 3
  • (5 > 3) or (2 == 3) → True
  • not (10 <= 5) → True

Workshop: Real-World Applications

Workshop 1: Temperature Converter

Write a script that converts Celsius to Fahrenheit using the formula: F = (C * 9/5) + 32.

celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 9/5) + 32
print(f"{celsius}°C = {fahrenheit}°F")

Workshop 2: User Login Validation

Check if a user’s input meets these conditions:

  • Username is at least 5 characters long.
  • Password contains at least 8 characters.
username = input("Enter username: ")
password = input("Enter password: ")

is_valid = (len(username) >= 5) and (len(password) >= 8)
print("Valid credentials?" , is_valid)

Best Practices

  • Use Parentheses for Clarity: (5 + 3) * 2 is clearer than 5 + 3 * 2.
  • Avoid Complex One-Liners: Break complicated expressions into multiple lines.
  • Prefer Descriptive Variables: discount_rate = 0.1 instead of dr = 0.1.

Conclusion

Mastering operators and understanding the difference between expressions and statements will help you write efficient and readable Python code. Practice the exercises and workshops to reinforce these concepts.

Next Steps: Explore our posts on Python Control Flow and Python Functions.

 

Python Variables and Identifiers: Rules, Examples, and Practice

Variables and identifiers are fundamental to programming in Python. In this guide, you’ll learn how to name variables correctly, avoid syntax errors, and follow Python’s naming conventions. We’ll also explore reserved keywords and practice with hands-on exercises.

Variables and Identifiers in Python

What Are Variables?

Variables are containers for storing data. They are created using an identifier (name) and the assignment operator =.

age = 25
name = "Mourad"
user_name = 'admin'
server_ip = '192.168.1.1'

Rules for Naming Identifiers

  • Can include letters, numbers, and underscores.
  • Cannot start with a number.
  • Cannot use reserved keywords (e.g., def, class).
  • Case-sensitive (Ageage).

Invalid Identifiers Example

#def = 5  # SyntaxError: "def" is a reserved keyword

Reserved Keywords

Python has predefined keywords that cannot be used as identifiers. View them using the keyword module:

import keyword
print(keyword.kwlist)

Practice Work

Exercise 1: Fix Invalid Identifiers

Correct the invalid identifiers in the code below:

2nd_name = "Ali"
class = "Python101"
user-email = "[email protected]"
Solution:

second_name = "Ali"
course_class = "Python101"
user_email = "[email protected]"

Exercise 2: Create Valid Identifiers

Write variables for the following data:

  1. A constant for maximum login attempts (value: 3).
  2. A string storing a server’s domain name (“api.example.com”).
  3. A boolean indicating whether a user is active (True/False).
Solution:

MAX_LOGIN_ATTEMPTS = 3
server_domain = "api.example.com"
is_user_active = True

Exercise 3: Reserved Keywords Check

Write a script to check if the word "async" is a reserved keyword in Python.

Solution:

import keyword
print("async" in keyword.kwlist)  # Output: True (in Python 3.7+)

Workshop: Real-World Practice

Workshop 1: User Registration Script

Create a script that asks for a user’s first name, last name, and age. Store the data in variables and print a summary. Follow these rules:

  • Use snake_case for variable names.
  • Avoid reserved keywords.
first_name = input("Enter your first name: ")
last_name = input("Enter your last name: ")
user_age = int(input("Enter your age: "))

print(f"User: {first_name} {last_name}, Age: {user_age}")

Workshop 2: Data Processing

Calculate the total price of items in a shopping cart using variables:

item1_price = 20.5
item2_price = 15.75
item3_price = 5.0
total = item1_price + item2_price + item3_price
print(f"Total: ${total:.2f}")

Best Practices

  • Use Descriptive Names: user_age instead of a.
  • Follow Case Conventions:
    • snake_case for variables (e.g., server_ip).
    • UPPER_CASE for constants (e.g., MAX_USERS).
  • Avoid Abbreviations: first_name is clearer than fn.

Conclusion

Mastering variables and identifiers is the first step to writing clean, maintainable Python code. Practice the exercises and workshops to solidify your understanding, and always follow Python’s naming conventions.

Want more? Check out our post on Python Data Types or Python Functions.

 

Python Code Structure: Scripts vs. Modules, Execution, and Best Practices

Understanding Python’s code structure is essential for writing reusable, maintainable, and executable programs. In this guide, we’ll explore the differences between scripts and modules, how to use the shebang line (#!/usr/bin/env python3), and best practices for organizing and executing Python code.

Scripts vs. Modules in Python

1. Scripts: Executable Files

A script is a Python file (.py) designed to be executed directly. Scripts typically perform tasks like data processing, automation, or running applications.

#!/usr/bin/env python3
# This is a script named "greet.py"
print("Hello, World!")

2. Modules: Reusable Code Libraries

A module is a Python file intended to be imported and reused in other scripts or modules. Modules contain functions, classes, or variables.

# This is a module named "math_utils.py"
def add(a, b):
    return a + b

def subtract(a, b):
    return a - b

Shebang Line and File Permissions

Shebang Line: #!/usr/bin/env python3

The shebang line tells the operating system which interpreter to use to execute the script. Place it at the top of your script:

#!/usr/bin/env python3
print("This script uses Python 3!")

Setting File Permissions

To run a script directly, you must make it executable using chmod:

chmod +x script.py  # Grant execute permission
./script.py         # Run the script

Example: Script Execution Workflow

  1. Create a script: greet.py
  2. Add the shebang line and code:
#!/usr/bin/env python3
name = input("Enter your name: ")
print(f"Hello, {name}!")
  1. Make it executable:
chmod +x greet.py
  1. Run it:
./greet.py

Practice Work

Exercise 1: Create a Script

Write a script called calculator.py that asks the user for two numbers and prints their sum. Include the shebang line and make it executable.

#!/usr/bin/env python3
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
print(f"Sum: {num1 + num2}")

Exercise 2: Convert Script to Module

Convert the calculator.py script into a reusable module with functions for addition, subtraction, multiplication, and division.

# Module: calculator.py
def add(a, b):
    return a + b

def subtract(a, b):
    return a - b

def multiply(a, b):
    return a * b

def divide(a, b):
    return a / b

Exercise 3: Fix Permissions

If a script returns a “Permission denied” error, what command would you use to fix it? Write the answer below.

# Answer:
chmod +x script_name.py

Best Practices

  • Use Shebang for Clarity: Always include #!/usr/bin/env python3 in scripts to specify the Python version.
  • Organize Code into Modules: Reuse functions/classes across projects by separating logic into modules.
  • Name Scripts and Modules Clearly: Use descriptive filenames like data_analysis.py or utils.py.

Conclusion

Mastering Python’s code structure—scripts, modules, and execution—is key to building scalable and maintainable applications. Practice creating scripts, converting them to modules, and using the shebang line to ensure your code runs smoothly across systems.

Need more Python tutorials? Check out our posts on Python Functions and Object-Oriented Programming in Python.

 

Basic Syntax and Semantics: Python Indentation

Python is a powerful and beginner-friendly programming language known for its simplicity and readability. One of the most distinctive features of Python is its use of indentation to define code blocks. Unlike other programming languages that use braces {}, Python relies on proper spacing and alignment to group statements. In this chapter, we’ll explore Python’s indentation rules, comments, and line continuation, along with examples, exercises, and practical work (TP) to help you master these concepts.

Why Indentation Matters in Python

In many programming languages like C, Java, or JavaScript, curly braces {} are used to define blocks of code. However, Python takes a different approach. It uses indentation (spaces or tabs) to group statements logically. This makes Python code visually clean and easy to read.

Example of Indentation

if True:
    print('This is indented properly')  # This code is indented

In the example above:

  • The if statement is followed by a colon :.
  • The print() statement is indented with 4 spaces (or a tab) to indicate that it belongs to the if block.
  • If the indentation is incorrect, Python will throw an IndentationError.

Comments in Python

Comments are essential for explaining your code. Python supports two types of comments:

  1. Single-line comments: Use the # symbol.
  2. Multi-line comments: Use triple quotes ''' or """.

Example of Comments

# This is a single-line comment

"""
This is a multi-line comment.
It can span across multiple lines.
"""

Line Continuation in Python

Sometimes, a single line of code can become too long. Python allows you to break it into multiple lines using the backslash \ for line continuation.

Example of Line Continuation

total = 1 + 2 + 3 + \
        4 + 5 + 6
print(total)  # Output: 21

Here, the backslash \ tells Python that the statement continues on the next line.

Exercises to Practice

Now that you’ve learned the basics, let’s test your understanding with some exercises.

Exercise 1: Fix the Indentation

The following code has incorrect indentation. Fix it so it runs without errors.

if 5 > 2:
print('5 is greater than 2')

Exercise 2: Add Comments

Add a single-line comment and a multi-line comment to the code below.

x = 10
y = 20
sum = x + y
print(sum)

Exercise 3: Line Continuation

Rewrite the following code using line continuation to make it more readable.

result = 10 + 20 + 30 + 40 + 50 + 60 + 70 + 80 + 90 + 100
print(result)

TP (Practical Work)

To solidify your understanding, here are some practical tasks to complete. These tasks will help you apply the concepts of indentation, comments, and line continuation in real-world scenarios.

TP 1: Create a Simple Calculator

Write a Python program that performs basic arithmetic operations (addition, subtraction, multiplication, and division) using proper indentation and comments to explain each step.

# Example structure
num1 = 10
num2 = 5

# Addition
sum = num1 + num2
print("Sum:", sum)

# Subtraction
difference = num1 - num2
print("Difference:", difference)

# Add more operations here...

TP 2: Fix and Improve Code

The following code is poorly formatted and lacks comments. Fix the indentation, add comments, and use line continuation where necessary.

if 10 > 5:
print('10 is greater than 5')
else:
print('5 is greater than 10')
total = 10 + 20 + 30 + 40 + 50 + 60 + 70 + 80 + 90 + 100
print(total)

TP 3: Write a Program with Nested Conditions

Write a Python program that uses nested if statements to check multiple conditions. Ensure proper indentation and add comments to explain the logic.

# Example structure
age = 18
has_license = True

if age >= 18:
    if has_license:
        print("You are eligible to drive.")
    else:
        print("You need a license to drive.")
else:
    print("You are too young to drive.")

Conclusion

Understanding Python’s indentation, comments, and line continuation is crucial for writing clean and error-free code. By mastering these basics and completing the exercises and practical work (TP), you’ll be well on your way to becoming a proficient Python programmer. Practice the exercises provided, and don’t forget to experiment with your own code!

If you found this post helpful, share it with your friends and leave a comment below. Happy coding!

Basic Syntax and Semantics

“`

Python is a versatile and powerful programming language that emphasizes readability and simplicity. In this chapter, we will explore the basic syntax and semantics of Python, focusing on indentation, comments, and line continuation. By the end of this chapter, you will understand how to structure your Python code properly.

Python Indentation

Unlike many other programming languages that use braces {} to define code blocks, Python relies on indentation. This means that the grouping of your code depends on how it is indented. Proper indentation is not optional in Python—it is a requirement for the code to execute.

Example: Proper Indentation

if True:
print('This is indented properly')
print('Another indented line')
```

“`

In the example above, the lines following the if statement are indented, making them part of the same block. If you fail to indent correctly, Python will raise an error.

Incorrect Indentation Example

if True:
```

print(‘This will cause an error’) # Missing indentation

“`

Error: IndentationError: expected an indented block

Tips for Proper Indentation

  • Use 4 spaces per level of indentation (this is the Python convention).
  • Avoid mixing spaces and tabs.
  • Many code editors, such as VS Code and PyCharm, can help you format your code correctly.

Comments in Python

Comments are essential for making your code readable and maintainable. Python supports two types of comments:

Single-line Comments

Single-line comments begin with a # symbol. Everything after the # on the same line is ignored by Python.

Example:

# This is a single-line comment
```

print(‘Hello, World!’) # This comment explains the line

“`

Multi-line Comments

Python does not have a specific syntax for multi-line comments. Instead, you can use a series of single-line comments or a string literal (usually triple quotes) that is not assigned to a variable.

Example 1: Using multiple #

# This is a comment
```

# spanning multiple lines

# to explain the code

“`

Example 2: Using a string literal

"""
```

This is a multi-line comment. It is often used for documentation. “””

“`

Line Continuation in Python

In Python, you can split long lines of code into multiple lines using a backslash \. This is especially useful for improving readability.

Example:

total = 1 + 2 + 3 + \
    4 + 5 + 6
```

print(total) # Output: 21

“`

Alternatively, you can use parentheses for implicit line continuation. This is often preferred because it eliminates the need for a backslash.

Example:

total = (1 + 2 + 3 +
     4 + 5 + 6)
```

print(total) # Output: 21

“`

Exercises

To solidify your understanding of Python’s basic syntax and semantics, try the following exercises:

Exercise 1: Fix the Indentation Error

The following code has an indentation error. Fix it to make it work:

if 5 > 3:
```

print(‘Five is greater than three!’)

“`

Exercise 2: Add Comments

Write a Python script with at least three single-line comments explaining what the code does. For example:

# This program calculates the sum of two numbers
```

number1 = 10 number2 = 20

# Adding the two numbers

sum = number1 + number2 print(sum) # Displaying the result

“`

Exercise 3: Use Line Continuation

Rewrite the following code using both backslash \ and parentheses:

result = 10 + 20 + 30 + 40 + 50 + 60
```

“`


With this foundational knowledge, you are now ready to explore more advanced Python topics. Remember, good coding practices such as proper indentation and clear comments will make your code easier to understand and maintain.

“`


Study of a Parallel Resonant Circuit (RLC Circuit)

Objective:

We aim to study the properties of a passive circuit composed of two branches:

  1. One capacitive branch.
  2. One branch consisting of a resistor and an inductor in series.

When a sinusoidal voltage EE with an effective value and angular frequency ω\omega (or frequency ff) is applied to the circuit:

E=ZIE = ZI

Application of a “Notch Circuit”:

Parallel RLC circuits are often called “notch circuits” because they present high impedance at a particular frequency f0f_0, preventing signals at that frequency from passing to certain parts of the circuit. Notch circuits are used in:

  • Electronics: Audio systems for equalization, and color televisions for separating audio, chrominance, and luminance frequencies.
  • Electricity: Centralized remote controls to avoid frequency dispersion on the network.

Characteristics of a Notch Circuit:

To better understand the functioning of notch circuits, we perform measurements in the lab. A Bode plotter helps visualize the output voltage of the notch filter relative to the generator frequency. We observe that the circuit exhibits high impedance at a certain frequency, leading to significant attenuation at that point on the curve.

Complex Impedance Expression:

We know that:

Z=1jωC+RjωLR2+(ωL)2Z = \frac{1}{j \omega C} + \frac{R – j \omega L}{R^2 + (\omega L)^2}

Resonant Frequency Determination:

The resonant condition occurs when the imaginary part of the admittance cancels out, giving:

ω0=1LC\omega_0 = \frac{1}{\sqrt{LC}}

The theoretical resonant frequency:

f0th=ω02πf_{0th} = \frac{\omega_0}{2\pi}

With actual values:

ω0=79056.94rad/s,f0th=12.89kHz,fopractical=13kHz\omega_0 = 79056.94 \, \text{rad/s}, \quad f_{0th} = 12.89 \, \text{kHz}, \quad f_{opractical} = 13 \, \text{kHz}

The difference between theoretical and practical results arises due to measurement and equipment errors.


Quality Factor of the Inductive Branch:

The quality factor QQ is given by:

Q=ω0LRQ = \frac{\omega_0 L}{R}

For R0=0ΩR_0 = 0 \Omega:

Q=83.85Q = 83.85

For R0=348.2ΩR_0 = 348.2 \Omega:

Q=4.11Q = 4.11

Practical Tasks:

  1. Circuit Assembly: Assemble the circuit as shown.
  2. Internal Resistance Measurement: R=18.5ΩR = 18.5 \Omega, L=0.019HL = 0.019 \, H.
  3. Resonant Frequency Measurement and Comparison: Compare theoretical and practical results.
  4. Current and Phase Values Around Resonance:
Frequency (kHz) VsV_s (V) Φ\Phi (degrees) II (A)
2 1.3 10 0.066
4 0.7 6 0.033
13 0 0 0

Observations:

  • The current II decreases to zero at resonance frequency f0=13kHzf_0 = 13 \, \text{kHz} and increases for frequencies above f0f_0.
  • The phase Φ\Phi decreases for f<f0f < f_0 and becomes negative for f>f0f > f_0.

Conclusion:

At resonance, both current and phase are zero. The quality factor greatly affects the precision of the resonant frequency and the bandwidth, which is evident from the curves.

Comparing Linux and Windows

comparing Linux and Windows
1. Cost and Licensing
Windows: A paid operating system that requires a license for each device, making it costlier for individuals and businesses.
Linux: Free and open-source, available to download and use at no cost, with the freedom to modify its source code.
2. Stability and Performance
Windows: Despite regular improvements, Windows can occasionally suffer from crashes due to software conflicts or system updates.
Linux: Known for its reliability and often used in servers and large networks, Linux can handle heavy workloads more smoothly.
3. Security
Windows: As one of the most popular OSs, Windows is more vulnerable to viruses and malware, making it a frequent target for hackers.
Linux: Generally more secure, with permission management that limits virus access and widespread use in secure network environments.
4. Customization and Flexibility
Windows: Customization options are somewhat limited, relying mostly on preset system settings provided by Microsoft.
Linux: Highly customizable, allowing users to adjust virtually any part of the system. Different distributions (e.g., Ubuntu, Fedora, Debian) are tailored for various user needs.
5. Software and Application Support
Windows: Supports a wide array of commercial software like Adobe Photoshop and Microsoft Office, and is popular among gamers.
Linux: While there are open-source alternatives, commercial software support is more limited. However, tools like Wine enable running some Windows apps on Linux.
6. User Interface and Experience
Windows: Known for its user-friendly, consistent interface, which is accessible for users with little technical expertise.
Linux: May be challenging for beginners, although some distributions (like Ubuntu) provide easy-to-navigate graphical interfaces.
7. Updates and Maintenance
Windows: Regularly updated by Microsoft, sometimes requiring a restart to install updates.
Linux: Offers flexible update management, where users control updates without typically needing a reboot, ideal for continuous use environments.
Primary Use Cases
Windows: Dominates in personal, educational, and office use, preferred by non-technical users.
Linux: Common in server environments, technical fields, and projects requiring high security and stability, also frequently used in IoT devices.

dc

$$f(t) = \mathcal{F}^{-1}\{F(\omega)\} = \frac{1}{2\pi} \int_{-\infty}^{\infty} F(\omega) e^{i \omega t} \, d\omega$$

ALIMENTATION STABILISEE OU REGULEE

Définition

Un redresseur simple alternance monophasé est un redresseur supprimant les alternances négatives et conservant les alternances positives d’une entrée monophasée. La fréquence en sortie du redresseur est alors égale à la fréquence d’entrée.

Si v(t) est la tension d’entrée et vs(t) la tension en sortie du redresseur, on obtient alors une tension de sortie qui ressemble à la suivante :

$$ f(t) = \mathcal{F}^{-1}\{F(\omega)\} = \frac{1}{2\pi} \int_{-\infty}^{\infty} F(\omega) e^{i \omega t} \, d\omega $$

\[
\mathcal{F}\{f(t)\} = F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-i \omega t} \, dt
\]
\[
\mathcal{F}\{f(t)\} = F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-i \omega t} \, dt
\]

\[
f(t) = \mathcal{F}^{-1}\{F(\omega)\} = \frac{1}{2\pi} \int_{-\infty}^{\infty} F(\omega) e^{i \omega t} \, d\omega
\]

\[
f(t) = \mathcal{F}^{-1}\{F(\omega)\} = \frac{1}{2\pi} \int_{-\infty}^{\infty} F(\omega) e^{i \omega t} \, d\omega
\]

F{f(t)}=F(ω)=−∞f(t)etdt

La tension d’entrée utilisée pour illustrer le chapitre est une tension sinusoïdale. En effet, la tension à redresser est souvent le réseau monophasé domestique (le réseau 50Hz d’EDF en France, par exemple).C:\Documents and Settings\fouad\Bureau\dioddd\diode+ttttttttttp\Redresseur-Redresseur simple alternance monophasé 1 - Wikiversité_fichiers\Redresseur_monophase_simple_alternance.png

Il existe deux types de redresseurs simple alternance :

  • les redresseurs non commandés, constitués d’une diode en série avec la charge
  • les redresseurs commandés, constitués d’un thyristor en série avec la charge, qui permettent de faire varier les grandeurs électriques en sortie du convertisseur
  • Redresseur simple alternance non commandé
  • Ce type de redresseur est réalisé en mettant simplement une diode en série avec la charge comme le montre le schéma suivant :

Les redresseurs monophasés simple alternance non commandés conservent la partie positive du signal d’entrée et coupent la partie négative. Leur comportement dépend cependant du type de charge.

Nous allons étudier leur comportement avec différents types de charges :

  • une charge purement résistive
  • une charge inductive
  • une charge inductive et une diode de roue libre
  • une charge comprenant une force électromotrice C:\Documents and Settings\fouad\Bureau\dioddd\diode+ttttttttttp\Redresseur-Redresseur simple alternance monophasé 1 - Wikiversité_fichiers\400px-Redresseur_monophase_resistif.png

Charge purement résistive

Une diode en série avec une résistance pure peut jouer le rôle de redresseur.On suppose que v(t) = \sqrt2Vsin(\omega t)et T = \frac{2\pi}\omegaest la période de v(t).


Calcul de la valeur moyenne du courant de sortie du redresseur :
Lorsque la diode conduit, on a, d’après la 
loi d’Ohm :

i(t) = \frac {v(t)}R = \frac {\sqrt2Vsin(\omega t)}R

La diode est passante jusqu’à ce que le courant qui la traverse s’annule. Or i(t) s’annule pour \scriptstyle{t =} \textstyle{\frac T2}. À partir de cet instant, la diode est bloquée.

Par conséquent, le courant traversant la charge est :

  • Pour~0<t<\frac T2 \qquad i(t) = \frac {v(t)}R = \frac {\sqrt2Vsin(\omega t)}R
  • Pour~\frac T2<t<T \qquad i(t) = 0

La valeur moyenne du courant i(t) est donc :

<i(t)> = \frac1T\int_0^T i(t)\mathrm dt = \frac1T\int_0^{\frac T2} \frac {\sqrt2Vsin(\omega t)}R\mathrm dt

donc

La présence de la diode impose que le courant ait un signe constant. La valeur moyenne de ce courant est imposé par les paramètres de la source et de la charge résistive.

<i(t)> = \frac \sqrt2 \pi \frac VR


Calcul de la valeur moyenne de la tension de sortie du redresseur :
La 
loi des mailles donne v(t) = v_s(t) + v_D(t)~. On a alors, en supposant que vD(t) est nulle lorsque la diode conduit :

  • Pour~0<t<\frac T2 \qquad v_s(t) = v(t) = \sqrt2Vsin(\omega t)
  • Pour~\frac T2<t<T \qquad v_s(t) = 0

La valeur moyenne de la tension vs(t) est donc :

<v_s(t)> = \frac1T\int_0^T v_s(t)\mathrm dt = \frac1T\int_0^{\frac T2} \sqrt2Vsin(\omega t)\mathrm dt

Donc

<v_s(t)> = \frac \sqrt2 \pi V

La valeur moyenne de la tension de sortie est positive. On peut également remarquer que cette valeur moyenne dépend uniquement des paramètres de la tension d’entrée.

Définition

Un redresseur double alternance monophasé est un redresseur redressant les alternances négatives et conservant les alternances positives d’une entrée monophasée. La fréquence en sortie du redresseur est alors le double de la fréquence d’entrée.

Si V(t) est la tension d’entrée et Vs(t) la tension en sortie du redresseur, on obtient alors une tension de sortie qui ressemble à la suivante 

C:\Documents and Settings\fouad\Bureau\dioddd\diode+ttttttttttp\Redresseur-Redresseur double alternance monophasé - Wikiversité_fichiers\Redresseur_monophase_double_alternance_courbe.png

La tension d’entrée utilisée pour illustrer le chapitre est une tension sinusoïdale. En effet, la tension à redresser est souvent le réseau monophasé domestique (le réseau 50Hz d’EDF en France, par exemple).

Il existe deux types de redresseurs simple alternance :

  • les redresseurs double alternance non commandés ou ponts de diodes, composés de diodes
  • les redresseurs double alternance commandés, composés de thyristors

Dans les montages qui suivent, la charge, qui est souvent de type inductif, est représentée par une source de courant.

Pont de Graëtz non commandéC:\Documents and Settings\fouad\Bureau\dioddd\diode+ttttttttttp\Redresseur-Redresseur double alternance monophasé - Wikiversité_fichiers\Redresseur_monophase_double_alternance.png

Ce type de redresseur est réalisé en utilisant un montage en pont de Graëtz avec des diodes comme le montre le schéma suivant :

Le fonctionnement de ce montage est basé sur les fonctions Max et Min vues en introduction. En effet, les diodes D1 et D2 conduisent quand V(t), la tension d’entrée, est positive. Les diodes D3 et D4 conduisent quand V(t) est négative.

Supposons que la tension d’entrée est de la forme :

V(t) = V\sqrt2sin(\omega t)

et \omega = \frac{2\pi}T


Calcul de la valeur moyenne de la tension de sortie :
Entre 0 et 
\textstyle{\frac T2}D1 et D2 conduisent, on a alors Vs(t) = V(t). Entre \textstyle{\frac T2}et TD3 et D4 conduisent, on a alors Vs(t) = − V(t).

La tension de sortie est donc périodique de période \textstyle{\frac T2}. La valeur moyenne de la tension de sortie est :

<V_s(t)> = \frac1{\left(\frac T2\right)}\int_0^{\frac T2}V(t)\mathrm dt = \frac1{\left(\frac T2\right)}\int_0^{\frac T2}V\sqrt2sin(\omega t)\mathrm dt

Finalement,

<V_s(t)> = \frac {2\sqrt2}\pi V

1

Résonance Parallèle (Circuit Bouchon)

1.  Objectif :

On se propose d’étudier les propriétés d’un circuit passif comportant deux branches dont l’une est capacitive et l’autre composée d’une résistance et d’une self-induction en série .

 

Lorsque’on applique au circuit (fig1)

Une tension sinusoidale, de valeur

Efficace E,et de pulsation w,(ou de fréquence f) :on a :

E=Zi et et

1

Utilisation d’un circuit bouchon ;

Les circuits RLC parallèle, sont souvent appelés circuits bouchons, car ils présentent une grande impédance pour fo et ils « empêchent » les signaux à cette fréquence d’accéder à une partie de circuit.En électronique, les circuits bouchons sont utilisés pour « trier » différentes fréquences dans les chaînes audio (égaliser) ou dans les téléviseurs couleur (séparation des fréquences son, chrominance et luminance). En électricité, les circuits bouchons sont utilisés dans les télécommandes centralisées pour éviter une dispersion des fréquences pilotes sur le réseau

Caractéristiques d’un circuit bouchon ;

Pour mieux comprendre le fonctionnement des circuits bouchons, il est pratique de réaliser une mesure au laboratoire.

Le traceur de Bode nous permet de visualiser la tension de sortie du filtre bouchon en fonction de la fréquence du générateur.

Nous constatons que pour une certaine fréquence, le circuit oppose une grande impédance, ce qui crée la forte atténuation au milieu de la courbe.

 

1. L’expression complexe de Z :

on sait que :

2. La détermination de la fréquence de résonance :

1er   terme :

 

En Z=0

Posons    pulsation naturelle

3. Le comportement de courant I :

4.Le coefficient de qualité de la branche selfique :

 

2. Travail demandé :

1.La réalisation de montage

123

 

2.La mesure de la résistance interne de la bobine :

R=18,5Ω     et L=0,019H

3. La détermination de la fréquence de résonance pratique et théorique et la comparaison :

On a :  Foth= w0/ 2л

w0=1/LC

AN:   w0=79056,94 rd/s

Foth=12,89 Khz

Et  on a Fopratique=13Khz

En  comparant les  résultat théorique et pratique  on remarque qu’il y a des petit différence due au erreurs de manipulations et de matériels.

donc Fopratique= Fotheorique

4. Les valeurs de courant I et du déphasage   autour de la fréquence de résonance

-Tableau

:

F 2 4 6 8 10 13 15 17 19 25,84 37
Vs 1,3 0,7 0,4 0,3 0,18 0 0,1 0,2 0,3 0,5 0,57
Φ 10 6 10 4 10 3 10 10 0 -10 -1,2 10 -1,5 10 -2 10 -6 10
I(A) 0,066 0,033 0,022 0,011 9,34 10 0 5,49 10 0,011 0,016 0,02 0,03

On a VR=RI     I=VR/R

3. Les courbes :

Pour la courbe I=f(f)

– Après avoir dessiné la courbes on obtien une courbes décroissante jusqu’au pointe ou qu’elle s’annule et se points et représenter par la fréquence Fo  =13Khz et commence a s’acroitre après c-ad pour les valeurs supérieur a Fo

Pour la courbe φ=f(f) :

-pour les valeurs de la fréquence  compris entre 2Khz et Fo=13Khz on a une courbe décroissante (mais  φ >0) ceux qui changera pour des valeurs supérieurs à  Fo=13Khz.

Conclusion :

L’intensité et le déphasage s’annulent pour f= Fo et ils sont donne des courbes décroissante.

4. Les courbes : voir la feuilles millimétriques

  1. pour R0=0 Ω
F (Khz) 2 4 6 8 10 12 14 16 18 20
V s (v) 1.2 0.6 0.3 0.2 0.1 0.01 0.06 0.11 0.22 0.3
∆ T -1.10-4 -6.10-5 -3.10-5 -2.10-5 -1.10-5 1.2.10-5 1.6.10-5 1.6.10-5 1.2.10-5 1.10-5
∆ ρ -72◦ -86.4◦ -64.8◦ -43.2◦ -36◦ 51.84◦ 80.64◦ 92.16◦ 77.76◦ 72◦
zeq 32079.8 64163.33 96247.1 128300 160390 192400 224570 256660 288700 320820
I( A) 6,5.10-2 3,2.10-2 1,62.10-2 1,02.10-2 5,4.10-3 5,4.10-4 3,24.10-3 5,9.10-3 1,18.10-2 1,62.10-2

2) pour R0= 330 Ω         R=r+R0= 18.5+330= 348,5Ω

F (Khz) 2 4 6 8 10 12 14 16 18 20
V s (v) 0.57 0.4 0.17 0.16 0.08 0.06 0.08 0.13 0.18 0.22
∆ T 4.10-5 3.10-5 3.10-5 2.10-5 1.10-5 1.10-5 8.10-6 1.4.10-5 1.4.10-5 1.2.10-5
∆ ρ -28.8° -43.2° -64.8° -57.6° -36° 43.2° 40.32° 80.64° 90.72° 86.4°
Zeq 11462.4 22925 34387.5 45850.1 57312.6 68775.14 80237.66 91700.2 103162.7 114625..2
I( A) 1,6.10-3 1,1.10-3 4.8.10-4 4,6.10-4 2,3.10-4 1,72.10-4 2 ,3.10-4 . 3,710-4 5,17.10-4 6,3.10-4

VR=(R0 +r)I     , I= VR/(R0 + r)

À la resonance on obtient Z0=R

Le calcul théorique de Z0

Z0=jcw0+1/R+jLw0

Z0 =R+ jLw0  / 1- jLw0 (w0) +jRcw0)

Cas 1 :  R=0 la valeur théorique Z=1/k+j(cw-1/Lw)      Zmax=1/K

Z0 =R  donc Z0 = R0 +r alors  Z0 = 18,2  Ω

La valeur pratique    Z0 = V/I0 = 18,3 Ω

Cas 2 :  R0 =330Ω

La valeur théorique : Z0 = R0 +r  donc Z0 = 348,2 Ω

La valeur pratique :   Z0  =V/ I0 =350 Ω

Les résultat sont presque égaux et la difference trouvé et due aux erreurs de calcules et de manipulation.

Le Coefficient de qualité

Pour R0 =0 on a Q=Lw/R =:83,85     Q=83,85

Pour R0 =348,2 Ω  on aura Q =Lw/R = 4,11    Q = 4,11

Le coefficient de  qualité a une importante influence sur la branche selfique et sur les caractéristique de circuit bouchon que j’ai déjà expliquer au début de se TP car lorsque on dit coefficient de qualité  on parle de la précision de la fréquence de résonance et sur les courbes sa se voit clairement et on implique la largeur de la bande passante.