gcode_reader.emulate.extruders ============================== .. py:module:: gcode_reader.emulate.extruders Classes ------- .. autoapisummary:: gcode_reader.emulate.extruders.Extruder gcode_reader.emulate.extruders.LinearScrewModel gcode_reader.emulate.extruders.MeltPumpExtruder gcode_reader.emulate.extruders.MeltPumpModel gcode_reader.emulate.extruders.ScrewExtruder gcode_reader.emulate.extruders.ScrewModel gcode_reader.emulate.extruders.StepperExtruder Module Contents --------------- .. py:class:: Extruder(options: gcode_reader.emulate.machine_options.MachineOptions = None) Bases: :py:obj:`gcode_reader.emulate.tools.Tool` A 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. .. attribute:: last_deposited_volume The volume of material deposited by the most recent `commands.Extrude` command. :type: float .. attribute:: last_extrusion_rate The control value for the extrusion rate (e.g., RPM, mm/s, volumetric flow) set by the most recent command. :type: float Initializes a new Extruder instance. :param options: Configuration settings for the machine and this tool. :type options: MachineOptions .. py:method:: process_command(command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData) 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. :param command: The command to process. :type command: Command :param process_data: The data object to populate with post-processing information. :type process_data: AdditiveProcessData :returns: The updated AdditiveProcessData object. .. py:method:: reset_history() .. py:property:: extrusion_type .. py:attribute:: last_bead_area :type: float :value: None .. py:attribute:: last_deposited_volume :type: float :value: 0.0 .. py:attribute:: last_extrusion_rate :type: float :value: 0.0 .. py:property:: relative_extrusion .. py:class:: LinearScrewModel(nozzle_diameter=0, displacement=1.0) Bases: :py:obj:`ScrewModel` A 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. :param nozzle_diameter: The diameter of the extruder nozzle (in length units). :type nozzle_diameter: float :param displacement: The volume of material extruded per full revolution of the screw (e.g., in units³/revolution). :type displacement: float .. py:method:: calc_deposited_volume(extruder, command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData) Calculates deposited volume based on RPM and time. Uses the formula: `Volume = (RPM * displacement / self.flow_rate_time_base_s) * elapsed_time` :returns: A tuple of (deposited_volume, extrusion_rate). :rtype: (float, float) .. py:method:: calc_extrusion_rate(extruder, command: gcode_reader.emulate.commands.Extrude, process_data: gcode_reader.emulate.operations.AdditiveProcessData) 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` :returns: A tuple of (extrusion_rate, deposited_volume). :rtype: (float, float) .. py:class:: MeltPumpExtruder(options: gcode_reader.emulate.machine_options.MachineOptions = None, model: ScrewModel = None) Bases: :py:obj:`ScrewExtruder` A 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. :param options: Configuration settings for the machine and this tool. :type options: MachineOptions .. py:attribute:: model :value: None .. py:class:: MeltPumpModel(nozzle_diameter=0, displacement=1.0) Bases: :py:obj:`ScrewModel` A 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_volume`` is the method called for both ``MoveExtrude`` commands (explicit E) and plain ``Move`` commands (no E, i.e. implicit extruder off). Initializes the screw model's physical parameters. :param nozzle_diameter: The diameter of the extruder nozzle (in length units). :type nozzle_diameter: float :param displacement: The volume of material extruded per full revolution of the screw (e.g., in units³/revolution). :type displacement: float .. py:method:: calc_deposited_volume(extruder, command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData) 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. :returns: A tuple of (deposited_volume, extrusion_rate). :rtype: (float, float) .. py:method:: calc_extrusion_rate(extruder, command: gcode_reader.emulate.commands.Extrude, process_data: gcode_reader.emulate.operations.AdditiveProcessData) 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. :returns: A tuple of (extrusion_rate, deposited_volume). :rtype: (float, float) .. py:class:: ScrewExtruder(options: gcode_reader.emulate.machine_options.MachineOptions = None, model: ScrewModel = None) Bases: :py:obj:`Extruder` An 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. .. attribute:: nozzle_diameter The diameter of the extruder nozzle. :type: float .. attribute:: displacement A factor representing the volume of material extruded per full revolution of the screw (e.g., in mm^3/revolution). :type: float Initializes a new Extruder instance. :param options: Configuration settings for the machine and this tool. :type options: MachineOptions .. py:method:: process_command(command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData) 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. :param command: The command to process. :type command: Command :param process_data: The data object to populate with post-processing information. :type process_data: AdditiveProcessData :returns: The updated AdditiveProcessData object. .. py:attribute:: model :value: None .. py:class:: ScrewModel(nozzle_diameter=0, displacement=1.0) (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. .. attribute:: nozzle_diameter The diameter of the extruder nozzle (in length units). :type: float .. attribute:: displacement The volume of material extruded per full revolution of the screw (e.g., in units³/revolution). :type: float .. attribute:: 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: float Initializes the screw model's physical parameters. :param nozzle_diameter: The diameter of the extruder nozzle (in length units). :type nozzle_diameter: float :param displacement: The volume of material extruded per full revolution of the screw (e.g., in units³/revolution). :type displacement: float .. py:method:: calc_deposited_volume(extruder, command: gcode_reader.emulate.commands.Command, process_data: gcode_reader.emulate.operations.AdditiveProcessData) :abstractmethod: Calculates deposited volume from screw RPM and elapsed time. :returns: A tuple of (deposited_volume, extrusion_rate). :rtype: (float, float) .. py:method:: calc_extrusion_rate(extruder, command: gcode_reader.emulate.commands.Extrude, process_data: gcode_reader.emulate.operations.AdditiveProcessData) :abstractmethod: Calculates the required screw RPM to achieve a target deposited volume. :returns: A tuple of (extrusion_rate, deposited_volume). :rtype: (float, float) .. py:attribute:: displacement .. py:attribute:: flow_rate_time_base_s :value: 60.0 .. py:attribute:: nozzle_diameter .. py:class:: StepperExtruder(options: gcode_reader.emulate.machine_options.MachineOptions = None, filament_area=1.0, extrusion_multiplier=1.0) Bases: :py:obj:`Extruder` An 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). .. attribute:: filament_area The cross-sectional area of the filament, calculated from its diameter. :type: float Initializes a new Extruder instance. :param options: Configuration settings for the machine and this tool. :type options: MachineOptions .. py:attribute:: extrusion_multiplier :value: 1.0 .. py:attribute:: filament_area :value: 1.0 .. py:attribute:: relative_extrusion :value: True