gcode_reader.emulate.extruders¶
Classes¶
A generic base class for an additive manufacturing extruder. |
|
A linear model for a screw extruder. |
|
A special ScrewExtruder where the control value directly specifies deposition volume. |
|
A special model where the control value directly specifies deposition volume. |
|
An extruder controlled by screw RPM, which processes pellets into a bead. |
|
(Abstract) Defines the physical calculation interface for a screw extruder. |
|
An extruder controlled by filament length, common in FDM/FFF printers. |
Module Contents¶
- class gcode_reader.emulate.extruders.Extruder(options: gcode_reader.emulate.machine_options.MachineOptions = None)[source]¶
Bases:
gcode_reader.emulate.tools.ToolA generic base class for an additive manufacturing extruder.
This class provides the core structure for tracking extrusion state, such as the last deposited volume and extrusion rate. It is not meant to be used directly but should be subclassed to implement a specific physical model for a given extrusion technology.
- last_deposited_volume¶
The volume of material deposited by the most recent commands.Extrude command.
- Type:
- last_extrusion_rate¶
The control value for the extrusion rate (e.g., RPM, mm/s, volumetric flow) set by the most recent command.
- Type:
Initializes a new Extruder instance.
- Parameters:
options (MachineOptions) – Configuration settings for the machine and this tool.
- process_command(command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData)[source]¶
Processes a command to update the extruder’s state.
If the command is an commands.Extrude command, this method dispatches to the appropriate _calc_* method to update the tool’s state based on the extrusion model implemented by the subclass.
- Parameters:
command (Command) – The command to process.
process_data (AdditiveProcessData) – The data object to populate with post-processing information.
- Returns:
The updated AdditiveProcessData object.
- property extrusion_type¶
- property relative_extrusion¶
- class gcode_reader.emulate.extruders.LinearScrewModel(nozzle_diameter=0, displacement=1.0)[source]¶
Bases:
ScrewModelA linear model for a screw extruder.
This model assumes a direct, linear relationship between the screw’s rotational speed (RPM) and the volumetric flow rate: Flow Rate (units³/min) = RPM * displacement.
Initializes the screw model’s physical parameters.
- Parameters:
- calc_deposited_volume(extruder, command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData)[source]¶
Calculates deposited volume based on RPM and time.
Uses the formula: Volume = (RPM * displacement / self.flow_rate_time_base_s) * elapsed_time
- calc_extrusion_rate(extruder, command: gcode_reader.emulate.commands.Extrude, process_data: gcode_reader.emulate.operations.AdditiveProcessData)[source]¶
Calculates the required screw RPM to achieve a target deposited volume.
Uses the formula: RPM = (Volume / elapsed_time * self.flow_rate_time_base_s) / displacement
- class gcode_reader.emulate.extruders.MeltPumpExtruder(options: gcode_reader.emulate.machine_options.MachineOptions = None, model: ScrewModel = None)[source]¶
Bases:
ScrewExtruderA special ScrewExtruder where the control value directly specifies deposition volume.
This model assumes the extrusion_rate in a command is a direct specification of the volume to be deposited for that command’s duration. It operates in a relative mode.
Initializes a new Extruder instance.
- Parameters:
options (MachineOptions) – Configuration settings for the machine and this tool.
- model = None¶
- class gcode_reader.emulate.extruders.MeltPumpModel(nozzle_diameter=0, displacement=1.0)[source]¶
Bases:
ScrewModelA special model where the control value directly specifies deposition volume.
This model assumes the extrusion_rate in a command (e.g., ‘E100’) is a direct specification of the cumulative volume deposited so far (e.g., 100 mm³). The volume deposited for a given move is the delta between the current E value and the previous E value:
deposited_volume = max(E_current - E_last, 0).Time and displacement are ignored — rate == volume.
calc_deposited_volumeis the method called for bothMoveExtrudecommands (explicit E) and plainMovecommands (no E, i.e. implicit extruder off).Initializes the screw model’s physical parameters.
- Parameters:
- calc_deposited_volume(extruder, command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData)[source]¶
Calculates the deposited volume based on the command’s extrusion rate.
For the MeltPump, the command’s extrusion rate is taken directly as the deposited volume, as they are equivalent.
- calc_extrusion_rate(extruder, command: gcode_reader.emulate.commands.Extrude, process_data: gcode_reader.emulate.operations.AdditiveProcessData)[source]¶
Calculates the required extrusion rate based on the command’s deposited volume.
For the MeltPumpExtruder, the command’s volume is taken directly as the required tool extrusion rate, as they are equivalent.
- class gcode_reader.emulate.extruders.ScrewExtruder(options: gcode_reader.emulate.machine_options.MachineOptions = None, model: ScrewModel = None)[source]¶
Bases:
ExtruderAn extruder controlled by screw RPM, which processes pellets into a bead.
The extrusion_rate control value is interpreted as the screw’s rotational speed (e.g., in RPM). The deposited volume is calculated based on this speed, the tool’s displacement factor, and the command’s duration.
- displacement¶
A factor representing the volume of material extruded per full revolution of the screw (e.g., in mm^3/revolution).
- Type:
Initializes a new Extruder instance.
- Parameters:
options (MachineOptions) – Configuration settings for the machine and this tool.
- process_command(command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData)[source]¶
Processes a command to update the extruder’s state.
If the command is an commands.Extrude command, this method dispatches to the appropriate _calc_* method to update the tool’s state based on the extrusion model implemented by the subclass.
- Parameters:
command (Command) – The command to process.
process_data (AdditiveProcessData) – The data object to populate with post-processing information.
- Returns:
The updated AdditiveProcessData object.
- model = None¶
- class gcode_reader.emulate.extruders.ScrewModel(nozzle_diameter=0, displacement=1.0)[source]¶
(Abstract) Defines the physical calculation interface for a screw extruder.
This class acts as a strategy for the ScrewExtruder, separating the physical model (how RPM relates to volume) from the extruder’s state-holding logic.
- displacement¶
The volume of material extruded per full revolution of the screw (e.g., in units³/revolution).
- Type:
- flow_rate_time_base_s¶
The conversion factor (in seconds) for the extrusion rate. Defaults to 60.0 to convert RPM (units/minute) to the emulator’s standard units/second.
- Type:
Initializes the screw model’s physical parameters.
- Parameters:
- abstract calc_deposited_volume(extruder, command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData)[source]¶
Calculates deposited volume from screw RPM and elapsed time.
- abstract calc_extrusion_rate(extruder, command: gcode_reader.emulate.commands.Extrude, process_data: gcode_reader.emulate.operations.AdditiveProcessData)[source]¶
Calculates the required screw RPM to achieve a target deposited volume.
- displacement¶
- flow_rate_time_base_s = 60.0¶
- nozzle_diameter¶
- class gcode_reader.emulate.extruders.StepperExtruder(options: gcode_reader.emulate.machine_options.MachineOptions = None, filament_area=1.0, extrusion_multiplier=1.0)[source]¶
Bases:
ExtruderAn extruder controlled by filament length, common in FDM/FFF printers.
This model processes a continuous filament. The extrusion_rate control value represents the length of filament to feed (in relative mode) or the absolute position of the extruder motor (in absolute mode).
Initializes a new Extruder instance.
- Parameters:
options (MachineOptions) – Configuration settings for the machine and this tool.
- extrusion_multiplier = 1.0¶
- filament_area = 1.0¶
- relative_extrusion = True¶